id
stringlengths
11
46
question
stringlengths
828
4.77k
question_title
stringlengths
11
48
platform
stringclasses
1 value
difficulty
stringclasses
9 values
contest_date
stringclasses
1 value
starter_code
stringclasses
1 value
public_test_cases
stringlengths
71
679
private_test_cases
stringlengths
2
4.73M
metadata
stringclasses
1 value
1548_C._The_Three_Little_Pigs
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: Three little pigs from all over the world are meeting for a convention! Every minute, a triple of 3 new pigs arrives on the convention floor. After the n-th min...
1548_C. The Three Little Pigs
codeforces
C
[{"input": "2 3\n1\n5\n6\n", "output": "9\n6\n1\n", "testtype": "stdin"}, {"input": "5 4\n2\n4\n6\n8\n", "output": "225\n2001\n6014\n6939\n", "testtype": "stdin"}]
[{"input": "1 3\n1\n2\n3\n", "output": "3\n3\n1\n", "testtype": "stdin"}, {"input": "3 9\n1\n2\n3\n4\n5\n6\n7\n8\n9\n", "output": "18\n54\n105\n141\n132\n85\n36\n9\n1\n", "testtype": "stdin"}]
{}
1548_D1._Gregor_and_the_Odd_Cows_Easy
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: This is the easy version of the problem. The only difference from the hard version is that in this version all coordinates are even. There are n fence-posts at...
1548_D1. Gregor and the Odd Cows (Easy)
codeforces
D
[{"input": "5\n0 0\n2 16\n30 14\n4 6\n2 10\n", "output": "3\n", "testtype": "stdin"}, {"input": "3\n0 0\n2 0\n0 4\n", "output": "1\n", "testtype": "stdin"}]
[{"input": "20\n200 716\n88 526\n434 134\n996 890\n718 220\n820 462\n614 178\n848 208\n724 536\n124 710\n408 228\n846 606\n222 32\n642 180\n694 964\n438 994\n718 524\n688 692\n126 494\n102 116\n", "output": "650\n", "testtype": "stdin"}, {"input": "4\n12 10\n6 14\n2 6\n6 12\n", "output": "2\n", "testtype": "stdin"}]
{}
1548_D2._Gregor_and_the_Odd_Cows_Hard
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: This is the hard version of the problem. The only difference from the easy version is that in this version the coordinates can be both odd and even. There are ...
1548_D2. Gregor and the Odd Cows (Hard)
codeforces
D
[{"input": "10\n170 59\n129 54\n5 98\n129 37\n58 193\n154 58\n24 3\n13 138\n136 144\n174 150\n", "output": "29\n", "testtype": "stdin"}, {"input": "3\n0 0\n2 0\n0 4\n", "output": "1\n", "testtype": "stdin"}, {"input": "4\n1 8\n0 6\n5 2\n5 6\n", "output": "1\n", "testtype": "stdin"}]
[]
{}
1548_E._Gregor_and_the_Two_Painters
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: Two painters, Amin and Benj, are repainting Gregor's living room ceiling! The ceiling can be modeled as an n × m grid. For each i between 1 and n, inclusive, p...
1548_E. Gregor and the Two Painters
codeforces
E
[{"input": "3 4 12\n9 8 5\n10 6 7 2\n", "output": "1\n", "testtype": "stdin"}, {"input": "3 4 11\n9 8 5\n10 6 7 2\n", "output": "2\n", "testtype": "stdin"}, {"input": "5 23 6\n1 4 3 5 2\n2 3 1 6 1 5 5 6 1 3 2 6 2 3 1 6 1 4 1 6 1 5 5\n", "output": "6\n", "testtype": "stdin"}, {"input": "3 3 2\n1 2 1\n1 2 1\n", "output":...
[{"input": "1 1 2\n1\n1\n", "output": "1\n", "testtype": "stdin"}, {"input": "1 1 1\n1\n1\n", "output": "0\n", "testtype": "stdin"}, {"input": "3 3 4\n2 3 2\n3 2 2\n", "output": "2\n", "testtype": "stdin"}, {"input": "5 5 6\n1 2 3 4 5\n5 4 3 2 1\n", "output": "1\n", "testtype": "stdin"}, {"input": "3 3 7\n3 4 3\n3 4 3\...
{}
1549_A._Gregor_and_Cryptography
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: Gregor is learning about RSA cryptography, and although he doesn't understand how RSA works, he is now fascinated with prime numbers and factoring them. Gregor...
1549_A. Gregor and Cryptography
codeforces
A
[{"input": "2\n17\n5\n", "output": "2 16\n2 4\n", "testtype": "stdin"}]
[{"input": "2\n17\n5\n", "output": "2 16\n2 4\n", "testtype": "stdin"}, {"input": "1\n55439\n", "output": "2 55438\n", "testtype": "stdin"}, {"input": "5\n5\n7\n11\n13\n19\n", "output": "2 4\n2 6\n2 10\n2 12\n2 18\n", "testtype": "stdin"}]
{}
1549_B._Gregor_and_the_Pawn_Game
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: There is a chessboard of size n by n. The square in the i-th row from top and j-th column from the left is labelled (i,j). Currently, Gregor has some pawns in ...
1549_B. Gregor and the Pawn Game
codeforces
B
[{"input": "4\n3\n000\n111\n4\n1111\n1111\n3\n010\n010\n5\n11001\n00000\n", "output": "3\n4\n0\n0\n", "testtype": "stdin"}]
[{"input": "1\n20\n01001100111111000100\n00101100011010001110\n", "output": "8\n", "testtype": "stdin"}]
{}
1549_C._Web_of_Lies
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are n nobl...
1549_C. Web of Lies
codeforces
C
[{"input": "4 3\n2 1\n1 3\n3 4\n4\n3\n1 2 3\n2 3 1\n3\n", "output": "2\n1\n", "testtype": "stdin"}, {"input": "4 3\n2 3\n3 4\n4 1\n1\n3\n", "output": "1\n", "testtype": "stdin"}]
[{"input": "3 0\n2\n1 2 1\n3\n", "output": "2\n", "testtype": "stdin"}, {"input": "20 0\n1\n3\n", "output": "20\n", "testtype": "stdin"}, {"input": "1000 0\n1\n3\n", "output": "1000\n", "testtype": "stdin"}, {"input": "20 0\n20\n3\n3\n1 17 19\n1 19 20\n1 4 8\n1 9 18\n1 1 14\n1 16 19\n1 10 19\n1 1 7\n1 6 10\n1 18 19\n1 ...
{}
1549_D._Integers_Have_Friends
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: British mathematician John Littlewood once said about Indian mathematician Srinivasa Ramanujan that "every positive integer was one of his personal friends." I...
1549_D. Integers Have Friends
codeforces
D
[{"input": "4\n5\n1 5 2 4 6\n4\n8 2 5 10\n2\n1000 2000\n8\n465 55 3 54 234 12 45 78\n", "output": "3\n3\n2\n6\n", "testtype": "stdin"}]
[{"input": "1\n3\n1 137438953474 274877906947\n", "output": "3\n", "testtype": "stdin"}, {"input": "5\n1\n13\n1\n1\n6\n7 19 28 25 4 10\n3\n3 19 10\n9\n26 1 28 8 24 27 12 16 17\n", "output": "1\n1\n6\n2\n3\n", "testtype": "stdin"}, {"input": "1\n69\n2 4 10 16 22 28 34 40 46 52 58 64 70 76 82 88 94 100 106 112 118 124 13...
{}
1551_A._Polycarp_and_Coins
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: Polycarp must pay exactly n burles at the checkout. He has coins of two nominal values: 1 burle and 2 burles. Polycarp likes both kinds of coins equally. So he ...
1551_A. Polycarp and Coins
codeforces
A
[{"input": "6\n1000\n30\n1\n32\n1000000000\n5\n", "output": "334 333\n10 10\n1 0\n10 11\n333333334 333333333\n1 2\n", "testtype": "stdin"}]
[{"input": "1\n10111\n", "output": "3371 3370\n", "testtype": "stdin"}, {"input": "1\n10555\n", "output": "3519 3518\n", "testtype": "stdin"}, {"input": "2\n3000002\n3000001\n", "output": "1000000 1000001\n1000001 1000000\n", "testtype": "stdin"}, {"input": "1\n3000002\n", "output": "1000000 1000001\n", "testtype": "st...
{}
1551_B1._Wonderful_Coloring_-_1
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: This is a simplified version of the problem B2. Perhaps you should read the problem B2 before you start solving B1. Paul and Mary have a favorite string s whic...
1551_B1. Wonderful Coloring - 1
codeforces
B
[{"input": "5\nkzaaa\ncodeforces\narchive\ny\nxxxxxx\n", "output": "2\n5\n3\n0\n1\n", "testtype": "stdin"}]
[{"input": "1\ndscnjksdcnsjkvndfjkvndfjkvnkdfnv\n", "output": "8\n", "testtype": "stdin"}, {"input": "1\naa\n", "output": "1\n", "testtype": "stdin"}, {"input": "1\nabbdsdndsncjksdncjkdsncknsdkcnskc\n", "output": "7\n", "testtype": "stdin"}, {"input": "61\nkzaaa\ncodeforces\narchive\ny\nxxxxxx\nkzaaa\ncodeforces\narchi...
{}
1551_B2._Wonderful_Coloring_-_2
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: This problem is an extension of the problem "Wonderful Coloring - 1". It has quite many differences, so you should read this statement completely. Recently, Pa...
1551_B2. Wonderful Coloring - 2
codeforces
B
[{"input": "6\n10 3\n3 1 1 1 1 10 3 10 10 2\n4 4\n1 1 1 1\n1 1\n1\n13 1\n3 1 4 1 5 9 2 6 5 3 5 8 9\n13 2\n3 1 4 1 5 9 2 6 5 3 5 8 9\n13 3\n3 1 4 1 5 9 2 6 5 3 5 8 9\n", "output": "2 1 2 3 0 1 3 2 3 1 \n1 2 3 4 \n1 \n1 1 1 0 1 1 1 1 0 0 0 1 0 \n2 1 2 2 1 1 1 1 2 1 0 2 2 \n1 1 3 2 1 3 3 1 2 2 3 2 0 \n", "testtype": "stdi...
[{"input": "12\n10 3\n3 1 1 1 1 10 3 10 10 2\n4 4\n1 1 1 1\n1 1\n1\n13 1\n3 1 4 1 5 9 2 6 5 3 5 8 9\n13 2\n3 1 4 1 5 9 2 6 5 3 5 8 9\n13 3\n3 1 4 1 5 9 2 6 5 3 5 8 9\n10 3\n3 1 1 1 1 10 3 10 10 2\n4 4\n1 1 1 1\n1 1\n1\n13 1\n3 1 4 1 5 9 2 6 5 3 5 8 9\n13 2\n3 1 4 1 5 9 2 6 5 3 5 8 9\n13 3\n3 1 4 1 5 9 2 6 5 3 5 8 9\n",...
{}
1551_C._Interesting_Story
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: Stephen Queen wants to write a story. He is a very unusual writer, he uses only letters 'a', 'b', 'c', 'd' and 'e'! To compose a story, Stephen wrote out n wor...
1551_C. Interesting Story
codeforces
C
[{"input": "6\n3\nbac\naaada\ne\n3\naba\nabcde\naba\n2\nbaba\nbaba\n4\nab\nab\nc\nbc\n5\ncbdca\nd\na\nd\ne\n3\nb\nc\nca\n", "output": "3\n2\n0\n2\n3\n2\n", "testtype": "stdin"}]
[]
{}
1551_D1._Domino_easy_version
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: The only difference between this problem and D2 is that you don't have to provide the way to construct the answer in this problem, but you have to do it in D2. ...
1551_D1. Domino (easy version)
codeforces
D
[{"input": "8\n4 4 2\n2 3 0\n3 2 3\n1 2 0\n2 4 2\n5 2 2\n2 17 16\n2 1 1\n", "output": "YES\nYES\nYES\nNO\nYES\nNO\nYES\nNO\n", "testtype": "stdin"}]
[{"input": "1\n6 7 20\n", "output": "NO\n", "testtype": "stdin"}, {"input": "10\n26 80 521\n34 14 232\n62 66 767\n80 72 2664\n70 50 461\n85 92 108\n59 44 732\n55 6 13\n47 22 504\n79 16 8\n", "output": "NO\nYES\nNO\nYES\nNO\nYES\nYES\nYES\nNO\nYES\n", "testtype": "stdin"}, {"input": "10\n8 67 208\n87 58 1834\n96 82 2079...
{}
1551_D2._Domino_hard_version
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: The only difference between this problem and D1 is that you don't have to provide the way to construct the answer in D1, but you have to do it in this problem. ...
1551_D2. Domino (hard version)
codeforces
D
[{"input": "8\n4 4 2\n2 3 0\n3 2 3\n1 2 0\n2 4 2\n5 2 2\n2 17 16\n2 1 1\n", "output": "YES\naaca\nbbca\nacab\nacab\nYES\naba\naba\nYES\naa\nbb\naa\nNO\nYES\naaca\nbbca\nNO\nYES\naabbaabbaabbaabbc\nbbaabbaabbaabbaac\nNO\n", "testtype": "stdin"}]
[{"input": "10\n4 1 1\n10 2 2\n2 1 1\n5 2 2\n5 6 8\n2 2 1\n1 32 8\n11 2 3\n2 17 16\n2 7 3\n", "output": "NO\nYES\naa\nbb\nac\nac\nba\nba\nab\nab\nba\nba\nNO\nNO\nNO\nNO\nNO\nYES\naa\nbb\naa\nbc\nbc\nab\nab\nba\nba\nab\nab\nYES\naabbaabbaabbaabbc\nbbaabbaabbaabbaac\nNO\n", "testtype": "stdin"}, {"input": "1\n5 4 2\n", "...
{}
1551_E._Fixed_Points
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: Consider a sequence of integers a_1, a_2, …, a_n. In one move, you can select any element of the sequence and delete it. After an element is deleted, all elemen...
1551_E. Fixed Points
codeforces
E
[{"input": "4\n7 6\n1 1 2 3 4 5 6\n5 2\n5 1 3 2 3\n5 2\n5 5 5 5 4\n8 4\n1 2 3 3 2 2 5 5\n", "output": "1\n2\n-1\n2\n", "testtype": "stdin"}]
[{"input": "2\n15 6\n10 7 6 7 9 7 7 10 10 7 9 12 11 12 7\n8 1\n1 3 6 3 7 2 4 8\n", "output": "-1\n0\n", "testtype": "stdin"}]
{}
1551_F._Equidistant_Vertices
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: A tree is an undirected connected graph without cycles. You are given a tree of n vertices. Find the number of ways to choose exactly k vertices in this tree (...
1551_F. Equidistant Vertices
codeforces
F
[{"input": "3\n\n4 2\n1 2\n2 3\n2 4\n\n3 3\n1 2\n2 3\n\n5 3\n1 2\n2 3\n2 4\n4 5\n", "output": "6\n0\n1\n", "testtype": "stdin"}]
[{"input": "8\n\n3 2\n3 1\n1 2\n\n5 5\n4 1\n5 4\n1 3\n2 4\n\n10 2\n2 5\n4 10\n9 4\n7 1\n6 2\n9 6\n3 1\n8 7\n7 2\n\n2 2\n2 1\n\n7 4\n5 1\n1 3\n3 6\n6 4\n3 7\n2 3\n\n10 3\n8 4\n1 4\n7 1\n5 1\n10 2\n8 9\n5 3\n2 4\n6 9\n\n5 5\n1 5\n3 5\n1 2\n4 2\n\n8 3\n1 2\n5 8\n5 4\n2 7\n7 6\n8 7\n3 2\n", "output": "3\n0\n45\n1\n1\n4\n0\...
{}
1552_A._Subsequence_Permutation
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: A string s of length n, consisting of lowercase letters of the English alphabet, is given. You must choose some number k between 0 and n. Then, you select k ch...
1552_A. Subsequence Permutation
codeforces
A
[{"input": "4\n3\nlol\n10\ncodeforces\n5\naaaaa\n4\ndcba\n", "output": "2\n6\n0\n4\n", "testtype": "stdin"}]
[{"input": "1\n20\naaaaaaaaaaaaaaaaaqwq\n", "output": "2\n", "testtype": "stdin"}]
{}
1552_B._Running_for_Gold
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: The Olympic Games have just started and Federico is eager to watch the marathon race. There will be n athletes, numbered from 1 to n, competing in the marathon...
1552_B. Running for Gold
codeforces
B
[{"input": "4\n1\n50000 1 50000 50000 50000\n3\n10 10 20 30 30\n20 20 30 10 10\n30 30 10 20 20\n3\n1 1 1 1 1\n2 2 2 2 2\n3 3 3 3 3\n6\n9 5 3 7 1\n7 4 1 6 8\n5 6 7 3 2\n6 7 8 8 6\n4 2 2 4 5\n8 3 6 9 4\n", "output": "1\n-1\n1\n5\n", "testtype": "stdin"}]
[]
{}
1552_C._Maximize_the_Intersections
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: On a circle lie 2n distinct points, with the following property: however you choose 3 chords that connect 3 disjoint pairs of points, no point strictly inside t...
1552_C. Maximize the Intersections
codeforces
C
[{"input": "4\n4 2\n8 2\n1 5\n1 1\n2 1\n2 0\n10 6\n14 6\n2 20\n9 10\n13 18\n15 12\n11 7\n", "output": "4\n0\n1\n14\n", "testtype": "stdin"}]
[]
{}
1552_D._Array_Differentiation
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: You are given a sequence of n integers a_1, a_2, ..., a_n. Does there exist a sequence of n integers b_1, b_2, ..., b_n such that the following pro...
1552_D. Array Differentiation
codeforces
D
[{"input": "5\n5\n4 -7 -1 5 10\n1\n0\n3\n1 10 100\n4\n-3 2 10 2\n9\n25 -171 250 174 152 242 100 -205 -258\n", "output": "YES\nYES\nNO\nYES\nYES\n", "testtype": "stdin"}]
[{"input": "20\n5\n6711 19885 -3098 -16272 -10076\n4\n86522 29647 -12464 -9627\n4\n-82555 -5215 -15221 -63129\n4\n-18147 4 5 -5\n5\n-17427 -19079 17427 15043 19079\n5\n15148 5942 361 9206 21087\n3\n-1 -55 1\n5\n47214 53109 39369 11561 -22908\n4\n-74790 54187 -2 30242\n2\n-68120 94070\n3\n-27228 46215 -33546\n2\n75489 9...
{}
1552_E._Colors_and_Intervals
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: The numbers 1, 2, ..., n ⋅ k are colored with n colors. These colors are indexed by 1, 2, ..., n. For each 1 ≤ i ≤ n, there are exactly k numbers co...
1552_E. Colors and Intervals
codeforces
E
[{"input": "4 3\n2 4 3 1 1 4 2 3 2 1 3 4\n", "output": "4 5\n7 9\n8 11\n2 6\n", "testtype": "stdin"}, {"input": "1 2\n1 1\n", "output": "1 2\n", "testtype": "stdin"}, {"input": "3 3\n3 1 2 3 2 1 2 1 3\n", "output": "6 8\n3 5\n1 4\n", "testtype": "stdin"}, {"input": "2 3\n2 1 1 1 2 2\n", "output": "2 3\n5 6\n", "testtyp...
[{"input": "3 3\n3 1 2 3 2 1 2 1 3\n", "output": "6 8\n3 5\n1 4\n", "testtype": "stdin"}, {"input": "4 3\n2 4 3 1 1 4 2 3 2 1 3 4\n", "output": "4 5\n7 9\n8 11\n2 6\n", "testtype": "stdin"}, {"input": "15 9\n9 5 3 8 6 7 12 14 4 15 10 2 1 13 9 5 6 7 12 14 4 15 10 2 11 3 13 9 4 5 6 7 12 14 15 4 15 10 2 1 13 14 5 8 6 7 12...
{}
1552_F._Telepanting
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: An ant moves on the real line with constant speed of 1 unit per second. It starts at 0 and always moves to the right (so its position increases by 1 each second...
1552_F. Telepanting
codeforces
F
[{"input": "5\n243385510 42245605 0\n644426565 574769163 0\n708622105 208990040 0\n786625660 616437691 0\n899754846 382774619 0\n", "output": "899754847", "testtype": "stdin"}, {"input": "5\n200000000 100000000 1\n600000000 400000000 0\n800000000 300000000 0\n900000000 700000000 1\n1000000000 500000000 0\n", "output": ...
[{"input": "1\n998244352 1 0\n", "output": "0", "testtype": "stdin"}, {"input": "1\n799441970 23271048 0\n", "output": "799441971", "testtype": "stdin"}]
{}
1552_G._A_Serious_Referee
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: Andrea has come up with what he believes to be a novel sorting algorithm for arrays of length n. The algorithm works as follows. Initially there is an array of...
1552_G. A Serious Referee
codeforces
G
[{"input": "5 2\n3 2 3 4\n5 1 2 3 4 5\n", "output": "ACCEPTED\n", "testtype": "stdin"}, {"input": "4 3\n3 1 2 3\n3 2 3 4\n2 1 2\n", "output": "ACCEPTED\n", "testtype": "stdin"}, {"input": "3 4\n1 1\n1 2\n1 3\n2 1 3\n", "output": "REJECTED\n", "testtype": "stdin"}, {"input": "4 3\n3 1 2 3\n3 2 3 4\n3 1 3 4\n", "output":...
[{"input": "40 10\n2 19 32\n6 13 19 25 34 36 40\n4 13 18 36 40\n5 13 18 19 25 30\n5 13 19 29 32 40\n5 2 22 29 32 40\n17 6 7 9 12 15 18 21 22 24 26 27 28 29 31 32 34 36\n15 2 13 15 18 19 20 21 24 25 26 27 28 30 36 40\n33 1 3 4 5 8 9 10 11 14 15 16 17 18 19 21 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40\n30 1 2...
{}
1552_I._Organizing_a_Music_Festival
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: You are the organizer of the famous "Zurich Music Festival". There will be n singers who will perform at the festival, identified by the integers 1, 2, ..., n. ...
1552_I. Organizing a Music Festival
codeforces
I
[{"input": "5 1\n5 1 2 3 4 5\n", "output": "120\n", "testtype": "stdin"}, {"input": "11 4\n5 4 5 7 9 11\n2 2 10\n2 9 11\n7 1 2 3 5 8 10 11\n", "output": "384\n", "testtype": "stdin"}, {"input": "3 1\n2 1 3\n", "output": "4\n", "testtype": "stdin"}, {"input": "100 1\n1 50\n", "output": "35305197\n", "testtype": "stdin"}...
[{"input": "98 10\n4 37 47 54 83\n3 11 21 30\n2 44 51\n5 3 34 35 64 73\n4 2 8 76 91\n8 4 6 44 50 75 77 82 97\n4 15 20 56 62\n11 5 25 31 48 55 69 70 74 78 90 94\n3 29 80 81\n2 33 38\n", "output": "554141469\n", "testtype": "stdin"}, {"input": "99 20\n3 32 40 48\n1 79\n2 34 87\n5 6 16 23 78 92\n2 28 34\n3 41 51 54\n1 57\...
{}
1553_A._Digits_Sum
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: Let's define S(x) to be the sum of digits of number x written in decimal system. For example, S(5) = 5, S(10) = 1, S(322) = 7. We will call an integer x intere...
1553_A. Digits Sum
codeforces
A
[{"input": "5\n1\n9\n10\n34\n880055535\n", "output": "0\n1\n1\n3\n88005553\n", "testtype": "stdin"}]
[]
{}
1553_B._Reverse_String
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: You have a string s and a chip, which you can place onto any character of this string. After placing the chip, you move it to the right several (maybe zero) t...
1553_B. Reverse String
codeforces
B
[{"input": "6\nabcdef\ncdedcb\naaa\naaaaa\naab\nbaaa\nab\nb\nabcdef\nabcdef\nba\nbaa\n", "output": "Yes\nYes\nNo\nYes\nYes\nNo\n", "testtype": "stdin"}]
[{"input": "1\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
{}
1553_C._Penalty
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: Consider a simplified penalty phase at the end of a football match. A penalty phase consists of at most 10 kicks, the first team takes the first kick, the seco...
1553_C. Penalty
codeforces
C
[{"input": "4\n1?0???1001\n1111111111\n??????????\n0100000000\n", "output": "7\n10\n6\n9\n", "testtype": "stdin"}]
[]
{}
1553_D._Backspace
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: You are given two strings s and t, both consisting of lowercase English letters. You are going to type the string s character by character, from the first chara...
1553_D. Backspace
codeforces
D
[{"input": "4\nababa\nba\nababa\nbb\naaa\naaaa\naababa\nababa\n", "output": "YES\nNO\nNO\nYES\n", "testtype": "stdin"}]
[{"input": "1\nbaa\nba\n", "output": "NO\n", "testtype": "stdin"}, {"input": "1\nabb\nab\n", "output": "NO\n", "testtype": "stdin"}, {"input": "1\nedcca\nec\n", "output": "NO\n", "testtype": "stdin"}, {"input": "1\naabc\nab\n", "output": "NO\n", "testtype": "stdin"}, {"input": "1\nabcde\nabcd\n", "output": "NO\n", "tes...
{}
1553_E._Permutation_Shift
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: An identity permutation of length n is an array [1, 2, 3, ..., n]. We performed the following operations to an identity permutation of length n: * firstly, ...
1553_E. Permutation Shift
codeforces
E
[{"input": "4\n4 1\n2 3 1 4\n3 1\n1 2 3\n3 1\n3 2 1\n6 0\n1 2 3 4 6 5\n", "output": "1\n3 \n1\n0 \n3\n0 1 2 \n0\n\n", "testtype": "stdin"}]
[{"input": "3\n18 5\n5 6 7 8 3 4 2 1 9 10 11 12 13 14 15 16 17 18\n18 4\n5 6 7 8 3 4 2 1 9 10 11 12 13 14 15 16 17 18\n18 6\n5 6 7 8 3 4 2 1 9 10 11 12 13 14 15 16 17 18\n", "output": "0\n\n0\n\n0\n\n", "testtype": "stdin"}, {"input": "1\n12 4\n1 2 3 4 9 10 11 12 5 6 7 8\n", "output": "3\n0 4 8 \n", "testtype": "stdin"...
{}
1553_F._Pairwise_Modulo
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: You have an array a consisting of n distinct positive integers, numbered from 1 to n. Define p_k as $$$p_k = ∑_{1 ≤ i, j ≤ k} a_i mod a_j, where x \bmod y denot...
1553_F. Pairwise Modulo
codeforces
F
[{"input": "4\n6 2 7 3\n", "output": "0 2 12 22 \n", "testtype": "stdin"}, {"input": "3\n3 2 1\n", "output": "0 3 5 \n", "testtype": "stdin"}]
[{"input": "82\n3 10 19 34 53 84 87 92 99 121 143 173 188 202 239 245 246 259 273 278 280 292 316 321 323 324 341 399 400 406 422 429 452 456 463 466 510 522 532 542 565 570 575 596 617 632 635 636 643 644 672 674 678 679 689 723 729 734 736 740 773 784 787 809 821 823 835 857 867 870 873 875 894 898 900 901 903 908 91...
{}
1553_G._Common_Divisor_Graph
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: Consider a sequence of distinct integers a_1, …, a_n, each representing one node of a graph. There is an edge between two nodes if the two values are not coprim...
1553_G. Common Divisor Graph
codeforces
G
[{"input": "3 3\n2 10 3\n1 2\n1 3\n2 3\n", "output": "0\n1\n1\n", "testtype": "stdin"}, {"input": "5 12\n3 8 7 6 25\n1 2\n1 3\n1 4\n1 5\n2 1\n2 3\n2 4\n2 5\n3 1\n3 2\n3 4\n3 5\n", "output": "0\n1\n0\n1\n0\n1\n0\n1\n1\n1\n1\n2\n", "testtype": "stdin"}]
[{"input": "3 3\n9901 101 1000000\n1 2\n1 3\n2 3\n", "output": "1\n1\n1\n", "testtype": "stdin"}, {"input": "10 20\n89 86 73 22 76 78 33 97 42 56\n7 4\n8 7\n3 9\n4 7\n7 8\n9 1\n9 3\n7 1\n8 10\n3 5\n3 1\n3 8\n7 8\n10 1\n4 8\n1 8\n9 3\n8 9\n7 8\n10 7\n", "output": "0\n1\n1\n0\n1\n1\n1\n1\n1\n1\n2\n2\n1\n1\n1\n2\n1\n1\n1\...
{}
1553_H._XOR_and_Distance
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: You are given an array a consisting of n distinct elements and an integer k. Each element in the array is a non-negative integer not exceeding 2^k-1. Let's def...
1553_H. XOR and Distance
codeforces
H
[{"input": "3 3\n6 0 3\n", "output": "3 1 1 2 2 1 1 3 ", "testtype": "stdin"}, {"input": "3 4\n13 4 2\n", "output": "2 2 6 6 3 1 2 2 2 2 1 3 6 6 2 2 ", "testtype": "stdin"}]
[{"input": "2 1\n0 1\n", "output": "1 1 ", "testtype": "stdin"}, {"input": "3 2\n0 3 1\n", "output": "1 1 1 1 ", "testtype": "stdin"}, {"input": "2 2\n3 1\n", "output": "2 2 2 2 ", "testtype": "stdin"}]
{}
1553_I._Stairs
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: For a permutation p of numbers 1 through n, we define a stair array a as follows: a_i is length of the longest segment of permutation which contains position i ...
1553_I. Stairs
codeforces
I
[{"input": "1\n1\n", "output": "1\n", "testtype": "stdin"}, {"input": "4\n3 2 3 1\n", "output": "0\n", "testtype": "stdin"}, {"input": "8\n2 2 2 2 2 2 1 1\n", "output": "370\n", "testtype": "stdin"}, {"input": "6\n3 3 3 1 1 1\n", "output": "6\n", "testtype": "stdin"}, {"input": "7\n4 4 4 4 3 3 3\n", "output": "6\n", "t...
[]
{}
1554_A._Cherry
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: You are given n integers a_1, a_2, …, a_n. Find the maximum value of max(a_l, a_{l + 1}, …, a_r) ⋅ min(a_l, a_{l + 1}, …, a_r) over all pairs (l, r) of integers...
1554_A. Cherry
codeforces
A
[{"input": "4\n3\n2 4 3\n4\n3 2 3 1\n2\n69 69\n6\n719313 273225 402638 473783 804745 323328\n", "output": "12\n6\n4761\n381274500335\n", "testtype": "stdin"}]
[{"input": "1\n2\n140537 269100\n", "output": "37818506700\n", "testtype": "stdin"}, {"input": "1\n2\n411662 754535\n", "output": "310613387170\n", "testtype": "stdin"}]
{}
1554_B._Cobb
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: You are given n integers a_1, a_2, …, a_n and an integer k. Find the maximum value of i ⋅ j - k ⋅ (a_i | a_j) over all pairs (i, j) of integers with 1 ≤ i < j ≤...
1554_B. Cobb
codeforces
B
[{"input": "4\n3 3\n1 1 3\n2 2\n1 2\n4 3\n0 1 2 3\n6 6\n3 2 0 0 5 6\n", "output": "-1\n-4\n3\n12\n", "testtype": "stdin"}]
[{"input": "1\n2 1\n2 2\n", "output": "0\n", "testtype": "stdin"}, {"input": "1\n8 5\n0 1 5 0 8 8 8 6\n", "output": "4\n", "testtype": "stdin"}]
{}
1554_C._Mikasa
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: You are given two integers n and m. Find the \operatorname{MEX} of the sequence n ⊕ 0, n ⊕ 1, …, n ⊕ m. Here, ⊕ is the [bitwise XOR operator](https://en.wikiped...
1554_C. Mikasa
codeforces
C
[{"input": "5\n3 5\n4 6\n3 2\n69 696\n123456 654321\n", "output": "4\n3\n0\n640\n530866\n", "testtype": "stdin"}]
[]
{}
1554_D._Diane
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: You are given an integer n. Find any string s of length n consisting only of English lowercase letters such that each non-empty substring of s occurs in s an od...
1554_D. Diane
codeforces
D
[{"input": "4\n3\n5\n9\n19\n", "output": "abc\naabca\naaaabcaaa\naaaaaaaaabcaaaaaaaa\n", "testtype": "stdin"}]
[{"input": "1\n99999\n", "output": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
{}
1554_E._You
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: You are given a tree with n nodes. As a reminder, a tree is a connected undirected graph without cycles. Let a_1, a_2, …, a_n be a sequence of integers. Perfor...
1554_E. You
codeforces
E
[{"input": "2\n3\n2 1\n1 3\n2\n1 2\n", "output": "3 1 0 \n2 0 \n", "testtype": "stdin"}]
[{"input": "3\n3\n2 1\n1 3\n3\n1 2\n2 3\n3\n1 3\n2 3\n", "output": "3 1 0 \n3 1 0 \n3 1 0 \n", "testtype": "stdin"}, {"input": "1\n2\n1 2\n", "output": "2 0 \n", "testtype": "stdin"}, {"input": "10\n4\n2 1\n3 1\n1 4\n4\n3 1\n1 2\n2 4\n4\n2 1\n1 3\n3 4\n4\n2 1\n1 4\n3 4\n4\n1 2\n3 2\n2 4\n4\n1 2\n2 3\n3 4\n4\n1 2\n2 4\n...
{}
1555_A._PizzaForces
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: PizzaForces is Petya's favorite pizzeria. PizzaForces makes and sells pizzas of three sizes: small pizzas consist of 6 slices, medium ones consist of 8 slices, ...
1555_A. PizzaForces
codeforces
A
[{"input": "6\n12\n15\n300\n1\n9999999999999999\n3\n", "output": "30\n40\n750\n15\n25000000000000000\n15\n", "testtype": "stdin"}]
[{"input": "1\n42042069\n", "output": "105105175\n", "testtype": "stdin"}, {"input": "1\n13594805\n", "output": "33987015\n", "testtype": "stdin"}, {"input": "1\n6239398373929\n", "output": "15598495934825\n", "testtype": "stdin"}, {"input": "1\n199199199199195\n", "output": "497997997997990\n", "testtype": "stdin"}, {...
{}
1555_B._Two_Tables
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: You have an axis-aligned rectangle room with width W and height H, so the lower left corner is in point (0, 0) and the upper right corner is in (W, H). There i...
1555_B. Two Tables
codeforces
B
[{"input": "5\n8 5\n2 1 7 4\n4 2\n5 4\n2 2 5 4\n3 3\n1 8\n0 3 1 6\n1 5\n8 1\n3 0 6 1\n5 1\n8 10\n4 5 7 8\n8 5\n", "output": "1.000000000\n-1\n2.000000000\n2.000000000\n0.000000000\n", "testtype": "stdin"}]
[]
{}
1555_C._Coin_Rows
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: Alice and Bob are playing a game on a matrix, consisting of 2 rows and m columns. The cell in the i-th row in the j-th column contains a_{i, j} coins in it. In...
1555_C. Coin Rows
codeforces
C
[{"input": "3\n3\n1 3 7\n3 5 1\n3\n1 3 9\n3 5 1\n1\n4\n7\n", "output": "7\n8\n0\n", "testtype": "stdin"}]
[]
{}
1555_D._Say_No_to_Palindromes
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: Let's call the string beautiful if it does not contain a substring of length at least 2, which is a palindrome. Recall that a palindrome is a string that reads ...
1555_D. Say No to Palindromes
codeforces
D
[{"input": "5 4\nbaacb\n1 3\n1 5\n4 5\n2 3\n", "output": "1\n2\n0\n1\n", "testtype": "stdin"}]
[{"input": "10 3\nababababab\n1 2\n1 2\n1 2\n", "output": "0\n0\n0\n", "testtype": "stdin"}, {"input": "1 1\na\n1 1\n", "output": "0\n", "testtype": "stdin"}]
{}
1555_E._Boring_Segments
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: You are given n segments on a number line, numbered from 1 to n. The i-th segments covers all integer points from l_i to r_i and has a value w_i. You are asked...
1555_E. Boring Segments
codeforces
E
[{"input": "1 10\n1 10 23\n", "output": "0\n", "testtype": "stdin"}, {"input": "5 12\n1 5 5\n3 4 10\n4 10 6\n11 12 5\n10 12 3\n", "output": "3\n", "testtype": "stdin"}]
[{"input": "10 100000\n1 49856 954208\n98389 98970 222740\n78151 99991 323776\n63089 100000 263298\n19955 99994 342017\n27228 99998 310177\n13398 98500 187599\n95925 99993 643614\n36475 99999 556166\n1224 98485 55420\n", "output": "690910\n", "testtype": "stdin"}, {"input": "4 10\n6 10 4\n1 5 7\n2 6 5\n5 9 8\n", "outpu...
{}
1555_F._Good_Graph
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: You have an undirected graph consisting of n vertices with weighted edges. A simple cycle is a cycle of the graph without repeated vertices. Let the weight of ...
1555_F. Good Graph
codeforces
F
[{"input": "9 12\n6 1 0\n1 3 1\n3 6 0\n6 2 0\n6 4 1\n3 4 1\n2 4 0\n2 5 0\n4 5 0\n7 8 1\n8 9 1\n9 7 0\n", "output": "YES\nYES\nYES\nYES\nYES\nNO\nYES\nYES\nNO\nYES\nYES\nNO\n", "testtype": "stdin"}]
[{"input": "10 25\n1 6 0\n6 9 1\n1 9 1\n9 7 1\n6 7 0\n7 8 0\n9 8 1\n8 10 1\n7 10 1\n10 2 1\n8 2 0\n10 4 1\n2 4 0\n4 5 1\n2 5 1\n5 3 0\n4 3 0\n10 1 0\n6 8 1\n3 6 1\n8 5 0\n4 6 0\n1 8 0\n7 3 0\n1 3 0\n", "output": "YES\nYES\nNO\nYES\nNO\nYES\nNO\nYES\nNO\nYES\nNO\nYES\nNO\nYES\nNO\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO\n...
{}
1556_A._A_Variety_of_Operations
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: <image> William has two numbers a and b initially both equal to zero. William mastered performing three different operations with them quickly. Before performi...
1556_A. A Variety of Operations
codeforces
A
[{"input": "6\n1 2\n3 5\n5 3\n6 6\n8 0\n0 0\n", "output": "-1\n2\n2\n1\n2\n0\n", "testtype": "stdin"}]
[]
{}
1556_B._Take_Your_Places
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: <image> William has an array of n integers a_1, a_2, ..., a_n. In one move he can swap two neighboring items. Two items a_i and a_j are considered neighboring ...
1556_B. Take Your Places!
codeforces
B
[{"input": "5\n3\n6 6 1\n1\n9\n6\n1 1 1 2 2 2\n2\n8 6\n6\n6 2 3 4 5 1\n", "output": "1\n0\n3\n-1\n2\n", "testtype": "stdin"}]
[{"input": "1\n7\n3 3 4 4 4 4 4\n", "output": "-1\n", "testtype": "stdin"}, {"input": "5\n3\n2 4 6\n5\n4 4 4 4 4\n5\n1 3 5 7 9\n5\n1 1 1 1 1\n5\n4 8 10 6 2\n", "output": "-1\n-1\n-1\n-1\n-1\n", "testtype": "stdin"}, {"input": "1\n3\n1 1 1\n", "output": "-1\n", "testtype": "stdin"}]
{}
1556_C._Compressed_Bracket_Sequence
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: <image> William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers c_1, c_2, .....
1556_C. Compressed Bracket Sequence
codeforces
C
[{"input": "6\n1 1 1 1 2 2\n", "output": "7\n", "testtype": "stdin"}, {"input": "6\n1 3 2 1 2 4\n", "output": "6\n", "testtype": "stdin"}, {"input": "5\n4 1 2 3 1\n", "output": "5\n", "testtype": "stdin"}]
[{"input": "1\n6\n", "output": "0\n", "testtype": "stdin"}, {"input": "100\n111 123 170 115 128 189 192 180 122 180 200 151 186 183 152 163 192 181 138 164 132 149 108 176 187 187 104 108 114 147 160 144 168 102 121 154 139 148 140 200 166 187 181 117 188 114 188 157 173 146 193 151 107 198 122 122 184 189 158 139 131 ...
{}
1556_D._Take_a_Guess
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: <image> This is an interactive task William has a certain sequence of integers a_1, a_2, ..., a_n in his mind, but due to security concerns, he does not want ...
1556_D. Take a Guess
codeforces
D
[{"input": "7 6\n\n2\n\n7", "output": "and 1 2\nor 1 2\nand 1 3\nor 1 3\nand 2 3\nor 2 3\nand 1 4\nor 1 4\nand 1 5\nor 1 5\nand 1 6\nor 1 6\nand 1 7\nor 1 7\nfinish 7\n", "testtype": "stdin"}]
[{"input": "50 43\n868459110 111980246 912464887 345564083 50698562 567895482 523308042 361618581 255638441 472446260 708745255 175715709 646865671 350601298 258860025 492164452 321079037 859323542 159865077 128563959 259209508 781885841 392147760 735212901 5819700 508394386 837384236 975501975 252880628 76008256 51804...
{}
1556_E._Equilibrium
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: <image> William has two arrays a and b, each consisting of n items. For some segments l..r of these arrays William wants to know if it is possible to equalize...
1556_E. Equilibrium
codeforces
E
[{"input": "8 5\n0 1 2 9 3 2 7 5\n2 2 1 9 4 1 5 8\n2 6\n1 7\n2 4\n7 8\n5 8\n", "output": "1\n3\n1\n-1\n-1\n", "testtype": "stdin"}]
[{"input": "10 10\n500007913 856079006 196913426 406692832 364084743 994266054 378700256 38254769 479272503 393613505\n923435067 432651852 196913426 406692832 364084743 994266054 378700256 988322977 166602985 393613505\n1 3\n3 10\n1 7\n3 7\n3 5\n3 4\n1 5\n1 9\n6 9\n5 9\n", "output": "423427154\n-1\n423427154\n0\n0\n0\n...
{}
1556_F._Sports_Betting
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: <image> William is not only interested in trading but also in betting on sports matches. n teams participate in each match. Each team is characterized by stren...
1556_F. Sports Betting
codeforces
F
[{"input": "2\n1 2\n", "output": "1\n", "testtype": "stdin"}, {"input": "5\n1 5 2 11 14\n", "output": "642377629\n", "testtype": "stdin"}]
[{"input": "12\n392850 5106 875938 182161 428704 549289 288659 412650 535721 134149 452414 453967\n", "output": "515132587\n", "testtype": "stdin"}, {"input": "12\n568 458 137 58 355 983 701 835 7 849 264 878\n", "output": "179581657\n", "testtype": "stdin"}, {"input": "11\n913 380 423 296 411 508 201 365 269 274 579\n...
{}
1556_G._Gates_to_Another_World
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: <image> As mentioned previously William really likes playing video games. In one of his favorite games, the player character is in a universe where every plane...
1556_G. Gates to Another World
codeforces
G
[{"input": "6 10\nblock 12 26\nask 44 63\nblock 32 46\nask 1 54\nblock 27 30\nask 10 31\nask 11 31\nask 49 31\nblock 31 31\nask 2 51\n", "output": "1\n1\n0\n0\n1\n0\n", "testtype": "stdin"}, {"input": "3 3\nask 0 7\nblock 3 6\nask 0 7\n", "output": "1\n0\n", "testtype": "stdin"}]
[{"input": "7 4\nblock 63 125\nblock 126 127\nask 54 36\nask 43 45\n", "output": "1\n1\n", "testtype": "stdin"}, {"input": "7 4\nblock 37 112\nask 18 122\nask 119 127\nblock 122 127\n", "output": "0\n1\n", "testtype": "stdin"}, {"input": "10 10\nblock 230 855\nask 864 114\nblock 879 990\nask 187 168\nblock 859 869\nask...
{}
1556_H._DIY_Tree
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: <image> William really likes puzzle kits. For one of his birthdays, his friends gifted him a complete undirected edge-weighted graph consisting of n vertices. ...
1556_H. DIY Tree
codeforces
H
[{"input": "10 5\n5 3 4 2 1\n29 49 33 12 55 15 32 62 37\n61 26 15 58 15 22 8 58\n37 16 9 39 20 14 58\n10 15 40 3 19 55\n53 13 37 44 52\n23 59 58 4\n69 80 29\n89 28\n48\n", "output": "95\n", "testtype": "stdin"}]
[{"input": "5 1\n3\n67 62 64 5\n45 84 10\n60 64\n29\n", "output": "89\n", "testtype": "stdin"}, {"input": "10 5\n5 3 4 2 5\n61 54 31 1 61 51 55 61 37\n11 20 4 68 37 4 68 24\n57 62 53 67 34 51 34\n31 18 14 33 23 26\n33 51 27 31 50\n33 48 94 19\n68 18 84\n74 74\n88\n", "output": "120\n", "testtype": "stdin"}, {"input": "...
{}
1557_A._Ezzat_and_Two_Subsequences
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: Ezzat has an array of n integers (maybe negative). He wants to split it into two non-empty subsequences a and b, such that every element from the array belongs ...
1557_A. Ezzat and Two Subsequences
codeforces
A
[{"input": "4\n3\n3 1 2\n3\n-7 -6 -6\n3\n2 2 2\n4\n17 3 5 -3\n", "output": "4.5\n-12.5\n4.0\n18.666666666666668\n", "testtype": "stdin"}]
[]
{}
1557_B._Moamen_and_k-subarrays
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: Moamen has an array of n distinct integers. He wants to sort that array in non-decreasing order by doing the following operations in order exactly once: 1. S...
1557_B. Moamen and k-subarrays
codeforces
B
[{"input": "3\n5 4\n6 3 4 2 1\n4 2\n1 -4 0 -2\n5 1\n1 2 3 4 5\n", "output": "Yes\nNo\nYes\n", "testtype": "stdin"}]
[]
{}
1557_C._Moamen_and_XOR
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: Moamen and Ezzat are playing a game. They create an array a of n non-negative integers where every element is less than 2^k. Moamen wins if a_1 \& a_2 \& a...
1557_C. Moamen and XOR
codeforces
C
[{"input": "3\n3 1\n2 1\n4 0\n", "output": "5\n2\n1\n", "testtype": "stdin"}]
[{"input": "5\n10522 49291\n36426 49737\n48772 14993\n33447 42227\n3497 6588\n", "output": "357088684\n352090898\n955599131\n643643684\n112221458\n", "testtype": "stdin"}, {"input": "5\n26522 28224\n6426 4535\n24772 21028\n31447 35982\n17497 28737\n", "output": "614165725\n295215954\n111774336\n788811583\n94457069\n", ...
{}
1557_D._Ezzat_and_Grid
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: Moamen was drawing a grid of n rows and 10^9 columns containing only digits 0 and 1. Ezzat noticed what Moamen was drawing and became interested in the minimum ...
1557_D. Ezzat and Grid
codeforces
D
[{"input": "5 4\n1 2 3\n2 4 6\n3 3 5\n5 1 1\n", "output": "3\n1 4 5\n", "testtype": "stdin"}, {"input": "3 6\n1 1 1\n1 7 8\n2 7 7\n2 15 15\n3 1 1\n3 15 15\n", "output": "0\n", "testtype": "stdin"}]
[{"input": "5 4\n1 2 3\n2 4 6\n3 3 5\n5 1 1\n", "output": "3\n1 4 5\n", "testtype": "stdin"}, {"input": "3 4\n1 2 3\n2 3 6\n3 4 8\n1 7 9\n", "output": "0\n", "testtype": "stdin"}, {"input": "2 2\n1 2 2\n2 1 1\n", "output": "1\n2 \n", "testtype": "stdin"}, {"input": "64 19\n2 9775794 295412328\n34 22564262 484762546\n47...
{}
1557_E._Assiut_Chess
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: This is an interactive problem. ICPC Assiut Community decided to hold a unique chess contest, and you were chosen to control a queen and hunt down the hidden k...
1557_E. Assiut Chess
codeforces
E
[{"input": "1\nLeft\nRight\nDone", "output": "1 1\n1 2\n1 3\n", "testtype": "stdin"}]
[{"input": "60\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n4 7\n", "...
{}
1558_C._Bottom-Tier_Reversals
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: You have a permutation: an array a = [a_1, a_2, …, a_n] of distinct integers from 1 to n. The length of the permutation n is odd. You need to sort the permutat...
1558_C. Bottom-Tier Reversals
codeforces
C
[{"input": "3\n3\n1 2 3\n5\n3 4 5 2 1\n3\n2 1 3\n", "output": "5\n3 1 3 3 3 \n10\n3 1 3 3 5 3 1 3 3 3 \n-1\n", "testtype": "stdin"}]
[]
{}
1558_D._Top-Notch_Insertions
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: Consider the insertion sort algorithm used to sort an integer sequence [a_1, a_2, …, a_n] of length n in non-decreasing order. For each i in order from 2 to n,...
1558_D. Top-Notch Insertions
codeforces
D
[{"input": "3\n3 0\n3 2\n2 1\n3 1\n5 3\n3 1\n4 1\n5 3\n", "output": "10\n1\n21\n", "testtype": "stdin"}]
[]
{}
1558_E._Down_Below
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: In a certain video game, the player controls a hero characterized by a single integer value: power. On the current level, the hero got into a system of n caves...
1558_E. Down Below
codeforces
E
[{"input": "3\n4 4\n11 22 13\n8 7 5\n1 2\n2 3\n3 4\n4 1\n4 4\n11 22 13\n5 7 8\n1 2\n2 3\n3 4\n4 1\n5 7\n10 40 20 30\n7 2 10 5\n1 2\n1 5\n2 3\n2 4\n2 5\n3 4\n4 5\n", "output": "15\n15\n19\n", "testtype": "stdin"}]
[{"input": "2\n3 3\n1 1\n1 1\n1 2\n2 3\n3 1\n10 12\n10 10 10 10 10 10 12345 10 10\n10 10 10 10 10 10 10 10 10\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 4\n4 8\n8 1\n5 9\n9 10\n10 5\n", "output": "2\n12266\n", "testtype": "stdin"}]
{}
1559_A._Mocha_and_Math
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: Mocha is a young girl from high school. She has learned so much interesting knowledge from her teachers, especially her math teacher. Recently, Mocha is learnin...
1559_A. Mocha and Math
codeforces
A
[{"input": "4\n2\n1 2\n3\n1 1 3\n4\n3 11 3 7\n5\n11 7 15 3 7\n", "output": "0\n1\n3\n3\n", "testtype": "stdin"}]
[{"input": "1\n2\n1 1\n", "output": "1\n", "testtype": "stdin"}, {"input": "1\n1\n123\n", "output": "123\n", "testtype": "stdin"}, {"input": "1\n1\n1\n", "output": "1\n", "testtype": "stdin"}, {"input": "3\n8\n1 3 6 12 24 48 96 192\n15\n1 3 6 12 24 48 96 192 96 48 24 12 6 3 1\n6\n47 7 21 21 21 21\n", "output": "0\n0\n5...
{}
1559_B._Mocha_and_Red_and_Blue
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: As their story unravels, a timeless tale is told once again... Shirahime, a friend of Mocha's, is keen on playing the music game Arcaea and sharing Mocha inter...
1559_B. Mocha and Red and Blue
codeforces
B
[{"input": "5\n7\n?R???BR\n7\n???R???\n1\n?\n1\nB\n10\n?R??RB??B?\n", "output": "BRBRBBR\nBRBRBRB\nB\nB\nBRBRRBRBBR\n", "testtype": "stdin"}]
[{"input": "5\n7\n?R???BR\n7\n???R???\n1\n?\n1\nB\n10\n?R??RB??B?\n", "output": "BRBRBBR\nBRBRBRB\nB\nB\nBRBRRBRBBR\n", "testtype": "stdin"}, {"input": "1\n2\n??\n", "output": "BR\n", "testtype": "stdin"}]
{}
1559_C._Mocha_and_Hiking
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: The city where Mocha lives in is called Zhijiang. There are n+1 villages and 2n-1 directed roads in this city. There are two kinds of roads: * n-1 roads ar...
1559_C. Mocha and Hiking
codeforces
C
[{"input": "2\n3\n0 1 0\n3\n1 1 0\n", "output": "1 2 3 4\n1 2 3 4\n", "testtype": "stdin"}]
[{"input": "1\n3\n1 1 1\n", "output": "4 1 2 3 \n", "testtype": "stdin"}, {"input": "1\n5\n1 1 1 1 1\n", "output": "6 1 2 3 4 5 \n", "testtype": "stdin"}, {"input": "1\n4\n1 1 1 1\n", "output": "5 1 2 3 4 \n", "testtype": "stdin"}, {"input": "2\n1\n1\n1\n0\n", "output": "2 1 \n1 2\n", "testtype": "stdin"}, {"input": "1...
{}
1559_D1._Mocha_and_Diana_Easy_Version
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: This is the easy version of the problem. The only difference between the two versions is the constraint on n. You can make hacks only if all versions of the pro...
1559_D1. Mocha and Diana (Easy Version)
codeforces
D
[{"input": "8 1 2\n1 7\n2 6\n1 5\n", "output": "5\n1 2\n1 3\n1 4\n1 8\n5 7\n", "testtype": "stdin"}, {"input": "5 3 2\n5 4\n2 1\n4 3\n4 3\n1 4\n", "output": "1\n1 5\n", "testtype": "stdin"}, {"input": "3 2 2\n1 2\n2 3\n1 2\n1 3\n", "output": "0\n", "testtype": "stdin"}]
[{"input": "1000 14 13\n714 839\n350 175\n221 401\n76 388\n264 539\n3 990\n781 304\n500 155\n471 694\n879 88\n742 729\n657 993\n294 647\n148 839\n640 877\n168 119\n481 113\n655 959\n22 79\n196 482\n112 362\n606 341\n558 847\n528 723\n105 481\n189 413\n510 155\n", "output": "985\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n1 9\n...
{}
1559_D2._Mocha_and_Diana_Hard_Version
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: This is the hard version of the problem. The only difference between the two versions is the constraint on n. You can make hacks only if all versions of the pro...
1559_D2. Mocha and Diana (Hard Version)
codeforces
D
[{"input": "3 2 2\n1 2\n2 3\n1 2\n1 3\n", "output": "0\n", "testtype": "stdin"}, {"input": "5 3 2\n5 4\n2 1\n4 3\n4 3\n1 4\n", "output": "1\n1 5\n", "testtype": "stdin"}, {"input": "8 1 2\n1 7\n2 6\n1 5\n", "output": "5\n1 2\n1 3\n1 4\n1 8\n5 7\n", "testtype": "stdin"}]
[{"input": "100 10 9\n34 53\n72 57\n66 76\n24 2\n80 2\n80 63\n70 34\n71 48\n91 9\n73 3\n32 29\n73 38\n87 66\n19 28\n19 86\n77 5\n14 83\n67 26\n93 30\n", "output": "89\n1 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 25\n1 26\n1 27\n1 29\n1 30...
{}
1559_E._Mocha_and_Stars
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: Mocha wants to be an astrologer. There are n stars which can be seen in Zhijiang, and the brightness of the i-th star is a_i. Mocha considers that these n sta...
1559_E. Mocha and Stars
codeforces
E
[{"input": "5 10\n1 10\n1 10\n1 10\n1 10\n1 10\n", "output": "251\n", "testtype": "stdin"}, {"input": "2 4\n1 3\n1 2\n", "output": "4\n", "testtype": "stdin"}, {"input": "5 100\n1 94\n1 96\n1 91\n4 96\n6 97\n", "output": "47464146\n", "testtype": "stdin"}]
[{"input": "50 10000\n6 9997\n7 9999\n8 9998\n2 10000\n7 9999\n10 10000\n1 9992\n7 9998\n2 9992\n7 10000\n9 9999\n2 9998\n3 10000\n7 9999\n4 9998\n3 9997\n1 9994\n4 10000\n8 10000\n7 9998\n5 9995\n9 9999\n2 9998\n5 10000\n2 9998\n2 9996\n10 10000\n5 9999\n5 9995\n9 10000\n8 9999\n7 9997\n4 9994\n5 9999\n1 9991\n8 9998\...
{}
1560_A._Dislike_of_Threes
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: 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 ...
1560_A. Dislike of Threes
codeforces
A
[{"input": "10\n1\n2\n3\n4\n5\n6\n7\n8\n9\n1000\n", "output": "1\n2\n4\n5\n7\n8\n10\n11\n14\n1666\n", "testtype": "stdin"}]
[{"input": "1\n5\n", "output": "7\n", "testtype": "stdin"}, {"input": "100\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n971\n972\n973\n974\n975\n976\n977\n978\n979\n980\n981\n982\n983\n984\n985\n986\n987\n988\n989\n990\n991\n992\n993\n994\n995\n996\n997...
{}
1560_B._Who_s_Opposite
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: Some number of people (this number is even) have stood in a circle. The people stand in the circle evenly. They are numbered clockwise starting from a person wi...
1560_B. Who's Opposite?
codeforces
B
[{"input": "7\n6 2 4\n2 3 1\n2 4 10\n5 3 4\n1 3 2\n2 5 4\n4 3 2\n", "output": "8\n-1\n-1\n-1\n4\n1\n-1\n", "testtype": "stdin"}]
[{"input": "1\n4440444 1 5\n", "output": "4440448\n", "testtype": "stdin"}, {"input": "1\n1110333 6 7\n", "output": "1110334\n", "testtype": "stdin"}, {"input": "1\n777777 3 4\n", "output": "777778\n", "testtype": "stdin"}, {"input": "1\n9990111 6 3\n", "output": "9990108\n", "testtype": "stdin"}, {"input": "1\n9999991...
{}
1560_C._Infinity_Table
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: Polycarp has found a table having an infinite number of rows and columns. The rows are numbered from 1, starting from the topmost one. The columns are numbered ...
1560_C. Infinity Table
codeforces
C
[{"input": "7\n11\n14\n5\n4\n1\n2\n1000000000\n", "output": "2 4\n4 3\n1 3\n2 1\n1 1\n1 2\n31623 14130\n", "testtype": "stdin"}]
[{"input": "1\n9865\n", "output": "64 100\n", "testtype": "stdin"}, {"input": "99\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n49\n50\n51\n52\n53\n54\n55\n56\n57\n58\n59\n60\n61\n62...
{}
1560_D._Make_a_Power_of_Two
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: You are given an integer n. In 1 move, you can do one of the following actions: * erase any digit of the number (it's acceptable that the number before the o...
1560_D. Make a Power of Two
codeforces
D
[{"input": "12\n1052\n8888\n6\n75\n128\n1\n301\n12048\n1504\n6656\n1000000000\n687194767\n", "output": "2\n3\n1\n3\n0\n0\n2\n1\n3\n4\n9\n2\n", "testtype": "stdin"}]
[{"input": "1\n1\n", "output": "0\n", "testtype": "stdin"}, {"input": "1\n99999\n", "output": "6\n", "testtype": "stdin"}, {"input": "3\n1\n1\n1\n", "output": "0\n0\n0\n", "testtype": "stdin"}, {"input": "2\n1\n1\n", "output": "0\n0\n", "testtype": "stdin"}]
{}
1560_E._Polycarp_and_String_Transformation
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: Polycarp has a string s. Polycarp performs the following actions until the string s is empty (t is initially an empty string): * he adds to the right to the ...
1560_E. Polycarp and String Transformation
codeforces
E
[{"input": "7\nabacabaaacaac\nnowyouknowthat\npolycarppoycarppoyarppyarppyrpprppp\nisi\neverywherevrywhrvryhrvrhrvhv\nhaaha\nqweqeewew\n", "output": "abacaba bac\n-1\npolycarp lcoayrp\nis si\neverywhere ewyrhv\n-1\n-1\n", "testtype": "stdin"}]
[]
{}
1560_F1._Nearest_Beautiful_Number_easy_version
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: It is a simplified version of problem F2. The difference between them is the constraints (F1: k ≤ 2, F2: k ≤ 10). You are given an integer n. Find the minimum ...
1560_F1. Nearest Beautiful Number (easy version)
codeforces
F
[{"input": "4\n1 1\n221 2\n177890 2\n998244353 1\n", "output": "1\n221\n181111\n999999999\n", "testtype": "stdin"}]
[{"input": "1\n9994444 1\n", "output": "9999999\n", "testtype": "stdin"}, {"input": "1\n88884444 1\n", "output": "88888888\n", "testtype": "stdin"}]
{}
1560_F2._Nearest_Beautiful_Number_hard_version
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: It is a complicated version of problem F1. The difference between them is the constraints (F1: k ≤ 2, F2: k ≤ 10). You are given an integer n. Find the minimum...
1560_F2. Nearest Beautiful Number (hard version)
codeforces
F
[{"input": "6\n2021 3\n177890 2\n34512 3\n724533 4\n998244353 1\n12345678 10\n", "output": "2021\n181111\n34533\n724542\n999999999\n12345678\n", "testtype": "stdin"}]
[{"input": "1\n11110999 3\n", "output": "11110999\n", "testtype": "stdin"}, {"input": "1\n3330099 2\n", "output": "3330300\n", "testtype": "stdin"}, {"input": "1\n3330999 3\n", "output": "3330999\n", "testtype": "stdin"}, {"input": "1\n114514 9\n", "output": "114514\n", "testtype": "stdin"}, {"input": "1\n5550099 2\n",...
{}
1561_A._Simply_Strange_Sort
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: You have a permutation: an array a = [a_1, a_2, …, a_n] of distinct integers from 1 to n. The length of the permutation n is odd. Consider the following algori...
1561_A. Simply Strange Sort
codeforces
A
[{"input": "3\n3\n3 2 1\n7\n4 5 7 1 3 2 6\n5\n1 2 3 4 5\n", "output": "3\n5\n0\n", "testtype": "stdin"}]
[]
{}
1561_B._Charmed_by_the_Game
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: Alice and Borys are playing tennis. A tennis match consists of games. In each game, one of the players is serving and the other one is receiving. Players serv...
1561_B. Charmed by the Game
codeforces
B
[{"input": "3\n2 1\n1 1\n0 5\n", "output": "4\n0 1 2 3 \n2\n0 2 \n2\n2 3 \n", "testtype": "stdin"}]
[{"input": "2\n99999 0\n0 99999\n", "output": "2\n49999 50000 \n2\n49999 50000 \n", "testtype": "stdin"}, {"input": "2\n99999 1\n1 99999\n", "output": "2\n49999 50001 \n2\n49999 50001 \n", "testtype": "stdin"}, {"input": "2\n0 100000\n100000 0\n", "output": "1\n50000 \n1\n50000 \n", "testtype": "stdin"}, {"input": "2\n...
{}
1561_C._Deep_Down_Below
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: In a certain video game, the player controls a hero characterized by a single integer value: power. The hero will have to beat monsters that are also characteri...
1561_C. Deep Down Below
codeforces
C
[{"input": "2\n1\n1 42\n2\n3 10 15 8\n2 12 11\n", "output": "43\n13\n", "testtype": "stdin"}]
[]
{}
1561_D1._Up_the_Strip_simplified_version
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: This version of the problem differs from the next one only in the constraint on n. Note that the memory limit in this problem is lower than in others. You hav...
1561_D1. Up the Strip (simplified version)
codeforces
D
[{"input": "5 998244353\n", "output": "25", "testtype": "stdin"}, {"input": "42 998244353\n", "output": "793019428", "testtype": "stdin"}, {"input": "3 998244353\n", "output": "5", "testtype": "stdin"}]
[{"input": "6 732284177\n", "output": "55", "testtype": "stdin"}, {"input": "634 982032773\n", "output": "695544646", "testtype": "stdin"}, {"input": "199862 999999937\n", "output": "750469605", "testtype": "stdin"}, {"input": "2 554714911\n", "output": "2", "testtype": "stdin"}, {"input": "124953 922406879\n", "output...
{}
1561_D2._Up_the_Strip
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: Note that the memory limit in this problem is lower than in others. You have a vertical strip with n cells, numbered consecutively from 1 to n from top to bott...
1561_D2. Up the Strip
codeforces
D
[{"input": "3 998244353\n", "output": "5", "testtype": "stdin"}, {"input": "42 998244353\n", "output": "793019428", "testtype": "stdin"}, {"input": "787788 100000007\n", "output": "94810539", "testtype": "stdin"}, {"input": "5 998244353\n", "output": "25", "testtype": "stdin"}]
[{"input": "2 872207251\n", "output": "2", "testtype": "stdin"}, {"input": "182550 383331199\n", "output": "234598461", "testtype": "stdin"}, {"input": "47 318786553\n", "output": "134462650", "testtype": "stdin"}, {"input": "363 418169771\n", "output": "65078475", "testtype": "stdin"}, {"input": "3912472 178711691\n",...
{}
1562_A._The_Miracle_and_the_Sleeper
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: You are given two integers l and r, l≤ r. Find the largest possible value of a mod b over all pairs (a, b) of integers for which r≥ a ≥ b ≥ l. As a reminder, a...
1562_A. The Miracle and the Sleeper
codeforces
A
[{"input": "4\n1 1\n999999999 1000000000\n8 26\n1 999999999\n", "output": "0\n1\n12\n499999999\n", "testtype": "stdin"}]
[]
{}
1562_B._Scenes_From_a_Memory
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: During the hypnosis session, Nicholas suddenly remembered a positive integer n, which doesn't contain zeros in decimal notation. Soon, when he returned home, ...
1562_B. Scenes From a Memory
codeforces
B
[{"input": "7\n3\n237\n5\n44444\n3\n221\n2\n35\n3\n773\n1\n4\n30\n626221626221626221626221626221\n", "output": "2\n27\n1\n4\n1\n1\n2\n35\n2\n77\n1\n4\n1\n6\n", "testtype": "stdin"}]
[{"input": "1\n2\n77\n", "output": "2\n77\n", "testtype": "stdin"}]
{}
1562_C._Rings
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: Frodo was caught by Saruman. He tore a pouch from Frodo's neck, shook out its contents —there was a pile of different rings: gold and silver... "How am I to te...
1562_C. Rings
codeforces
C
[{"input": "7\n6\n101111\n9\n111000111\n8\n10000000\n5\n11011\n6\n001111\n3\n101\n30\n100000000000000100000000000000\n", "output": "2 6 3 6\n4 9 5 9\n2 8 3 8\n1 3 1 2\n1 6 2 6\n1 2 1 1\n2 30 3 30\n", "testtype": "stdin"}]
[{"input": "7\n6\n101111\n9\n111000111\n8\n10000000\n5\n11011\n6\n001111\n3\n101\n30\n100000000000000100000000000000\n", "output": "2 6 3 6\n4 9 5 9\n2 8 3 8\n1 3 1 2\n1 6 2 6\n1 2 1 1\n2 30 3 30\n", "testtype": "stdin"}]
{}
1562_D1._Two_Hundred_Twenty_One_easy_version
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: This is the easy version of the problem. The difference between the versions is that the easy version does not require you to output the numbers of the rods to ...
1562_D1. Two Hundred Twenty One (easy version)
codeforces
D
[{"input": "3\n14 1\n+--++---++-++-\n1 14\n14 3\n+--++---+++---\n1 14\n6 12\n3 10\n4 10\n+-+-\n1 1\n1 2\n1 3\n1 4\n2 2\n2 3\n2 4\n3 3\n3 4\n4 4\n", "output": "2\n2\n1\n0\n1\n2\n1\n2\n1\n2\n1\n1\n2\n1\n", "testtype": "stdin"}]
[]
{}
1562_D2._Two_Hundred_Twenty_One_hard_version
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: This is the hard version of the problem. The difference between the versions is that the hard version does require you to output the numbers of the rods to be r...
1562_D2. Two Hundred Twenty One (hard version)
codeforces
D
[{"input": "3\n14 1\n+--++---++-++-\n1 14\n14 3\n+--++---+++---\n1 14\n6 12\n3 10\n4 10\n+-+-\n1 1\n1 2\n1 3\n1 4\n2 2\n2 3\n2 4\n3 3\n3 4\n4 4\n", "output": "2\n1 2\n2\n1 9\n1\n9\n0\n1\n1\n2\n1 2\n1\n2\n2\n1 3\n1\n2\n2\n2 3\n1\n3\n1\n3\n2\n3 4\n1\n4\n", "testtype": "stdin"}]
[{"input": "3\n14 1\n+--++---++-++-\n1 14\n14 3\n+--++---+++---\n1 14\n6 12\n3 10\n4 10\n+-+-\n1 1\n1 2\n1 3\n1 4\n2 2\n2 3\n2 4\n3 3\n3 4\n4 4\n", "output": "2\n1 2\n2\n1 9\n1\n9\n0\n1\n1\n2\n1 2\n1\n2\n2\n1 3\n1\n2\n2\n2 3\n1\n3\n1\n3\n2\n3 4\n1\n4\n", "testtype": "stdin"}]
{}
1562_E._Rescue_Niwen
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: Morning desert sun horizon Rise above the sands of time... Fates Warning, "Exodus" After crossing the Windswept Wastes, Ori has finally reached the Windtorn ...
1562_E. Rescue Niwen!
codeforces
E
[{"input": "7\n5\nacbac\n8\nacabacba\n12\naaaaaaaaaaaa\n10\nabacabadac\n8\ndcbaabcd\n3\ncba\n6\nsparky\n", "output": "9\n17\n12\n29\n14\n3\n9\n", "testtype": "stdin"}]
[{"input": "1\n10\ngepardotop\n", "output": "27\n", "testtype": "stdin"}, {"input": "7\n1\na\n2\naa\n2\nab\n2\nba\n2\nbb\n26\nabcdefghijklmnopqrstuvwxyz\n26\nzyxwvutsrqponmlkjihgfedcba\n", "output": "1\n2\n3\n2\n2\n351\n26\n", "testtype": "stdin"}]
{}
1566_A._Median_Maximization
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: You are given two positive integers n and s. Find the maximum possible median of an array of n non-negative integers (not necessarily distinct), such that the s...
1566_A. Median Maximization
codeforces
A
[{"input": "8\n1 5\n2 5\n3 5\n2 1\n7 17\n4 14\n1 1000000000\n1000000000 1\n", "output": "5\n2\n2\n0\n4\n4\n1000000000\n0\n", "testtype": "stdin"}]
[]
{}
1566_B._MIN-MEX_Cut
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: A binary string is a string that consists of characters 0 and 1. Let \operatorname{MEX} of a binary string be the smallest digit among 0, 1, or 2 that does not...
1566_B. MIN-MEX Cut
codeforces
B
[{"input": "6\n01\n1111\n01100\n101\n0000\n01010\n", "output": "1\n0\n2\n1\n1\n2\n", "testtype": "stdin"}]
[]
{}
1566_C._MAX-MEX_Cut
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: A binary string is a string that consists of characters 0 and 1. A bi-table is a table that has exactly two rows of equal length, each being a binary string. L...
1566_C. MAX-MEX Cut
codeforces
C
[{"input": "4\n7\n0101000\n1101100\n5\n01100\n10101\n2\n01\n01\n6\n000000\n111111\n", "output": "8\n8\n2\n12\n", "testtype": "stdin"}]
[]
{}
1566_D1._Seating_Arrangements_easy_version
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: It is the easy version of the problem. The only difference is that in this version n = 1. In the cinema seats can be represented as the table with n rows and m...
1566_D1. Seating Arrangements (easy version)
codeforces
D
[{"input": "4\n1 3\n1 2 3\n1 5\n2 1 5 3 3\n1 2\n2 1\n1 6\n2 3 2 1 1 1\n", "output": "3\n6\n0\n1\n", "testtype": "stdin"}]
[]
{}
1566_D2._Seating_Arrangements_hard_version
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: It is the hard version of the problem. The only difference is that in this version 1 ≤ n ≤ 300. In the cinema seats can be represented as the table with n rows...
1566_D2. Seating Arrangements (hard version)
codeforces
D
[{"input": "7\n1 2\n1 2\n3 2\n1 1 2 2 3 3\n3 3\n3 4 4 1 1 1 1 1 2\n2 2\n1 1 2 1\n4 2\n50 50 50 50 3 50 50 50\n4 2\n6 6 6 6 2 2 9 6\n2 9\n1 3 3 3 3 3 1 1 3 1 3 1 1 3 3 1 1 3\n", "output": "1\n0\n4\n0\n0\n0\n1\n", "testtype": "stdin"}]
[]
{}
1566_E._Buds_Re-hanging
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: A tree is a connected graph without cycles. A rooted tree has a special vertex called the root. The parent of a vertex v (different from root) is the previous t...
1566_E. Buds Re-hanging
codeforces
E
[{"input": "5\n7\n1 2\n1 3\n1 4\n2 5\n2 6\n4 7\n6\n1 2\n1 3\n2 4\n2 5\n3 6\n2\n1 2\n7\n7 3\n1 5\n1 3\n4 6\n4 7\n2 1\n6\n2 1\n2 3\n4 5\n3 4\n3 6\n", "output": "2\n2\n1\n2\n1\n", "testtype": "stdin"}]
[]
{}
1566_F._Points_Movement
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: There are n points and m segments on the coordinate line. The initial coordinate of the i-th point is a_i. The endpoints of the j-th segment are l_j and r_j — l...
1566_F. Points Movement
codeforces
F
[{"input": "2\n4 11\n2 6 14 18\n0 3\n4 5\n11 15\n3 5\n10 13\n16 16\n1 4\n8 12\n17 19\n7 13\n14 19\n4 12\n-9 -16 12 3\n-20 -18\n-14 -13\n-10 -7\n-3 -1\n0 4\n6 11\n7 9\n8 10\n13 15\n14 18\n16 17\n18 19\n", "output": "5\n22\n", "testtype": "stdin"}]
[]
{}
1566_G._Four_Vertices
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: You are given an undirected weighted graph, consisting of n vertices and m edges. Some queries happen with this graph: * Delete an existing edge from the gr...
1566_G. Four Vertices
codeforces
G
[{"input": "6 6\n1 3 6\n4 3 1\n1 4 1\n2 6 4\n2 4 2\n5 4 3\n4\n1 2 5 2\n0 1 4\n0 3 4\n1 6 1 3\n", "output": "4\n3\n3\n7\n5\n", "testtype": "stdin"}]
[{"input": "100000 4\n93489 72442 764134104\n84918 15431 441437022\n15431 69065 51817176\n50985 69065 242704743\n0\n", "output": "684141765\n", "testtype": "stdin"}, {"input": "4 6\n3 1 442228919\n4 2 818678361\n4 1 236842689\n3 2 354486856\n1 2 680197301\n4 3 82662218\n0\n", "output": "591329545\n", "testtype": "stdin...
{}
1566_H._Xor-quiz
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: This is an interactive problem. You are given two integers c and n. The jury has a randomly generated set A of distinct positive integers not greater than c (i...
1566_H. Xor-quiz
codeforces
H
[{"input": "10 6\n\n1 4 2 11 4 4 4\n\n", "output": "7 1 2 3 5 6 7 10 \n", "testtype": "stdin"}]
[{"input": "104 48\n1 3 9 10 13 14 17 19 20 22 24 25 26 29 30 32 34 37 39 42 47 51 52 53 54 56 59 63 68 71 72 74 75 76 78 80 83 85 89 90 91 95 96 97 98 101 102 103\n", "output": "64 1 2 3 5 6 7 10 11 13 14 15 17 19 21 22 23 26 29 30 31 33 34 35 37 38 39 41 42 43 46 47 51 53 55 57 58 59 61 62 65 66 67 69 70 71 73 74 77 ...
{}
1567_B._MEXor_Mixup
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: Alice gave Bob two integers a and b (a > 0 and b ≥ 0). Being a curious boy, Bob wrote down an array of non-negative integers with \operatorname{MEX} value of al...
1567_B. MEXor Mixup
codeforces
B
[{"input": "5\n1 1\n2 1\n2 0\n1 10000\n2 10000\n", "output": "3\n2\n3\n2\n3\n", "testtype": "stdin"}]
[{"input": "1\n187994 180766\n", "output": "187995\n", "testtype": "stdin"}]
{}
1567_C._Carrying_Conundrum
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: Alice has just learned addition. However, she hasn't learned the concept of "carrying" fully — instead of carrying to the next column, she carries to the column...
1567_C. Carrying Conundrum
codeforces
C
[{"input": "5\n100\n12\n8\n2021\n10000\n", "output": "9\n4\n7\n44\n99\n", "testtype": "stdin"}]
[{"input": "1\n721156322\n", "output": "154725877\n", "testtype": "stdin"}, {"input": "2\n999999999\n1000000000\n", "output": "999999998\n9999\n", "testtype": "stdin"}]
{}
1567_D._Expression_Evaluation_Error
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: On the board, Bob wrote n positive integers in [base](https://en.wikipedia.org/wiki/Positional_notation#Base_of_the_numeral_system) 10 with sum s (i. e. in deci...
1567_D. Expression Evaluation Error
codeforces
D
[{"input": "6\n97 2\n17 1\n111 4\n100 2\n10 9\n999999 3\n", "output": "10 87\n17\n100 1 1 9\n10 90\n1 1 1 1 1 1 1 1 2\n100000 100000 799999\n", "testtype": "stdin"}]
[{"input": "6\n97 2\n17 1\n111 4\n100 2\n10 9\n999999 3\n", "output": "10 87\n17\n100 1 1 9\n10 90\n1 1 1 1 1 1 1 1 2\n100000 100000 799999\n", "testtype": "stdin"}, {"input": "1\n1 1\n", "output": "1\n", "testtype": "stdin"}]
{}
1567_E._Non-Decreasing_Dilemma
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: Alice has recently received an array a_1, a_2, ..., a_n for her birthday! She is very proud of her array, and when she showed her friend Bob the array, he was v...
1567_E. Non-Decreasing Dilemma
codeforces
E
[{"input": "5 6\n3 1 4 1 5\n2 2 5\n2 1 3\n1 4 4\n2 2 5\n1 2 6\n2 2 5\n", "output": "6\n4\n10\n7\n", "testtype": "stdin"}]
[{"input": "10 20\n1 9 15 26 8 4 25 24 23 14\n2 8 9\n1 8 20\n2 8 8\n1 6 21\n1 9 15\n2 8 10\n1 2 23\n1 10 4\n1 3 13\n2 6 7\n1 1 19\n1 1 18\n1 4 2\n2 5 5\n1 1 2\n1 6 17\n1 4 10\n1 7 5\n2 1 7\n1 9 28\n", "output": "2\n1\n3\n3\n1\n9\n", "testtype": "stdin"}]
{}
1567_F._One-Four_Overload
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: Alice has an empty grid with n rows and m columns. Some of the cells are marked, and no marked cells are adjacent to the edge of the grid. (Two squares are adja...
1567_F. One-Four Overload
codeforces
F
[{"input": "5 5\n.....\n.XXX.\n.X.X.\n.XXX.\n.....\n", "output": "YES\n1 1 1 1 1 \n4 5 5 5 4 \n1 5 4 5 1 \n1 5 5 5 1 \n1 4 1 4 1 \n", "testtype": "stdin"}, {"input": "3 2\n..\n..\n..\n", "output": "YES\n1 1 \n1 1 \n1 1 \n", "testtype": "stdin"}, {"input": "5 5\n.....\n.XXX.\n.XXX.\n.XXX.\n.....\n", "output": "NO\n", "t...
[{"input": "5 5\n.....\n.XXX.\n.X.X.\n.XXX.\n.....\n", "output": "YES\n1 1 1 1 1 \n4 5 5 5 4 \n1 5 4 5 1 \n1 5 5 5 1 \n1 4 1 4 1 \n", "testtype": "stdin"}, {"input": "9 9\n.........\n.XXXXX.X.\n.X...X...\n.X.XXXXX.\n.X.X.X.X.\n.X.XXX.X.\n.X.....X.\n.XXXXXXX.\n.........\n", "output": "YES\n1 1 1 1 1 1 1 1 1 \n4 5 5 5 5 ...
{}
1569_A._Balanced_Substring
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: You are given a string s, consisting of n letters, each letter is either 'a' or 'b'. The letters in the string are numbered from 1 to n. s[l; r] is a continuou...
1569_A. Balanced Substring
codeforces
A
[{"input": "4\n1\na\n6\nabbaba\n6\nabbaba\n9\nbabbabbaa\n", "output": "-1 -1\n1 2\n1 2\n1 2\n", "testtype": "stdin"}]
[{"input": "1\n30\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n", "output": "-1 -1\n", "testtype": "stdin"}, {"input": "1\n29\naaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n", "output": "-1 -1\n", "testtype": "stdin"}, {"input": "4\n1\na\n6\nabbaba\n6\nabbaba\n9\nbabbabbaa\n", "output": "-1 -1\n1 2\n1 2\n1 2\n", "testtype": "stdin"}]
{}
1569_B._Chess_Tournament
You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. Question: A chess tournament will be held soon, where n chess players will take part. Every participant will play one game against every other participant. Each game ends...
1569_B. Chess Tournament
codeforces
B
[{"input": "3\n3\n111\n2\n21\n4\n2122\n", "output": "YES\nX==\n=X=\n==X\nNO\nYES\nX=+-\n=X==\n-=X+\n+=-X\n", "testtype": "stdin"}]
[{"input": "3\n3\n111\n2\n21\n4\n2122\n", "output": "YES\nX==\n=X=\n==X\nNO\nYES\nX=+-\n=X==\n-=X+\n+=-X\n", "testtype": "stdin"}]
{}