messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
2 values
[ { "content": "We have a long seat of width X centimeters.\nThere are many people who wants to sit here. A person sitting on the seat will always occupy an interval of length Y centimeters.\nWe would like to seat as many people as possible, but they are all very shy, and there must be a gap of length at least Z ...
[{"input": "100010 0 -1", "output": "-100011\n"}, {"input": "64146 123 456\n", "output": "110\n"}, {"input": "64145 123 456\n", "output": "109\n"}, {"input": "100000 1 1\n", "output": "49999\n"}, {"input": "100010 1 0", "output": "100010\n"}, {"input": "110010 1 0", "output": "110010\n"}, {"input": "108320 205 44", "ou...
code_stdio
[ { "content": "You have a simple undirected graph consisting of $n$ vertices and $m$ edges. The graph doesn't contain self-loops, there is at most one edge between a pair of vertices. The given graph can be disconnected.\n\nLet's make a definition.\n\nLet $v_1$ and $v_2$ be two some nonempty subsets of vertices ...
[{"input": "21 35\n1 4\n2 4\n1 5\n2 5\n1 6\n2 6\n1 7\n2 7\n1 8\n2 8\n1 9\n2 9\n1 10\n2 10\n1 11\n2 11\n1 12\n2 12\n1 13\n2 13\n1 14\n2 14\n1 15\n2 15\n1 16\n2 16\n1 17\n2 17\n1 18\n2 18\n1 19\n2 19\n1 20\n2 20\n3 21\n", "output": "-1\n"}, {"input": "21 35\n1 4\n2 4\n1 5\n2 5\n1 6\n2 6\n1 7\n2 7\n1 8\n2 8\n1 4\n2 9\n1 1...
code_stdio
[ { "content": "A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity.\n\nYour favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i...
[{"input": "30 1000000000\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 1000000...
code_stdio
[ { "content": "One foggy Stockholm morning, Karlsson decided to snack on some jam in his friend Lillebror Svantenson's house. Fortunately for Karlsson, there wasn't anybody in his friend's house. Karlsson was not going to be hungry any longer, so he decided to get some food in the house.\n\nKarlsson's gaze immed...
[{"input": "15\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n", "output": "0\n"}, {"input": "15\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n", "output": "0\n"}, {"input": "8\n0 1\n1 0\n0 1\n1 1\n0 1\n1 0\n0 1\n1 0\n", "output": "7\n"}, {"input": "8\n1 0\n1 0...
code_stdio
[ { "content": "The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts $h$ hours and each hour lasts $m$ minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (...
[{"input": "15\n1 1\n00:00\n1 100\n00:01\n100 100\n02:82\n10 10\n04:04\n100 100\n99:00\n100 2\n30:00\n50 3\n30:00\n51 3\n30:01\n52 16\n21:12\n100 20\n20:07\n23 100\n21:45\n11 11\n02:02\n89 89\n88:86\n100 1\n01:00\n1 100\n00:01\n", "output": "00:00\n00:00\n02:82\n00:00\n00:00\n00:00\n00:00\n50:00\n21:12\n20:08\n21:50\n1...
code_stdio
[ { "content": "Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\nPetya recently learned to determine whether a string of lowercase Latin lett...
[{"input": "99994\n", "output": "abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabc...
code_stdio
[ { "content": "There is a trampoline park with $n$ trampolines in a line. The $i$-th of which has strength $S_i$.\n\nPekora can jump on trampolines in multiple passes. She starts the pass by jumping on any trampoline of her choice.\n\nIf at the moment Pekora jumps on trampoline $i$, the trampoline will launch he...
[{"input": "3\n7\n1 2 10 2 2 2 2\n2\n2 1\n5\n1 1 1 2 1\n", "output": "10\n1\n1\n"}, {"input": "3\n7\n2 4 3 2 2 13 2\n2\n3 3\n5\n1 1 1 1 2\n", "output": "13\n4\n1\n"}, {"input": "3\n7\n3 4 3 2 2 24 2\n2\n3 3\n5\n1 1 1 1 2\n", "output": "24\n4\n1\n"}, {"input": "3\n7\n2 1 2 3 2 11 3\n2\n1 9\n5\n1 2 1 2 2\n", "output": "1...
code_stdio
[ { "content": "Snuke is playing a puzzle game.\nIn this game, you are given a rectangular board of dimensions R × C, filled with numbers. Each integer i from 1 through N is written twice, at the coordinates (x_{i,1},y_{i,1}) and (x_{i,2},y_{i,2}).\nThe objective is to draw a curve connecting the pair of points w...
[{"input": "5 5 7\n1 -1 2 4\n2 3 4 4\n3 5 5 4\n5 5 2 4\n0 4 5 1\n2 2 1 1\n0 10 4 1", "output": "YES\n"}, {"input": "5 5 7\n1 -1 2 4\n1 3 4 4\n3 5 5 4\n5 5 2 4\n0 4 5 1\n2 2 1 1\n0 10 4 1", "output": "YES\n"}, {"input": "5 5 7\n-1 -1 2 4\n2 3 4 5\n3 5 5 2\n5 5 5 4\n0 3 5 1\n1 2 1 4\n0 7 3 1", "output": "YES\n"}, {"input...
code_stdio
[ { "content": "The trafic on the Internet is increasing these days due to smartphones. The wireless carriers have to enhance their network infrastructure.\n\nThe network of a wireless carrier consists of a number of base stations and lines. Each line connects two base stations bi-directionally. The bandwidth of ...
[{"input": "3 3\n1 2 x+2\n2 3 2x+1\n3 1 x+1\n2 0\n3 2\n1 2 x\n1 3 2\n4 3\n1 2 x^3+2x^2+3x+4\n2 4 x^2+2x+3\n3 4 x+2\n0 0", "output": "2x+3\n0\n2\nx^2+2x+3\n"}, {"input": "3 3\n1 2 x+2\n2 3 2x+1\n3 1 x+1\n2 -1\n3 2\n2 2 x\n2 3 2\n4 3\n1 2 x^3+2x^2+3x+4\n2 3 x^2+2x+3\n3 4 x+2\n0 0", "output": "2x+3\n0\n0\nx+2\n"}, {"input...
code_stdio
[ { "content": "Mike is trying rock climbing but he is awful at it. \n\nThere are n holds on the wall, i-th hold is at height a_{i} off the ground. Besides, let the sequence a_{i} increase, that is, a_{i} < a_{i} + 1 for all i from 1 to n - 1; we will call such sequence a track. Mike thinks that the track a_1, .....
[{"input": "100\n2 43 47 49 50 57 59 67 74 98 901 903 904 906 907 908 909 910 911 912 913 914 915 916 917 1525 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 938 939 940 942 943 944 945 946 947 948 949 950 952 953 954 956 957 1027 959 960 961 962 963 965 966 967 968 969 970 971 972 973 974 975 ...
code_stdio
[ { "content": "Polycarp is a great fan of television.\n\nHe wrote down all the TV programs he is interested in for today. His list contains n shows, i-th of them starts at moment l_{i} and ends at moment r_{i}.\n\nPolycarp owns two TVs. He can watch two different shows simultaneously with two TVs but he can only...
[{"input": "5\n15 18\n23 24\n23 28\n26 24\n15 19\n", "output": "YES\n"}, {"input": "5\n15 18\n23 24\n23 11\n26 24\n15 19\n", "output": "YES\n"}, {"input": "5\n15 18\n23 24\n23 28\n22 24\n15 19\n", "output": "NO\n"}, {"input": "5\n15 18\n23 24\n23 28\n22 24\n15 19\n", "output": "NO\n"}, {"input": "5\n19 23\n12 17\n16 21...
code_stdio
[ { "content": "You gave the twins Ai and Zu a program of games using strings. In this game, Ai and Zu each select a substring from the character string, compare them, and the person who chooses the smaller one will get points. The two competed and played the game many times. However, I got tired of playing games...
[{"input": "13\naizualgorithm\n9\ncomp 1 0 4 5\ncomp 2 6 1 4\nset 15 12 b\ncomp 9 9 10 10\ncomp 0 13 1 4\nset 1 10 z\nset 11 13 x\ncomp 8 10 0 5\ncomp 1 5 1 5", "output": "s\nt\nt\ns\nt\ne\n"}, {"input": "13\nmhtiroglauzia\n9\ncomp 1 1 4 5\ncomp 2 6 1 2\nset 15 12 b\ncomp 9 9 17 11\ncomp 3 16 1 4\nset 1 10 z\nset 11 13...
code_stdio
[ { "content": "Let's call a string good if and only if it consists of only two types of letters — 'a' and 'b' and every two consecutive letters are distinct. For example \"baba\" and \"aba\" are good strings and \"abb\" is a bad string.\n\nYou have $a$ strings \"a\", $b$ strings \"b\" and $c$ strings \"ab\". You...
[{"input": "1000000000 1000000000 1000000000\n", "output": "4000000000\n"}, {"input": "1000000000 1010000000 1000000000\n", "output": "4000000001\n"}, {"input": "1000000000 1000000000 1000000000\n", "output": "4000000000\n"}, {"input": "1000000000 1000000000 99999999\n", "output": "2199999998\n"}, {"input": "1000000000...
code_stdio
[ { "content": "Meg the Rabbit decided to do something nice, specifically — to determine the shortest distance between two points on the surface of our planet. But Meg... what can you say, she wants everything simple. So, she already regards our planet as a two-dimensional circle. No, wait, it's even worse — as a...
[{"input": "1000 984 0 1000 999\n", "output": "1015\n"}, {"input": "1000 564 0 436 1000\n", "output": "2000\n"}, {"input": "1000 379 0 436 1000\n", "output": "1815\n"}, {"input": "686 615 686 470 686\n", "output": "145\n"}, {"input": "684 684 113 314 684\n", "output": "941\n"}, {"input": "1000 0 0 1000 1000\n", "output...
code_stdio
[ { "content": "The amount of information on the World Wide Web is growing quite rapidly. In this information explosion age, we must survive by accessing only the Web pages containing information relevant to our own needs. One of the key technologies for this purpose is keyword search. By using well-known search ...
[{"input": "3 1\naa\nb\nccc\naabccczbaacccbaazaabbcccaa\n3 1\na\nb\nc\ncbbcbcbabaacabccaccbaacbccbcaaaccccbcbcbbcacbaacccaccbbcaacbbabbabaccc\n3 4\naaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
code_stdio
[ { "content": "# A History Lesson\n\nSoundex is an interesting phonetic algorithm developed nearly 100 years ago for indexing names as they are pronounced in English. The goal is for homophones to be encoded to the same representation so that they can be matched despite minor differences in spelling.\n\nReferenc...
[{"input": "\"Sayra Cunnarr\"", "output": "[\"S600 C560\"]", "fn_name": "soundex"}, {"input": "\"Sarah Connor\"", "output": "[\"S600 C560\"]", "fn_name": "soundex"}, {"input": "\"Serah Coner\"", "output": "[\"S600 C560\"]", "fn_name": "soundex"}, {"input": "\"Sarh Connor\"", "output": "[\"S600 C560\"]", "fn_name": "sou...
code_functional
[ { "content": "# Task\n Call two arms equally strong if the heaviest weights they each are able to lift are equal.\n\n Call two people equally strong if their strongest arms are equally strong (the strongest arm can be both the right and the left), and so are their weakest arms.\n\n Given your and your friend's ...
[{"input": "10\n15\n15\n10", "output": "[true]", "fn_name": "are_equally_strong"}, {"input": "15\n10\n15\n10", "output": "[true]", "fn_name": "are_equally_strong"}, {"input": "10\n10\n10\n10", "output": "[true]", "fn_name": "are_equally_strong"}, {"input": "15\n10\n15\n9", "output": "[false]", "fn_name": "are_equally_s...
code_functional
[ { "content": "Alice and Bob are going to celebrate Christmas by playing a game with a tree of presents. The tree has n nodes (numbered 1 to n, with some node r as its root). There are a_i presents are hanging from the i-th node.\n\nBefore beginning the game, a special integer k is chosen. The game proceeds as f...
[{"input": "4 3\n1 2\n1 3\n3 4\n1000000000 999999999 0 1\n", "output": "0 1 0 1 "}, {"input": "4 3\n1 2\n1 3\n3 4\n1000000000 999999999 0 2\n", "output": "0 1 0 1\n"}, {"input": "4 3\n1 2\n1 3\n1 4\n1000000000 999999999 0 2\n", "output": "0 0 0 0\n"}, {"input": "4 1\n1 2\n1 3\n1 4\n1000000000 999999999 0 2\n", "output"...
code_stdio
[ { "content": "Snuke 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.\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 max...
[{"input": "15\n0 -4 1 8 0 1 -1 -25 49 -3 -35 -2 -8 2 -9", "output": "13\n"}, {"input": "15\n1 2 9 -1 0 12 1 -1 1 11 -2 4 13 4 3", "output": "11\n"}, {"input": "15\n1 1 9 -1 0 12 1 -1 0 11 -1 2 13 2 3", "output": "9\n"}, {"input": "15\n1 1 9 -1 0 12 1 -1 1 11 -1 2 13 2 3", "output": "9\n"}, {"input": "15\n1 1 9 -1 0 12...
code_stdio
[ { "content": "Read problems statements in Mandarin Chinese and Russian. \nSereja is playing a game called Winner Eats Sandwich with his friends. There are N persons in total, including Sereja. Sereja is allotted the number 1, while his friends are allotted numbers from 2 to N. A set of this game consists of M ...
[{"input": "2\n2 2\n1.919491227426865 1.0000\n0.20458667640312156 0.015709866169253517\n2 3\n1.2649803683768097 0.9607117929679821 1.4783278968924718\n0.5000 0.5000 1.059778001251625", "output": "0.998328\n0.871482\n"}, {"input": "2\n2 2\n1.919491227426865 1.0000\n0.20458667640312156 0.015709866169253517\n2 3\n1.429710...
code_stdio
[ { "content": "There are N towns in Snuke Kingdom, conveniently numbered 1 through N. Town 1 is the capital.\n\nEach town in the kingdom has a Teleporter, a facility that instantly transports a person to another place. The destination of the Teleporter of town i is town a_i (1≤a_i≤N). It is guaranteed that one c...
[{"input": "8 1\n-1 1 4 5 1 1 5 4", "output": "5\n"}, {"input": "8 2\n-1 1 4 5 1 2 5 4", "output": "2\n"}, {"input": "8 2\n-1 1 4 5 1 4 5 4", "output": "2\n"}, {"input": "8 2\n-1 1 4 5 1 1 5 4", "output": "2\n"}, {"input": "8 2\n-1 1 4 5 1 7 5 4", "output": "3\n"}, {"input": "8 2\n-1 1 4 5 2 7 5 4", "output": "3\n"}, {...
code_stdio
[ { "content": "Alice and Bonnie are sisters, but they don't like each other very much. So when some old family photos were found in the attic, they started to argue about who should receive which photos. In the end, they decided that they would take turns picking photos. Alice goes first.\n\nThere are n stacks o...
[{"input": "7\n479456257 682467462 202838061 802929167\n133179116 541657110 703996842 253385760\n829210948 865639323 321812660 580155067\n723036605 467995973 911771109 838534160\n732332969 59715289 216696388 60573917\n515702466 655741352 105418444 651954316\n884987644 907866122 399463262 952777963\n", "output": "-25346...
code_stdio
[ { "content": "One day in the IT lesson Anna and Maria learned about the lexicographic order.\n\nString x is lexicographically less than string y, if either x is a prefix of y (and x ≠ y), or there exists such i (1 ≤ i ≤ min(|x|, |y|)), that xi < yi, and for any j (1 ≤ j < i) xj = yj. Here |a| denotes the length...
[{"input": "kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk...
code_stdio
[ { "content": "A conglomerate consists of $n$ companies. To make managing easier, their owners have decided to merge all companies into one. By law, it is only possible to merge two companies, so the owners plan to select two companies, merge them into one, and continue doing so until there is only one company l...
[{"input": "20\n1 1228\n7 957 657 854 608 621 874 617\n6 159 43 19 122 116 194\n7 813 984 847 953 808 801 900\n2 693 844\n12 903 910 764 949 990 959 987 884 876 743 838 1017\n1 636\n8 107 201 935 203 159 67 550 948\n1 919\n14 934 742 1000 707 801 958 889 980 799 841 927 676 918 841\n7 590 569 480 533 513 398 430\n2 865...
code_stdio
[ { "content": "Bob is a theoretical coder - he doesn't write code, but comes up with theories, formulas and algorithm ideas. You are his secretary, and he has tasked you with writing the code for his newest project - a method for making the short form of a word. Write a function ```shortForm```(C# ```ShortForm``...
[{"input": "\"incorrigible\"", "output": "[\"incrrgble\"]", "fn_name": "short_form"}, {"input": "\"UnInTENtiONAl\"", "output": "[\"UnnTNtNl\"]", "fn_name": "short_form"}, {"input": "\"inCRediBLE\"", "output": "[\"inCRdBLE\"]", "fn_name": "short_form"}, {"input": "\"IMpOsSiblE\"", "output": "[\"IMpsSblE\"]", "fn_name": ...
code_functional
[ { "content": "Determine if an N-sided polygon (not necessarily convex) with sides of length L_1, L_2, ..., L_N can be drawn in a two-dimensional plane.\nYou can use the following theorem:\nTheorem: an N-sided polygon satisfying the condition can be drawn if and only if the longest side is strictly shorter than ...
[{"input": "10\n100 100 100 100 100 100 100 100 100 100\n", "output": "Yes\n"}, {"input": "10\n72 91 66 75 90 52 94 1 87 59\n", "output": "Yes\n"}, {"input": "10\n11 11 11 11 99 11 11 11 11 11\n", "output": "No\n"}, {"input": "10\n1 0 10 10 16 12 34 110 11 3", "output": "No\n"}, {"input": "10\n1 0 10 10 16 22 34 110 11...
code_stdio
[ { "content": "###BACKGROUND:\nJacob recently decided to get healthy and lose some weight. He did a lot of reading and research and after focusing on steady exercise and a healthy diet for several months, was able to shed over 50 pounds! Now he wants to share his success, and has decided to tell his friends and ...
[{"input": "\"F\"\n-461.9\n0.0", "output": "[\"Invalid weight\"]", "fn_name": "lose_weight"}, {"input": "\"F\"\n160\n-10", "output": "[\"Invalid duration\"]", "fn_name": "lose_weight"}, {"input": "\"llama\"\n1\n-10", "output": "[\"Invalid gender\"]", "fn_name": "lose_weight"}, {"input": "\"??\"\n-10\n-10", "output": "[...
code_functional
[ { "content": "We have an H-by-W matrix. Let a_{ij} be the element at the i-th row from the top and j-th column from the left. In this matrix, each a_{ij} is a lowercase English letter.\n\nSnuke is creating another H-by-W matrix, A', by freely rearranging the elements in A. Here, he wants to satisfy the followin...
[{"input": "3 4\nabbb\naabb\naacc", "output": "No\n"}, {"input": "3 4\naabb\naabb\naacc", "output": "Yes"}, {"input": "0 10\na`ycb\nabbya", "output": "Yes\n"}, {"input": "-1 0\naaxbb\nabyba", "output": "Yes\n"}, {"input": "-1 0\naaxbb\naybba", "output": "Yes\n"}, {"input": "0 -1\nbcy`a\naybba", "output": "Yes\n"}, {"in...
code_stdio
[ { "content": "Iroha 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.\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 ...
[{"input": "5 5 7\n", "output": "YES\n"}, {"input": "13 4 -2", "output": "NO\n"}, {"input": "13 4 -1", "output": "NO\n"}, {"input": "20 4 -1", "output": "NO\n"}, {"input": "-1 -1 3", "output": "NO\n"}, {"input": "-1 -1 5", "output": "NO\n"}, {"input": "-1 -1 4", "output": "NO\n"}, {"input": "16 4 -2", "output": "NO\n"}...
code_stdio
[ { "content": "## Problem\n\nDetermine whether a positive integer number is **colorful** or not.\n\n`263` is a colorful number because `[2, 6, 3, 2*6, 6*3, 2*6*3]` are all different; whereas `236` is not colorful, because `[2, 3, 6, 2*3, 3*6, 2*3*6]` have `6` twice.\n\nSo take all consecutive subsets of digits, ...
[{"input": "2357893", "output": "[false]", "fn_name": "colorful"}, {"input": "235789", "output": "[true]", "fn_name": "colorful"}, {"input": "236", "output": "[false]", "fn_name": "colorful"}, {"input": "263", "output": "[true]", "fn_name": "colorful"}, {"input": "50", "output": "[false]", "fn_name": "colorful"}, {"inp...
code_functional
[ { "content": "Problem statement\n\nGiven the string $ S $. Find the number of all anagrams in $ S $ that are palindromic.\n\nAn anagram of the string $ X $ is an anagram of $ Y $, which means that $ X $ is equal to $ Y $, or that the rearranged characters of $ X $ are equal to $ Y $. For example, for the string...
[{"input": "cbcb", "output": "2\n"}, {"input": "abca", "output": "0\n"}, {"input": "aaca", "output": "0\n"}, {"input": "aacb", "output": "0\n"}, {"input": "bacb", "output": "0\n"}, {"input": "bbca", "output": "0\n"}, {"input": "bcca", "output": "0\n"}, {"input": "accb", "output": "0\n"}, {"input": "ccca", "output": "0\...
code_stdio
[ { "content": "You are given a string S of length N consisting of A, C, G and T. Answer the following Q queries:\n - Query 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...
[{"input": "8 3\nACACTABG\n6 3\n4 6\n2 1", "output": "-1\n0\n-1\n"}, {"input": "8 3\nACACTACG\n3 7\n2 3\n1 8\n", "output": "2\n0\n3\n"}, {"input": "8 3\nACACTACG\n3 7\n4 3\n1 2", "output": "2\n-1\n1\n"}, {"input": "8 3\nACACTACG\n3 7\n8 5\n1 6", "output": "2\n-1\n2\n"}, {"input": "8 3\nACACTACG\n3 7\n8 1\n1 6", "output...
code_stdio
[ { "content": "Let $n$ be an integer. Consider all permutations on integers $1$ to $n$ in lexicographic order, and concatenate them into one big sequence $p$. For example, if $n = 3$, then $p = [1, 2, 3, 1, 3, 2, 2, 1, 3, 2, 3, 1, 3, 1, 2, 3, 2, 1]$. The length of this sequence will be $n \\cdot n!$.\n\nLet $1 \...
[{"input": "1000000\n", "output": " 549766631"}, {"input": "771623\n", "output": " 501916356"}, {"input": "623847\n", "output": " 407299584"}, {"input": "2598...
code_stdio
[ { "content": "A chess board is normally played with 16 pawns and 16 other pieces, for this kata a variant will be played with only the pawns. All other pieces will not be on the board. \nFor information on how pawns move, refer [here](http://www.chesscorner.com/tutorial/basic/pawn/pawn.htm)\n \n \nWrite a f...
[{"input": "[\"a3\", \"h6\", \"a4\", \"h5\", \"a5\", \"h4\", \"a6\", \"h3\", \"axb7\", \"hxg2\"]", "output": "[[[\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\"p\", \"P\", \"p\", \"p\", \"p\", \"p\", \"p\", \".\"], [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"], [\".\", \".\", \".\", \".\", \".\"...
code_functional
[ { "content": "You've got a 5 × 5 matrix, consisting of 24 zeroes and a single number one. Let's index the matrix rows by numbers from 1 to 5 from top to bottom, let's index the matrix columns by numbers from 1 to 5 from left to right. In one move, you are allowed to apply one of the two following transformation...
[{"input": "0 0 0 0 0\n0 0 0 0 1\n0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n", "output": "3\n"}, {"input": "0 0 0 0 0\n0 0 0 0 0\n0 1 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n", "output": "1\n"}, {"input": "0 0 0 0 0\n0 0 0 0 0\n0 0 1 0 0\n0 0 0 0 0\n0 0 0 0 0\n", "output": "0\n"}, {"input": "0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n0 0...
code_stdio
[ { "content": "Astronaut Natasha arrived on Mars. She knows that the Martians are very poor aliens. To ensure a better life for the Mars citizens, their emperor decided to take tax from every tourist who visited the planet. Natasha is the inhabitant of Earth, therefore she had to pay the tax to enter the territo...
[{"input": "2 420\n412 363\n", "output": "420\n0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 9...
code_stdio
[ { "content": "You are wandering in the explorer space of the 2050 Conference.\n\nThe explorer space can be viewed as an undirected weighted grid graph with size n× m. The set of vertices is \\{(i, j)|1≤ i≤ n, 1≤ j≤ m\\}. Two vertices (i_1,j_1) and (i_2, j_2) are connected by an edge if and only if |i_1-i_2|+|j_...
[{"input": "3 3 10\n1 1\n1 1\n1 1\n1 1 1\n1 1 1\n", "output": "\n10 10 10\n10 10 10\n10 10 10\n"}, {"input": "3 3 10\n1 1\n2 1\n1 1\n1 1 1\n1 1 1\n", "output": "10 10 10\n10 10 10\n10 10 10\n"}, {"input": "3 3 10\n1 1\n2 2\n1 1\n1 2 1\n2 2 1\n", "output": "10 10 10\n10 12 10\n10 10 10\n"}, {"input": "3 3 10\n1 1\n3 4\n...
code_stdio
[ { "content": "Hint\n\nIn solving this problem, the following may be referred to. Shows how to convert an integer value to a string. Assign value as a string to str.\n\nFor C\n\n\ninclude <stdio.h>\n\nint main () {\nint value = 123; // Convert this value to a string\nchar str [6]; // This variable contains a str...
[{"input": "6 101\n111 101 101 101 001 101 101 001 101 101", "output": "444444\n"}, {"input": "5 100\n101 101 101 101 001 101 101 101 101 101", "output": "44444\n"}, {"input": "5 100\n101 101 101 101 101 101 001 101 101 101", "output": "66666\n"}, {"input": "5 100\n111 101 101 101 001 101 101 101 101 101", "output": "4...
code_stdio
[ { "content": "Given are a permutation p_1, p_2, \\dots, p_N of (1, 2, ..., N) and an integer K. Maroon performs the following operation for i = 1, 2, \\dots, N - K + 1 in this order:\n\n* Shuffle p_i, p_{i + 1}, \\dots, p_{i + K - 1} uniformly randomly.\n\n\n\nFind the expected value of the inversion number of ...
[{"input": "10 5\n1 8 4 9 2 3 7 10 5 6", "output": "610446407\n"}, {"input": "10 7\n1 8 4 9 2 3 7 10 5 6", "output": "347784862\n"}, {"input": "10 8\n1 8 4 9 2 3 7 10 5 6", "output": "561512471\n"}, {"input": "10 4\n1 8 4 9 2 3 7 10 5 6", "output": "907096085\n"}, {"input": "10 3\n1 8 4 9 2 3 7 10 5 6", "output": "1640...
code_stdio
[ { "content": "Chouti was tired of the tedious homework, so he opened up an old programming problem he created years ago.\n\nYou are given a connected undirected graph with $n$ vertices and $m$ weighted edges. There are $k$ special vertices: $x_1, x_2, \\ldots, x_k$.\n\nLet's define the cost of the path as the m...
[{"input": "4 4 2\n3 1\n1 2 1000000000\n2 3 1000000000\n3 1 1000000000\n3 4 1\n", "output": "1000000000 1000000000\n"}, {"input": "4 4 2\n3 1\n1 2 1000000000\n2 3 1000000001\n3 1 1000000000\n3 4 1\n", "output": "1000000000 1000000000\n"}, {"input": "4 4 2\n3 1\n1 2 1000000000\n2 3 1000000001\n3 2 1000000000\n3 4 1\n", ...
code_stdio
[ { "content": "A famous gang of pirates, Sea Dogs, has come back to their hideout from one of their extravagant plunders. They want to split their treasure fairly amongst themselves, that is why You, their trusted financial advisor, devised a game to help them:\n\nAll of them take a sit at their round table, som...
[{"input": "1000010000 3\n44431 10822\n45250 1096927361\n264372930 1\n", "output": "-1"}, {"input": "1000010001 3\n44431 10822\n45250 1096927361\n264372930 1\n", "output": "-1"}, {"input": "1000000000 3\n30490 19232\n45250 999980767\n264372930 1\n", "output": "-1"}, {"input": "1000010000 3\n30490 19232\n45250 999980767...
code_stdio
[ { "content": "Mr. Suzuki has opened a new mobile sales shop for freshly squeezed milk in the Aizu area. It is assumed that all the customers who come to buy that day are already in the store with bottles to take home and will not increase any more. Customers only order once each. There is only one faucet in the...
[{"input": "5\n-2\n45\n162\n2\n15\n0", "output": "73\n"}, {"input": "5\n-2\n32\n30\n2\n12\n0", "output": "52\n"}, {"input": "5\n-1\n-1\n4\n106\n0\n0", "output": "-3\n"}, {"input": "5\n4\n31\n14\n11\n14\n0", "output": "91\n"}, {"input": "5\n-1\n-1\n4\n20\n-1\n0", "output": "-5\n"}, {"input": "5\n-2\n-1\n4\n204\n0\n0", "...
code_stdio
[ { "content": "For a rooted tree, find the lowest common ancestor of two nodes u and v.\n\nThe given tree consists of n nodes and every node has a unique ID from 0 to n-1 where 0 is the root.\n\nConstraints\n\n* 1 ≤ n ≤ 100000\n* 1 ≤ q ≤ 100000\n\nInput\n\n\nn\nk0 c1 c2 ... ck0\nk1 c1 c2 ... ck1\n:\nkn-1 c1 c2 ....
[{"input": "8\n3 1 2 3\n2 4 5\n0\n-1\n-1\n2 6 7\n-1\n0\n4\n4 6\n4 7\n4 3\n5 2", "output": "1\n1\n0\n0\n"}, {"input": "8\n3 1 2 3\n2 4 5\n0\n0\n-1\n2 6 7\n-1\n0\n4\n4 6\n4 7\n4 1\n5 2", "output": "1\n1\n1\n0\n"}, {"input": "8\n3 1 2 3\n2 4 5\n0\n0\n-1\n2 6 7\n-1\n0\n4\n4 6\n4 7\n2 2\n5 2", "output": "1\n1\n2\n0\n"}, {"i...
code_stdio
[ { "content": "You are given a string S consisting of 0 and 1.\nFind the maximum integer K not greater than |S| such that we can turn all the characters of S into 0 by repeating the following operation some number of times.\n - Choose a contiguous segment [l,r] in S whose length is at least K (that is, r-l+1\\ge...
[{"input": "100000000\n", "output": "8\n"}, {"input": "00001111\n", "output": "4\n"}, {"input": "100000010", "output": "7\n"}, {"input": "100000101", "output": "6\n"}, {"input": "000000000", "output": "9\n"}, {"input": "100000011", "output": "7\n"}, {"input": "100001011", "output": "5\n"}, {"input": "100101011", "outpu...
code_stdio
[ { "content": "Famil Door wants to celebrate his birthday with his friends from Far Far Away. He has n friends and each of them can come to the party in a specific range of days of the year from a_{i} to b_{i}. Of course, Famil Door wants to have as many friends celebrating together with him as possible.\n\nFar ...
[{"input": "40\nM 55 363\nF 117 252\nM 157 282\nF 322 345\nM 330 363\nF 154 231\nF 216 352\nF 357 365\nM 279 292\nF 353 359\nF 82 183\nM 78 297\nM 231 314\nM 107 264\nF 34 318\nM 44 244\nF 42 339\nM 253 307\nM 128 192\nF 119 328\nM 135 249\nF 303 358\nF 348 352\nF 8 364\nF 126 303\nM 226 346\nF 110 300\nF 47 303\nF 201...
code_stdio
[ { "content": "Alan decided to get in shape for the summer, so he created a precise workout plan to follow. His plan is to go to a different gym every day during the next N days and lift X[i] grams on day i. In order to improve his workout performance at the gym, he can buy exactly one pre-workout drink at the g...
[{"input": "5 10000\n10010 1629 30000 40724 20000\n20000\n12 1 5 3 10\n", "output": "13\n"}, {"input": "5 10000\n10010 1552 30000 40724 20000\n20000\n20 1 5 3 10\n", "output": "21\n"}, {"input": "5 10000\n10010 1552 30000 40724 20000\n20000\n20 0 5 3 10\n", "output": "20\n"}, {"input": "5 00001\n00010 1552 25295 19999 ...
code_stdio
[ { "content": "When Masha came to math classes today, she saw two integer sequences of length $n - 1$ on the blackboard. Let's denote the elements of the first sequence as $a_i$ ($0 \\le a_i \\le 3$), and the elements of the second sequence as $b_i$ ($0 \\le b_i \\le 3$).\n\nMasha became interested if or not the...
[{"input": "100\n2 2 2 2 3 3 3 3 3 3 1 3 3 2 3 3 0 3 3 3 2 3 3 3 3 1 3 3 3 3 3 3 3 1 1 2 2 2 2 2 1 3 3 2 2 1 3 3 3 2 3 3 3 1 1 2 3 1 0 0 1 3 3 3 1 3 2 2 2 2 3 3 2 2 2 3 3 2 2 3 1 1 1 1 3 3 3 3 3 3 3 3 3 3 3 2 3 3 3\n0 0 0 2 2 1 0 0 0 0 0 0 2 2 2 0 0 0 3 2 2 2 2 2 1 1 1 3 3 1 0 2 1 1 0 0 2 2 2 0 0 1 2 2 0 0 0 2 0 0 2 2 ...
code_stdio
[ { "content": "Snuke can change a string t of length N into a string t' of length N - 1 under the following rule:\n\n* For each i (1 ≤ i ≤ N - 1), the i-th character of t' must be either the i-th or (i + 1)-th character of t.\n\n\n\nThere is a string s consisting of lowercase English letters. Snuke's objective i...
[{"input": "whcrjpbyhtxywkrlxnbrbaojmr", "output": "10\n"}, {"input": "smjoabjdoxmrjwypugydyqrchv", "output": "11\n"}, {"input": "xwwwnajdrxmrqwzpugnhlojced", "output": "12\n"}, {"input": "xpwzglbjquntrci{axpdikofyw", "output": "13\n"}, {"input": "whcrjxbyhtpywkrlxnbrbaojmr", "output": "10\n"}, {"input": "whcrjxbyhtpyw...
code_stdio
[ { "content": "Once upon a time Mike and Mike decided to come up with an outstanding problem for some stage of ROI (rare olympiad in informatics). One of them came up with a problem prototype but another stole the idea and proposed that problem for another stage of the same olympiad. Since then the first Mike ha...
[{"input": "5 6\n1 2 3 4 5\n2 10\n1 1 5\n2 10\n1 1 6\n2 10\n1 1 7\n", "output": "50\n45\n50\n46\n50\n47\n"}, {"input": "5 5\n5 6 2 10 10\n1 2 7\n2 4\n1 1 10\n2 8\n1 3 4\n", "output": "34\n20\n26\n40\n36\n"}, {"input": "5 5\n1 2 3 4 5\n1 1 5\n2 10\n1 5 11\n1 4 1\n2 1\n", "output": "19\n50\n51\n42\n5\n"}, {"input": "4 5\...
code_stdio
[ { "content": "Counting was a difficult task in ancient Rome. The Arabic numerals 0,1,2,3,…, 9 have not yet been disseminated. Instead, the following symbols were used:\n\nArabic numerals | Roman numerals | Arabic numerals | Roman numerals | Arabic numerals | Roman numerals\n--- | --- | --- | --- | --- | ---\n1 ...
[{"input": "VI\nCXDCXXMCXVIIII\nDXDCIX", "output": "6\n1809\n1099\n"}, {"input": "IV\nCXDCXXMCXVIIII\nDXDCIX", "output": "4\n1809\n1099\n"}, {"input": "IV\nCCDIIXXXXVIDLI\nXIDXDC", "output": "4\n1095\n1099\n"}, {"input": "IV\nCXCCXXMCXVIIII\nDXDCIX", "output": "4\n1409\n1099\n"}, {"input": "IV\nCCCIMXXXXVIDII\nCDXCIX",...
code_stdio
[ { "content": "Oh, no!\n\nThe coronavirus has caught you, and now you're sitting in a dark cellar, with tied legs (but not hands). You have a delicious cookie, a laptop in front of you, and your ideal development environment is open. The coronavirus convinces you to solve the following problem.\n\nYou are given ...
[{"input": "3\n8707 7998 1614\n999941093851 131953876 8707\n", "output": "SMALL\n15155\nPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP...
code_stdio
[ { "content": "Mr.X, who the handle name is T, looked at the list which written N handle names, S_1, S_2, ..., S_N.\nBut he couldn't see some parts of the list. Invisible part is denoted `?`.\n\nPlease calculate all possible index of the handle name of Mr.X when you sort N+1 handle names (S_1, S_2, ..., S_N and ...
[{"input": "2\ntourist\neptr\ne", "output": "1\n"}, {"input": "2\nssvuhnr\nerrs\nf", "output": "2\n"}, {"input": "2\nhupouvt\netor\ni", "output": "3\n"}, {"input": "2\nsourist\neptr\ne", "output": "1\n"}, {"input": "2\nsourist\neqtr\ne", "output": "1\n"}, {"input": "2\nsourist\netqr\ne", "output": "1\n"}, {"input": "2\...
code_stdio
[ { "content": "Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.\n\nMaksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the...
[{"input": "5 5 3\n-1 2 3 2 -1\n", "output": "5\n"}, {"input": "5 10 3\n0 2 3 2 1\n", "output": "5\n"}, {"input": "5 4 3\n1 2 3 2 -1\n", "output": "5\n"}, {"input": "5 6 3\n0 2 3 2 -1\n", "output": "5\n"}, {"input": "5 4 3\n0 2 3 2 -1\n", "output": "5\n"}, {"input": "5 6 3\n0 2 3 1 -1\n", "output": "5\n"}, {"input": "5...
code_stdio
[ { "content": "Natasha travels around Mars in the Mars rover. But suddenly it broke down, namely — the logical scheme inside it. The scheme is an undirected tree (connected acyclic graph) with a root in the vertex 1, in which every leaf (excluding root) is an input, and all other vertices are logical elements, i...
[{"input": "60\nAND 20 4\nNOT 42\nAND 48 59\nOR 17 7\nIN 0\nAND 36 37\nIN 1\nIN 0\nIN 1\nNOT 47\nAND 52 49\nOR 44 35\nIN 0\nIN 1\nAND 33 56\nIN 0\nIN 0\nIN 0\nAND 31 41\nOR 15 3\nOR 43 46\nIN 1\nXOR 22 28\nIN 1\nIN 1\nIN 1\nAND 34 21\nIN 1\nIN 1\nIN 0\nXOR 51 23\nXOR 10 54\nOR 57 40\nIN 0\nNOT 18\nNOT 25\nIN 1\nAND 5 5...
code_stdio
[ { "content": "You're playing a game with a friend involving a bag of marbles. In the bag are ten marbles:\n\n* 1 smooth red marble\n* 4 bumpy red marbles\n* 2 bumpy yellow marbles\n* 1 smooth yellow marble\n* 1 bumpy green marble\n* 1 smooth green marble\n\nYou can see that the probability of picking a smooth r...
[{"input": "\"yellow\"\n\"smooth\"", "output": "[\"0.33\"]", "fn_name": "color_probability"}, {"input": "\"green\"\n\"smooth\"", "output": "[\"0.33\"]", "fn_name": "color_probability"}, {"input": "\"yellow\"\n\"bumpy\"", "output": "[\"0.28\"]", "fn_name": "color_probability"}, {"input": "\"green\"\n\"bumpy\"", "output"...
code_functional
[ { "content": "An adult game master and N children are playing a game on an ice rink. The game consists of K rounds. In the i-th round, the game master announces:\n\n* Form groups consisting of A_i children each!\n\n\n\nThen the children who are still in the game form as many groups of A_i children as possible. ...
[{"input": "10\n2 3 2 2 2 2 2 2 2 2", "output": "4 5\n"}, {"input": "10\n2 3 3 2 2 2 2 2 2 2", "output": "4 5\n"}, {"input": "10\n2 3 2 2 2 2 4 2 2 2", "output": "-1\n"}, {"input": "10\n2 3 2 2 2 2 4 1 2 2", "output": "-1\n"}, {"input": "10\n2 3 2 2 2 2 4 1 4 2", "output": "-1\n"}, {"input": "10\n2 3 2 2 1 2 4 1 2 2", ...
code_stdio
[ { "content": "Baby Badawy's first words were \"AND 0 SUM BIG\", so he decided to solve the following problem. Given two integers $n$ and $k$, count the number of arrays of length $n$ such that:\n\nall its elements are integers between $0$ and $2^k-1$ (inclusive);\n\nthe bitwise AND of all its elements is $0$;\n...
[{"input": "10\n99281 18\n100000 16\n100000 15\n100000 14\n100000 6\n8823 3\n283 17\n299 18\n182 19\n1928 20\n", "output": "207307884\n95964640\n764800965\n570057652\n999657007\n829332965\n995193330\n759808819\n657208696\n258367760\n"}, {"input": "10\n99281 18\n100000 16\n100000 15\n100000 14\n100000 6\n8823 3\n283 17\...
code_stdio
[ { "content": "You are given integer $n$. You have to arrange numbers from $1$ to $2n$, using each of them exactly once, on the circle, so that the following condition would be satisfied:\n\nFor every $n$ consecutive numbers on the circle write their sum on the blackboard. Then any two of written on the blackboa...
[{"input": "7807\n", "output": "YES\n1 4 5 8 9 12 13 16 17 20 21 24 25 28 29 32 33 36 37 40 41 44 45 48 49 52 53 56 57 60 61 64 65 68 69 72 73 76 77 80 81 84 85 88 89 92 93 96 97 100 101 104 105 108 109 112 113 116 117 120 121 124 125 128 129 132 133 136 137 140 141 144 145 148 149 152 153 156 157 160 161 164 165 168 1...
code_stdio
[ { "content": "Some time ago Mister B detected a strange signal from the space, which he started to study.\n\nAfter some transformation the signal turned out to be a permutation p of length n or its cyclic shift. For the further investigation Mister B need some basis, that's why he decided to choose cyclic shift...
[{"input": "108\n1 102 33 99 6 83 4 20 61 100 76 71 44 9 24 87 57 2 81 82 90 85 12 30 66 53 47 36 43 29 31 64 96 84 77 23 93 78 58 68 42 55 13 70 62 19 92 14 10 65 63 75 91 48 11 105 37 50 32 94 18 26 52 89 104 106 86 97 80 95 17 72 40 22 79 103 25 101 35 51 15 98 67 5 34 69 54 27 45 88 56 16 46 60 74 108 21 41 73 39 1...
code_stdio
[ { "content": "Stepan has n pens. Every day he uses them, and on the i-th day he uses the pen number i. On the (n + 1)-th day again he uses the pen number 1, on the (n + 2)-th — he uses the pen number 2 and so on.\n\nOn every working day (from Monday to Saturday, inclusive) Stepan spends exactly 1 milliliter of ...
[{"input": "28\n2033 2033 2033 2033 2033 2033 2033 2033 2033 2033 2033 2033 2033 2033 2033 2033 2033 2033 2033 2033 2033 2033 2033 2033 2033 2033 2033 2033\n", "output": "1\n"}, {"input": "28\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 10...
code_stdio
[ { "content": "Your task is to develop a tiny little part of spreadsheet software.\n\nWrite a program which adds up columns and rows of given table as shown in the following figure:\n\n<image>\n\n\n\nInput\n\nThe input consists of several datasets. Each dataset consists of:\n\n\nn (the size of row and column of ...
[{"input": "4\n52 26 16 20\n143 22 35 45\n45 78 54 36\n10 86 74 55\n4\n52 151 15 28\n86 22 24 45\n45 78 54 36\n16 86 74 55\n0", "output": " 52 26 16 20 114\n 143 22 35 45 245\n 45 78 54 36 213\n 10 86 74 55 225\n 250 212 179 156 797\n 52 151 15 28 246\n 86 22 24 4...
code_stdio
[ { "content": "Watchmen are in a danger and Doctor Manhattan together with his friend Daniel Dreiberg should warn them as soon as possible. There are n watchmen on a plane, the i-th watchman is located at point (xi, yi).\n\nThey need to arrange a plan, but there are some difficulties on their way. As you know, D...
[{"input": "10\n46 -55\n46 45\n46 89\n81 -34\n46 45\n83 -55\n46 45\n83 45\n83 45\n34 -110\n", "output": "20\n"}, {"input": "10\n46 -55\n46 45\n19 89\n81 -34\n46 45\n83 -55\n46 45\n83 45\n83 45\n34 -110\n", "output": "16\n"}, {"input": "10\n46 -55\n46 30\n19 89\n81 -34\n46 45\n83 -55\n46 45\n83 45\n83 45\n34 -110\n", "o...
code_stdio
[ { "content": "For given integers m and n, compute mn (mod 1,000,000,007). Here, A (mod M) is the remainder when A is divided by M.\n\nConstraints\n\n* 1 ≤ m ≤ 100\n* 1 ≤ n ≤ 109\n\nInput\n\n\nm n\n\n\nTwo integers m and n are given in a line.\n\nOutput\n\nPrint mn (mod 1,000,000,007) in a line.\n\nExamples\n\nI...
[{"input": "-1 1", "output": "1000000006\n"}, {"input": "-2 1", "output": "1000000005\n"}, {"input": "-4 1", "output": "1000000003\n"}, {"input": "-3 1", "output": "1000000004\n"}, {"input": "-5 1", "output": "1000000002\n"}, {"input": "-2 11", "output": "999997959\n"}, {"input": "-3 11", "output": "999822860\n"}, {"in...
code_stdio
[ { "content": "\"You must lift the dam. With a lever. I will give it to you.\n\nYou must block the canal. With a rock. I will not give the rock to you.\" \n\nDanik urgently needs rock and lever! Obviously, the easiest way to get these things is to ask Hermit Lizard for them.\n\nHermit Lizard agreed to give Danik...
[{"input": "5\n5\n1 5 3 12 10\n3\n1 1 2\n4\n6 2 5 3\n2\n2 4\n1\n1\n", "output": "1\n1\n2\n0\n0\n"}, {"input": "5\n5\n1 5 3 12 10\n3\n1 1 1\n4\n6 2 5 3\n2\n2 4\n1\n1\n", "output": "1\n3\n2\n0\n0\n"}, {"input": "5\n5\n1 5 3 12 10\n3\n2 1 2\n4\n6 2 5 3\n2\n2 4\n1\n1\n", "output": "1\n1\n2\n0\n0\n"}, {"input": "5\n5\n1 5 3...
code_stdio
[ { "content": "The season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he needs an altar, which consists of three parts, one in each of the three categories: upper, middle and lower.\n\nHe has N parts for each of the three categories. The...
[{"input": "6\n5 30 290 0 -1 25\n106 2 21 1619 34 5\n1103 1563 -1 0 26 885", "output": "58\n"}, {"input": "6\n5 26 290 0 -1 25\n106 4 8 1619 60 5\n1103 1563 0 0 26 1803", "output": "64\n"}, {"input": "6\n4 43 290 -1 6 27\n106 13 11 837 28 8\n1103 700 5 8 14 460", "output": "69\n"}, {"input": "6\n4 30 290 -1 6 25\n106 1...
code_stdio
[ { "content": "Read problems statements in Mandarin Chinese and Russian. \n\nGiven a string S consisting of only 1s and 0s, find the number of substrings which start and end both in 1.\n\nIn this problem, a substring is defined as a sequence of continuous characters S_{i}, S_{i+1}, ..., S_{j} where 1 ≤ i ≤ j ≤ ...
[{"input": "2\n4\n1111\n5\n11011", "output": "10\n10\n"}, {"input": "2\n4\n1111\n5\n10000", "output": "10\n1\n"}, {"input": "2\n4\n1111\n5\n10100", "output": "10\n3\n"}, {"input": "2\n4\n1111\n5\n10011", "output": "10\n6\n"}, {"input": "2\n4\n1111\n5\n00000", "output": "10\n0\n"}, {"input": "2\n4\n1110\n5\n11110", "out...
code_stdio
[ { "content": "$k$ people want to split $n$ candies between them. Each candy should be given to exactly one of them or be thrown away.\n\nThe people are numbered from $1$ to $k$, and Arkady is the first of them. To split the candies, Arkady will choose an integer $x$ and then give the first $x$ candies to himsel...
[{"input": "1815995848677761959 576460752303423488 202657637814241276 1000\n", "output": "202657637814241276\n"}, {"input": "576460752303423488 576460752303423488 351082447248993993 1000\n", "output": "351082447248993993\n"}, {"input": "576460752303423488 576460752303423488 351082447248993993 1000\n", "output": "351082...
code_stdio
[ { "content": "A robot cleaner is placed on the floor of a rectangle room, surrounded by walls. The floor consists of $n$ rows and $m$ columns. The rows of the floor are numbered from $1$ to $n$ from top to bottom, and columns of the floor are numbered from $1$ to $m$ from left to right. The cell on the intersec...
[{"input": "5\n18 20 11 1 2 11\n10 10 5 9 2 1\n17 17 3 10 2 2\n6 9 2 2 5 8\n3 2 1 2 2 2\n", "output": "10\n10\n22\n3\n0\n"}, {"input": "5\n18 20 11 1 2 11\n10 10 5 9 2 1\n17 17 3 10 2 1\n6 9 2 2 5 8\n3 2 1 2 2 2\n", "output": "10\n10\n23\n3\n0\n"}, {"input": "5\n18 17 11 1 2 11\n10 10 5 9 2 1\n17 17 3 6 2 1\n6 9 2 2 5 ...
code_stdio
[ { "content": "You are given $n$ points on the plane. The polygon formed from all the $n$ points is strictly convex, that is, the polygon is convex, and there are no three collinear points (i.e. lying in the same straight line). The points are numbered from $1$ to $n$, in clockwise order.\n\nWe define the distan...
[{"input": "20\n-2967010 48581504\n-2967318 48581765\n-2967443 48581988\n-2967541 48582265\n-2967443 48582542\n-2967318 48582765\n-2967010 48583026\n-2966691 48583154\n-2966252 48583234\n-2965813 48583154\n-2965494 48583026\n-2965186 48582765\n-2965061 48582542\n-2964963 48582265\n-2965061 48581988\n-2965186 48581765\n...
code_stdio
[ { "content": "Bob watches TV every day. He always sets the volume of his TV to $b$. However, today he is angry to find out someone has changed the volume to $a$. Of course, Bob has a remote control that can change the volume.\n\nThere are six buttons ($-5, -2, -1, +1, +2, +5$) on the control, which in one press...
[{"input": "3\n-1 -1\n13 93\n3 2\n", "output": "0\n16\n1\n"}, {"input": "3\n-1 -1\n15 93\n3 2\n", "output": "0\n17\n1\n"}, {"input": "3\n-1 -1\n19 93\n3 2\n", "output": "0\n16\n1\n"}, {"input": "3\n-1 -1\n9 93\n3 6\n", "output": "0\n18\n2\n"}, {"input": "3\n-1 0\n13 93\n3 3\n", "output": "1\n16\n0\n"}, {"input": "3\n-1...
code_stdio
[ { "content": "The height of the student was measured at the medical examination. Create a program that takes height data as input, creates a frequency distribution, and outputs it. The frequency distribution is divided into 6 classes in 5 cm increments, and the number of people is indicated by * (half-width ast...
[{"input": "21\n182.52038838661136\n173.59035199874677\n159.1654152748587\n178.37721834424076\n171.14400777912027\n182.81130283538022\n174.6786970584368\n172.29285424816956\n164.63708333553282\n170.35024430895632\n176.98250427300766\n170.33088547272038\n163.32499378168183\n173.12553016807985\n178.05439416838166\n176.82...
code_stdio
[ { "content": "German mathematician Christian Goldbach (1690-1764) [conjectured](https://en.wikipedia.org/wiki/Goldbach%27s_conjecture) that every even number greater than 2 can be represented by the sum of two prime numbers. For example, `10` can be represented as `3+7` or `5+5`.\n\nYour job is to make the func...
[{"input": "1500", "output": "[[\"7+1493\", \"11+1489\", \"13+1487\", \"17+1483\", \"19+1481\", \"29+1471\", \"41+1459\", \"47+1453\", \"53+1447\", \"61+1439\", \"67+1433\", \"71+1429\", \"73+1427\", \"101+1399\", \"127+1373\", \"139+1361\", \"173+1327\", \"179+1321\", \"181+1319\", \"193+1307\", \"197+1303\", \"199+13...
code_functional
[ { "content": "Paprika loves permutations. She has an array $a_1, a_2, \\dots, a_n$. She wants to make the array a permutation of integers $1$ to $n$.\n\nIn order to achieve this goal, she can perform operations on the array. In each operation she can choose two integers $i$ ($1 \\le i \\le n$) and $x$ ($x > 0$)...
[{"input": "4\n2\n2 7\n3\n2 5 2\n4\n12345678 87654321 18276684 23571113\n9\n2 3 1 4 18 23 5 12 7\n", "output": "1\n-1\n4\n-1\n"}, {"input": "4\n2\n2 7\n3\n2 5 2\n4\n12345678 87654321 18276684 23571113\n9\n2 3 1 4 18 34 5 12 7\n", "output": "1\n-1\n4\n-1\n"}, {"input": "4\n2\n2 7\n3\n2 5 4\n4\n12345678 87654321 20211218...
code_stdio
[ { "content": "Let's denote as <image> the number of bits set ('1' bits) in the binary representation of the non-negative integer x.\n\nYou are given multiple queries consisting of pairs of integers l and r. For each query, find the x, such that l ≤ x ≤ r, and <image> is maximum possible. If there are multiple s...
[{"input": "18\n0 18\n1 101\n1 1001\n0 10000\n2 100000\n1 1001010\n1 10000000\n1 100000001\n1 1000000000\n1 10000010000\n1 100000000000\n0 1100000000000\n2 10000100000000\n0 100000000000000\n1 1000100000000000\n1 10000000000000000\n1 100000000000000001\n2 1000000000000000100\n", "output": "15\n63\n511\n8191\n65535\n524...
code_stdio
[ { "content": "Taro is an elementary school student and has graffiti on the back of the leaflet. At one point, Taro came up with the next game.\n\n* Write n × n grid-like squares.\n* The initial state of each square is either marked or unmarked.\n* Erase or write these circles so that there is always exactly one...
[{"input": "4\n1 2 3 4\n1 2 3 4\n1 2 3 4\n2 2 3 4\n1 2 3 4\n1 2 3 4\n1 2 3 4\n1 2 3 4\noooo\noooo\noooo\noooo", "output": "30\n12\n1 1 erase\n1 2 erase\n1 3 erase\n2 1 erase\n2 2 erase\n2 4 erase\n3 1 erase\n3 3 erase\n3 4 erase\n4 2 erase\n4 3 erase\n4 4 erase\n"}, {"input": "4\n1 2 3 4\n1 2 3 4\n1 3 3 4\n2 2 3 4\n1 2...
code_stdio
[ { "content": "There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.\nYou can perform the following operation on this integer sequence any number of times:\nOperation: Choose an integer i satisfying 1 \\leq i \\leq N-1. Multiply both A_i and A_{i+1} by -1.\nLet B_1, B_2, ..., B_N be the inte...
[{"input": "3584\n-447106060 -577310777 533985029 -953712286 574078473 571843694 636021509 -698941342 -685181628 -272695297 -275390499 -462127395 -392988914 370931736 375508378 -73997840 348137412 730547143 -211184259 782279375 -623827027 -369233996 -456713311 -796223085 -632198818 -912600553 815796805 -308550354 -2021...
code_stdio
[ { "content": "Consider a linear function f(x) = Ax + B. Let's define g^{(0)}(x) = x and g^{(}n)(x) = f(g^{(}n - 1)(x)) for n > 0. For the given integer values A, B, n and x find the value of g^{(}n)(x) modulo 10^9 + 7.\n\n\n-----Input-----\n\nThe only line contains four integers A, B, n and x (1 ≤ A, B, x ≤ 10^...
[{"input": "1377612828 606974665 846646545585165081 745145208\n", "output": "891861122\n"}, {"input": "978837295 606974665 846646545585165081 745145208\n", "output": "154788991\n"}, {"input": "978837295 606974665 846646545585165081 745145208\n", "output": "154788991\n"}, {"input": "1 1000000000 1000000000000000000 1000...
code_stdio
[ { "content": "C: Canisal cryptography\n\nproblem\n\nEbi-chan was given the string C obtained by encrypting a non-negative integer D with \"canisal cipher\". This cipher replaces each number in decimal notation with a fixed number (not necessarily different from the original). Different numbers will not be repla...
[{"input": "2\n1000000007", "output": "1000000009"}, {"input": "2\n1036219253", "output": "-1\n"}, {"input": "2\n1612950356", "output": "-1\n"}, {"input": "2\n2998753809", "output": "-1\n"}, {"input": "2\n1978754927", "output": "-1\n"}, {"input": "2\n2655259302", "output": "-1\n"}, {"input": "2\n3155611415", "output": ...
code_stdio
[ { "content": "Nikolay lives in a two-storied house. There are $n$ rooms on each floor, arranged in a row and numbered from one from left to right. So each room can be represented by the number of the floor and the number of the room on this floor (room number is an integer between $1$ and $n$). \n\nIf Nikolay i...
[{"input": "1\n100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "output": "100\n"}, {"input": "1\n100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "output": "100\n"}, {"input": "1\n100\n000000000000...
code_stdio
[ { "content": "Origami, or the art of folding paper\n\nMaster Grus is a famous origami (paper folding) artist, who is enthusiastic about exploring the possibility of origami art. For future creation, he is now planning fundamental experiments to establish the general theory of origami.\n\nOne rectangular piece o...
[{"input": "2 1 1 1\n1 1\n0 0\n1 3 2 1\n2 1\n2 1\n0 0\n15 10 3 2\n2 2\n1 1\n1 1\n0 0\n3 4\n4 3 3 2\n1 2\n1 2\n1 1\n0 1\n0 0\n0 0 0 0", "output": "2\n3\n6\n1\n4\n4\n"}, {"input": "2 1 1 1\n2 1\n0 0\n1 3 2 1\n2 0\n2 1\n0 1\n10 13 3 2\n2 2\n1 3\n1 1\n0 1\n3 4\n3 5 3 2\n1 2\n2 1\n1 1\n0 1\n0 0\n0 0 0 0", "output": "1\n1\n8...
code_stdio
[ { "content": "The finalists of the \"Russian Code Cup\" competition in 2214 will be the participants who win in one of the elimination rounds.\n\nThe elimination rounds are divided into main and additional. Each of the main elimination rounds consists of c problems, the winners of the round are the first n peop...
[{"input": "100 100\n100 100\n100\n", "output": "9900\n"}, {"input": "100 100\n100 100\n100\n", "output": "9900\n"}, {"input": "10 100\n100 100\n99\n", "output": "1000\n"}, {"input": "10 100\n100 100\n99\n", "output": "1000\n"}, {"input": "100 2\n50 100\n0\n", "output": "10000\n"}, {"input": "35 28\n35 60\n44\n", "outp...
code_stdio
[ { "content": "There are N cities on a number line. The i-th city is located at coordinate x_i.\nYour objective is to visit all these cities at least once.\nIn order to do so, you will first set a positive integer D.\nThen, you will depart from coordinate X and perform Move 1 and Move 2 below, as many times as y...
[{"input": "82 819942511\n805387705 958559711 124084167 364585009 219730035 133094285 857369155 830338801 544787369 320920591 252305077 961332055 280721603 463003221 621026829 125470339 334089225 712514181 631423119 930143185 620333743 645977925 905885175 45765449 835190403 69330373 934994787 187154993 711128009 485377...
code_stdio
[ { "content": "There is an automatic door at the entrance of a factory. The door works in the following way: when one or several people come to the door and it is closed, the door immediately opens automatically and all people immediately come inside, when one or several people come to the door and it is open,...
[{"input": "97 60 1 1\n5 6 6 7 9 10 10 11 11 11 12 13 13 13 13 14 14 15 16 18 20 23 23 24 25 26 29 31 32 35 38 41 43 43 46 47 48 48 49 52 53 54 55 56 58 59 68 70 72 74 78 81 81 82 91 92 96 96 97 98\n", "output": "49\n"}, {"input": "97 60 1 1\n5 6 6 7 9 10 10 11 11 11 12 13 13 13 13 14 14 15 16 18 20 23 23 24 25 26 29 3...
code_stdio
[ { "content": "Gerald is setting the New Year table. The table has the form of a circle; its radius equals R. Gerald invited many guests and is concerned whether the table has enough space for plates for all those guests. Consider all plates to be round and have the same radii that equal r. Each plate must be co...
[{"input": "10 1000 236\n", "output": "YES\n"}, {"input": "1 1484 1100\n", "output": "YES\n"}, {"input": "1 1484 0100\n", "output": "YES\n"}, {"input": "100 821 25\n", "output": "YES\n"}, {"input": "10 1000 237\n", "output": "NO\n"}, {"input": "13 927 179\n", "output": "YES\n"}, {"input": "100 1000 1\n", "output": "YES...
code_stdio
[ { "content": "Given an array of integers.\n\nReturn an array, where the first element is the count of positives numbers and the second element is sum of negative numbers.\n\nIf the input array is empty or null, return an empty array.\n\n# Example\n\nFor input `[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -11, -12, -13, -14,...
[{"input": "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -11, -12, -13, -14, -15]", "output": "[[10, -65]]", "fn_name": "count_positives_sum_negatives"}, {"input": "[0, 2, 3, 0, 5, 6, 7, 8, 9, 10, -11, -12, -13, -14]", "output": "[[8, -50]]", "fn_name": "count_positives_sum_negatives"}, {"input": "[0, 0, 0, 0, 0, 0, 0, 0, 0]", "out...
code_functional
[ { "content": "William has two numbers $a$ and $b$ initially both equal to zero. William mastered performing three different operations with them quickly. Before performing each operation some positive integer $k$ is picked, which is then used to perform one of the following operations: (note, that for each oper...
[{"input": "6\n7 0\n0 15\n7 12\n2 5\n0 0\n-1 6\n", "output": "-1\n-1\n-1\n-1\n0\n-1\n"}, {"input": "6\n7 0\n0 15\n10 12\n2 5\n0 0\n-1 6\n", "output": "-1\n-1\n2\n-1\n0\n-1\n"}, {"input": "6\n2 -1\n3 0\n0 3\n6 3\n4 1\n0 1\n", "output": "-1\n-1\n-1\n-1\n-1\n-1\n"}, {"input": "6\n7 0\n0 15\n10 24\n2 5\n0 0\n-2 6\n", "outp...
code_stdio
[ { "content": "Little penguin Polo adores strings. But most of all he adores strings of length n.\n\nOne day he wanted to find a string that meets the following conditions:\n\n 1. The string consists of n lowercase English letters (that is, the string's length equals n), exactly k of these letters are distinct....
[{"input": "70054 25\n", "output": "abababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab...
code_stdio
[ { "content": "You are given a binary string $s$ (recall that a string is binary if each character is either $0$ or $1$).\n\nLet $f(t)$ be the decimal representation of integer $t$ written in binary form (possibly with leading zeroes). For example $f(011) = 3, f(00101) = 5, f(00001) = 1, f(10) = 2, f(000) = 0$ a...
[{"input": "4\n0110\n0101\n00001000\n0001000\n", "output": "4\n3\n4\n3\n"}, {"input": "4\n0110\n1101\n00001000\n0001000\n", "output": "4\n4\n4\n3\n"}, {"input": "4\n0110\n1101\n00001000\n0101000\n", "output": "4\n4\n4\n5\n"}, {"input": "4\n0110\n1101\n00000000\n0101000\n", "output": "4\n4\n0\n5\n"}, {"input": "4\n0110\...
code_stdio
[ { "content": "Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of b consecutive cells. No cell can be part of two ships, however, the ships can touch each other.\n\nGalya doesn't know the ships location. She can shoot to some ce...
[{"input": "100 4 1 11\n0100000100000000000000001000000000010001101000000000101000000000000000000000001000001000000000000000\n", "output": "86\n1 3 4 5 6 7 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 26 27 28 29 30 31 32 33 34 35 37 38 39 42 44 45 46 47 48 49 50 51 52 54 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 ...
code_stdio
[ { "content": "Giant chess is quite common in Geraldion. We will not delve into the rules of the game, we'll just say that the game takes place on an h × w field, and it is painted in two colors, but not like in chess. Almost all cells of the field are white and only some of them are black. Currently Gerald is f...
[{"input": "100 10 30\n40 4\n15 3\n75 3\n88 10\n32 1\n16 5\n81 8\n45 2\n72 8\n11 6\n86 4\n50 2\n9 4\n11 1\n20 3\n47 3\n2 4\n68 3\n90 5\n85 2\n88 1\n88 5\n86 3\n70 9\n49 3\n34 4\n5 7\n77 5\n50 1\n87 5\n", "output": "402737011\n"}, {"input": "100 10 30\n40 4\n15 3\n75 3\n88 10\n32 1\n16 5\n81 8\n45 2\n72 8\n11 6\n86 4\n5...
code_stdio
[ { "content": "Little Petya was given this problem for homework:\n\nYou are given function <image> (here <image> represents the operation of taking the remainder). His task is to count the number of integers x in range [a;b] with property f(x) = x.\n\nIt is a pity that Petya forgot the order in which the remaind...
[{"input": "287 370 725 1148 19718 19895\n", "output": "0\n"}, {"input": "258 1076 952 491 2995 11942\n", "output": "0\n"}, {"input": "292 370 725 698 19718 19895\n", "output": "0\n"}, {"input": "258 1076 952 491 3802 11942\n", "output": "0\n"}, {"input": "202 329 1266 440 5705 28145\n", "output": "0\n"}, {"input": "28...
code_stdio
[ { "content": "In 2028 and after a continuous growth, AtCoder Inc. finally built an empire with six cities (City 1, 2, 3, 4, 5, 6)!\nThere are five means of transport in this empire:\n - Train: travels from City 1 to 2 in one minute. A train can occupy at most A people.\n - Bus: travels from City 2 to 3 in one m...
[{"input": "802565984633806\n802252530129536\n544410837252078\n872045491508709\n274353138702170\n562308817245826\n", "output": "7\n"}, {"input": "956131704220258\n897098524760050\n55734601880356\n155602009554546\n559895124828099\n830172607676349\n", "output": "22\n"}, {"input": "742872181398760\n816145891088938\n434646...
code_stdio
[ { "content": "Story:\nIn the realm of numbers, the apocalypse has arrived. Hordes of zombie numbers have infiltrated and are ready to turn everything into undead. The properties of zombies are truly apocalyptic: they reproduce themselves unlimitedly and freely interact with each other. Anyone who equals them is...
[{"input": "[687, 829, 998]", "output": "[45664]", "fn_name": "survivor"}, {"input": "[1, 7, 15]", "output": "[0]", "fn_name": "survivor"}, {"input": "[7, 11]", "output": "[59]", "fn_name": "survivor"}, {"input": "[2, 10]", "output": "[-1]", "fn_name": "survivor"}, {"input": "[]", "output": "[-1]", "fn_name": "survivor...
code_functional
[ { "content": "Given is an integer N.\nDetermine whether there is a pair of positive integers (A, B) such that 3^A + 5^B = N, and find one such pair if it exists.\n\n-----Constraints-----\n - 1 \\leq N \\leq 10^{18}\n - All values in input are integers.\n\n-----Input-----\nInput is given from Standard Input in t...
[{"input": "748307129767950488\n", "output": "37 25\n"}, {"input": "450283905890997368\n", "output": "37 1\n"}, {"input": "298023223876953128\n", "output": "1 25\n"}, {"input": "150094635296999246\n", "output": "36 3\n"}, {"input": "61457664964242466\n", "output": "32 24\n"}, {"input": "11920928955078134\n", "output": ...
code_stdio
[ { "content": "Alice gave Bob two integers $a$ and $b$ ($a > 0$ and $b \\ge 0$). Being a curious boy, Bob wrote down an array of non-negative integers with $\\operatorname{MEX}$ value of all elements equal to $a$ and $\\operatorname{XOR}$ value of all elements equal to $b$.\n\nWhat is the shortest possible lengt...
[{"input": "5\n1 1\n2 1\n2 0\n1 10000\n2 10000\n", "output": "3\n2\n3\n2\n3\n"}, {"input": "5\n1 1\n2 1\n2 0\n1 10000\n2 10000\n", "output": "3\n2\n3\n2\n3\n"}, {"input": "1\n187994 180766\n", "output": "187995\n"}, {"input": "1\n187994 180766\n", "output": "187995\n"}, {"input": "1\n187994 204747\n", "output": "187995...
code_stdio
[ { "content": "Having learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together.\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\n-----Constraints-----\n - ...
[{"input": "00010", "output": "Yes\n"}, {"input": "00001", "output": "Yes\n"}, {"input": "11111", "output": "No\n"}, {"input": "10111", "output": "No\n"}, {"input": "10011", "output": "No\n"}, {"input": "10010", "output": "No\n"}, {"input": "11010", "output": "No\n"}, {"input": "01010", "output": "No\n"}, {"input": "01...
code_stdio
[ { "content": "Takahashi has an N \\times N grid. The square at the i-th row and the j-th column of the grid is denoted by (i,j). Particularly, the top-left square of the grid is (1,1), and the bottom-right square is (N,N).\n\nAn integer, 0 or 1, is written on M of the squares in the Takahashi's grid. Three inte...
[{"input": "5 2\n3 1 1\n2 2 0\n0 2 1\n-1 4 4\n2 0 0\n2 1 -1\n8 1 0\n4 15 -2", "output": "8192\n"}, {"input": "3 2\n1 1 1\n2 2 0\n0 2 1\n0 4 1\n2 1 0\n2 1 -1\n7 1 1\n4 15 -1", "output": "16\n"}, {"input": "4 1\n1 1 1\n2 2 0\n0 2 1\n0 4 1\n2 1 0\n1 1 -1\n7 1 1\n4 15 1", "output": "512\n"}, {"input": "4 1\n1 1 1\n2 2 0\n0...
code_stdio
[ { "content": "Example\n\nInput\n\n2 3 1 3 1 0\n\n\nOutput\n\n2\n\nWrite Python code to solve this problem. Your program should read the input from stdin and write the output to stdout. Enclose your complete solution in a single ```python code block.", "role": "user" } ]
[{"input": "15 18 0 12 0 4", "output": "138\n"}, {"input": "15 18 0 22 0 4", "output": "124\n"}, {"input": "15 18 1 22 0 4", "output": "120\n"}, {"input": "11 51 4 0 1 -1", "output": "255\n"}, {"input": "11 72 4 0 1 -1", "output": "285\n"}, {"input": "17 18 1 22 0 4", "output": "137\n"}, {"input": "11 51 2 0 1 0", "out...
code_stdio
[ { "content": "Polycarp doesn't like integers that are divisible by $3$ or end with the digit $3$ in their decimal representation. Integers that meet both conditions are disliked by Polycarp, too.\n\nPolycarp starts to write out the positive (greater than $0$) integers which he likes: $1, 2, 4, 5, 7, 8, 10, 11, ...
[{"input": "100\n1000\n999\n998\n997\n996\n995\n994\n993\n992\n991\n990\n989\n988\n987\n986\n985\n984\n983\n982\n981\n980\n979\n978\n977\n976\n975\n974\n973\n972\n971\n970\n969\n968\n967\n966\n965\n964\n963\n962\n961\n960\n959\n958\n957\n956\n955\n954\n953\n952\n951\n950\n949\n948\n947\n946\n945\n944\n943\n942\n941\n94...
code_stdio
[ { "content": "A: Flick input\n\nA college student who loves 2D, commonly known as 2D, replaced his long-used Galapagos mobile phone with a smartphone. 2D, who operated the smartphone for the first time, noticed that the character input method was a little different from that of old mobile phones. On smartphones...
[{"input": "5R3D", "output": "neso\n"}, {"input": "5D2R", "output": "noke\n"}, {"input": "5T2D", "output": "nako\n"}, {"input": "5D3R", "output": "nose\n"}, {"input": "5U2D", "output": "nuko\n"}, {"input": "4D2R", "output": "toke\n"}, {"input": "6T2D", "output": "hako\n"}, {"input": "3R5D", "output": "seno\n"}, {"input...
code_stdio