messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 1
value |
|---|---|---|
[
{
"content": "Of course you have heard the famous task about Hanoi Towers, but did you know that there is a special factory producing the rings for this wonderful game? Once upon a time, the ruler of the ancient Egypt ordered the workers of Hanoi Factory to create as high tower as possible. They were not ready ... | [{"input": "15\n1 30 1409523818\n12 13 463027806\n9 14 846985104\n20 21 770345346\n17 22 514758030\n2 15 438137019\n18 19 331182033\n16 29 613043570\n10 19 765879041\n6 7 960155075\n13 27 323764310\n24 25 724736351\n4 9 107208241\n3 8 992951987\n23 28 125300818\n", "output": "6581903942\n"}, {"input": "15\n1 30 1409523... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese , Russian and Vietnamese \n\nA number is called palindromic if its decimal representation is a palindrome. You are given a range, described by a pair of integers L and R. Find the sum of all palindromic numbers lying in the range [L, R], inclusive of b... | [{"input": "2\n2 10\n123 150", "output": "44\n272\n"}, {"input": "2\n1 10\n123 150", "output": "45\n272\n"}, {"input": "2\n1 10\n123 150", "output": "45\n272"}, {"input": "2\n1 7\n100 112", "output": "28\n212\n"}, {"input": "2\n1 7\n110 112", "output": "28\n111\n"}, {"input": "2\n-1 120\n000 0", "output": "752\n0\n"}, ... | code_stdio |
[
{
"content": "Create a program that converts data based on the given conversion table.\n\nThe characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table.\n\nThe conversion table has two charact... | [{"input": "3\nA a\n0 5\n5 4\n10\nB\nB\nC\n0\n1\n4\n5\na\nb\nA\n3\nA a\n0 5\n5 4\n10\nA\nB\nC\n0\n1\n4\n5\na\nb\nA\n0", "output": "BBC5144aba\naBC5144aba\n"}, {"input": "3\nA a\n0 0\n5 4\n10\nB\nB\nC\n0\n1\n4\n5\na\nb\nA\n3\nA a\n0 5\n5 4\n10\nA\nB\nC\n0\n1\n4\n5\na\nb\nA\n0", "output": "BBC0144aba\naBC5144aba\n"}, {"i... | code_stdio |
[
{
"content": "You are given a tree consisting of $n$ vertices. A number is written on each vertex; the number on vertex $i$ is equal to $a_i$.\n\nRecall that a simple path is a path that visits each vertex at most once. Let the weight of the path be the bitwise XOR of the values written on vertices it consists ... | [{"input": "20\n4 1 3 4 7 3 8 7 7 3 1 1 7 1 9 5 1 10 6 3\n6 15\n12 11\n18 1\n9 17\n8 1\n1 20\n13 7\n10 15\n20 19\n10 16\n8 5\n2 11\n14 3\n6 1\n1 12\n3 18\n6 4\n8 13\n9 18\n", "output": "3\n"}, {"input": "10\n7 4 6 7 6 6 7 5 7 5\n8 7\n4 5\n9 6\n2 5\n4 8\n9 10\n4 3\n9 4\n1 8\n", "output": "1\n"}, {"input": "6\n3 2 1 3 2 ... | code_stdio |
[
{
"content": "There is a game called \"Unique Bid Auction\". You can read more about it here:\n\nhttps://en.wikipedia.org/wiki/Unique_bid_auction\n\n(though you don't have to do it to solve this problem).\n\nLet's simplify this game a bit. Formally, there are $n$ participants, the $i$-th participant chose the n... | [{"input": "8\n12\n10 1 3 3 11 5 12 11 12 12 9 4\n11\n10 9 7 6 6 3 8 4 1 7 9\n12\n3 11 8 4 5 9 6 5 11 12 8 1\n15\n12 6 13 12 7 6 1 7 14 12 14 13 11 3 11\n40\n31 32 2 37 19 39 21 19 18 14 17 11 33 7 17 30 33 27 16 37 37 29 19 32 20 32 24 20 20 24 32 2 7 33 30 25 23 11 35 39\n16\n11 9 16 2 10 5 10 4 13 11 8 1 13 7 4 12\n... | code_stdio |
[
{
"content": "Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct.\n\nFortunately the child knows how to solve such c... | [{"input": "A.He_nan_de_yang_guang_zhao_yao_zhe_wo_men_mei_guo_ren_lian_shang_dou_xiao_kai_yan_wahaaaaaaaaaaaaaaaa\nB.Li_bai_li_bai_fei_liu_zhi_xia_san_qian_chi_yi_si_yin_he_luo_jiu_tian_li_bai_li_bai_li_bai_li_bai_shi\nC.Peng_yu_xiang_shi_zai_tai_shen_le_jian_zhi_jiu_shi_ye_jie_du_liu_a_si_mi_da_zhen_shi_tai_shen_le_a... | code_stdio |
[
{
"content": "Sensation, sensation in the two-dimensional kingdom! The police have caught a highly dangerous outlaw, member of the notorious \"Pihters\" gang. The law department states that the outlaw was driving from the gang's headquarters in his car when he crashed into an ice cream stall. The stall, the car... | [{"input": "10\nUR\nDR\nUL\nDR\nUL\nULDR\nUR\nUL\nULDR\nUL\n", "output": "45\n"}, {"input": "10\nUL\nUL\nUL\nUL\nUL\nUL\nUL\nUL\nUL\nUL\n", "output": "11\n"}, {"input": "10\nUL\nUR\nUR\nDR\nDR\nDR\nDL\nDL\nDL\nDL\n", "output": "35\n"}, {"input": "6\nUL\nDL\nDL\nUL\nUL\nDL\n", "output": "16\n"}, {"input": "6\nUR\nDL\nUR... | code_stdio |
[
{
"content": "Being a nonconformist, Volodya is displeased with the current state of things, particularly with the order of natural numbers (natural number is positive integer number). He is determined to rearrange them. But there are too many natural numbers, so Volodya decided to start with the first n. He wr... | [{"input": "1000000000000 1000000000000\n", "output": "1000000000000\n"}, {"input": "1000000000000 1276759536556\n", "output": "1553519073112\n"}, {"input": "1000000000000 1000000000000\n", "output": "1000000000000"}, {"input": "1000100000000 1000000000000\n", "output": "999900000000\n"}, {"input": "1001100000000 10000... | code_stdio |
[
{
"content": "Today, Mezo is playing a game. Zoma, a character in that game, is initially at position $x = 0$. Mezo starts sending $n$ commands to Zoma. There are two possible commands: 'L' (Left) sets the position $x: =x - 1$; 'R' (Right) sets the position $x: =x + 1$. \n\nUnfortunately, Mezo's controller ma... | [{"input": "13\nLRLLLLRRLLRLR\n", "output": "14\n"}, {"input": "13\nLRLLLLRRLLRLR\n", "output": "14\n"}, {"input": "13\nLRLRLLRLLLRLR\n", "output": "14\n"}, {"input": "13\nRLRLLRRLLLLRL\n", "output": "14\n"}, {"input": "13\nLRLRLLRLRLRLL\n", "output": "14\n"}, {"input": "13\nRLRLLRLLLLRRL\n", "output": "14\n"}, {"input... | code_stdio |
[
{
"content": "You have $n$ stacks of blocks. The $i$-th stack contains $h_i$ blocks and it's height is the number of blocks in it. In one move you can take a block from the $i$-th stack (if there is at least one block) and put it to the $i + 1$-th stack. Can you make the sequence of heights strictly increasing?... | [{"input": "1\n30\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000... | code_stdio |
[
{
"content": "Taro made a sugoroku so that everyone can play at the children's association event. In order to make the game interesting, I wrote instructions such as \"advance 6\" and \"back 5\" in some of the sugoroku squares other than \"Furidashi\" and \"Agari\". Turn the roulette wheel to advance as many ti... | [{"input": "3\n3\n-1\n1\n-1\n3\n0\n4\n2\n0\n-6\n4\n2\n-1\n-7\n0", "output": "OK\nOK\nOK\nOK\n"}, {"input": "3\n3\n0\n1\n-1\n3\n0\n4\n2\n0\n-6\n4\n2\n-1\n-8\n0", "output": "OK\nOK\nOK\nOK\n"}, {"input": "3\n3\n0\n1\n-1\n3\n0\n4\n2\n0\n-6\n4\n2\n-1\n-7\n0", "output": "OK\nOK\nOK\nOK\n"}, {"input": "3\n3\n-2\n1\n-1\n2\n4\... | code_stdio |
[
{
"content": "One day Vasya painted a Cartesian coordinate system on a piece of paper and marked some set of points (x1, y1), (x2, y2), ..., (xn, yn). Let's define neighbors for some fixed point from the given set (x, y): \n\n * point (x', y') is (x, y)'s right neighbor, if x' > x and y' = y\n * point (x', y'... | [{"input": "30\n507 836\n525 836\n-779 196\n507 -814\n525 -814\n525 42\n525 196\n525 -136\n-779 311\n507 -360\n525 300\n507 578\n507 311\n-779 836\n507 300\n525 -360\n525 311\n-779 -360\n-779 578\n-779 300\n507 42\n525 578\n-779 379\n507 196\n525 379\n507 379\n-779 -814\n-779 42\n-779 -136\n507 -136\n", "output": "8\n"... | code_stdio |
[
{
"content": "<image>\n\n\nMy grandmother uses a balance. The balance will balance if you place the same size on both of the two dishes, otherwise it will tilt to the heavier side. The weights of the 10 weights are 1g, 2g, 4g, 8g, 16g, 32g, 64g, 128g, 256g, 512g in order of lightness.\n\nMy grandmother says, \"... | [{"input": "5\n11\n731", "output": "1 4\n1 2 8\n1 2 8 16 64 128 512\n"}, {"input": "5\n17\n731", "output": "1 4\n1 16\n1 2 8 16 64 128 512\n"}, {"input": "5\n17\n994", "output": "1 4\n1 16\n2 32 64 128 256 512\n"}, {"input": "5\n27\n186", "output": "1 4\n1 2 8 16\n2 8 16 32 128\n"}, {"input": "5\n6\n731", "output": "1 ... | code_stdio |
[
{
"content": "Pasha has a positive integer a without leading zeroes. Today he decided that the number is too small and he should make it larger. Unfortunately, the only operation Pasha can do is to swap two adjacent decimal digits of the integer.\n\nHelp Pasha count the maximum number he can get if he has the t... | [{"input": "1541326723729813719 14\n", "output": "9541132672372813719\n"}, {"input": "219810011901120912 100\n", "output": "999822211111110000\n"}, {"input": "191919191919119911 100\n", "output": "999999991111111111\n"}, {"input": "123456789123456789 100\n", "output": "998877665544213123\n"}, {"input": "191919191919119... | code_stdio |
[
{
"content": "Omkar is creating a mosaic using colored square tiles, which he places in an n × n grid. When the mosaic is complete, each cell in the grid will have either a glaucous or sinoper tile. However, currently he has only placed tiles in some cells. \n\nA completed mosaic will be a mastapeece if and onl... | [{"input": "20\n..............S.....\n....................\n.............S.....S\n....................\n....................\n...S................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n..................... | code_stdio |
[
{
"content": "Aiz Onsen has a bathhouse and a pool. To use the bathhouse, you need to buy a bathing ticket, and to use the pool, you need to buy a pool ticket. Prices for these tickets may vary from day to day. In addition, Aiz Onsen has the following rules.\n\n* Tickets are valid only once on the day of purcha... | [{"input": "2\n111 101 -1 -2\n1001 722 131 -3", "output": "-313\n106060\n"}, {"input": "2\n111 001 -1 -2\n1001 722 131 -3", "output": "-113\n106060\n"}, {"input": "2\n111 000 -1 -2\n1001 722 131 -3", "output": "-111\n106060\n"}, {"input": "2\n011 101 -1 -2\n1001 722 102 -3", "output": "-213\n82836\n"}, {"input": "2\n01... | code_stdio |
[
{
"content": "Jett is tired after destroying the town and she wants to have a rest. She likes high places, that's why for having a rest she wants to get high and she decided to craft staircases.\n\nA staircase is a squared figure that consists of square cells. Each staircase consists of an arbitrary number of s... | [{"input": "4\n1\n10\n28\n0111101000000000100\n", "output": "1\n2\n2\n28\n"}, {"input": "4\n1\n10\n28\n0101101000000000100\n", "output": "1\n2\n2\n28\n"}, {"input": "4\n2\n10\n28\n0101101000000000100\n", "output": "1\n2\n2\n28\n"}, {"input": "4\n2\n10\n26\n0101101000000000100\n", "output": "1\n2\n2\n28\n"}, {"input": "... | code_stdio |
[
{
"content": "You are given an array $a$ consisting of $n$ integers $a_1, a_2, \\dots, a_n$.\n\nYour problem is to find such pair of indices $i, j$ ($1 \\le i < j \\le n$) that $lcm(a_i, a_j)$ is minimum possible.\n\n$lcm(x, y)$ is the least common multiple of $x$ and $y$ (minimum positive number such that both... | [{"input": "4\n9999991 9999883 9999659 9999433\n", "output": "3 4\n"}, {"input": "4\n9999991 9999883 9999659 9999433\n", "output": "3 4\n"}, {"input": "4\n9999991 5101198 9999659 9999433\n", "output": "2 4\n"}, {"input": "3\n10000000 9999999 9999997\n", "output": "2 3\n"}, {"input": "3\n10000000 9999999 9999998\n", "ou... | code_stdio |
[
{
"content": "Today, as a friendship gift, Bakry gave Badawy $n$ integers $a_1, a_2, \\dots, a_n$ and challenged him to choose an integer $X$ such that the value $\\underset{1 \\leq i \\leq n}{\\max} (a_i \\oplus X)$ is minimum possible, where $\\oplus$ denotes the bitwise XOR operation.\n\nAs always, Badawy is... | [{"input": "5\n1073741823 1073741823 181085488 1073741823 1073741823\n", "output": "536870912\n"}, {"input": "5\n1073741823 29972487 1073741823 1073741823 1073741823\n", "output": "536870912\n"}, {"input": "5\n219338430 29972487 1073741823 1073741823 1073741823\n", "output": "536870912\n"}, {"input": "5\n684690029 2997... | code_stdio |
[
{
"content": "Taro has decided to move. Taro has a lot of luggage, so I decided to ask a moving company to carry the luggage. Since there are various weights of luggage, I asked them to arrange them in order from the lightest one for easy understanding, but the mover left the luggage in a different order. So Ta... | [{"input": "8\n7 2 1 3 8 5 4 6", "output": "20\n"}, {"input": "8\n5 2 1 3 8 6 4 7", "output": "18\n"}, {"input": "8\n6 4 1 1 8 5 4 7", "output": "20\n"}, {"input": "8\n6 2 1 3 8 5 4 7", "output": "19"}, {"input": "7\n1 2 5 4 3 6 7", "output": "7\n"}, {"input": "7\n1 3 2 4 5 6 7", "output": "2\n"}, {"input": "7\n1 2 8 1... | code_stdio |
[
{
"content": "You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.\n\nWe'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 < p2 < ... < pk ≤ |s|) a subsequence of string s = s1s2... s|s|.\n\nString x = x1x2... x|x| is lexicographically ... | [{"input": "zyxzxzwyxywxxwabcdabdacdbcacdbcacabaaba\n", "output": "zzzyyxxwddddccbba\n"}, {"input": "zyxzxzwyxywxxwabcdabcacdbcacdbdacabaaba\n", "output": "zzzyyxxwddddcbba\n"}, {"input": "thankstosamarasauteddybearsforthiscontest\n", "output": "yttt\n"}, {"input": "shankstosamarasauteddybearsforthiscontest\n", "output... | code_stdio |
[
{
"content": "For given a circle $c$ and a line $l$, print the coordinates of the cross points of them.\n\nConstraints\n\n* $p1$ and $p2$ are different\n* The circle and line have at least one cross point\n* $1 \\leq q \\leq 1,000$\n* $-10,000 \\leq cx, cy, x1, y1, x2, y2 \\leq 10,000$\n* $1 \\leq r \\leq 10,00... | [{"input": "2 0 3\n2\n-1 -1 11 0\n1 -1 12 3", "output": "-0.83330025 -0.98610835 4.95743818 -0.50354682\n-0.55841103 -1.56669492 4.96717016 0.44260733\n"}, {"input": "2 -1 3\n2\n0 -1 14 0\n1 0 10 11", "output": "-0.99915098 -1.07136793 4.97884641 -0.64436811\n-0.76686667 -2.15950371 2.58864885 1.94168192\n"}, {"input":... | code_stdio |
[
{
"content": "The clique problem is one of the most well-known NP-complete problems. Under some simplification it can be formulated as follows. Consider an undirected graph G. It is required to find a subset of vertices C of the maximum size such that any two of them are connected by an edge in graph G. Sounds ... | [{"input": "12\n66 4\n12 7\n60 1\n24 4\n48 4\n-1 4\n36 4\n30 4\n6 4\n54 4\n42 2\n18 4\n", "output": "8\n"}, {"input": "12\n67 4\n12 7\n60 1\n24 4\n48 4\n-1 4\n36 4\n30 4\n6 4\n54 4\n42 2\n18 4\n", "output": "8\n"}, {"input": "12\n67 8\n12 7\n60 1\n24 4\n48 4\n-1 4\n36 4\n30 4\n6 4\n54 4\n42 2\n18 4\n", "output": "7\n"}... | code_stdio |
[
{
"content": "----- Statement -----\n\nYou need to find a string which has exactly K positions in it such that the character at that position comes alphabetically later than the character immediately after it. If there are many such strings, print the one which has the shortest length. If there is still a tie, ... | [{"input": "2\n1\n38", "output": "ba\nnmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\n"}, {"input": "2\n4\n31", "output": "edcba\ngfedcbazyxwvutsrqponmlkjihgfedcba\n"}, {"input": "2\n1\n31", "output": "ba\ngfedcbazyxwvutsrqponmlkjihgfedcba\n"}, {"input": "2\n8\n23", "output": "ihgfedcba\nxwvutsrqponmlkjihgfedcba\n"}, {"input... | code_stdio |
[
{
"content": "Little Joty has got a task to do. She has a line of n tiles indexed from 1 to n. She has to paint them in a strange pattern.\n\nAn unpainted tile should be painted Red if it's index is divisible by a and an unpainted tile should be painted Blue if it's index is divisible by b. So the tile with the... | [{"input": "1000000000 1000000000 1000000000 1000000000 1000000000\n", "output": "1000000000\n"}, {"input": "1000000000 1000000000 1 1000000000 1000000000\n", "output": "1000000000000000000\n"}, {"input": "1000000000 1000000000 1000000000 1000000000 1000000000\n", "output": "1000000000\n"}, {"input": "1000000000 100000... | code_stdio |
[
{
"content": "There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling.\n\nThere is a deck of n cards. Starting from the p-th card from the top of the deck, c cards are pulled out and put o... | [{"input": "1 -2\n3 1\n3 1\n10 1\n1 10\n10 0\n8 -1\n0 0", "output": "1\n1\n10\n10\n8\n"}, {"input": "1 -2\n3 1\n3 1\n10 1\n4 10\n10 0\n8 -1\n0 0", "output": "1\n1\n7\n10\n8\n"}, {"input": "5 -1\n3 1\n1 1\n10 2\n1 10\n14 1\n11 0\n0 0", "output": "5\n3\n10\n11\n"}, {"input": "5 0\n3 1\n3 1\n19 2\n1 10\n10 2\n11 -1\n0 0",... | code_stdio |
[
{
"content": "Fox Ciel has a board with n rows and n columns. So, the board consists of n × n cells. Each cell contains either a symbol '.', or a symbol '#'.\n\nA cross on the board is a connected set of exactly five cells of the board that looks like a cross. The picture below shows how it looks.[Image]\n\nCie... | [{"input": "15\n.#...##.##.....\n.###.#.#.##..#.\n##.#####......#\n#....###.#..#..\n#.##.#.###.###.\n.###....#.###.#\n##.....##..#...\n.#.########...#\n##..#..##..#.##\n#...#....##....\n.......#.......\n.#..#.#.####...\n.#..#...#..###.\n#..#.#..#......\n###.....##....#\n", "output": "NO\n"}, {"input": "15\n.#...##.##..... | code_stdio |
[
{
"content": "You are enthusiastic about the popular web game \"Moonlight Ranch\". The purpose of this game is to grow crops in the fields, sell them to earn income, and use that income to grow the ranch.\n\nYou wanted to grow the field quickly. Therefore, we decided to arrange the crops that can be grown in th... | [{"input": "5\nelppa 2 2 -1 1 1 0 1 13 1\nan`ban 1 0 3 9 2 2 4 1 0\ncatror 0 2 2 2 1 4 1 18 2\ncqniau 1 3 0 2 -1 3 1 -1 1\nfghplant 0 4 0 3 2 3 0 110 1\n4\nenoki 1 3 2 -1 6 3 1 10 1\ntpmato 1 0 0 10 0 3 -1 1 1\nqotato -1 0 8 4 1 -1 4 7 1\nonion 3 4 0 3 3 7 0 10 1\n3\na 15 1 1 1 1 1 1 14 5\nc 16 -1 2 0 2 1 2 10 2\nc 14 ... | code_stdio |
[
{
"content": "You are given a permutation p_1, p_2, …, p_n.\n\nIn one move you can swap two adjacent values.\n\nYou want to perform a minimum number of moves, such that in the end there will exist a subsegment 1,2,…, k, in other words in the end there should be an integer i, 1 ≤ i ≤ n-k+1 such that p_i = 1, p_{... | [{"input": "100\n98 52 63 2 18 96 31 58 84 40 41 45 66 100 46 71 26 48 81 20 73 91 68 76 13 93 17 29 64 95 79 21 55 75 19 85 54 51 89 78 15 87 43 59 36 1 90 35 65 56 62 28 86 5 82 49 3 99 33 9 92 32 74 69 27 22 77 16 44 94 34 6 57 70 23 12 61 25 8 11 67 47 83 88 10 14 30 7 97 60 42 37 24 38 53 50 4 80 72 39\n", "output... | code_stdio |
[
{
"content": "Seryozha conducts a course dedicated to building a map of heights of Stepanovo recreation center. He laid a rectangle grid of size $n \\times m$ cells on a map (rows of grid are numbered from $1$ to $n$ from north to south, and columns are numbered from $1$ to $m$ from west to east). After that he... | [{"input": "3000 3000 4 10\n623629309 917769297 890844966 987654319\n", "output": "215591588260257\n"}, {"input": "3000 3000 10 4\n122375063 551934841 132649021 999999937\n", "output": "218197599525055\n"}, {"input": "3000 3000 1000 1000\n794639486 477380537 986566001 987456307\n", "output": "3906368067\n"}, {"input": ... | code_stdio |
[
{
"content": "Natasha is planning an expedition to Mars for $n$ people. One of the important tasks is to provide food for each participant.\n\nThe warehouse has $m$ daily food packages. Each package has some food type $a_i$.\n\nEach participant must eat exactly one food package each day. Due to extreme loads, e... | [{"input": "4 100\n84 99 66 69 86 94 89 96 98 93 93 82 87 93 91 100 69 99 93 81 99 84 75 100 86 88 98 100 84 96 44 70 94 91 85 78 86 79 45 88 91 78 98 94 81 87 93 72 96 88 96 97 96 62 86 72 94 84 80 98 88 90 93 73 73 98 78 50 91 96 97 82 85 90 87 41 97 82 97 77 100 100 92 83 98 81 70 81 74 78 84 79 98 98 55 99 97 99 79... | code_stdio |
[
{
"content": "You need to execute several tasks, each associated with number of processors it needs, and the compute power it will consume.\n\nYou have sufficient number of analog computers, each with enough processors for any task. Each computer can execute up to one task at a time, and no more than two tasks ... | [{"input": "50\n83 43 73 75 11 53 6 43 67 38 83 12 70 27 60 13 9 79 61 30 29 71 10 11 95 87 26 26 19 99 13 47 66 93 91 47 90 75 68 3 22 29 59 12 44 41 64 3 99 100\n31 36 69 25 18 33 15 70 12 91 41 44 1 96 80 74 12 80 16 82 88 25 87 17 53 63 3 42 81 6 50 78 34 68 65 78 94 14 53 14 41 97 63 44 21 62 95 37 36 31\n", "outp... | code_stdio |
[
{
"content": "There is a sequence X of length N, where every element is initially 0. Let X_i denote the i-th element of X.\n\nYou are given a sequence A of length N. The i-th element of A is A_i. Determine if we can make X equal to A by repeating the operation below. If we can, find the minimum number of operat... | [{"input": "9\n0\n-1\n-1\n-1\n-2\n2\n1\n1\n-2", "output": "-1\n"}, {"input": "9\n0\n-1\n-1\n-1\n-1\n2\n1\n1\n-2", "output": "-1\n"}, {"input": "9\n0\n-1\n-1\n-1\n-1\n2\n0\n1\n-2", "output": "-1\n"}, {"input": "9\n0\n-1\n-1\n-1\n-1\n2\n0\n1\n-4", "output": "-1\n"}, {"input": "9\n0\n-1\n-1\n-1\n-1\n2\n0\n1\n-6", "output"... | code_stdio |
[
{
"content": "Two participants are each given a pair of distinct numbers from 1 to 9 such that there's exactly one number that is present in both pairs. They want to figure out the number that matches by using a communication channel you have access to without revealing it to you.\n\nBoth participants communica... | [{"input": "12 12\n6 7 5 4 7 8 2 9 12 5 3 5 1 6 7 3 7 9 5 7 1 8 6 8\n6 4 2 1 7 8 1 6 8 5 9 8 1 5 7 2 5 9 6 3 9 2 9 4\n", "output": "-1\n"}, {"input": "12 12\n1 6 2 6 8 3 6 4 4 8 7 2 7 5 9 4 2 4 9 5 8 5 3 2\n2 8 6 9 2 6 7 4 6 5 6 3 5 8 7 8 7 1 1 9 9 7 7 3\n", "output": "-1\n"}, {"input": "12 2\n6 7 5 4 7 8 2 9 12 5 3 5 ... | code_stdio |
[
{
"content": "A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string \"aabaabaabaab\" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.\n\n... | [{"input": "250\ncececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececec... | code_stdio |
[
{
"content": "There are n cities in Berland. Each city has its index — an integer number from 1 to n. The capital has index r1. All the roads in Berland are two-way. The road system is such that there is exactly one path from the capital to each city, i.e. the road map looks like a tree. In Berland's chronicles... | [{"input": "100 62 42\n45 66 13 18 93 47 83 19 41 66 5 70 16 29 54 28 65 91 92 24 90 54 7 40 77 53 68 58 70 65 68 30 94 80 16 18 69 21 94 1 99 61 97 2 69 15 79 38 61 46 88 32 57 84 35 18 17 77 38 91 84 2 53 54 68 19 13 78 62 16 63 17 76 49 28 45 94 13 35 69 37 56 12 41 95 70 57 24 45 84 87 65 14 76 95 94 31 67 5\n", "o... | code_stdio |
[
{
"content": "Every year a race takes place on the motorway between cities A and B. This year Vanya decided to take part in the race and drive his own car that has been around and bears its own noble name — The Huff-puffer.\n\nSo, Vasya leaves city A on the Huff-puffer, besides, at the very beginning he fills t... | [{"input": "76\n342 684 1027 1369 1711 2054 2396 2738 3081 3423 3765 4108 4450 4792 5135 5477 5819 6162 6504 6846 7189 7531 7873 8216 8558 8900 9243 9585 9927 10270 10612 10954 11297 11639 11981 12324 12666 13009 13351 13693 14036 14378 14720 15063 15405 15747 16090 16432 16774 17117 17459 17801 18144 18486 18828 19171... | code_stdio |
[
{
"content": "The Little Elephant has an integer a, written in the binary notation. He wants to write this number on a piece of paper.\n\nTo make sure that the number a fits on the piece of paper, the Little Elephant ought to delete exactly one any digit from number a in the binary record. At that a new number ... | [{"input": "11100010010010000110101101101100111111001010001101101001001111010110010111001011010000001100110101000101111000001111101111110010000010101110011110101101010110001100011101111011100010011101100111110010111111100110101000000111101000000000110100100101111101000110101010101101001110001110000101011010101100011100... | code_stdio |
[
{
"content": "Even if the world is full of counterfeits, I still regard it as wonderful.\n\nPile up herbs and incense, and arise again from the flames and ashes of its predecessor — as is known to many, the phoenix does it like this.\n\nThe phoenix has a rather long lifespan, and reincarnates itself once every ... | [{"input": "1000000000000000000 1000000000000000000\n", "output": "1\n"}, {"input": "1000000000000000000 1000000000000000000\n", "output": "1\n"}, {"input": "1000000000000000000 1000000000100000000\n", "output": "0\n"}, {"input": "1000000000001000000 1000000000100000000\n", "output": "0\n"}, {"input": "1000000000001000... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian as well. \n\nIn every contest there should be an easy problem about matrices. December Cook-Off is not an exception.\n\nGiven a matrix A which consists of n rows and m columns, and contains integer numbers.\n\nConsider every possible vector ... | [{"input": "1 2\n1 -1\n14 -2", "output": "10000006\n"}, {"input": "2 2\n-1 0\n8 -1", "output": "10000000\n"}, {"input": "2 2\n0 0\n14 -1", "output": "9999993\n"}, {"input": "1 2\n-1 2\n3 4", "output": "10000005\n"}, {"input": "1 2\n-2 2\n3 4", "output": "10000003\n"}, {"input": "2 2\n1 -1\n15 0", "output": "9999991\n"}... | code_stdio |
[
{
"content": "There are $n$ boxers, the weight of the $i$-th boxer is $a_i$. Each of them can change the weight by no more than $1$ before the competition (the weight cannot become equal to zero, that is, it must remain positive). Weight is always an integer number.\n\nIt is necessary to choose the largest boxi... | [{"input": "125\n8 85 125 177 140 158 2 152 67 102 9 61 29 188 102 193 112 194 15 7 133 134 145 7 89 193 130 149 134 51 13 194 191 149 73 106 151 85 42 53 163 134 127 7 51 61 178 105 117 197 35 21 122 164 133 165 135 12 192 60 54 187 173 75 74 195 85 62 166 195 131 109 191 196 61 44 61 20 95 147 199 142 71 198 36 153 5... | code_stdio |
[
{
"content": "Kirill plays a new computer game. He came to the potion store where he can buy any potion. Each potion is characterized by two integers — amount of experience and cost. The efficiency of a potion is the ratio of the amount of experience to the cost. Efficiency may be a non-integer number.\n\nFor e... | [{"input": "6134912 6134912 10000000 10000000 999869\n", "output": "NO\n"}, {"input": "9222174 9829060 9418763 14615160 9092468\n", "output": "NO\n"}, {"input": "6134912 8670745 10000000 10000000 999869\n", "output": "NO\n"}, {"input": "9222174 9829060 9418763 9955619 9092468\n", "output": "NO\n"}, {"input": "5426234 6... | code_stdio |
[
{
"content": "Having bought his own apartment, Boris decided to paper the walls in every room. Boris's flat has n rooms, each of which has the form of a rectangular parallelepiped. For every room we known its length, width and height of the walls in meters (different rooms can have different dimensions, includi... | [{"input": "20\n110 466 472\n112 153 152\n424 492 490\n348 366 113\n208 337 415\n491 448 139\n287 457 403\n444 382 160\n325 486 284\n447 454 136\n216 412 418\n217 208 228\n109 436 291\n293 382 421\n483 339 174\n213 327 183\n278 268 147\n181 424 457\n388 289 430\n174 269 305\n20\n221 4 334\n257 4 331\n444 3 127\n492 3 3... | code_stdio |
[
{
"content": "To decide which is the strongest among Rock, Paper, and Scissors, we will hold an RPS tournament.\nThere are 2^k players in this tournament, numbered 0 through 2^k-1. Each player has his/her favorite hand, which he/she will use in every match.\nA string s of length n consisting of R, P, and S repr... | [{"input": "100 100\nPSRRPRRSPSPSSSPSSSPSSSSSPSRSPRRPSRSSPSPPRRSRRRRPSSRRRRPSPSPSSRPRPPRSSRSSPSRPRSRPPSRPRPRPSPSPRRSRSPSP\n", "output": "R\n"}, {"input": "100 100\nRRPSSPPPPSRSRPSSPRSPPSPRSRRPSSPRRPSPPSPSPPRSSRPRPRRSSPSRSSRPSRSRRPRPPPSSSRRRPPRRRSPRRSPSSRRRRRPPPRPP\n", "output": "R\n"}, {"input": "100 100\nRSPSRSSPSPPPS... | code_stdio |
[
{
"content": "You are given a sequence A, where its elements are either in the form + x or -, where x is an integer.\n\nFor such a sequence S where its elements are either in the form + x or -, define f(S) as follows:\n\n * iterate through S's elements from the first one to the last one, and maintain a multise... | [{"input": "15\n+ 2101039\n-\n+ 4567886\n+ 113371486\n-\n+ 578943\n-\n-\n+ 62356680\n-\n+ 711111\n-\n+ 797735011\n-\n-\n", "output": "431927902\n"}, {"input": "15\n+ 2168539\n-\n+ 4567886\n+ 113371486\n-\n+ 578943\n-\n-\n+ 62356680\n-\n+ 711111\n-\n+ 797735011\n-\n-\n", "output": "465407902\n"}, {"input": "15\n+ 216853... | code_stdio |
[
{
"content": "Manao is taking part in a quiz. The quiz consists of n consecutive questions. A correct answer gives one point to the player. The game also has a counter of consecutive correct answers. When the player answers a question correctly, the number on this counter increases by 1. If the player answers a... | [{"input": "1000000000 1000000000 1000000000\n", "output": " 999999991"}, {"input": "1000000000 1000000000 772625255\n", "output": " 772625246"}, {"input": "999998212 999998211 499998210\n", "output": " ... | code_stdio |
[
{
"content": "C: Skewering\n\nproblem\n\nOne day, when Homura was playing with blocks, Tempura came. Homura decided to play with blocks with Tempura.\n\nThere is a rectangular parallelepiped of A \\ times B \\ times C, which is made by stacking A \\ times B \\ times C blocks of cubic blocks with a side length o... | [{"input": "28 11 20", "output": "Tem\n"}, {"input": "28 11 17", "output": "Hom\n"}, {"input": "54 11 17", "output": "Hom\n"}, {"input": "12 6 20", "output": "Tem\n"}, {"input": "24 6 20", "output": "Tem\n"}, {"input": "28 6 20", "output": "Tem\n"}, {"input": "54 11 1", "output": "Hom\n"}, {"input": "15 10 2", "output"... | code_stdio |
[
{
"content": "Ujan has been lazy lately, but now has decided to bring his yard to good shape. First, he decided to paint the path from his house to the gate.\n\nThe path consists of $n$ consecutive tiles, numbered from $1$ to $n$. Ujan will paint each tile in some color. He will consider the path aesthetic if f... | [{"input": "963201794869\n", "output": "963201794869\n"}, {"input": "930881829259\n", "output": "930881829259\n"}, {"input": "974059904437\n", "output": "974059904437\n"}, {"input": "912943012301\n", "output": "912943012301\n"}, {"input": "912943012301\n", "output": "912943012301\n"}, {"input": "974059904437\n", "outpu... | code_stdio |
[
{
"content": "Lots of geeky customers visit our chef's restaurant everyday. So, when asked to fill the feedback form, these customers represent the feedback using a binary string (i.e a string that contains only characters '0' and '1'. \n\nNow since chef is not that great in deciphering binary strings, he has d... | [{"input": "2\n11101110\n10101010101010", "output": "Good\nGood\n"}, {"input": "2\n11101110\n10101010111010", "output": "Good\nGood\n"}, {"input": "2\n01111010\n10100010111010", "output": "Good\nGood\n"}, {"input": "2\n01111010\n10100010111011", "output": "Good\nGood\n"}, {"input": "2\n01110010\n10100010111011", "outpu... | code_stdio |
[
{
"content": "At the end of last year, Santa Claus forgot to give Christmas presents to the children in JOI village. Therefore, I decided to deliver the chocolate cake to the children as an apology. The day to deliver is approaching tomorrow, so it's time to come up with a move plan.\n\nJOI village is divided i... | [{"input": "12 8\n3\n-1 1\n3 4\n18 6", "output": "31\n3 4\n"}, {"input": "1 4\n3\n1 -1\n0 6\n2 -1", "output": "10\n1 -1\n"}, {"input": "12 8\n3\n-1 1\n3 4\n18 5", "output": "30\n3 4\n"}, {"input": "12 8\n3\n-1 1\n5 4\n10 5", "output": "21\n5 4\n"}, {"input": "12 8\n3\n-1 1\n5 3\n10 5", "output": "22\n5 3\n"}, {"input":... | code_stdio |
[
{
"content": "As we all know, F.C. Barcelona is the best soccer team of our era! Their entangling and mesmerizing game style usually translates into very high ball possession, consecutive counter-attack plays and goals. Lots of goals, thanks to the natural talent of their attacker and best player in history, Li... | [{"input": "2\n28 3\n8 2", "output": "198073708\n86\n"}, {"input": "2\n28 3\n8 1", "output": "198073708\n1\n"}, {"input": "2\n28 3\n8 0", "output": "198073708\n0\n"}, {"input": "2\n16 3\n8 2", "output": "10761681\n86\n"}, {"input": "2\n31 3\n8 1", "output": "347990060\n1\n"}, {"input": "2\n28 4\n3 0", "output": "706704... | code_stdio |
[
{
"content": "Limak is a little polar bear. He has n balls, the i-th ball has size t_{i}.\n\nLimak wants to give one ball to each of his three friends. Giving gifts isn't easy — there are two rules Limak must obey to make friends happy: No two friends can get balls of the same size. No two friends can get bal... | [{"input": "50\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 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000\n", "output": "NO\n"}, {"input": "50\n1000 1000 1000 1... | code_stdio |
[
{
"content": "There are two towers consisting of blocks of two colors: red and blue. Both towers are represented by strings of characters B and/or R denoting the order of blocks in them from the bottom to the top, where B corresponds to a blue block, and R corresponds to a red block.\n\nThese two towers are rep... | [{"input": "23\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n1 1\nR\nB\n", "output": "YES\nYES\nYES\nYES\nYES\nYES\nYES\nYE... | code_stdio |
[
{
"content": "Some people leave the lights at their workplaces on when they leave that is a waste of resources. As a hausmeister of DHBW, Sagheer waits till all students and professors leave the university building, then goes and turns all the lights off.\n\nThe building consists of n floors with stairs at the ... | [{"input": "5 93\n00000000000000000000000000000000000000000000000000000000100000000000000000000000000000000001010\n00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n00000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n00000000000... | code_stdio |
[
{
"content": "There are an integer sequence A_1,...,A_N consisting of N terms, and N buttons. When the i-th (1 ≦ i ≦ N) button is pressed, the values of the i terms from the first through the i-th are all incremented by 1.\n\nThere is also another integer sequence B_1,...,B_N. Takahashi will push the buttons so... | [{"input": "7\n4 1\n11 1\n11 20\n2 4\n6 3\n5 12\n9 7", "output": "29\n"}, {"input": "7\n5 1\n4 2\n10 12\n2 4\n6 1\n1 8\n24 5", "output": "14\n"}, {"input": "7\n0 1\n4 2\n0 11\n2 8\n6 1\n5 16\n24 6", "output": "22\n"}, {"input": "7\n3 1\n4 2\n9 17\n2 4\n1 3\n5 15\n5 12", "output": "26\n"}, {"input": "7\n3 1\n4 2\n5 12\n... | code_stdio |
[
{
"content": "Okabe needs bananas for one of his experiments for some strange reason. So he decides to go to the forest and cut banana trees.\n\nConsider the point (x, y) in the 2D plane such that x and y are integers and 0 ≤ x, y. There is a tree in such a point, and it has x + y bananas. There are no trees no... | [{"input": "1000 10000\n", "output": "74133360011484445\n"}, {"input": "1000 10000\n", "output": "74133360011484445"}, {"input": "1581 6030\n", "output": "40628923515290265\n"}, {"input": "1061 8096\n", "output": "44286779591578800\n"}, {"input": "1581 5974\n", "output": "39507636740343456\n"}, {"input": "1486 5974\n",... | code_stdio |
[
{
"content": "It's Galactik Football time! The Galactik Football Assosiation (GFA) has announced a football tournament between all the teams of all the planets in the galaxy.\n\nEach planet of the galaxy has a government. Some governments have a mutual agreement between them. If planet $A$ has mutual agreement ... | [{"input": "6 6\n1 2\n1 5\n1 3\n4 5\n5 4\n4 6\n1\n3\n-1\n2\n2\n10", "output": "0\n"}, {"input": "6 6\n1 2\n1 5\n2 2\n4 5\n5 4\n2 1\n1\n1\n5\n2\n2\n6", "output": "13\n"}, {"input": "6 6\n1 2\n2 3\n1 3\n2 5\n5 2\n4 4\n1\n2\n8\n3\n4\n6", "output": "11\n"}, {"input": "6 6\n1 2\n1 5\n1 3\n4 5\n5 4\n4 6\n1\n3\n0\n2\n7\n12", ... | code_stdio |
[
{
"content": "When you enter 8 numbers from 0 to 9, write a program that outputs the difference between the largest integer and the smallest integer that can sort the 8 numbers. The number that can be sorted may start from 0, such as 00135569.\n\n\n\nInput\n\nGiven multiple datasets. The number of datasets n (n... | [{"input": "2\n65539010\n102034250", "output": "96417531\n543098655\n"}, {"input": "2\n124008976\n66277190", "output": "986395311\n96499431\n"}, {"input": "2\n188122632\n66277190", "output": "774098523\n96499431\n"}, {"input": "2\n169123376\n66277190", "output": "864296532\n96499431\n"}, {"input": "2\n211592187\n662771... | code_stdio |
[
{
"content": "A dice is a cube, its faces contain distinct integers from 1 to 6 as black points. The sum of numbers at the opposite dice faces always equals 7. Please note that there are only two dice (these dices are mirror of each other) that satisfy the given constraints (both of them are shown on the pictur... | [{"input": "100\n3\n6 5\n1 5\n2 1\n5 1\n6 5\n5 1\n6 2\n1 2\n6 5\n5 1\n5 1\n1 5\n2 6\n6 2\n5 6\n1 2\n1 5\n5 6\n1 5\n1 2\n2 6\n1 2\n6 2\n1 5\n6 2\n2 6\n1 5\n6 2\n6 5\n5 6\n1 5\n5 6\n5 1\n5 1\n2 1\n1 2\n5 6\n6 5\n1 5\n5 1\n1 2\n1 5\n1 2\n2 6\n5 1\n2 6\n2 6\n5 6\n2 6\n6 5\n6 5\n1 5\n2 1\n5 6\n5 6\n1 2\n2 1\n1 2\n1 2\n1 2\n... | code_stdio |
[
{
"content": "Someday, Drazil wanted to go on date with Varda. Drazil and Varda live on Cartesian plane. Drazil's home is located in point (0, 0) and Varda's home is located in point (a, b). In each step, he can move in a unit distance in horizontal or vertical direction. In other words, from position (x, y) he... | [{"input": "-1000000000 -1000000000 2000000000\n", "output": "Yes\n"}, {"input": "-1000000000 1000000000 2000000000\n", "output": "Yes\n"}, {"input": "-1000000000 -1000000000 1000000000\n", "output": "No\n"}, {"input": "-1000000000 -1000000000 1000000100\n", "output": "No\n"}, {"input": "-232833910 -880680184 177454979... | code_stdio |
[
{
"content": "Arkady plays Gardenscapes a lot. Arkady wants to build two new fountains. There are n available fountains, for each fountain its beauty and cost are known. There are two types of money in the game: coins and diamonds, so each fountain cost can be either in coins or diamonds. No money changes betwe... | [{"input": "52 38 22\n9 25 D\n28 29 C\n29 25 D\n4 28 D\n23 29 D\n24 25 D\n17 12 C\n11 19 C\n13 14 C\n12 15 D\n7 25 C\n2 25 C\n6 17 C\n2 20 C\n15 23 D\n8 21 C\n13 15 D\n29 15 C\n25 20 D\n22 20 C\n2 13 D\n13 22 D\n27 20 C\n1 21 D\n22 17 C\n14 21 D\n4 25 D\n5 23 C\n9 21 C\n2 20 C\n14 18 C\n29 24 C\n14 29 D\n9 27 C\n23 21 ... | code_stdio |
[
{
"content": "Mishka received a gift of multicolored pencils for his birthday! Unfortunately he lives in a monochrome world, where everything is of the same color and only saturation differs. This pack can be represented as a sequence a_1, a_2, ..., a_{n} of n integer numbers — saturation of the color of each p... | [{"input": "10 5 293149357\n79072863 760382815 358896034 663269192 233367425 32795628 837363300 46932461 179556769 763342555\n", "output": "NO\n"}, {"input": "10 5 293149357\n79072863 760382815 358896034 663269192 233367425 32795628 837363300 46932461 179556769 763342555\n", "output": "NO\n"}, {"input": "18 2 86\n665 4... | code_stdio |
[
{
"content": "You are given an array a. Some element of this array a_{i} is a local minimum iff it is strictly less than both of its neighbours (that is, a_{i} < a_{i} - 1 and a_{i} < a_{i} + 1). Also the element can be called local maximum iff it is strictly greater than its neighbours (that is, a_{i} > a_{i} ... | [{"input": "4\n1 5 2 5\n", "output": "2\n"}, {"input": "4\n1 5 2 1\n", "output": "1\n"}, {"input": "4\n1 7 2 1\n", "output": "1\n"}, {"input": "2\n-1 1100\n", "output": "0\n"}, {"input": "4\n1 3 2 1\n", "output": "1\n"}, {"input": "2\n-1 1110\n", "output": "0\n"}, {"input": "4\n1 1 2 1\n", "output": "1\n"}, {"input": "... | code_stdio |
[
{
"content": "You are playing one famous sandbox game with the three-dimensional world. The map of the world can be represented as a matrix of size n × m, where the height of the cell (i, j) is a_{i, j}.\n\nYou are in the cell (1, 1) right now and want to get in the cell (n, m). You can move only down (from the... | [{"input": "1\n8 6\n1 2 3 4 5 6\n7 8 9 10 11 12\n13 14 15 16 17 18\n19 20 21 22 23 24\n26 27 28 29 30 31\n33 34 35 36 34 35\n37 38 39 40 41 42\n44 45 46 47 48 49\n", "output": " 141\n"}, {"input": "5\n3 4\n1 2 3 4\n5 6 7 12\n9 10 11 12\n5 5\n2 5 4 4 3\n9 14 11... | code_stdio |
[
{
"content": "Omkar is building a waterslide in his water park, and he needs your help to ensure that he does it as efficiently as possible.\n\nOmkar currently has $n$ supports arranged in a line, the $i$-th of which has height $a_i$. Omkar wants to build his waterslide from the right to the left, so his suppor... | [{"input": "3\n4\n5 3 2 1\n5\n1 2 3 10 3\n3\n1 1 1\n", "output": "4\n7\n0\n"}, {"input": "3\n4\n5 3 2 0\n5\n1 2 3 10 3\n3\n1 1 1\n", "output": "5\n7\n0\n"}, {"input": "3\n4\n5 3 2 0\n5\n1 2 3 10 3\n3\n2 1 1\n", "output": "5\n7\n1\n"}, {"input": "3\n4\n5 3 2 0\n5\n1 2 3 10 1\n3\n2 1 1\n", "output": "5\n9\n1\n"}, {"input... | code_stdio |
[
{
"content": "It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.\n\nMarmot brought Mole n ordered piles of worms such that i-th pile contains a_{i} worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a_1, worms in second ... | [{"input": "5\n2 12 3 4 9\n3\n1 25 11\n", "output": "1\n5\n2\n"}, {"input": "5\n2 12 3 4 9\n3\n1 25 17\n", "output": "1\n5\n3\n"}, {"input": "5\n2 17 3 4 9\n3\n1 25 13\n", "output": "1\n4\n2\n"}, {"input": "5\n2 12 3 4 9\n3\n1 25 13\n", "output": "1\n5\n2\n"}, {"input": "5\n4 10 4 4 9\n3\n1 25 17\n", "output": "1\n5\n3... | code_stdio |
[
{
"content": "Ashish has a tree consisting of $n$ nodes numbered $1$ to $n$ rooted at node $1$. The $i$-th node in the tree has a cost $a_i$, and binary digit $b_i$ is written in it. He wants to have binary digit $c_i$ written in the $i$-th node in the end.\n\nTo achieve this, he can perform the following opera... | [{"input": "10\n64 0 0\n10 0 0\n17 0 1\n90 1 1\n97 1 1\n19 1 0\n26 1 1\n95 1 1\n46 0 0\n86 0 0\n5 4\n7 1\n9 5\n6 8\n1 6\n7 5\n8 10\n3 7\n3 2\n", "output": "128"}, {"input": "10\n92 0 1\n19 1 0\n46 1 0\n53 1 0\n13 1 0\n63 0 1\n3 0 1\n67 1 0\n20 0 1\n82 0 1\n6 5\n9 1\n3 7\n10 4\n4 8\n2 8\n5 2\n3 8\n9 10\n", "output": "33... | code_stdio |
[
{
"content": "Your city has n junctions. There are m one-way roads between the junctions. As a mayor of the city, you have to ensure the security of all the junctions.\n\nTo ensure the security, you have to build some police checkposts. Checkposts can only be built in a junction. A checkpost at junction i can p... | [{"input": "100\n174 174 49 152 10 185 101 157 28 177 105 83 155 178 119 123 197 197 56 174 39 53 85 94 72 166 71 43 177 123 186 11 64 82 145 81 11 29 100 10 106 45 138 79 131 90 80 104 149 116 129 30 96 192 11 182 92 157 95 136 152 38 68 34 42 95 164 134 117 75 186 185 28 146 86 24 147 12 166 169 116 44 46 99 55 179 8... | code_stdio |
[
{
"content": "Read the coordinates of four different points on the plane, $ A (x_A, y_A) $, $ B (x_B, y_B) $, $ C (x_C, y_C) $, $ D (x_D, y_D) $, and straight line $ Create a program that outputs YES if AB $ and $ CD $ are orthogonal, and NO if they are not orthogonal. Here, \"straight line\" does not mean a li... | [{"input": "3.338679167476614 4.153021285774258 3.5962681645685493 3.0562783924178016 0.7824583380395241 0.6535611152381731 1.4307644766957708 0.2352661769827814\n2.6749426974072605 2.336361124342693 3.280415305064114 1.6735605571901062 -0.04476814775527138 2.2725919391555047 3.1294550602222495 2.8167160930096795\n10.9... | code_stdio |
[
{
"content": "Snuke has a string s. From this string, Anuke, Bnuke, and Cnuke obtained strings a, b, and c, respectively, as follows:\n\n* Choose a non-empty (contiguous) substring of s (possibly s itself). Then, replace some characters (possibly all or none) in it with `?`s.\n\n\n\nFor example, if s is `missis... | [{"input": "redocta\natcoder\n?????>?", "output": "15\n"}, {"input": "eacodtr\naoetdcr\n?????>>", "output": "16\n"}, {"input": "ebdobur\nppedact\n>>????@", "output": "21\n"}, {"input": "qcbdpvg\nbfpepbs\n?>A>>@<", "output": "20\n"}, {"input": "tocojcb\nbs_fpph\n=?>@@@?", "output": "19\n"}, {"input": "redocta\nateodcr\n... | code_stdio |
[
{
"content": "Problem A: Swap crypto\n\nA 2D enthusiast at R University, he often writes embarrassing sentences that blush when seen by people. Therefore, in order for a third party to not be able to see the text he is writing, he encrypts the text using a method called swap encryption that he devised independe... | [{"input": "1\ntojxo\n1 4\n5\nuhcqmlnkv\n4 5\n6 9\n3 6\n1 4\n3 6\n5\nshzxadexonr\n8 9\n3 9\n5 10\n4 9\n10 11\n0", "output": "aojwo\nthinyynku\nshitxdegyfo\n"}, {"input": "1\ntojxo\n1 4\n5\nuhcqmlnkv\n4 6\n6 9\n3 6\n1 4\n3 6\n5\nshzxadexonr\n8 9\n3 9\n5 10\n4 9\n10 11\n0", "output": "aojwo\nthiamznku\nshitxdegyfo\n"}, {... | code_stdio |
[
{
"content": "Pashmak has fallen in love with an attractive girl called Parmida since one year ago...\n\nToday, Pashmak set up a meeting with his partner in a romantic garden. Unfortunately, Pashmak has forgotten where the garden is. But he remembers that the garden looks like a square with sides parallel to th... | [{"input": "-100 -100 100 100\n", "output": "-100 100 100 -100\n"}, {"input": "-100 100 100 -100\n", "output": "-100 -100 100 100\n"}, {"input": "-100 -100 -100 100\n", "output": "100 -100 100 100\n"}, {"input": "100 -100 -100 -100\n", "output": "100 100 -100 100\n"}, {"input": "-100 -100 100 100\n", "output": "-100 10... | code_stdio |
[
{
"content": "problem\n\nThere are the following two-player card games.\n\n* This game uses a total of 2n cards with each integer from 1 to 2n written on it. Here, n is an integer between 1 and 100.\n* Deal n cards to each of the two.\n* Put cards into play alternately one by one according to the following rule... | [{"input": "5\n1\n7\n9\n6\n4\n10\n10\n7\n13\n18\n1\n11\n12\n17\n5\n19\n0", "output": "0\n1\n2\n0\n"}, {"input": "5\n1\n7\n9\n6\n4\n10\n10\n7\n13\n18\n1\n20\n12\n17\n5\n19\n0", "output": "0\n1\n4\n0\n"}, {"input": "5\n1\n2\n9\n6\n10\n10\n16\n7\n14\n18\n4\n11\n6\n17\n5\n19\n0", "output": "2\n0\n2\n0\n"}, {"input": "5\n1\... | code_stdio |
[
{
"content": "Valery is a PE teacher at a school in Berland. Soon the students are going to take a test in long jumps, and Valery has lost his favorite ruler! \n\nHowever, there is no reason for disappointment, as Valery has found another ruler, its length is l centimeters. The ruler already has n marks, with w... | [{"input": "112 1867 1261 1606\n0 7 17 43 67 70 87 112 129 141 148 162 179 180 189 202 211 220 231 247 250 277 308 311 327 376 400 406 409 417 418 444 480 512 514 515 518 547 572 575 578 587 612 617 654 684 701 742 757 761 788 821 825 835 841 843 850 858 869 872 881 936 939 969 970 971 997 1026 1040 1045 1068 1070 1073... | code_stdio |
[
{
"content": "Have you ever played Hanabi? If not, then you've got to try it out! This problem deals with a simplified version of the game.\n\nOverall, the game has 25 types of cards (5 distinct colors and 5 distinct values). Borya is holding n cards. The game is somewhat complicated by the fact that everybody ... | [{"input": "100\nW4 Y1 W5 R4 W3 Y1 R4 W2 G3 G1 B5 Y5 Y2 Y3 G4 B5 W1 G5 Y5 Y3 G2 Y5 Y5 G5 R2 B3 B1 W5 Y1 W5 B4 W4 R4 B1 R1 W3 R5 R4 G2 W3 W3 R2 W5 Y2 B2 R3 R3 Y1 G5 G2 Y1 R4 Y5 W5 G5 B3 W2 R1 B2 W2 W2 Y5 W3 G1 B1 G2 Y3 W3 G1 W5 W1 G5 G2 Y1 W5 B5 W4 Y5 G2 R3 B4 R5 B1 R1 B4 Y4 Y4 Y3 R5 Y3 B3 W5 R5 Y5 G2 G5 W5 B4 G4 W5\n",... | code_stdio |
[
{
"content": "Bessie and the cows are playing with sequences and need your help. They start with a sequence, initially containing just the number 0, and perform n operations. Each operation is one of the following: Add the integer x_{i} to the first a_{i} elements of the sequence. Append an integer k_{i} to t... | [{"input": "5\n2 -1569\n1 2 -156\n2 641\n2 -253\n2 -400\n", "output": "-784.500000\n-940.500000\n-413.333333\n-373.250000\n-378.600000\n"}, {"input": "5\n2 -1481\n1 2 -156\n2 194\n2 -253\n2 -400\n", "output": "-740.500000\n-896.500000\n-533.000000\n-463.000000\n-450.400000\n"}, {"input": "5\n2 -980\n1 2 -156\n2 641\n2 ... | code_stdio |
[
{
"content": "Welcome to PC Koshien, players. At PC Koshien, competitions are currently being held in a total of three categories: programming category, mobile category, and Ichimai's picture CG category.\n\nGiven the number of participants in each department, create a program that calculates the total number o... | [{"input": "0000 1000 1000", "output": "2000\n"}, {"input": "0000 0000 1000", "output": "1000\n"}, {"input": "0001 0000 1000", "output": "1001\n"}, {"input": "0101 0000 1000", "output": "1101\n"}, {"input": "0100 0000 1000", "output": "1100\n"}, {"input": "0100 0010 1000", "output": "1110\n"}, {"input": "0101 1001 0000... | code_stdio |
[
{
"content": "Phone number in Berland is a sequence of n digits. Often, to make it easier to memorize the number, it is divided into groups of two or three digits. For example, the phone number 1198733 is easier to remember as 11-987-33. Your task is to find for a given phone number any of its divisions into gr... | [{"input": "100\n4004223124942730640235383244438257614581534320356060987241659784249551110165034719443327659510644224\n", "output": "40-04-22-31-24-94-27-30-64-02-35-38-32-44-43-82-57-61-45-81-53-43-20-35-60-60-98-72-41-65-97-84-24-95-51-11-01-65-03-47-19-44-33-27-65-95-10-64-42-24\n"}, {"input": "100\n2131060505689219... | code_stdio |
[
{
"content": "Given is a string S, where each character is `0`, `1`, or `?`.\n\nConsider making a string S' by replacing each occurrence of `?` with `0` or `1` (we can choose the character for each `?` independently). Let us define the unbalancedness of S' as follows:\n\n* (The unbalancedness of S') = \\max \\\... | [{"input": "??00????0??1????0?0??00??1???11?1?1???1?11?111???1", "output": "4\n"}, {"input": "1???11??11?1???1?1?11???1??00??0?0?1??1??0>>??00??", "output": "3\n"}, {"input": "1???111?11?1???111?11???1??00??0?0?@?????0????00??", "output": "5\n"}, {"input": "????111?11?1?1?111?11???1??00??0???@?????0???000??", "output":... | code_stdio |
[
{
"content": "You are given N points on a plane. Write a program which will find the sum of squares of distances between all pairs of points.\n\nInput\n\nThe first line of input contains one integer number N (1 ≤ N ≤ 100 000) — the number of points. Each of the following N lines contain two integer numbers X an... | [{"input": "30\n-7 -23\n-2 5\n13 8\n12 17\n15 -18\n20 6\n21 8\n-13 12\n-4 -20\n-11 -16\n-6 16\n1 -1\n5 -12\n13 -17\n11 10\n8 -9\n-13 3\n19 -13\n-19 -8\n-14 10\n10 3\n-16 -8\n-17 16\n-14 -15\n5 1\n-13 -14\n13 17\n-12 -8\n2 1\n18 5\n", "output": "279169\n"}, {"input": "30\n-7 -23\n-2 5\n13 8\n12 17\n15 -18\n11 6\n21 8\n-... | code_stdio |
[
{
"content": "Let's call a sequence $b_1, b_2, b_3 \\dots, b_{k - 1}, b_k$ almost increasing if $$\\min(b_1, b_2) \\le \\min(b_2, b_3) \\le \\dots \\le \\min(b_{k - 1}, b_k).$$ In particular, any sequence with no more than two elements is almost increasing.\n\nYou are given a sequence of integers $a_1, a_2, \\d... | [{"input": "3\n8\n1 2 7 3 2 1 2 3\n2\n2 1\n7\n4 1 5 2 6 3 7\n", "output": "\n6\n2\n7\n"}, {"input": "3\n8\n1 2 7 3 2 1 2 3\n2\n2 1\n7\n4 1 5 2 6 3 7\n", "output": "6\n2\n7\n"}, {"input": "3\n8\n1 2 7 3 2 1 2 5\n2\n2 1\n7\n4 1 5 2 6 3 7\n", "output": "6\n2\n7\n"}, {"input": "3\n8\n1 2 7 6 2 1 1 3\n2\n2 1\n7\n4 1 5 2 6 3... | code_stdio |
[
{
"content": "Many years ago Berland was a small country where only $n$ people lived. Each person had some savings: the $i$-th one had $a_i$ burles.\n\nThe government considered a person as wealthy if he had at least $x$ burles. To increase the number of wealthy people Berland decided to carry out several refor... | [{"input": "4\n4 3\n6 1 2 1\n4 10\n11 9 11 18\n2 5\n4 3\n3 7\n9 4 11\n", "output": "3\n4\n0\n3\n"}, {"input": "4\n4 3\n10 1 2 1\n4 10\n11 7 11 9\n2 5\n4 3\n3 7\n9 2 9\n", "output": "4\n3\n0\n2\n"}, {"input": "4\n4 3\n10 1 3 1\n4 10\n11 7 11 9\n2 5\n4 3\n3 6\n9 2 9\n", "output": "4\n3\n0\n3\n"}, {"input": "4\n4 3\n6 1 2... | code_stdio |
[
{
"content": "A subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is a string x = sk1sk2... sk|x| (1 ≤ k1 < k2 < ... < k|x| ≤ |s|).\n\nYou've got two strings — s and t. Let's consider all subsequences of string s, coinciding with string t. Is it true that each character ... | [{"input": "ctkhagrifaztmnxhmqztzibnmzzkojiztvrkfeoqegvwtbxlvvjhebshqaicsovtkcdovytimjggglyxlvglgunbohnkxargymbqvzgsnvjzgxivdgnaesgxqcruaopjuqsyyorrobnelehjnxcetveehlbmeskptivsuhuqupbieumycwczxyqjtwfofehfkpqmjngygwxkaviuyouiippgvlxjgtkxmhcwtzacbllsybgiujyryngapfwjkkyapfgxtcdpc\nctkhagrifaztmnxhmqztzibnmzzkojiztvrkfeoqe... | code_stdio |
[
{
"content": "Lord Omkar would like to have a tree with n nodes (3 ≤ n ≤ 10^5) and has asked his disciples to construct the tree. However, Lord Omkar has created m (1 ≤ m < n) restrictions to ensure that the tree will be as heavenly as possible. \n\nA tree with n nodes is an connected undirected graph with n no... | [{"input": "2\n27 4\n1 3 3\n4 2 2\n5 7 10\n4 9 4\n6 0\n1 2 -1\n2 6 4\n4 1 8\n", "output": "1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n1 9\n1 10\n1 11\n1 12\n1 13\n1 14\n1 15\n1 16\n1 17\n1 18\n1 19\n1 20\n1 21\n1 22\n1 23\n1 24\n1 25\n1 26\n1 27\n1 2\n1 3\n1 4\n1 5\n1 6\n"}, {"input": "2\n26 4\n1 3 3\n4 4 7\n5 1 17\n4 9 4\n6 0... | code_stdio |
[
{
"content": "Evi has N integers a_1,a_2,..,a_N. His objective is to have N equal integers by transforming some of them.\nHe may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transform... | [{"input": "4\n-100 -45 -100 -100", "output": "2269\n"}, {"input": "4\n-100 -100 -100 -100\n", "output": "0\n"}, {"input": "4\n-100 -100 -100 -100", "output": "0"}, {"input": "3\n-3 -1 23", "output": "419\n"}, {"input": "3\n-3 -1 21", "output": "355\n"}, {"input": "3\n-4 -1 21", "output": "373\n"}, {"input": "3\n1 -1 3... | code_stdio |
[
{
"content": "You are given integers N and K. Find the number of triples (a,b,c) of positive integers not greater than N such that a+b,b+c and c+a are all multiples of K.\nThe order of a,b,c does matter, and some of them can be the same.\n\n-----Constraints-----\n - 1 \\leq N,K \\leq 2\\times 10^5\n - N and K a... | [{"input": "200000 1\n", "output": "8000000000000000\n"}, {"input": "200000 2\n", "output": "2000000000000000\n"}, {"input": "200000 3\n", "output": "296287407496296\n"}, {"input": "100004 8\n", "output": "3906718787501\n"}, {"input": "100000 7\n", "output": "2915014599125\n"}, {"input": "10003 8\n", "output": "3906250... | code_stdio |
[
{
"content": "Vasily has a number a, which he wants to turn into a number b. For this purpose, he can do two types of operations: multiply the current number by 2 (that is, replace the number x by 2·x); append the digit 1 to the right of current number (that is, replace the number x by 10·x + 1). \n\nYou need... | [{"input": "1 536870912\n", "output": "YES\n30\n1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 2097152 4194304 8388608 16777216 33554432 67108864 134217728 268435456 536870912 \n"}, {"input": "1 536870912\n", "output": "YES\n30\n1 2 4 8 16 32 64 128 256 512 1024 2048 409... | code_stdio |
[
{
"content": "<image>\n\nInput\n\nThe input contains two integers a, b (1 ≤ a ≤ 10, 0 ≤ b ≤ 22·a - 1) separated by a single space.\n\nOutput\n\nOutput two integers separated by a single space.\n\nExamples\n\nInput\n\n1 0\n\n\nOutput\n\n0 0\n\n\nInput\n\n2 15\n\n\nOutput\n\n3 0\n\n\nInput\n\n4 160\n\n\nOutput\n\... | [{"input": "10 165056\n", "output": "391 431\n"}, {"input": "10 595169\n", "output": "619 770\n"}, {"input": "10 156555\n", "output": "468 325\n"}, {"input": "10 140634\n", "output": "323 383"}, {"input": "10 1048575\n", "output": "1023 0"}, {"input": "10 921462\n", "output": "757 203"}, {"input": "10 850222\n", "outpu... | code_stdio |
[
{
"content": "The Little Elephant loves Ukraine very much. Most of all he loves town Rozdol (ukr. \"Rozdil\").\n\nHowever, Rozdil is dangerous to settle, so the Little Elephant wants to go to some other town. The Little Elephant doesn't like to spend much time on travelling, so for his journey he will choose a ... | [{"input": "100\n922 938 103 689 526 118 314 496 373 47 224 544 495 656 804 754 269 356 354 536 817 597 787 178 516 659 790 993 786 169 866 779 997 350 674 310 219 546 564 893 402 449 751 628 329 686 392 951 716 439 332 563 215 146 746 311 866 773 548 1100 731 183 890 802 488 944 473 25 662 559 732 534 777 144 502 593 ... | code_stdio |
[
{
"content": "You are given a string s consisting of `A`, `B` and `C`.\n\nSnuke wants to perform the following operation on s as many times as possible:\n\n* Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.\n\n\n\nFind the maximum possible number of operations.\n\nConstraints\n\n* ... | [{"input": "ABBACCBACCBCAABCB", "output": "2\n"}, {"input": "ACBAACBCCABCCBBBA", "output": "1\n"}, {"input": "ABCAACBCAABCCBBBC", "output": "3\n"}, {"input": "ACCAAABCAABCCBBBC", "output": "8\n"}, {"input": "ABBBCCBACCBCAABCB", "output": "2\n"}, {"input": "ABBBCCBACCBCAABCA", "output": "2\n"}, {"input": "ACBAACBCAABCCB... | code_stdio |
[
{
"content": "Polycarpus is the director of a large corporation. There are n secretaries working for the corporation, each of them corresponds via the famous Spyke VoIP system during the day. We know that when two people call each other via Spyke, the Spyke network assigns a unique ID to this call, a positive i... | [{"input": "123\n0 6361 8903 10428 0 258 0 10422 0 0 2642 1958 0 0 0 0 0 8249 1958 0 0 2642 0 0 0 11566 4709 1847 3998 0 1331 0 0 10289 2739 6135 3450 0 0 10994 6069 4337 5854 1331 5854 0 630 630 11244 5928 2706 0 683 214 0 9080 0 0 0 10422 683 11566 10994 0 0 3450 11244 11542 3998 1847 2708 9871 2739 2001 0 12216 6069... | code_stdio |
[
{
"content": "While doing some spring cleaning, Daniel found an old calculator that he loves so much. However, it seems like it is broken. When he tries to compute $1 + 3$ using the calculator, he gets $2$ instead of $4$. But when he tries computing $1 + 4$, he gets the correct answer, $5$. Puzzled by this myst... | [{"input": "3\n1 8\n378 590\n0 1001000\n", "output": "26\n3586\n3444149719\n"}, {"input": "3\n0 4\n378 590\n1 1000000\n", "output": "17\n3586\n3439863766\n"}, {"input": "3\n1 4\n323 590\n1 1000000\n", "output": "8\n4758\n3439863766\n"}, {"input": "3\n0 4\n217 323\n1 1000000\n", "output": "17\n562\n3439863766\n"}, {"inp... | code_stdio |
[
{
"content": "Lately, Mr. Chanek frequently plays the game Arena of Greed. As the name implies, the game's goal is to find the greediest of them all, who will then be crowned king of Compfestnesia.\n\nThe game is played by two people taking turns, where Mr. Chanek takes the first turn. Initially, there is a tre... | [{"input": "2\n18\n122\n", "output": "14\n114\n"}, {"input": "2\n20\n122\n", "output": "15\n114\n"}, {"input": "2\n12\n122\n", "output": "9\n114\n"}, {"input": "2\n10\n122\n", "output": "8\n114\n"}, {"input": "2\n3\n122\n", "output": "2\n114\n"}, {"input": "2\n6\n122\n", "output": "4\n114\n"}, {"input": "2\n4\n122\n", ... | code_stdio |
[
{
"content": "Nezzar has a binary string s of length n that he wants to share with his best friend, Nanako. Nanako will spend q days inspecting the binary string. At the same time, Nezzar wants to change the string s into string f during these q days, because it looks better.\n\nIt is known that Nanako loves co... | [{"input": "4\n5 2\n00000\n00111\n1 5\n1 3\n2 1\n00\n01\n1 2\n10 6\n1111111111\n0110001110\n1 10\n5 9\n7 10\n1 7\n3 5\n6 10\n5 2\n10000\n11000\n2 5\n1 3\n", "output": "\nYES\nNO\nYES\nNO\n"}, {"input": "4\n5 2\n00000\n00111\n1 5\n1 3\n2 1\n00\n01\n1 2\n10 6\n1111111111\n0110000110\n1 10\n5 9\n7 10\n1 7\n3 5\n6 10\n5 2\... | code_stdio |
[
{
"content": "You are given a sequence a_1, a_2, ..., a_n, consisting of integers.\n\nYou can apply the following operation to this sequence: choose some integer x and move all elements equal to x either to the beginning, or to the end of a. Note that you have to move all these elements in one direction in one ... | [{"input": "3\n7\n3 1 6 6 3 1 1\n8\n1 1 4 4 4 7 8 8\n7\n2 2 5 2 6 2 7\n", "output": "2\n0\n1\n"}, {"input": "3\n7\n3 1 6 6 3 1 1\n8\n1 1 4 4 4 7 8 2\n7\n2 2 5 2 6 2 7\n", "output": "2\n2\n1\n"}, {"input": "3\n7\n3 1 6 6 3 1 1\n8\n1 1 4 4 4 3 8 2\n7\n2 2 5 2 6 2 7\n", "output": "2\n3\n1\n"}, {"input": "3\n7\n3 1 6 6 3 1... | code_stdio |
[
{
"content": "For a positive integer n, let us define f(n) as the number of digits in base 10.\nYou are given an integer S.\nCount the number of the pairs of positive integers (l, r) (l \\leq r) such that f(l) + f(l + 1) + ... + f(r) = S, and find the count modulo 10^9 + 7.\n\n-----Constraints-----\n - 1 \\leq ... | [{"input": "100000000\n", "output": "914705724\n"}, {"input": "91304885\n", "output": "555850206\n"}, {"input": "89317875\n", "output": "494668252\n"}, {"input": "78876118\n", "output": "915018436\n"}, {"input": "18434582\n", "output": "752917978\n"}, {"input": "15764866\n", "output": "563424334\n"}, {"input": "7952872... | code_stdio |
[
{
"content": "You are given a chessboard consisting of $n$ rows and $n$ columns. Rows are numbered from bottom to top from $1$ to $n$. Columns are numbered from left to right from $1$ to $n$. The cell at the intersection of the $x$-th column and the $y$-th row is denoted as $(x, y)$. Furthermore, the $k$-th col... | [{"input": "5 3 5\n4 4\n3 5\n2 4\n3 4\n3 5\n", "output": "0\n1\n2\n2\n1\n"}, {"input": "5 5 5\n4 4\n3 5\n2 4\n3 4\n3 5\n", "output": "0\n2\n3\n3\n2\n"}, {"input": "5 5 5\n4 4\n3 5\n2 3\n3 3\n3 5\n", "output": "0\n2\n2\n3\n2\n"}, {"input": "5 5 5\n1 4\n3 5\n2 3\n3 3\n3 5\n", "output": "3\n3\n3\n3\n3\n"}, {"input": "5 3 ... | code_stdio |
[
{
"content": "Please notice the unusual memory limit of this problem.\n\nOrac likes games. Recently he came up with the new game, \"Game of Life\".\n\nYou should play this game on a black and white grid with $n$ rows and $m$ columns. Each cell is either black or white.\n\nFor each iteration of the game (the ini... | [{"input": "5 5 3\n01011\n10110\n01101\n11010\n10101\n1 1 4\n1 2 3\n5 5 3\n", "output": "1\n0\n1\n"}, {"input": "5 5 3\n01011\n10110\n01101\n11010\n10001\n1 1 4\n1 2 3\n5 5 3\n", "output": "1\n0\n1\n"}, {"input": "5 5 3\n01011\n10110\n01101\n11010\n10001\n1 1 4\n1 2 2\n5 5 3\n", "output": "1\n1\n1\n"}, {"input": "5 5 3... | code_stdio |
[
{
"content": "There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. \n\nYou are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exac... | [{"input": "5\n3 0 0 0\n3 3 0 0\n6 4 1 0\n6 6 0 0\n3 3 3 2\n", "output": "yes\nyes\nyes\nyes\nno\n"}, {"input": "5\n3 0 0 0\n3 3 0 0\n6 4 1 0\n6 3 3 -1\n3 3 3 2\n", "output": "yes\nyes\nyes\nno\nno\n"}, {"input": "5\n3 0 0 0\n3 3 0 0\n6 4 1 0\n6 3 3 -1\n3 3 4 2\n", "output": "yes\nyes\nyes\nno\nno\n"}, {"input": "5\n3 ... | code_stdio |
[
{
"content": "Amugae has a hotel consisting of $10$ rooms. The rooms are numbered from $0$ to $9$ from left to right.\n\nThe hotel has two entrances — one from the left end, and another from the right end. When a customer arrives to the hotel through the left entrance, they are assigned to an empty room closest... | [{"input": "100\nLLLLLLLLLL0L2L48LL6L7L7L0L3L0L63LL3L4L9L2L7L6L3L8L2L5L9L0L3L3L9L3L3L3L5L2L2L2L1L8L5L7L9L2L05L0LL6L2L\n", "output": "1111111111\n"}, {"input": "100\nRRLLLLLLRR1R7R3L2R0L52RR2R4L1L7L6R4R0R4L5L4L5R2R8L7R0R6R4R8L6L8L4R5R7R3L9R7L64RR8L0R6R4R9L0R9R7R7R0L\n", "output": "1111111111\n"}, {"input": "100\nL0L0R9R... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.