messages listlengths 1 1 | ground_truth stringlengths 88 726k | dataset stringclasses 1
value |
|---|---|---|
[
{
"content": "Solve the following coding problem using the programming language python:\n\nCaptain Jack Sparrow and Davy Jones are having a furious sword fight to gain the key to the chest containing Davy Jones' heart. Jack wants to kill Davy Jones and live forever as the captain of The Flying Dutchman. On the ... | [{"type": "stdin_stdout", "input": "100\nlwvaneiwcugzlsreuxzpfyqmdkwvakuulwgmyfyonuvwfkpsohudvsnybxgxdpxnikrqpdrqpnrjewmshjsmhfixfbvlynoraktntxvjesvtrcchyjllqjttdjkizyzkryllzkstiileuwokennltseskfhqexxigmadpdtyyfbfikoqgqljhuktfbcoeyedgsesxaopbejmidsanwhsemsmcfjrekzcilpbombjqhqsovvyfgkemeegkdvqmfsroftjgrqasaghmwdncymavzu... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPanda is fond of numbers. Given a number, he subtracts it with squares of any one particular digit of that number to get new numbers. This operation can be applied any number of times (possibly zero) till he obtains a pan... | [{"type": "stdin_stdout", "input": "1000\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n10\n12\n23\n14\n15\n16\n26\n33\n19\n20\n21\n22\n23\n24\n25\n26\n26\n28\n29\n30\n31\n32\n16\n34\n35\n36\n37\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n49\n50\n51\n52\n53\n54\n55\n56\n57\n58\n24\n60\n61\n62\n63\n64\n65\n77\n77\n68\n5\n70\n71\n72\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA positive integer X is said to be a lunlun number if and only if the following condition is satisfied:\n\n* In the base ten representation of X (without leading zeros), for every pair of two adjacent digits, the absolute... | [{"type": "stdin_stdout", "input": "100000", "output": "3234566667"}, {"type": "stdin_stdout", "input": "333", "output": "10100\n"}, {"type": "stdin_stdout", "input": "139", "output": "2122\n"}, {"type": "stdin_stdout", "input": "183", "output": "3454\n"}, {"type": "stdin_stdout", "input": "174", "output": "3343\n"}, {... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGiven is a tree G with N vertices. The 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. We want to paint them so that... | [{"type": "stdin_stdout", "input": "8\n1 2\n2 3\n2 4\n2 5\n4 7\n5 6\n2 8", "output": "5\n1\n2\n3\n4\n1\n1\n5\n"}, {"type": "stdin_stdout", "input": "8\n1 2\n2 3\n2 4\n4 5\n4 7\n5 6\n2 8", "output": "4\n1\n2\n3\n1\n2\n2\n4\n"}, {"type": "stdin_stdout", "input": "8\n1 2\n2 3\n2 4\n2 5\n4 7\n3 6\n6 8", "output": "4\n1\n2\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a 4-character string S consisting of uppercase English letters. Determine if S consists of exactly two kinds of characters which both appear twice in S.\n\nConstraints\n\n* The length of S is 4.\n* S consist... | [{"type": "stdin_stdout", "input": "EEFF", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "SOOS", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "FFEE", "output": "Yes"}, {"type": "stdin_stdout", "input": "ASSA", "output": "Yes"}, {"type": "stdin_stdout", "input": "FQEE", "output": "No\n"}, {"type": "stdi... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a permutation of 1,2,...,N: p_1,p_2,...,p_N. Determine if the state where p_i=i for every i can be reached by performing the following operation any number of times:\n\n* Choose three elements p_{i-1},p_{i},... | [{"type": "stdin_stdout", "input": "7\n4\n2\n1\n6\n5\n4\n14", "output": "No\n"}, {"type": "stdin_stdout", "input": "7\n4\n2\n1\n11\n5\n4\n7", "output": "No\n"}, {"type": "stdin_stdout", "input": "7\n3\n2\n1\n6\n5\n4\n7", "output": "Yes"}, {"type": "stdin_stdout", "input": "7\n4\n2\n1\n6\n5\n4\n7", "output": "No\n"}, {"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are N holes in a two-dimensional plane. The coordinates of the i-th hole are (x_i,y_i).\n\nLet R=10^{10^{10^{10}}}. Ringo performs the following operation:\n\n* Randomly choose a point from the interior of a circle ... | [{"type": "stdin_stdout", "input": "5\n0 0\n2 8\n4 5\n2 6\n3 10", "output": "0.43160120892732328768\n0.03480224363653196956\n0.13880483535586193855\n0.00000000000000000000\n0.39479171208028279727"}, {"type": "stdin_stdout", "input": "5\n1 0\n2 13\n-1 1\n4 10\n3 10", "output": "0.277405019286\n0.367426913906\n0.21519775... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are in charge of controlling a dam. The dam can store at most L liters of water. Initially, the dam is empty. Some amount of water flows into the dam every morning, and any amount of water may be discharged every nigh... | [{"type": "stdin_stdout", "input": "4 15\n1000000000 15\n9 5\n13 6\n7 4", "output": "1000000000.000000000000\n666666669.666666626930\n400000007.000000000000\n293333340.333333313465\n"}, {"type": "stdin_stdout", "input": "4 15\n1100000000 15\n9 10\n8 6\n2 4", "output": "1100000000.000000000000\n366666672.666666686535\n2... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA prime number n (11, 19, 23, etc.) that divides by 4 and has 3 has an interesting property. The results of calculating the remainder of the square of a natural number (1, 2, ..., n -1) of 1 or more and less than n divide... | [{"type": "stdin_stdout", "input": "11\n173\n0", "output": "4\n4\n4\n4\n4\n84\n86\n86\n84\n86\n84\n86\n86\n84\n84\n86\n86\n84\n84\n84\n84\n86\n86\n86\n86\n84\n84\n84\n84\n84\n86\n86\n86\n84\n86\n84\n86\n84\n84\n84\n84\n84\n84\n86\n84\n84\n86\n84\n86\n86\n86\n84\n86\n84\n86\n84\n84\n86\n84\n84\n84\n84\n86\n86\n84\n86\n8... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOne of the games that uses the Hyakunin Isshu tag is \"Buddhist turning\". It is a simple game that uses only picture cards, so it is widely enjoyed. There are various derivative types of rules, but the shaved turn consid... | [{"type": "stdin_stdout", "input": "2\nSSSSSSSSSSSSSSSLLLLLLLLLLLLLLLLLLLLLMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM\n9\nSSSSSSSSSSSSSSLLLLLLLLLMLLLLLLLLLLMMMMMMMMMMMMMMMMMMMMMMMMMMMMMLMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMSL\n6\nMMMMMMSMSLLMMMSMMSLMMMLMMMMLSLLLLMMSMMLMMLLMSSSLMMMMLMLSMLMSMMMMMMMSMMM... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nproblem\n\nYou are playing with J using the Midakuji. The Amida lottery consists of n vertical bars and m horizontal bars. The vertical bars are numbered from 1 to n in order from the left, and the vertical bar i The posi... | [{"type": "stdin_stdout", "input": "4 5 12 2\n20\n80\n100\n50\n1 1\n2 6\n2 2\n1 5\n3 1\n2 0 5 1\n10\n20\n1 1\n1 0\n0 0 0 0", "output": "100\n10\n0\n"}, {"type": "stdin_stdout", "input": "4 5 12 2\n20\n80\n101\n50\n1 1\n2 6\n2 2\n1 5\n3 1\n2 0 5 1\n10\n20\n1 1\n1 0\n0 0 0 0", "output": "100\n10\n0\n"}, {"type": "stdin_s... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nHonestly, a rabbit does not matter.\n\nThere is a rabbit playing a stage system action game. In this game, every stage has a difficulty level. The rabbit, which always needs challenges, basically wants to play more diffic... | [{"type": "stdin_stdout", "input": "15 11\n35\n15\n4\n-4\n0", "output": "454041516\n"}, {"type": "stdin_stdout", "input": "14 15\n61\n10\n7\n-4\n0", "output": "227020758\n"}, {"type": "stdin_stdout", "input": "16 11\n29\n10\n7\n-4\n0", "output": "496068260\n"}, {"type": "stdin_stdout", "input": "14 27\n33\n6\n7\n-4\n1"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nD - Medical Inspection\n\nProblem Statement\n\nThe government has declared a state of emergency due to the MOFU syndrome epidemic in your country. Persons in the country suffer from MOFU syndrome and cannot get out of bed... | [{"type": "stdin_stdout", "input": "10 3 1\n1 3\n2 6\n4 1", "output": "Impossible\n"}, {"type": "stdin_stdout", "input": "10 3 1\n1 6\n2 6\n4 1", "output": "Impossible\n"}, {"type": "stdin_stdout", "input": "10 3 1\n2 6\n2 6\n4 1", "output": "Impossible\n"}, {"type": "stdin_stdout", "input": "6 1 0\n1 5\n-1 6\n4 1", "o... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA pitch-black room\n\nWhen I woke up, Mr. A was in a pitch-black room. Apparently, Mr. A got lost in a dungeon consisting of N rooms. You couldn't know which room A got lost in, but fortunately he got a map of the dungeon... | [{"type": "stdin_stdout", "input": "4 0 2\n2 4\n2 2\n1 1\n4 -1\n6 -1", "output": "0\n"}, {"type": "stdin_stdout", "input": "4 0 2\n2 4\n2 1\n1 1\n4 -1\n6 -1", "output": "0\n"}, {"type": "stdin_stdout", "input": "8 0 1\n2 4\n2 2\n-1 1\n4 0\n6 -1", "output": "0\n"}, {"type": "stdin_stdout", "input": "5 0 2\n2 7\n2 2\n1 1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe goal of the matrix-chain multiplication problem is to find the most efficient way to multiply given $n$ matrices $M_1, M_2, M_3,...,M_n$.\n\nWrite a program which reads dimensions of $M_i$, and finds the minimum numbe... | [{"type": "stdin_stdout", "input": "6\n30 35\n35 15\n15 5\n5 10\n10 20\n20 29", "output": "16125\n"}, {"type": "stdin_stdout", "input": "6\n30 35\n35 15\n15 5\n5 10\n10 20\n20 27", "output": "15625\n"}, {"type": "stdin_stdout", "input": "6\n30 35\n35 15\n15 5\n5 10\n10 20\n20 47", "output": "20625\n"}, {"type": "stdin_... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nFor given two sides of a triangle a and b and the angle C between them, calculate the following properties:\n\n* S: Area of the triangle\n* L: The length of the circumference of the triangle\n* h: The height of the triang... | [{"type": "stdin_stdout", "input": "1 2 -1", "output": "-0.0174524064373\n4.00030456331\n-0.0349048128746\n"}, {"type": "stdin_stdout", "input": "2 1 -2", "output": "-0.0348994967025\n4.00121760468\n-0.0348994967025\n"}, {"type": "stdin_stdout", "input": "1 1 -2", "output": "-0.0174497483513\n2.03490481287\n-0.03489949... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe [BFS](https://en.wikipedia.org/wiki/Breadth-first_search) algorithm is defined as follows.\n\n 1. Consider an undirected graph with vertices numbered from 1 to n. Initialize q as a new [queue](http://gg.gg/queue_en) ... | [{"type": "stdin_stdout", "input": "11\n1 2\n2 8\n3 7\n4 9\n5 10\n5 11\n6 4\n6 5\n7 1\n1 6\n1 6 7 2 5 4 3 8 11 10 9\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "11\n1 2\n2 8\n3 7\n4 9\n5 10\n5 11\n11 4\n6 5\n7 1\n1 6\n1 6 7 2 5 4 3 8 11 10 9\n", "output": "No\n"}, {"type": "stdin_stdout", "input": "11\n1 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn Morse code, an letter of English alphabet is represented as a string of some length from 1 to 4. Moreover, each Morse code representation of an English letter contains only dots and dashes. In this task, we will repres... | [{"type": "stdin_stdout", "input": "100\n1\n0\n0\n1\n0\n0\n1\n1\n0\n0\n1\n0\n0\n0\n0\n0\n1\n1\n0\n0\n0\n1\n1\n1\n1\n0\n0\n1\n1\n0\n1\n1\n0\n1\n1\n1\n1\n0\n0\n0\n0\n0\n0\n1\n1\n0\n0\n1\n1\n1\n1\n0\n1\n0\n0\n0\n1\n0\n0\n1\n0\n1\n1\n1\n1\n1\n0\n1\n0\n0\n1\n1\n0\n0\n1\n0\n0\n1\n1\n0\n0\n0\n1\n0\n0\n0\n0\n0\n0\n1\n1\n0\n0\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nCodefortia is a small island country located somewhere in the West Pacific. It consists of n settlements connected by m bidirectional gravel roads. Curiously enough, the beliefs of the inhabitants require the time needed ... | [{"type": "stdin_stdout", "input": "6 7 13 22\n1 2 13\n2 3 13\n1 4 22\n3 4 13\n4 5 13\n5 6 13\n6 1 13\n", "output": "0 13 26 39 26 13\n"}, {"type": "stdin_stdout", "input": "6 7 13 22\n1 2 13\n2 3 13\n1 4 22\n3 4 13\n4 1 13\n5 6 13\n6 1 13\n", "output": "0 13 26 13 26 13 "}, {"type": "stdin_stdout", "input": "6 7 13 22... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nConsider a sequence of digits of length 2^k [a_1, a_2, …, a_{2^k}]. We perform the following operation with it: replace pairs (a_{2i+1}, a_{2i+2}) with (a_{2i+1} + a_{2i+2})mod 10 for 0≤ i<2^{k-1}. For every i where a_{2i... | [{"type": "stdin_stdout", "input": "20\n4 8 6 6 3 0 1 8 3 6 1 4 3 2 1 3 6 4 5 4\n15\n16 19\n3 10\n9 9\n3 18\n6 7\n15 18\n12 19\n17 18\n12 12\n6 9\n3 10\n1 2\n2 3\n4 19\n16 16\n", "output": "1\n3\n0\n5\n0\n1\n2\n1\n0\n1\n3\n1\n1\n5\n0\n"}, {"type": "stdin_stdout", "input": "20\n4 8 6 6 3 0 1 8 3 6 1 4 3 2 1 2 6 4 5 4\n1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLet us define a magic grid to be a square matrix of integers of size n × n, satisfying the following conditions. \n\n * All integers from 0 to (n^2 - 1) inclusive appear in the matrix exactly once. \n * [Bitwise XOR](ht... | [{"type": "stdin_stdout", "input": "136\n", "output": "0 1 2 3 16 17 18 19 32 33 34 35 48 49 50 51 64 65 66 67 80 81 82 83 96 97 98 99 112 113 114 115 128 129 130 131 144 145 146 147 160 161 162 163 176 177 178 179 192 193 194 195 208 209 210 211 224 225 226 227 240 241 242 243 256 257 258 259 272 273 274 275 288 289 2... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLet's call two strings s and t anagrams of each other if it is possible to rearrange symbols in the string s to get a string, equal to t.\n\nLet's consider two strings s and t which are anagrams of each other. We say that... | [{"type": "stdin_stdout", "input": "aabbbbbbc\n6\n1 1\n2 4\n2 2\n1 9\n5 7\n3 5\n", "output": "YES\nYES\nYES\nYES\nNO\nNO\n"}, {"type": "stdin_stdout", "input": "aabbbbbbc\n6\n1 1\n2 4\n2 2\n1 9\n5 7\n3 8\n", "output": "YES\nYES\nYES\nYES\nNO\nNO\n"}, {"type": "stdin_stdout", "input": "aabbbbbbc\n6\n1 1\n2 7\n2 2\n1 9\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given two integers n and d. You need to construct a rooted binary tree consisting of n vertices with a root at the vertex 1 and the sum of depths of all vertices equals to d.\n\nA tree is a connected graph without... | [{"type": "stdin_stdout", "input": "9\n6 9\n5 7\n4 6\n4 4\n612 4624\n53 311\n8 25\n3 3\n6 11\n", "output": "YES\n1 1 2 2 4 \nYES\n1 1 2 4 \nYES\n1 2 3 \nYES\n1 1 2 \nYES\n1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are playing another computer game, and now you have to slay n monsters. These monsters are standing in a circle, numbered clockwise from 1 to n. Initially, the i-th monster has a_i health.\n\nYou may shoot the monster... | [{"type": "stdin_stdout", "input": "10\n8\n7 4\n9 10\n4 8\n3 1\n1 7\n9 5\n1 4\n2 5\n8\n9 8\n4 7\n7 7\n3 6\n14 9\n2 5\n4 9\n2 8\n7\n2 2\n2 7\n2 10\n8 6\n1 4\n2 6\n3 10\n4\n4 10\n7 5\n6 10\n9 5\n7\n8 9\n8 1\n3 4\n5 1\n3 10\n9 3\n5 5\n5\n6 1\n7 3\n6 5\n6 1\n1 8\n2\n7 8\n7 10\n4\n6 8\n9 3\n8 1\n9 7\n4\n13 7\n5 7\n10 10\n8 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given an undirected graph without self-loops or multiple edges which consists of n vertices and m edges. Also you are given three integers n_1, n_2 and n_3.\n\nCan you label each vertex with one of three numbers 1... | [{"type": "stdin_stdout", "input": "5000 1\n0 1 4999\n3801 107\n", "output": "YES\n333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333323333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given an array a consisting of n positive integers.\n\nInitially, you have an integer x = 0. During one move, you can do one of the following two operations:\n\n 1. Choose exactly one i from 1 to n and increase a... | [{"type": "stdin_stdout", "input": "5\n4 3\n1 2 1 3\n10 6\n8 7 1 8 3 7 1 10 8 9\n5 13\n20 100 74 20 100500\n10 25\n24 39 19 24 24 87 24 24 24 10\n8 8\n1 2 3 4 5 7 7 12\n", "output": "6\n24\n20\n127\n13\n"}, {"type": "stdin_stdout", "input": "5\n4 3\n1 2 1 3\n10 6\n8 7 1 8 3 7 0 10 8 9\n5 13\n20 100 50 20 100500\n10 25\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nZiota found a video game called \"Monster Invaders\".\n\nSimilar to every other shooting RPG game, \"Monster Invaders\" involves killing monsters and bosses with guns.\n\nFor the sake of simplicity, we only consider two d... | [{"type": "stdin_stdout", "input": "100 5 5 9 3\n3 4 2 3 4 3 8 5 2 1 1 4 1 1 10 10 7 5 2 9 4 2 10 10 8 2 4 9 6 2 6 7 7 5 7 7 1 8 10 9 9 3 10 3 10 1 1 8 3 6 4 5 5 4 9 5 9 4 8 2 10 8 9 1 5 9 7 2 1 7 9 3 2 9 1 5 4 2 3 10 6 7 8 2 10 1 6 2 1 6 10 9 1 2 2 7 2 8 4 4\n", "output": "1597\n"}, {"type": "stdin_stdout", "input": "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn order to celebrate Twice's 5th anniversary, Tzuyu and Sana decided to play a game.\n\nTzuyu gave Sana two integers a and b and a really important quest.\n\nIn order to complete the quest, Sana has to output the smalles... | [{"type": "stdin_stdout", "input": "6\n6 12\n8 4\n90 1219\n55 14\n6484 2912\n2 1\n", "output": "10\n12\n1177\n57\n4660\n3\n"}, {"type": "stdin_stdout", "input": "6\n6 12\n13 4\n90 1219\n55 14\n6484 2912\n2 1\n", "output": "10\n9\n1177\n57\n4660\n3\n"}, {"type": "stdin_stdout", "input": "6\n6 12\n8 6\n90 1219\n55 14\n64... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOnly a few know that Pan and Apollo weren't only battling for the title of the GOAT musician. A few millenniums later, they also challenged each other in math (or rather in fast calculations). The task they got to solve i... | [{"type": "stdin_stdout", "input": "8\n2\n1 7\n3\n1 2 4\n4\n5 5 5 5\n5\n6 2 2 1 0\n1\n0\n1\n1\n6\n1 12 123 1234 12345 123456\n5\n536870912 536870911 1152921504606846975 1152921504606846974 1152921504606846973\n", "output": "\n128\n91\n1600\n505\n0\n1\n502811676\n264880351\n"}, {"type": "stdin_stdout", "input": "8\n2\n1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPolycarp was gifted an array a of length n. Polycarp considers an array beautiful if there exists a number C, such that each number in the array occurs either zero or C times. Polycarp wants to remove some elements from t... | [{"type": "stdin_stdout", "input": "1\n36\n1 2 2 3 3 11 14 4 4 10 5 5 6 8 6 10 7 2 7 7 13 8 8 15 9 9 9 9 10 17 10 10 12 12 12 19\n", "output": "16\n"}, {"type": "stdin_stdout", "input": "1\n36\n1 2 2 3 2 38 14 4 1 10 5 2 2 8 6 6 16 4 7 7 13 8 5 9 9 2 2 9 10 17 10 10 24 12 29 37\n", "output": "17\n"}, {"type": "stdin_st... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA sequence of n non-negative integers (n ≥ 2) a_1, a_2, ..., a_n is called good if for all i from 1 to n-1 the following condition holds true: $$$a_1 \\: \\& \\: a_2 \\: \\& \\: ... \\: \\& \\: a_i = a_{i+1} \\: \\& \\: a... | [{"type": "stdin_stdout", "input": "4\n3\n2 1 1\n5\n1 0 2 0 27\n5\n1 2 1 16 0\n2\n3 8 18 2\n", "output": "0\n12\n0\n0\n"}, {"type": "stdin_stdout", "input": "4\n3\n2 0 0\n5\n0 3 2 0 51\n5\n1 2 1 16 0\n2\n3 8 21 2\n", "output": "2\n12\n0\n0\n"}, {"type": "stdin_stdout", "input": "4\n3\n2 1 1\n5\n0 4 2 0 21\n5\n0 4 2 8 0... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe new operating system BerOS has a nice feature. It is possible to use any number of characters '/' as a delimiter in path instead of one traditional '/'. For example, strings //usr///local//nginx/sbin// and /usr/local/... | [{"type": "stdin_stdout", "input": "/zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\n", "output": "/zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\n"}, {"type": "stdin_stdout", "input": "/a/a/a/a/a/a/a/a/a/a/a/a/a/... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe cows have just learned what a primitive root is! Given a prime p, a primitive root <image> is an integer x (1 ≤ x < p) such that none of integers x - 1, x2 - 1, ..., xp - 2 - 1 are divisible by p, but xp - 1 - 1 is. \... | [{"type": "stdin_stdout", "input": "1619\n", "output": "808\n"}, {"type": "stdin_stdout", "input": "1193\n", "output": "592\n"}, {"type": "stdin_stdout", "input": "1327\n", "output": "384\n"}, {"type": "stdin_stdout", "input": "1217\n", "output": "576\n"}, {"type": "stdin_stdout", "input": "1549\n", "output": "504\n"},... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPetya wrote a programme on C++ that calculated a very interesting function f(n). Petya ran the program with a certain value of n and went to the kitchen to have some tea. The history has no records concerning how long the... | [{"type": "stdin_stdout", "input": "32657\nint f(int n){if (n < 7) return 1; return f(n-1)+f(n-2)+f(n-3)+f(n-4)+f(n-5)-f(n-6)-f(n-7);}\n", "output": "32308"}, {"type": "stdin_stdout", "input": "1\nint f(int n){if (n < 1) return 1;if (n < 2) return 0;return f(f(f(f(f(f(f(f(f(f(n-1))))))))));}\n", "output": "32766"}, {"t... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIndian summer is such a beautiful time of the year! A girl named Alyona is walking in the forest and picking a bouquet from fallen leaves. Alyona is very choosy — she doesn't take a leaf if it matches the color and the sp... | [{"type": "stdin_stdout", "input": "17\njtbctslqq tosqzw\njtbctslqq tosqzw\njtbctslqq tosqzw\njtbctslqq tosqzw\njtbctslqq tosqzw\njtbctslqq tosqzw\njtbctslqq tosqzw\njtbctslqq tosqzw\njtbctslqq tosqzw\njtbctslqq tosqzw\njtbctslqq tosqzw\njtbltscqq tosqzw\njtbctslqq tosqzw\njtbctslqq tosqzw\njtbctslqq tosqzw\njtbctslqq ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA and B are preparing themselves for programming contests.\n\nTo train their logical thinking and solve problems better, A and B decided to play chess. During the game A wondered whose position is now stronger.\n\nFor eac... | [{"type": "stdin_stdout", "input": "rppppppr\n...k....\n........\n........\n........\n........\nK...Q...\n........\n", "output": "Black\n"}, {"type": "stdin_stdout", "input": "...QK...\n........\n........\n........\n........\n........\n........\n...rk...\n", "output": "White\n"}, {"type": "stdin_stdout", "input": "P...... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLittle Susie loves strings. Today she calculates distances between them. As Susie is a small girl after all, her strings contain only digits zero and one. She uses the definition of Hamming distance:\n\nWe will define the... | [{"type": "stdin_stdout", "input": "00001111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\n1111110000000000000000000000000000000000000000000000000000000000000000000000000000... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = ki·x + bi. It wa... | [{"type": "stdin_stdout", "input": "10\n22290 75956\n-66905 -22602\n-88719 12654\n-191 -81032\n0 -26057\n-39609 0\n0 51194\n2648 88230\n90584 15544\n0 23060\n-29107 26878\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "10\n22290 75956\n-66905 -22602\n-88719 12654\n-191 -81032\n0 -26057\n-39609 0\n0 51194\n490... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIvan wants to make a necklace as a present to his beloved girl. A necklace is a cyclic sequence of beads of different colors. Ivan says that necklace is beautiful relative to the cut point between two adjacent beads, if t... | [{"type": "stdin_stdout", "input": "3\n33332 19151 47433\n", "output": "0\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTwo positive integers a and b have a sum of s and a bitwise XOR of x. How many possible values are there for the ordered pair (a, b)?\n\nInput\n\nThe first line of the input contains two integers s and x (2 ≤ s ≤ 1012, 0 ... | [{"type": "stdin_stdout", "input": "549755813887 549755813887\n", "output": "549755813886"}, {"type": "stdin_stdout", "input": "549755813888 549755813886\n", "output": "274877906944"}, {"type": "stdin_stdout", "input": "274861129991 274861129463\n", "output": "34359738368"}, {"type": "stdin_stdout", "input": "412182675... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPari wants to buy an expensive chocolate from Arya. She has n coins, the value of the i-th coin is ci. The price of the chocolate is k, so Pari will take a subset of her coins with sum equal to k and give it to Arya.\n\nL... | [{"type": "stdin_stdout", "input": "9 436\n1 2 4 8 14 32 27 128 256\n", "output": "160\n0 1 2 3 4 6 8 9 10 11 14 15 16 17 18 20 22 23 24 25 27 28 29 30 32 34 35 36 37 38 41 42 43 44 46 48 49 50 51 52 128 129 130 131 132 134 136 137 138 139 142 143 144 145 146 148 150 151 152 153 155 156 157 158 160 162 163 164 165 166 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nFangy the little walrus, as all the modern walruses, loves to communicate via text messaging. One day he faced the following problem: When he sends large texts, they are split into parts each containing n characters (whic... | [{"type": "stdin_stdout", "input": "123\nOjg CVJm qfE RnHislFds nNKKt TCPLWukqNGAsVBplYbTfq? VeYKjfFGTzXWA ydpVZLIImNub yApKnAHv iXQmqv GjQvxrnAgtfTApiQyCKtg. GdmapGwvI udRqxTbnzgnOUNZx slAuEuLGCJycZJvtCczQ vommS xuuT eIK! DOJeFEaubbz HYLGlIIlNKfyaJQKVN eFNnUvKKCQLXvGhwX gjmRscMkedELUlHq? aTbyMGB EofzX wcAEjyRQpxghWvXh... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA famous Berland's painter Kalevitch likes to shock the public. One of his last obsessions is chess. For more than a thousand years people have been playing this old game on uninteresting, monotonous boards. Kalevitch dec... | [{"type": "stdin_stdout", "input": "BBBBBBBB\nBBBBBBBB\nBBBBBBBB\nBBBBBBBB\nBBBBBBBB\nBBBBBBBB\nBBBBBBBB\nBWBBWBWB\n", "output": "12\n"}, {"type": "stdin_stdout", "input": "BWBBBWWB\nBWBBBWWB\nBBBBBBBB\nBBBBBBBB\nBWBBBWWB\nBBBBBBBB\nBBBBBBBB\nBBBBBBBB\n", "output": "10\n"}, {"type": "stdin_stdout", "input": "BBBBBBBB\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSometimes Mister B has free evenings when he doesn't know what to do. Fortunately, Mister B found a new game, where the player can play against aliens.\n\nAll characters in this game are lowercase English letters. There a... | [{"type": "stdin_stdout", "input": "12 12 876543210 1000000000\n", "output": "13"}, {"type": "stdin_stdout", "input": "10 12 220000011 220000032\n", "output": "11"}, {"type": "stdin_stdout", "input": "3 10 498103029 1063506054\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "13 8 654321109 654321126\n", "output... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nRecently Luba bought a monitor. Monitor is a rectangular matrix of size n × m. But then she started to notice that some pixels cease to work properly. Luba thinks that the monitor will become broken the first moment when ... | [{"type": "stdin_stdout", "input": "29 50 5 29\n21 42 1565821\n21 43 53275635\n21 44 2717830\n21 45 9579585\n21 46 20725775\n22 42 2568372\n22 43 9584662\n22 44 31411635\n22 45 5089311\n22 46 4960702\n23 42 11362237\n23 43 42200296\n23 44 18762146\n23 45 8553819\n23 46 4819516\n24 42 10226552\n24 43 21022685\n24 44 329... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVova promised himself that he would never play computer games... But recently Firestorm — a well-known game developing company — published their newest game, World of Farcraft, and it became really popular. Of course, Vov... | [{"type": "stdin_stdout", "input": "10 5\n1 6 2 11 3 8 4 9 5 10\n1 2\n3 5\n5 6\n7 10\n9 10\n", "output": "27\n"}, {"type": "stdin_stdout", "input": "10 3\n1 6 2 27 1 8 1 9 5 1\n1 2\n3 1\n10 6\n7 8\n17 10\n", "output": "45\n"}, {"type": "stdin_stdout", "input": "10 3\n1 6 2 17 1 8 1 9 5 1\n1 2\n3 1\n10 6\n7 8\n17 10\n",... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVictor tries to write his own text editor, with word correction included. However, the rules of word correction are really strange.\n\nVictor thinks that if a word contains two consecutive vowels, then it's kinda weird an... | [{"type": "stdin_stdout", "input": "90\nbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n", "output": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n"}, {"type": "stdin_stdout", "input": "90\nbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIt is lunch time at the Vibrant Gujarat Summit and all the investors are called for the executive lunch. When Bruce reached the lunch area, he found that the waiter was taking out bowls from a big box containing some amou... | [{"type": "stdin_stdout", "input": "31509019101", "output": "22280241075\n"}, {"type": "stdin_stdout", "input": "21\n\nSAMPLE", "output": "15\n"}, {"type": "stdin_stdout", "input": "21\n\nSAMELP", "output": "15\n"}, {"type": "stdin_stdout", "input": "21\n\nSAMEKP", "output": "15\n"}, {"type": "stdin_stdout", "input": "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nMonk visits Biksy, the largest trading market in the land. Biksy has traders from all over the world.\nThere are a total of N items indexed from 1 to N, that are traded in the market by a total of M dealers. Each trader i... | [{"type": "stdin_stdout", "input": "2\n5 6\n1 2 2\n2 3 -2\n3 0 -7\n4 5 0\n2 3 -2\n3 5 6\n5 8\n1 0 10\n2 -2 -6\n5 2 5\n4 5 11\n1 5 1\n1 4 -10\n2 3 -2\n4 1 1\n\nSMAPLE", "output": "No\nYes\n"}, {"type": "stdin_stdout", "input": "2\n5 6\n1 2 2\n4 3 -2\n3 0 -7\n4 5 0\n2 3 -2\n3 5 6\n5 8\n1 0 10\n2 -2 -6\n5 2 5\n4 5 11\n1 5... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nDefinition:\nRoy's boolean function (RBF) is True, if number of the positive integers less than or equal to N that are relatively prime to N, is prime; else False.\nIn other words, let Z be the number of integers K in the... | [{"type": "stdin_stdout", "input": "10\n93937\n91678\n97274\n5\n90836\n94116\n91419\n91453\n96110\n95153", "output": "FALSE\nFALSE\nFALSE\nFALSE\nFALSE\nFALSE\nFALSE\nFALSE\nFALSE\nFALSE\n"}, {"type": "stdin_stdout", "input": "10\n93937\n91678\n97274\n5\n90836\n94116\n91419\n87816\n96110\n95153", "output": "FALSE\nFALS... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWith the T20 world cup going on, a list of batsmen was prepared with their country code and their T20I career runs. \nThe list contains data of N batsmen (country-code and runs). \nNumber of countries may range from 1 t... | [{"type": "stdin_stdout", "input": "5\n4 12\n2 1\n3 10\n2 7\n2 5\n\nSAMPLE", "output": "2 7\n2 5\n2 1\n3 10\n4 12\n"}, {"type": "stdin_stdout", "input": "5\n4 12\n2 1\n3 10\n2 6\n2 5\n\nSAMPLE", "output": "2 6\n2 5\n2 1\n3 10\n4 12\n"}, {"type": "stdin_stdout", "input": "5\n4 12\n2 1\n3 10\n2 6\n1 5\n\nSAMPLE", "output... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWe will buy a product for N yen (the currency of Japan) at a shop.\n\nIf we use only 1000-yen bills to pay the price, how much change will we receive?\n\nAssume we use the minimum number of bills required.\n\nConstraints\... | [{"type": "stdin_stdout", "input": "5614", "output": "386\n"}, {"type": "stdin_stdout", "input": "2651", "output": "349\n"}, {"type": "stdin_stdout", "input": "1858", "output": "142\n"}, {"type": "stdin_stdout", "input": "1054", "output": "946\n"}, {"type": "stdin_stdout", "input": "1861", "output": "139\n"}, {"type": ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nDoes \\sqrt{a} + \\sqrt{b} < \\sqrt{c} hold?\n\nConstraints\n\n* 1 \\leq a, b, c \\leq 10^9\n* All values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\n\na \\ b \\ c\n\n... | [{"type": "stdin_stdout", "input": "-10 -1 1", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "-10 -1 0", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "-16 -1 0", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "110 -1 -3", "output": "No\n"}, {"type": "stdin_stdout", "input": "-1 -14 2", "output":... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWe have two indistinguishable pieces placed on a number line. Both pieces are initially at coordinate 0. (They can occupy the same position.)\n\nWe can do the following two kinds of operations:\n\n* Choose a piece and mov... | [{"type": "stdin_stdout", "input": "1010000 100000 200000", "output": "489638142\n"}, {"type": "stdin_stdout", "input": "1010000 100001 200000", "output": "645079609\n"}, {"type": "stdin_stdout", "input": "1011000 100001 200000", "output": "150445035\n"}, {"type": "stdin_stdout", "input": "1011001 100001 200000", "outp... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\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 in... | [{"type": "stdin_stdout", "input": "8\n1 1 10 0 -1 -1 216 -1", "output": "201\n"}, {"type": "stdin_stdout", "input": "8\n1 1 10 1 -1 -1 216 -1", "output": "200\n"}, {"type": "stdin_stdout", "input": "8\n1 1 10 0 2 -1 190 -1", "output": "174\n"}, {"type": "stdin_stdout", "input": "8\n1 1 10 0 0 -1 359 -1", "output": "34... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nFor a positive integer n, let us define f(n) as the number of digits in base 10.\n\nYou are given an integer S. Count the number of the pairs of positive integers (l, r) (l \\leq r) such that f(l) + f(l + 1) + ... + f(r) ... | [{"type": "stdin_stdout", "input": "112006", "output": "281515698\n"}, {"type": "stdin_stdout", "input": "124627", "output": "691899329\n"}, {"type": "stdin_stdout", "input": "136594", "output": "280082176\n"}, {"type": "stdin_stdout", "input": "133460", "output": "890005486\n"}, {"type": "stdin_stdout", "input": "2109... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given N points (x_i,y_i) located on a two-dimensional plane. Consider a subset S of the N points that forms a convex polygon. Here, we say a set of points S forms a convex polygon when there exists a convex polygo... | [{"type": "stdin_stdout", "input": "5\n1 0\n-1 1\n0 2\n0 3\n1 2", "output": "16"}, {"type": "stdin_stdout", "input": "5\n0 0\n0 1\n0 2\n0 3\n1 1", "output": "11"}, {"type": "stdin_stdout", "input": "5\n0 0\n0 1\n0 2\n0 3\n1 2", "output": "11"}, {"type": "stdin_stdout", "input": "5\n1 0\n0 1\n0 2\n0 3\n1 2", "output": "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nDolphin loves programming contests. Today, he will take part in a contest in AtCoder.\nIn this country, 24-hour clock is used. For example, 9:00 p.m. is referred to as \"21 o'clock\".\nThe current time is A o'clock, and a... | [{"type": "stdin_stdout", "input": "405 14", "output": "11\n"}, {"type": "stdin_stdout", "input": "17 -1", "output": "16\n"}, {"type": "stdin_stdout", "input": "62 -1", "output": "13\n"}, {"type": "stdin_stdout", "input": "45 -1", "output": "20\n"}, {"type": "stdin_stdout", "input": "45 -2", "output": "19\n"}, {"type":... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere is a double-track line (up and down are separate lines and pass each other everywhere). There are 11 stations on this line, including the terminal station, and each station is called by the section number shown in t... | [{"type": "stdin_stdout", "input": "06,04,1,2,1,1,1,1,1,1,1,2\n1,1,1,1,1,4,3,3,3,3,505,0\n10,10,10,10,10,10,10,10,10,10,50,49", "output": "2\n10\n6\n"}, {"type": "stdin_stdout", "input": "06,14,1,1,0,1,1,1,1,1,1,0\n1,1,1,1,1,3,3,3,3,3,40,50\n10,10,10,10,10,10,10,20,10,10,59,40", "output": "10\n7\n7\n"}, {"type": "stdin... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nCreate a program that inputs the vertex information of two polygons inscribed in one circle and outputs the magnitude relationship of their areas.\n\nAssume that each vertex of the X-side is numbered counterclockwise from... | [{"type": "stdin_stdout", "input": "4\n30\n125\n75\n4\n30\n125\n75\n5\n30\n125\n149\n65\n4\n30\n125\n75\n4\n30\n125\n75\n6\n52\n50\n50\n25\n75\n0", "output": "0\n2\n2\n"}, {"type": "stdin_stdout", "input": "4\n30\n125\n75\n4\n30\n125\n75\n5\n30\n125\n149\n65\n4\n30\n125\n75\n4\n30\n125\n75\n6\n52\n79\n50\n25\n75\n0", "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAddition is easy to calculate by hand, but if some numbers are missing, is it easy to fill in the missing numbers? For example, in the following long division, if there is a condition that the numbers 1 to 9 appear only o... | [{"type": "stdin_stdout", "input": "-1 -1 -1 -1 -1 -1 -1 -1 -1", "output": "168"}, {"type": "stdin_stdout", "input": "-1 -1 -1 -1 -1 -1 8 4 6", "output": "12"}, {"type": "stdin_stdout", "input": "-1 -1 -1 -1 -1 -1 3 4 6", "output": "0\n"}, {"type": "stdin_stdout", "input": "-1 -1 -1 -1 -1 -1 3 2 6", "output": "0\n"}, {... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nproblem\n\nThe JOI building is a combination of regular hexagons with a side of 1 meter as shown in the figure. As Christmas is approaching, JOI decided to decorate the walls of the building with illuminations. However, s... | [{"type": "stdin_stdout", "input": "11 1\n0 1 0 1 0 1 1 1\n0 1 1 -4 0 1 -1 1\n2 1 1 0 1 1 1 1\n0 1 1 1 1 0 -1 0", "output": "36\n"}, {"type": "stdin_stdout", "input": "8 0\n-1 1 0 2 0 2 2 0\n1 4 1 0 -1 1 0 -2\n1 0 1 0 2 1 1 2\n0 1 1 0 1 -1 2 1", "output": "0\n"}, {"type": "stdin_stdout", "input": "8 0\n-1 1 0 2 0 2 2 0... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYoko’s math homework today was to calculate areas of polygons in the xy-plane. Vertices are all aligned to grid points (i.e. they have integer coordinates).\n\nYour job is to help Yoko, not good either at math or at compu... | [{"type": "stdin_stdout", "input": "4\n5 -3\n-1 0\n1 7\n-7 -1\n3\n5 5\n27 6\n5 14\n3\n-7 -5\n-5 -10\n-18 -10\n5\n0 0\n20 2\n11 1\n21 2\n2 0\n0", "output": "49\n124\n43\n23\n"}, {"type": "stdin_stdout", "input": "4\n5 -3\n-1 0\n1 7\n-7 -1\n3\n4 5\n27 6\n5 14\n3\n-7 -5\n-5 -10\n-18 -10\n5\n0 0\n20 2\n11 1\n21 2\n2 0\n0",... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nExample\n\nInput\n\n6\n2\n3\n1\n1\n4\n2\n\n\nOutput\n\nYes\nYes\nYes\nNo\nYes\nNo\n\nThe input will be given via stdin and the output should be printed to stdout by your code.\n\nNow solve the problem by providing the cod... | [{"type": "stdin_stdout", "input": "6\n2\n3\n2\n1\n11\n2", "output": "Yes\nYes\nYes\nNo\nYes\nYes\n"}, {"type": "stdin_stdout", "input": "6\n2\n10\n0\n4\n4\n1", "output": "Yes\nYes\nNo\nYes\nYes\nYes\n"}, {"type": "stdin_stdout", "input": "6\n6\n8\n1\n2\n5\n3", "output": "Yes\nYes\nYes\nYes\nYes\nYes\n"}, {"type": "std... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nEntrance Examination\n\nThe International Competitive Programming College (ICPC) is famous for its research on competitive programming. Applicants to the college are required to take its entrance examination.\n\nThe succe... | [{"type": "stdin_stdout", "input": "5 2 4\n100\n90\n82\n70\n65\n5 2 4\n100\n170\n80\n75\n65\n3 1 2\n5000\n6502\n3000\n4 2 3\n10000\n10100\n8000\n8000\n4 2 3\n10000\n10000\n10000\n8000\n5 2 3\n100\n80\n136\n60\n111\n0 0 0", "output": "3\n2\n2\n2\n3\n3\n"}, {"type": "stdin_stdout", "input": "5 2 3\n100\n161\n82\n70\n65\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nG --Derangement / Derangement\n\nStory\n\nPerson D is doing research on permutations. At one point, D found a permutation class called \"Derangement\". \"It's cool to have a perfect permutation !!! And it starts with D !!... | [{"type": "stdin_stdout", "input": "5\n4 0 0 10 12", "output": "0\n"}, {"type": "stdin_stdout", "input": "5\n4 1 0 10 12", "output": "0\n"}, {"type": "stdin_stdout", "input": "5\n4 1 0 10 19", "output": "0\n"}, {"type": "stdin_stdout", "input": "5\n4 1 0 10 38", "output": "0\n"}, {"type": "stdin_stdout", "input": "5\n4... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWrite a program which reads a sequence and prints it in the reverse order.\n\nNote\n\n解説\n\nConstraints\n\n* n ≤ 100\n* 0 ≤ ai < 1000\n\nInput\n\nThe input is given in the following format:\n\n\nn\na1 a2 . . . an\n\n\nn i... | [{"type": "stdin_stdout", "input": "8\n-2 0 0 32 -1 -2 153 26", "output": "26 153 -2 -1 32 0 0 -2\n"}, {"type": "stdin_stdout", "input": "8\n-2 0 0 32 -2 -2 153 26", "output": "26 153 -2 -2 32 0 0 -2\n"}, {"type": "stdin_stdout", "input": "8\n-2 1 0 32 -2 -2 153 26", "output": "26 153 -2 -2 32 0 1 -2\n"}, {"type": "std... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given two strings s and t. In a single move, you can choose any of two strings and delete the first (that is, the leftmost) character. After a move, the length of the string decreases by 1. You can't choose a stri... | [{"type": "stdin_stdout", "input": "lxuyspmieeuyxluv\naalbtcxzvavqxwfd\n", "output": "32\n"}, {"type": "stdin_stdout", "input": "kxuyspmieeuyxluv\naalbtcxzvavqxwfd\n", "output": "32\n"}, {"type": "stdin_stdout", "input": "vulxyueeimpsyuxk\naalbtcxzvavqxwfd\n", "output": "32\n"}, {"type": "stdin_stdout", "input": "vulxy... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a string s consisting only of lowercase Latin letters.\n\nYou can rearrange all letters of this string as you wish. Your task is to obtain a good string by rearranging the letters of the given string or repo... | [{"type": "stdin_stdout", "input": "100\naa\nb\ncbc\nc\nbab\nc\nbdb\ndd\nhfh\nebe\nb\nf\ngg\na\nm\nkkk\nqq\ni\noo\nss\ntt\nere\njgj\nqiq\nkk\nn\naaa\nb\naa\nb\nc\na\nf\ne\na\naa\nff\ne\na\nafa\no\nmom\nqq\nf\niii\nh\njj\njj\nkgk\nbb\nhih\nj\na\naaa\nbb\nbab\ne\naa\nd\nb\nfdf\nibi\nbb\nfhf\ncc\nf\ngig\nene\nbob\na\nrcr\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOne day Sasha visited the farmer 2D and his famous magnetic farm. On this farm, the crop grows due to the influence of a special magnetic field. Maintaining of the magnetic field is provided by n machines, and the power o... | [{"type": "stdin_stdout", "input": "166\n61 19 19 67 11 11 73 89 73 11 47 2 59 43 61 31 19 83 71 19 29 97 89 97 2 11 5 73 19 2 19 7 41 53 5 23 11 89 2 23 47 47 83 71 17 71 67 67 67 3 29 97 17 83 11 19 67 17 97 7 19 29 29 41 13 71 29 19 19 43 47 17 71 3 13 71 41 19 47 7 29 43 29 97 31 11 43 17 23 83 37 61 79 31 17 5 59 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA superhero fights with a monster. The battle consists of rounds, each of which lasts exactly n minutes. After a round ends, the next round starts immediately. This is repeated over and over again.\n\nEach round has the s... | [{"type": "stdin_stdout", "input": "1000000000000 10\n-10 5 -2 -2 -10 -7 -5 -9 -3 -4\n", "output": "212765957448\n"}, {"type": "stdin_stdout", "input": "1000000000000 10\n-10 9 -2 -2 -10 -7 -5 -9 -3 -4\n", "output": "232558139536\n"}, {"type": "stdin_stdout", "input": "1000000000000 10\n-14 9 -2 -2 -10 -7 -5 -9 -3 -4\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are organizing a boxing tournament, where n boxers will participate (n is a power of 2), and your friend is one of them. All boxers have different strength from 1 to n, and boxer i wins in the match against boxer j if... | [{"type": "stdin_stdout", "input": "128\n-1 37 147 12 24 35 86 39 20 27 86 95 51 8 33 32 55 35 8 75 74 79 64 51 66 32 34 45 39 89 19 11 86 31 69 58 40 58 62 11 99 54 31 10 4 70 88 22 94 23 46 20 65 97 61 39 31 65 23 31 95 78 40 25 51 14 12 55 8 63 18 57 91 75 31 26 22 84 29 22 32 64 20 12 49 92 50 4 97 17 26 88 10 56 7... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLogical quantifiers are very useful tools for expressing claims about a set. For this problem, let's focus on the set of real numbers specifically. The set of real numbers includes zero and negatives. There are two kinds ... | [{"type": "stdin_stdout", "input": "100 50\n55 13\n84 2\n22 63\n100 91\n2 18\n98 64\n1 86\n93 11\n17 12\n24 97\n14 35\n24 74\n22 3\n42 5\n63 79\n31 89\n81 22\n86 88\n77 51\n81 34\n19 55\n41 54\n34 57\n45 9\n55 72\n67 61\n41 84\n39 32\n51 89\n58 74\n32 79\n65 6\n86 64\n63 42\n100 57\n46 39\n100 9\n23 58\n26 81\n61 49\n7... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPolycarp wrote on the board a string s containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input.\n\nAfter that, he erased some letters from the string s, and he rewrote the re... | [{"type": "stdin_stdout", "input": "10\nvzsxyuyy\n3\n1 0 3\nwwvutuxsuxywut\n2\n0 0\nsuzvsvutvvstuz\n3\n3 1 0\nstyuwsutv\n4\n6 3 0 1\nzsustytvzsyw\n6\n0 9 5 7 7 5\nsvwxwwwyxuvszx\n1\n0\nxuyyvuztxwuuvsxwz\n5\n5 7 0 0 7\nuxuztuwsxz\n5\n4 2 2 0 10\nxystzstwtzwsz\n2\n1 0\nuuzss\n1\n0\n", "output": "yzx\nxx\nuvz\nuvyw\nztwtv... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nCaptain Fint is involved in another treasure hunt, but have found only one strange problem. The problem may be connected to the treasure's location or may not. That's why captain Flint decided to leave the solving the pro... | [{"type": "stdin_stdout", "input": "10\n-18 -1 2 3 5 -2 -3 -1 2 -11\n-1 -1 2 2 -1 5 5 7 7 9\n", "output": "-17\n3 4 2 9 5 7 10 8 6 1 "}, {"type": "stdin_stdout", "input": "10\n-10 -1 2 1 5 -2 -3 -3 2 -6\n-1 -1 2 2 -1 5 5 10 7 9\n", "output": "-10\n3 4 2 9 5 7 10 8 6 1 "}, {"type": "stdin_stdout", "input": "10\n-18 -1 2... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given four integers a, b, x and y. Initially, a ≥ x and b ≥ y. You can do the following operation no more than n times:\n\n * Choose either a or b and decrease it by one. However, as a result of this operation, v... | [{"type": "stdin_stdout", "input": "7\n10 10 8 5 3\n12 8 8 7 2\n12343 43 4543 39 123212\n1000000000 1000000000 1 1 1\n1000000000 1000000000 1 1 1000000000\n10 11 2 1 5\n10 11 9 1 10\n", "output": "70\n77\n177177\n999999999000000000\n999999999\n55\n10\n"}, {"type": "stdin_stdout", "input": "7\n10 10 8 5 3\n12 8 0 7 2\n1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGreg the Dwarf has been really busy recently with excavations by the Neverland Mountain. However for the well-known reasons (as you probably remember he is a very unusual dwarf and he cannot stand sunlight) Greg can only ... | [{"type": "stdin_stdout", "input": "1000 1000\n-20.534295190826231 133.273184243935670 865.154166109953510\n-711.474516721095600 -638.507879949720520 44.024947657417599\n", "output": "1355.67674395639642\n"}, {"type": "stdin_stdout", "input": "1000 1000\n-865.729850457726000 -306.217565767793640 81.709538567284440\n891... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGildong has an interesting machine that has an array a with n integers. The machine supports two kinds of operations:\n\n 1. Increase all elements of a suffix of the array by 1. \n 2. Decrease all elements of a suffix o... | [{"type": "stdin_stdout", "input": "7\n2\n0 1\n3\n-1 0 2\n4\n110 133 106 95\n4\n-3 -5 -2 1\n6\n1 8 3 8 4 1\n5\n5 0 0 0 5\n9\n-367741579 319422997 -415264583 -125558838 -300860379 721691728 294512916 -383235489 425814447\n", "output": "0\n1\n15\n4\n14\n5\n3449059550\n"}, {"type": "stdin_stdout", "input": "7\n2\n0 1\n3\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere is a deck of n cards. The i-th card has a number a_i on the front and a number b_i on the back. Every integer between 1 and 2n appears exactly once on the cards.\n\nA deck is called sorted if the front values are in... | [{"type": "stdin_stdout", "input": "20\n7 29\n4 34\n40 2\n39 10\n33 5\n1 37\n20 23\n14 21\n22 9\n8 28\n19 24\n26 13\n32 6\n30 16\n11 38\n36 3\n35 12\n15 31\n17 27\n18 25\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "20\n24 12\n37 1\n5 35\n36 19\n22 6\n25 4\n26 17\n15 31\n39 8\n28 16\n11 29\n21 18\n14 34\n30... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe only difference between the easy and hard versions is that the given string s in the easy version is initially a palindrome, this condition is not always true for the hard version.\n\nA palindrome is a string that rea... | [{"type": "stdin_stdout", "input": "3\n3\n110\n2\n00\n4\n1010\n", "output": "\nALICE\nBOB\nALICE\n"}, {"type": "stdin_stdout", "input": "3\n3\n110\n2\n00\n4\n1011\n", "output": "ALICE\nBOB\nALICE\n"}, {"type": "stdin_stdout", "input": "3\n3\n110\n2\n00\n4\n0011\n", "output": "ALICE\nBOB\nALICE\n"}, {"type": "stdin_stdo... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPolycarpus has a hobby — he develops an unusual social network. His work is almost completed, and there is only one more module to implement — the module which determines friends. Oh yes, in this social network one won't ... | [{"type": "stdin_stdout", "input": "10 2\nrclgdpxdefqu abrfhwigaihoqq 0\nabrfhwigaihoqq rclgdpxdefqu 1\nrclgdpxdefqu bvkfwutdtvxgvx 1\nrclgdpxdefqu abrfhwigaihoqq 1\nabrfhwigaihoqq bvkfwutdtvxgvx 2\nbvkfwutdtvxgvx abrfhwigaihoqq 2\nbvkfwutdtvxgvx abrfhwigaihoqq 3\nabrfhwigaihoqq rclgdpxdefqu 5\nabrfhwigaihoqq rclgdpxde... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe Smart Beaver from ABBYY loves puzzles. One of his favorite puzzles is the magic square. He has recently had an idea to automate the solution of this puzzle. The Beaver decided to offer this challenge to the ABBYY Cup ... | [{"type": "stdin_stdout", "input": "4\n-71868244 -24941524 -24941524 -24941524 -24941524 -24941524 -24941524 -6170836 21985196 21985196 21985196 21985196 40755884 40755884 40755884 68911916\n", "output": "12858032\n-24941524 -71868244 68911916 40755884\n21985196 40755884 -24941524 -24941524\n40755884 21985196 -24941524... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nRecently, Valery have come across an entirely new programming language. Most of all the language attracted him with template functions and procedures. Let us remind you that templates are tools of a language, designed to ... | [{"type": "stdin_stdout", "input": "5\n void 8os6s2b ( T )\n void 8os6s2b ( int, int, int,int, int ) \n void 8os6s2b ( int, int, T) \n void fow8dmm ( T,T, int, int ) \n void fow8dmm ( int) \n2\n int 2 \n double 9c9t0 \n7\n 8os6s2b ( 9c9t0 ) \n 8os6s2b (9c9t0,9c9t0,9c9t0 ) \n8os6s2b ( 9c9t0,... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nNowadays the one-way traffic is introduced all over the world in order to improve driving safety and reduce traffic jams. The government of Berland decided to keep up with new trends. Formerly all n cities of Berland were... | [{"type": "stdin_stdout", "input": "50\n30 34 48\n11 30 15\n11 5 179\n4 5 57\n43 4 21\n14 43 74\n14 19 52\n45 19 60\n45 28 52\n24 28 94\n24 26 2\n48 26 34\n48 13 53\n13 42 7\n42 37 23\n37 17 70\n17 7 29\n20 7 93\n33 20 21\n33 2 53\n21 2 83\n49 21 33\n46 49 28\n18 46 1\n36 18 99\n47 36 52\n47 29 41\n41 29 40\n31 41 45\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe employees of the R1 company often spend time together: they watch football, they go camping, they solve contests. So, it's no big deal that sometimes someone pays for someone else.\n\nToday is the day of giving out mo... | [{"type": "stdin_stdout", "input": "10 45\n10 5\n10 7\n6 1\n5 8\n3 5\n6 5\n1 2\n6 10\n2 9\n9 5\n4 1\n9 5\n1 8\n6 8\n10 9\n7 2\n7 9\n4 10\n7 3\n4 9\n10 3\n10 8\n2 10\n8 2\n3 2\n5 2\n9 1\n4 5\n1 3\n9 10\n3 8\n5 1\n6 4\n4 7\n8 7\n7 1\n9 3\n3 4\n6 3\n3 2\n6 7\n6 3\n4 9\n8 9\n1 10\n", "output": "10 4 3 7 8 5 9 2 1 6 "}, {"t... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOne day Vasya decided to have a look at the results of Berland 1910 Football Championship’s finals. Unfortunately he didn't find the overall score of the match; however, he got hold of a profound description of the match'... | [{"type": "stdin_stdout", "input": "89\nH\nVOCI\nVOCI\nH\nVOCI\nH\nH\nVOCI\nVOCI\nVOCI\nH\nH\nH\nVOCI\nVOCI\nVOCI\nH\nVOCI\nVOCI\nH\nVOCI\nVOCI\nVOCI\nH\nVOCI\nH\nVOCI\nH\nVOCI\nH\nVOCI\nVOCI\nH\nVOCI\nVOCI\nVOCI\nVOCI\nVOCI\nVOCI\nH\nVOCI\nVOCI\nVOCI\nVOCI\nH\nVOCI\nH\nH\nVOCI\nH\nVOCI\nH\nVOCI\nVOCI\nVOCI\nVOCI\nVOCI... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nMany computer strategy games require building cities, recruiting army, conquering tribes, collecting resources. Sometimes it leads to interesting problems. \n\nLet's suppose that your task is to build a square city. The w... | [{"type": "stdin_stdout", "input": "10\n-260530833 169589238\n-681955770 -35391010\n223450511 24504262\n479795061 -26191863\n-291344265 21153856\n714700263 -328447419\n-858655942 161086142\n-270884153 462537328\n-501424901 977460517\n115284904 -151626824\n", "output": "2475449747812002025\n"}, {"type": "stdin_stdout", ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAmr loves Chemistry, and specially doing experiments. He is preparing for a new interesting experiment.\n\nAmr has n different types of chemicals. Each chemical i has an initial volume of ai liters. For this experiment, A... | [{"type": "stdin_stdout", "input": "20\n1 2 3 4 6 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 100000\n", "output": "113\n"}, {"type": "stdin_stdout", "input": "20\n1 2 3 4 6 8 16 32 64 128 256 512 1024 2048 3647 8192 16384 32768 65536 100000\n", "output": "124\n"}, {"type": "stdin_stdout", "input": "20... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nCarl is a beginner magician. He has a blue, b violet and c orange magic spheres. In one move he can transform two spheres of the same color into one sphere of any other color. To make a spell that has never been seen befo... | [{"type": "stdin_stdout", "input": "1000000 1000000 1000000\n1000000 1000000 1000000\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "1000100 1000000 1000000\n1000000 1000000 1000000\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "1000000 500000 1000000\n500000 1000000 500000\n", "output": "Yes\n"}... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are several days left before the fiftieth birthday of a famous Berland's writer Berlbury. In this connection the local library decided to make an exposition of the works of this famous science-fiction writer. It was... | [{"type": "stdin_stdout", "input": "55 1000\n2612 1306 4300 1790 3173 9493 7209 7763 8563 4534 7466 1281 4483 6863 3787 7292 3957 8775 7221 4016 5743 6556 2070 2119 4795 9094 1913 2077 8786 4520 1865 2357 7871 3288 8231 5808 9383 9820 9974 3056 5343 2169 5177 6299 5805 8132 9315 6747 5226 3531 1206 4073 8290 1423 6720\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a text consisting of n lines. Each line contains some space-separated words, consisting of lowercase English letters.\n\nWe define a syllable as a string that contains exactly one vowel and any arbitrary num... | [{"type": "stdin_stdout", "input": "4\n13 11 15 15\nto be or not to be that is the question\nwhether tis nobler in the mind to suffer\nthe slings and arrows of outrageous fortune\nor to take arms against a sea of troubles\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "4\n13 11 28 15\nto be or not to be that... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVladik was bored on his way home and decided to play the following game. He took n cards and put them in a row in front of himself. Every card has a positive integer number not exceeding 8 written on it. He decided to fin... | [{"type": "stdin_stdout", "input": "120\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5\n", "output": "120\n"}, {"type": "stdin... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nFinally! Vasya have come of age and that means he can finally get a passport! To do it, he needs to visit the passport office, but it's not that simple. There's only one receptionist at the passport office and people can ... | [{"type": "stdin_stdout", "input": "37 3813 32\n117\n1 1 4 5 6 8 10 13 13 16 18 19 20 23 30 32 33 38 49 59 66 69 96 157 160 183 205 292 301 320 349 360 370 372 384 400 410 413 423 434 434 445 451 463 464 490 494 496 497 517 528 532 556 572 607 647 668 689 708 729 748 806 819 879 905 905 915 925 928 931 959 970 1133 114... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nBear Limak wants to become the largest of bears, or at least to become larger than his brother Bob.\n\nRight now, Limak and Bob weigh a and b respectively. It's guaranteed that Limak's weight is smaller than or equal to h... | [{"type": "stdin_stdout", "input": "10 10\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "11 12\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1 43\n", "output": "10\n"}, {"type": "stdin_stdout", "input": "11 15\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "11 16\n", "output": "1\n"}, {"ty... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVladik often travels by trains. He remembered some of his trips especially well and I would like to tell you about one of these trips:\n\nVladik is at initial train station, and now n people (including Vladik) want to get... | [{"type": "stdin_stdout", "input": "100\n931 4584 2116 3004 3813 62 2819 2998 2080 4906 3198 2443 2952 3793 1958 3864 3985 3169 3134 4011 4525 995 4163 308 4362 1148 4906 3092 1647 244 1370 1424 2753 84 2997 1197 2606 425 3501 2606 683 4747 3884 4787 2166 3017 3080 4303 3352 1667 2636 3994 757 2388 870 1788 988 1303 0 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVasya is studying number theory. He has denoted a function f(a, b) such that:\n\n * f(a, 0) = 0; \n * f(a, b) = 1 + f(a, b - gcd(a, b)), where gcd(a, b) is the greatest common divisor of a and b. \n\n\n\nVasya has two n... | [{"type": "stdin_stdout", "input": "999999999989 999999999988\n", "output": "999999999988\n"}, {"type": "stdin_stdout", "input": "999999999958 999999999957\n", "output": "499999999979\n"}, {"type": "stdin_stdout", "input": "414654652183 366894205623\n", "output": "366894205623\n"}, {"type": "stdin_stdout", "input": "48... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nFor a given positive integer n denote its k-rounding as the minimum positive integer x, such that x ends with k or more zeros in base 10 and is divisible by n.\n\nFor example, 4-rounding of 375 is 375·80 = 30000. 30000 is... | [{"type": "stdin_stdout", "input": "1005856822 8\n", "output": "50292841100000000\n"}, {"type": "stdin_stdout", "input": "1522186596 8\n", "output": "38054664900000000\n"}, {"type": "stdin_stdout", "input": "123456789 8\n", "output": "12345678900000000\n"}, {"type": "stdin_stdout", "input": "999999997 8\n", "output": "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVasya has a graph containing both directed (oriented) and undirected (non-oriented) edges. There can be multiple edges between a pair of vertices.\n\nVasya has picked a vertex s from the graph. Now Vasya wants to create t... | [{"type": "stdin_stdout", "input": "14 19 14\n2 5 7\n1 4 1\n2 9 8\n1 7 3\n2 14 2\n2 2 8\n2 6 7\n2 14 7\n1 7 8\n2 10 8\n2 11 10\n2 11 7\n2 3 13\n1 5 4\n1 14 8\n2 3 1\n2 6 1\n2 6 10\n2 8 1\n", "output": "13\n--++-+-+-+++++\n2\n-+-+--++-++++-"}, {"type": "stdin_stdout", "input": "14 19 14\n2 5 7\n1 4 1\n2 9 8\n1 7 3\n2 14... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTwo bears are playing tic-tac-toe via mail. It's boring for them to play usual tic-tac-toe game, so they are a playing modified version of this game. Here are its rules.\n\nThe game is played on the following field.\n\n<i... | [{"type": "stdin_stdout", "input": "xoo x.. x..\nooo ... ...\nooo ... ...\n\nx.. x.. x..\n... ... ...\n... ... ...\n\nx.. x.. x..\n... ... ...\n... ... ...\n7 4\n", "output": "xoo x!! x!! \nooo !!! !!! \nooo !!! !!! \n\nx!! x!! x!! \n!!! !!! !!! \n!!! !!! !!! \n\nx!! x!! x!! \n!!! !!! !!! \n!!! !!! !!! \n\n"}, {"type":... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPolycarp has a strict daily schedule. He has n alarms set for each day, and the i-th alarm rings each day at the same time during exactly one minute.\n\nDetermine the longest time segment when Polycarp can sleep, i. e. no... | [{"type": "stdin_stdout", "input": "70\n03:33\n23:36\n03:16\n18:18\n06:36\n06:58\n17:27\n04:07\n14:39\n15:53\n17:09\n05:16\n20:28\n09:34\n02:41\n14:18\n20:00\n04:14\n00:25\n20:18\n16:34\n10:13\n21:45\n11:08\n16:19\n20:50\n03:08\n05:06\n02:08\n02:51\n15:16\n11:02\n18:13\n18:35\n00:04\n08:50\n06:12\n20:16\n12:05\n04:01\n... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.