sample_inputs stringlengths 5 384 | input_specification stringlengths 48 911 | src_uid stringlengths 32 32 | source_code stringlengths 29 6.77k | sample_outputs stringlengths 5 393 | lang_cluster stringclasses 4
values | notes stringlengths 30 1.52k ⌀ | output_specification stringlengths 25 681 | description stringlengths 140 2.49k | human_testcases stringlengths 243 50.8k | human_pass_rate float64 100 100 | human_line_coverage float64 100 100 | human_branch_coverage float64 100 100 | human_sample_testcases_1 stringlengths 190 3.11k | human_sample_testcases_2 stringlengths 190 3.11k | human_sample_testcases_3 stringlengths 190 3.11k | human_sample_testcases_4 stringlengths 190 3.11k | human_sample_testcases_5 stringlengths 190 3.11k | human_sample_pass_rate_1 float64 100 100 | human_sample_pass_rate_2 float64 100 100 | human_sample_pass_rate_3 float64 100 100 | human_sample_pass_rate_4 float64 100 100 | human_sample_pass_rate_5 float64 100 100 | human_sample_line_coverage_1 float64 52.2 100 | human_sample_line_coverage_2 float64 60 100 | human_sample_line_coverage_3 float64 50 100 | human_sample_line_coverage_4 float64 43.5 100 | human_sample_line_coverage_5 float64 21.7 100 | human_sample_branch_coverage_1 float64 45.5 100 | human_sample_branch_coverage_2 float64 45.8 100 | human_sample_branch_coverage_3 float64 16.7 100 | human_sample_branch_coverage_4 float64 36.4 100 | human_sample_branch_coverage_5 float64 18.2 100 | id int64 1 400 | human_sample_pass_rate float64 100 100 | human_sample_line_coverage float64 47 100 | human_sample_branch_coverage float64 41.8 100 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
["127", "130", "123456789101112131415161718192021222324"] | The first line contains a positive number n. It consists of no more than 100 digits and doesn't contain any leading zeros. The number n can't be represented as an empty string. Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cout (also you may use %I64d). | 33041f1832fa7f641e37c4c638ab08a1 | n = int(input())
if n >= -128 and n <= 127:
print("byte")
elif n >= -32768 and n <= 32767:
print("short")
elif n >= -2147483648 and n <= 2147483647:
print("int")
elif n >= -9223372036854775808 and n <= 9223372036854775807:
print("long")
else:
print("BigInteger") | ["byte", "short", "BigInteger"] | Python | null | Print the first type from the list "byte, short, int, long, BigInteger", that can store the natural number n, in accordance with the data given above. | Little Petya has recently started attending a programming club. Naturally he is facing the problem of choosing a programming language. After long considerations he realized that Java is the best choice. The main argument in favor of choosing Java was that it has a very large integer data type, called BigInteger.But hav... | [{"input": "127\r\n", "output": ["byte"]}, {"input": "130\r\n", "output": ["short"]}, {"input": "123456789101112131415161718192021222324\r\n", "output": ["BigInteger"]}, {"input": "6\r\n", "output": ["byte"]}, {"input": "16\r\n", "output": ["byte"]}, {"input": "126\r\n", "output": ["byte"]}, {"input": "128\r\n", "outpu... | 100 | 100 | 100 | [{'input': '130\r\n', 'output': ['short']}, {'input': '69113784278456828987289369893745977\r\n', 'output': ['BigInteger']}, {'input': '188808426143\r\n', 'output': ['long']}, {'input': '1658370691480968202384509492140362150472696196949\r\n', 'output': ['BigInteger']}, {'input': '2147483647\r\n', 'output': ['int']}] | [{'input': '1403681723783491968617491075591006152690484825330764215796396316561122383310011589365655481428540208\r\n', 'output': ['BigInteger']}, {'input': '4491137842784568289872893698937459777201151060689848471272003426250808340375567208957554901863756992\r\n', 'output': ['BigInteger']}, {'input': '16\r\n', 'output':... | [{'input': '1111111111111111111111111111111111111111111111\r\n', 'output': ['BigInteger']}, {'input': '32768\r\n', 'output': ['int']}, {'input': '4491137842784568289872893698937459777201151060689848471272003426250808340375567208957554901863756992\r\n', 'output': ['BigInteger']}, {'input': '32766\r\n', 'output': ['short... | [{'input': '4596620932866717074931903995027173085744596193421095444317407919730992986418713478580824584919587030\r\n', 'output': ['BigInteger']}, {'input': '221020945402270233\r\n', 'output': ['long']}, {'input': '8713549841568602590705962611607726022334779480510421458817648621376683672722573289661127894678771177\r\n',... | [{'input': '2334083498248924849764007740114454487565621932425948046430072197452845278935316358800789014185793377\r\n', 'output': ['BigInteger']}, {'input': '2147483648\r\n', 'output': ['long']}, {'input': '1988808426143782131983811729737047667239979348184409855460833141044812532916921011366813880911319644\r\n', 'output... | 100 | 100 | 100 | 100 | 100 | 90 | 80 | 80 | 70 | 70 | 87.5 | 75 | 75 | 62.5 | 62.5 | 301 | 100 | 78 | 72.5 |
["6\n1 3 4 5 6 9", "3\n998 999 1000", "5\n1 2 3 4 5"] | The first line of the input contains a single integer $$$n$$$ ($$$1 \le n \le 100$$$) — the number of elements in the array. The second line of the input contains $$$n$$$ integers $$$a_i$$$ ($$$1 \le a_1<a_2<\dots<a_n \le 10^3$$$) — the array written by Giraffe. | 858b5e75e21c4cba6d08f3f66be0c198 | n = int(input())
a = list(map(int,input().split()))
count=ans=0
if(n>=2 and a[0]==1 and a[1]==2):
count+=1
for i in range(1,n-1):
if(a[i-1]+1==a[i] and a[i+1]-1==a[i]):
count+=1
else:
ans=max(ans,count)
count=0
if(n>=2 and a[-1]==1000 and a[-2]==999):
count+=1
ans=max(count,ans)
print(ans) | ["2", "2", "4"] | Python | NoteIn the first example, JATC can erase the third and fourth elements, leaving the array $$$[1, 3, \_, \_, 6, 9]$$$. As you can see, there is only one way to fill in the blanks.In the second example, JATC can erase the second and the third elements. The array will become $$$[998, \_, \_]$$$. Because all the elements a... | Print a single integer — the maximum number of consecutive elements in the array that JATC can erase. If it is impossible to erase even a single element, print $$$0$$$. | JATC and his friend Giraffe are currently in their room, solving some problems. Giraffe has written on the board an array $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ of integers, such that $$$1 \le a_1 < a_2 < \ldots < a_n \le 10^3$$$, and then went to the bathroom.JATC decided to prank his friend by erasing some con... | [{"input": "6\r\n1 3 4 5 6 9\r\n", "output": ["2"]}, {"input": "3\r\n998 999 1000\r\n", "output": ["2"]}, {"input": "5\r\n1 2 3 4 5\r\n", "output": ["4"]}, {"input": "1\r\n1\r\n", "output": ["0"]}, {"input": "2\r\n1 2\r\n", "output": ["1"]}, {"input": "2\r\n999 1000\r\n", "output": ["1"]}, {"input": "9\r\n1 4 5 6 7 100... | 100 | 100 | 100 | [{'input': '2\r\n2 4\r\n', 'output': ['0']}, {'input': '4\r\n1 2 3 7\r\n', 'output': ['2']}, {'input': '4\r\n2 3 4 5\r\n', 'output': ['2']}, {'input': '8\r\n1 2 5 6 7 8 9 11\r\n', 'output': ['3']}, {'input': '4\r\n3 4 5 6\r\n', 'output': ['2']}] | [{'input': '8\r\n2 3 4 5 997 998 999 1000\r\n', 'output': ['3']}, {'input': '4\r\n3 4 5 6\r\n', 'output': ['2']}, {'input': '9\r\n1 2 3 4 6 7 9 10 12\r\n', 'output': ['3']}, {'input': '63\r\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 ... | [{'input': '6\r\n1 2 3 5 6 7\r\n', 'output': ['2']}, {'input': '2\r\n1 1000\r\n', 'output': ['0']}, {'input': '2\r\n998 999\r\n', 'output': ['0']}, {'input': '2\r\n3 4\r\n', 'output': ['0']}, {'input': '7\r\n1 2 3 4 6 7 8\r\n', 'output': ['3']}] | [{'input': '39\r\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39\r\n', 'output': ['38']}, {'input': '4\r\n2 3 4 5\r\n', 'output': ['2']}, {'input': '7\r\n2 4 6 997 998 999 1000\r\n', 'output': ['3']}, {'input': '7\r\n1 2 3 4 6 9 18\r\n', 'output': ['3']}, {'i... | [{'input': '7\r\n1 2 3 4 6 7 8\r\n', 'output': ['3']}, {'input': '7\r\n2 3 4 6 997 998 999\r\n', 'output': ['1']}, {'input': '45\r\n145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 333 334 831 832 978 979 980 981\r\n', 'o... | 100 | 100 | 100 | 100 | 100 | 92.86 | 100 | 92.86 | 100 | 92.86 | 87.5 | 100 | 87.5 | 100 | 87.5 | 302 | 100 | 95.716 | 92.5 |
["3 6", "3 4"] | The only line contains two integers p and y (2 ≤ p ≤ y ≤ 109). | b533203f488fa4caf105f3f46dd5844d | p, y = [int(x) for x in input().split()]
res = -1
for i in range(y, p, -1):
flag = True
for a in range(2, min(p+1, int(i**0.5)+1)):
if i % a == 0:
flag = False
break
if flag:
res = i
break
print(res)
| ["5", "-1"] | Python | NoteIn the first sample case grasshopper from branch 2 reaches branches 2, 4 and 6 while branch 3 is initially settled by another grasshopper. Therefore the answer is 5.It immediately follows that there are no valid branches in second sample case. | Output the number of the highest suitable branch. If there are none, print -1 instead. | The weather is fine today and hence it's high time to climb the nearby pine and enjoy the landscape.The pine's trunk includes several branches, located one above another and numbered from 2 to y. Some of them (more precise, from 2 to p) are occupied by tiny vile grasshoppers which you're at war with. These grasshoppers... | [{"input": "3 6\r\n", "output": ["5"]}, {"input": "3 4\r\n", "output": ["-1"]}, {"input": "2 2\r\n", "output": ["-1"]}, {"input": "5 50\r\n", "output": ["49"]}, {"input": "944192806 944193066\r\n", "output": ["944192807"]}, {"input": "1000000000 1000000000\r\n", "output": ["-1"]}, {"input": "2 1000000000\r\n", "output"... | 100 | 100 | 100 | [{'input': '1541 834270209\r\n', 'output': ['834270209']}, {'input': '8793 950327842\r\n', 'output': ['950327831']}, {'input': '171837140 733094070\r\n', 'output': ['733094069']}, {'input': '649229491 965270051\r\n', 'output': ['965270051']}, {'input': '4 5\r\n', 'output': ['5']}] | [{'input': '404 28122086\r\n', 'output': ['28122079']}, {'input': '31333 981756889\r\n', 'output': ['981756871']}, {'input': '19137 476450875\r\n', 'output': ['476450861']}, {'input': '287894773 723316271\r\n', 'output': ['723316207']}, {'input': '5 50\r\n', 'output': ['49']}] | [{'input': '649229491 965270051\r\n', 'output': ['965270051']}, {'input': '404 28122086\r\n', 'output': ['28122079']}, {'input': '356423140 385941420\r\n', 'output': ['385941419']}, {'input': '20869 786360384\r\n', 'output': ['786360373']}, {'input': '3888 723508350\r\n', 'output': ['723508301']}] | [{'input': '3 4\r\n', 'output': ['-1']}, {'input': '14078 607450717\r\n', 'output': ['607450703']}, {'input': '37839169 350746807\r\n', 'output': ['350746727']}, {'input': '13067 350746807\r\n', 'output': ['350746727']}, {'input': '8699 234689174\r\n', 'output': ['234689137']}] | [{'input': '944192806 944193066\r\n', 'output': ['944192807']}, {'input': '2 7\r\n', 'output': ['7']}, {'input': '19137 476450875\r\n', 'output': ['476450861']}, {'input': '20869 786360384\r\n', 'output': ['786360373']}, {'input': '469621113 834270209\r\n', 'output': ['834270209']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 90 | 90 | 90 | 100 | 90 | 303 | 100 | 100 | 92 |
["monday\ntuesday", "sunday\nsunday", "saturday\ntuesday"] | The input consists of two lines, each of them containing the name of exactly one day of the week. It's guaranteed that each string in the input is from the set "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday". | 2a75f68a7374b90b80bb362c6ead9a35 | s1=input()
s2=input()
week=["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"]
if week[(week.index(s1)+31)%7]==s2:print("YES")
elif week[(week.index(s1)+28)%7]==s2:print("YES")
elif week[(week.index(s1)+30)%7]==s2:print("YES")
else:print("NO") | ["NO", "YES", "YES"] | Python | NoteIn the second sample, one can consider February 1 and March 1 of year 2015. Both these days were Sundays.In the third sample, one can consider July 1 and August 1 of year 2017. First of these two days is Saturday, while the second one is Tuesday. | Print "YES" (without quotes) if such situation is possible during some non-leap year. Otherwise, print "NO" (without quotes). | You are given names of two days of the week.Please, determine whether it is possible that during some non-leap year the first day of some month was equal to the first day of the week you are given, while the first day of the next month was equal to the second day of the week you are given. Both months should belong to ... | [{"input": "monday\r\ntuesday\r\n", "output": ["NO"]}, {"input": "sunday\r\nsunday\r\n", "output": ["YES"]}, {"input": "saturday\r\ntuesday\r\n", "output": ["YES"]}, {"input": "tuesday\r\nthursday\r\n", "output": ["YES"]}, {"input": "friday\r\nwednesday\r\n", "output": ["NO"]}, {"input": "sunday\r\nsaturday\r\n", "outp... | 100 | 100 | 100 | [{'input': 'friday\r\nthursday\r\n', 'output': ['NO']}, {'input': 'tuesday\r\nwednesday\r\n', 'output': ['NO']}, {'input': 'thursday\r\nmonday\r\n', 'output': ['NO']}, {'input': 'wednesday\r\nmonday\r\n', 'output': ['NO']}, {'input': 'tuesday\r\nsaturday\r\n', 'output': ['NO']}] | [{'input': 'monday\r\nsaturday\r\n', 'output': ['NO']}, {'input': 'tuesday\r\nmonday\r\n', 'output': ['NO']}, {'input': 'friday\r\nmonday\r\n', 'output': ['YES']}, {'input': 'monday\r\nsunday\r\n', 'output': ['NO']}, {'input': 'wednesday\r\nmonday\r\n', 'output': ['NO']}] | [{'input': 'friday\r\nwednesday\r\n', 'output': ['NO']}, {'input': 'saturday\r\nsunday\r\n', 'output': ['NO']}, {'input': 'thursday\r\ntuesday\r\n', 'output': ['NO']}, {'input': 'saturday\r\nmonday\r\n', 'output': ['YES']}, {'input': 'wednesday\r\ntuesday\r\n', 'output': ['NO']}] | [{'input': 'thursday\r\nthursday\r\n', 'output': ['YES']}, {'input': 'tuesday\r\ntuesday\r\n', 'output': ['YES']}, {'input': 'friday\r\nsunday\r\n', 'output': ['YES']}, {'input': 'wednesday\r\nmonday\r\n', 'output': ['NO']}, {'input': 'sunday\r\nfriday\r\n', 'output': ['NO']}] | [{'input': 'friday\r\nfriday\r\n', 'output': ['YES']}, {'input': 'tuesday\r\nwednesday\r\n', 'output': ['NO']}, {'input': 'monday\r\nsunday\r\n', 'output': ['NO']}, {'input': 'thursday\r\nwednesday\r\n', 'output': ['NO']}, {'input': 'wednesday\r\nsunday\r\n', 'output': ['NO']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 50 | 66.67 | 66.67 | 83.33 | 66.67 | 304 | 100 | 100 | 66.668 |
["X0X\n.0.\n.X."] | The input consists of three lines, each of the lines contains characters ".", "X" or "0" (a period, a capital letter X, or a digit zero). | 892680e26369325fb00d15543a96192c | def win(l,s):
if l[0] == [s, s, s] or l[1] == [s, s, s] or l[2] == [s, s, s] or l[0][0] == s and l[1][0] == s and l[2][0] == s or \
l[0][1] == s and l[1][1] == s and l[2][1] == s or l[0][2] == s and l[1][2] == s and l[2][2] == s or l[0][
0] == s and l[1][1] == s and l[2][2] == s or l[0][2] == s ... | ["second"] | Python | null | Print one of the six verdicts: first, second, illegal, the first player won, the second player won or draw. | Certainly, everyone is familiar with tic-tac-toe game. The rules are very simple indeed. Two players take turns marking the cells in a 3 × 3 grid (one player always draws crosses, the other — noughts). The player who succeeds first in placing three of his marks in a horizontal, vertical or diagonal line wins, and the g... | [{"input": "X0X\r\n.0.\r\n.X.\r\n", "output": ["second"]}, {"input": "0.X\r\nXX.\r\n000\r\n", "output": ["illegal"]}, {"input": "XXX\r\n.0.\r\n000\r\n", "output": ["illegal"]}, {"input": "XXX\r\n...\r\n000\r\n", "output": ["illegal"]}, {"input": "X.X\r\nX..\r\n00.\r\n", "output": ["second"]}, {"input": "X.X\r\nX.0\r\n0... | 100 | 100 | 100 | [{'input': 'X.0\r\n00.\r\nXXX\r\n', 'output': ['the first player won']}, {'input': 'X0.\r\n00.\r\nXXX\r\n', 'output': ['the first player won']}, {'input': '.0X\r\n.00\r\n00.\r\n', 'output': ['illegal']}, {'input': '..X\r\n0X.\r\n.0.\r\n', 'output': ['first']}, {'input': '00.\r\nX0.\r\n..X\r\n', 'output': ['illegal']}] | [{'input': '0..\r\n000\r\n...\r\n', 'output': ['illegal']}, {'input': '.0.\r\n00.\r\n00.\r\n', 'output': ['illegal']}, {'input': '0X0\r\nX00\r\nXXX\r\n', 'output': ['the first player won']}, {'input': 'X00\r\n0.X\r\nX..\r\n', 'output': ['first']}, {'input': '0X.\r\n.X.\r\n0X0\r\n', 'output': ['illegal']}] | [{'input': '0X0\r\nX..\r\nX.0\r\n', 'output': ['first']}, {'input': '.0X\r\n.X.\r\nX.0\r\n', 'output': ['the first player won']}, {'input': '.0.\r\n.X0\r\nX..\r\n', 'output': ['first']}, {'input': 'X.X\r\nX.0\r\n0.0\r\n', 'output': ['first']}, {'input': '.0.\r\n.00\r\nX00\r\n', 'output': ['illegal']}] | [{'input': 'X..\r\n.X0\r\nX0.\r\n', 'output': ['second']}, {'input': '.00\r\nX0.\r\n00X\r\n', 'output': ['illegal']}, {'input': '...\r\n.X.\r\n...\r\n', 'output': ['second']}, {'input': 'XXX\r\n0.0\r\n0..\r\n', 'output': ['illegal']}, {'input': '0.0\r\n0.X\r\nXXX\r\n', 'output': ['the first player won']}] | [{'input': '000\r\nX.X\r\nX.X\r\n', 'output': ['illegal']}, {'input': 'X00\r\n00X\r\nXXX\r\n', 'output': ['the first player won']}, {'input': '000\r\n000\r\n000\r\n', 'output': ['illegal']}, {'input': 'XX0\r\n0..\r\n000\r\n', 'output': ['illegal']}, {'input': '..0\r\nXX.\r\n00X\r\n', 'output': ['first']}] | 100 | 100 | 100 | 100 | 100 | 84.62 | 88.46 | 84.62 | 88.46 | 88.46 | 71.43 | 78.57 | 71.43 | 78.57 | 78.57 | 305 | 100 | 86.924 | 75.714 |
["10\nrocesfedoc", "16\nplmaetwoxesisiht", "1\nz"] | The first line of input consists of a single integer $$$n$$$ ($$$1 \le n \le 100$$$) — the length of the string $$$t$$$. The second line of input consists of the string $$$t$$$. The length of $$$t$$$ is $$$n$$$, and it consists only of lowercase Latin letters. | 1b0b2ee44c63cb0634cb63f2ad65cdd3 | a = int(input())
s = list(input())
b = []
for i in range(a, 1, -1):
if a % i == 0:
b.append(i)
for i in range(len(b)-1, -1, -1):
s[0:b[i]] = reversed(s[0:b[i]])
s = "".join(s)
print(s) | ["codeforces", "thisisexampletwo", "z"] | Python | NoteThe first example is described in the problem statement. | Print a string $$$s$$$ such that the above algorithm results in $$$t$$$. | A string $$$s$$$ of length $$$n$$$ can be encrypted by the following algorithm: iterate over all divisors of $$$n$$$ in decreasing order (i.e. from $$$n$$$ to $$$1$$$), for each divisor $$$d$$$, reverse the substring $$$s[1 \dots d]$$$ (i.e. the substring which starts at position $$$1$$$ and ends at position $$$d$$$)... | [{"input": "10\r\nrocesfedoc\r\n", "output": ["codeforces"]}, {"input": "16\r\nplmaetwoxesisiht\r\n", "output": ["thisisexampletwo"]}, {"input": "1\r\nz\r\n", "output": ["z"]}, {"input": "2\r\nir\r\n", "output": ["ri"]}, {"input": "3\r\nilj\r\n", "output": ["jli"]}, {"input": "4\r\njfyy\r\n", "output": ["yyjf"]}, {"inp... | 100 | 100 | 100 | [{'input': '96\r\nqtbcksuvxonzbkokhqlgkrvimzqmqnrvqlihrmksldyydacbtckfphenxszcnzhfjmpeykrvshgiboivkvabhrpphgavvprz\r\n', 'output': ['zrpvvaghpprhbavkviobighsvrkyepmjfhznczsxnehpfkctvrnqmqzmkokbvuctqbksxonzhqlgkrviqlihrmksldyydacb']}, {'input': '100\r\noooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo... | [{'input': '97\r\nfwffffffffffffffffffffffffrffffffffffffffzfffffffffffffffftfcfffffffqffffffffffffffffffffffyfffff\r\n', 'output': ['fffffyffffffffffffffffffffffqfffffffcftffffffffffffffffzffffffffffffffrffffffffffffffffffffffffwf']}, {'input': '16\r\nplmaetwoxesisiht\r\n', 'output': ['thisisexampletwo']}, {'input': '... | [{'input': '6\r\nkrdych\r\n', 'output': ['hcyrkd']}, {'input': '100\r\nedykhvzcntljuuoqghptioetqnfllwekzohiuaxelgecabvsbibgqodqxvyfkbyjwtgbyhvssntinkwsinwsmalusiwnjmtcoovf\r\n', 'output': ['fvooctmjnwisulamswniswknitnssvhybgtwjybkfyvxqdoqgbqteoitnczvkyedhljuuoqghptnfllwekzohiuaxelgecabvsbi']}, {'input': '10\r\nrocesfed... | [{'input': '100\r\ndjjjjjjjjjjgjjjjjjjjjjjjjjsvjjjjjjjjjjmjjjjjjjjjjjjjajjjjjjajjjjjjrjjjjjjjjjjjjrjjtjjjjjjjjjjjjjojjj\r\n', 'output': ['jjjojjjjjjjjjjjjjtjjrjjjjjjjjjjjjrjjjjjjajjjjjjajjjjjjjjjjjjjjdjjjgjjjjjjjjjsvjjjjjjjjjjmjjjjjjjjjjj']}, {'input': '99\r\nqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq... | [{'input': '60\r\nfnebsopcvmlaoecpzmakqigyuutueuozjxutlwwiochekmhjgwxsgfbcrpqj\r\n', 'output': ['jqprcbfgsxwgjhmkehcoiwwltuxjzokamzpalobnfespcvmoecqigyuutueu']}, {'input': '99\r\nqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\r\n', 'output': ['qqqqqqqqqqqqqqqqqqqqqqq... | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 306 | 100 | 100 | 100 |
["3 3", "6 5", "1000000000 1"] | The only line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^9$$$, $$$1 \le m \le 1000$$$) — the size of the field and the number of parts to split the sets into. | 2ec9e7cddc634d7830575e14363a4657 | n, m = [int(i) for i in input().split()]
ans = 0
ar = [n // m] * m
for i in range(1, n % m + 1, 1):
ar[i] += 1
for i in range(m):
for j in range(m):
if ((i * i + j * j) % m == 0):
ans += ar[i] * ar[j]
print(ans) | ["1", "13", "1000000000000000000"] | Python | NoteIn the first example, only the set for cell $$$(3, 3)$$$ can be split equally ($$$3^2 + 3^2 = 18$$$, which is divisible by $$$m=3$$$).In the second example, the sets for the following cells can be divided equally: $$$(1, 2)$$$ and $$$(2, 1)$$$, since $$$1^2 + 2^2 = 5$$$, which is divisible by $$$5$$$; $$$(1, 3)$... | Print a single integer — the number of sets that can be split equally. | Arkady and his friends love playing checkers on an $$$n \times n$$$ field. The rows and the columns of the field are enumerated from $$$1$$$ to $$$n$$$.The friends have recently won a championship, so Arkady wants to please them with some candies. Remembering an old parable (but not its moral), Arkady wants to give to ... | [{"input": "3 3\r\n", "output": ["1"]}, {"input": "6 5\r\n", "output": ["13"]}, {"input": "1000000000 1\r\n", "output": ["1000000000000000000"]}, {"input": "1 1\r\n", "output": ["1"]}, {"input": "1000000000 81\r\n", "output": ["12345678987654321"]}, {"input": "10000 1\r\n", "output": ["100000000"]}, {"input": "10000 2\... | 100 | 100 | 100 | [{'input': '15 1000\r\n', 'output': ['0']}, {'input': '1000000000 81\r\n', 'output': ['12345678987654321']}, {'input': '10 200\r\n', 'output': ['1']}, {'input': '100 100\r\n', 'output': ['260']}, {'input': '3 3\r\n', 'output': ['1']}] | [{'input': '100 100\r\n', 'output': ['260']}, {'input': '10000 2\r\n', 'output': ['50000000']}, {'input': '15 1000\r\n', 'output': ['0']}, {'input': '12345 1\r\n', 'output': ['152399025']}, {'input': '1 10\r\n', 'output': ['0']}] | [{'input': '1 2\r\n', 'output': ['1']}, {'input': '360 900\r\n', 'output': ['374']}, {'input': '15 1000\r\n', 'output': ['0']}, {'input': '10000 3\r\n', 'output': ['11108889']}, {'input': '3 3\r\n', 'output': ['1']}] | [{'input': '1 2\r\n', 'output': ['1']}, {'input': '3 3\r\n', 'output': ['1']}, {'input': '6 5\r\n', 'output': ['13']}, {'input': '10000 5\r\n', 'output': ['36000000']}, {'input': '1 1\r\n', 'output': ['1']}] | [{'input': '999999999 228\r\n', 'output': ['76946738381041']}, {'input': '10000 1\r\n', 'output': ['100000000']}, {'input': '10 200\r\n', 'output': ['1']}, {'input': '10000 2\r\n', 'output': ['50000000']}, {'input': '360 900\r\n', 'output': ['374']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 307 | 100 | 100 | 100 |
["Is it a melon?", "Is it an apple?", "Is it a banana ?", "Is it an apple and a banana simultaneouSLY?"] | The single line contains a question represented by a non-empty line consisting of large and small Latin letters, spaces and a question mark. The line length does not exceed 100. It is guaranteed that the question mark occurs exactly once in the line — as the last symbol and that the line contains at least one letter. | dea7eb04e086a4c1b3924eff255b9648 | s = input()
vowels = 'aeiouyAEIOUY'
if s.split()[-1] == '?':
if s.split()[-2][-1] in vowels:
print('YES')
else:
print('NO')
else:
if s.split()[-1][:-1][-1] in vowels:
print('YES')
else:
print('NO') | ["NO", "YES", "YES", "YES"] | Python | null | Print answer for the question in a single line: YES if the answer is "Yes", NO if the answer is "No". Remember that in the reply to the question the last letter, not the last character counts. I. e. the spaces and the question mark do not count as letters. | Vasya plays the sleuth with his friends. The rules of the game are as follows: those who play for the first time, that is Vasya is the sleuth, he should investigate a "crime" and find out what is happening. He can ask any questions whatsoever that can be answered with "Yes" or "No". All the rest agree beforehand to ans... | [{"input": "Is it a melon?\r\n", "output": ["NO"]}, {"input": "Is it an apple?\r\n", "output": ["YES"]}, {"input": " Is it a banana ?\r\n", "output": ["YES"]}, {"input": "Is it an apple and a banana simultaneouSLY?\r\n", "output": ["YES"]}, {"input": "oHtSbDwzHb?\r\n", "output": ["NO"]}, {"input": "sZecYdUvZ... | 100 | 100 | 100 | [{'input': ' q ?\r\n', 'output': ['NO']}, {'input': 'wmztmzFfwbGyOmNHENUFMTsFEMWYA?\r\n', 'output': ['YES']}, {'input': ' j ?\r\n', 'output': ['NO']}, {'input': 'YhCuZnrWUBEed?\r\n', 'output': ['NO... | [{'input': 'iehvZNQXDGCuVmJPOEysLyUryTdfaIxIuTzTadDbqRQGoCLXkxnyfWSGoLXebNnQQNTqAQJebbyYvHOfpUnXeWdjx?\r\n', 'output': ['NO']}, {'input': 'n?\r\n', 'output': ['NO']}, {'input': ' T ?\r\n', 'output': ['NO']}, {'input': 'gxzXbdcAQMuFKuuiPohtMgeypr w... | [{'input': 'iehvZNQXDGCuVmJPOEysLyUryTdfaIxIuTzTadDbqRQGoCLXkxnyfWSGoLXebNnQQNTqAQJebbyYvHOfpUnXeWdjx?\r\n', 'output': ['NO']}, {'input': 'mCDHENXjYbgMdBimAdPnewaHfpGWowjWrVAdvWczjw iDcUbyzMsmsnwbviiKiAyGVA?\r\n', 'output': ['YES']}, {'input': 'GlEmEPKrYcOnBNJUIFjszWUyVdvWw DGDjoCMtRJUburkPToCyDrOtMr?\r\n', 'output': ... | [{'input': 'wGsfZCSwN PEUhNUrLfABrxA?\r\n', 'output': ['YES']}, {'input': 'fgwg?\r\n', 'output': ['NO']}, {'input': 'n?\r\n', 'output': ['NO']}, {'input': ' T ?\r\n', 'output': ['NO']}, {'input': 'U?\r\n', 'output': ['YES']}] | [{'input': 'BueDOlxgzeNlxrzRrMbKiQdmGujEKmGxclvaPpTuHmTqBp?\r\n', 'output': ['NO']}, {'input': ' j ?\r\n', 'output': ['NO']}, {'input': 'FQXBisXaJFMiHFQlXjixBDMaQuIbyqSBKGsBfTmBKCjszlGVZxEOqYYqRTUkGpSDDAoOXyXcQbHcPaegeOUBNeS... | 100 | 100 | 100 | 100 | 100 | 88.89 | 77.78 | 66.67 | 88.89 | 88.89 | 83.33 | 66.67 | 50 | 83.33 | 83.33 | 308 | 100 | 82.224 | 73.332 |
["4", "6"] | The first line of the input contains integer n (1 ≤ n ≤ 1000). | 62db589bad3b7023418107de05b7a8ee | P = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]
def power(a, b):
res = 1
while (b):
if (b & 1): res *= a
a *= a
b >>= 1
return res
ans = []
ans.append(1e30)
def solve(pos, n, res):
if (n == 1):
ans[0] = min(ans[0], res)
for i in range(2, 62):
if (n % i == 0):
solve(pos + 1, n / i, res * p... | ["6", "12"] | Python | null | Output the smallest positive integer with exactly n divisors. | Given the number n, find the smallest positive integer which has exactly n divisors. It is guaranteed that for the given n the answer will not exceed 1018. | [{"input": "1\r\n", "output": ["1"]}, {"input": "7\r\n", "output": ["64"]}, {"input": "8\r\n", "output": ["24"]}, {"input": "9\r\n", "output": ["36"]}, {"input": "10\r\n", "output": ["48"]}, {"input": "15\r\n", "output": ["144"]}, {"input": "20\r\n", "output": ["240"]}, {"input": "47\r\n", "output": ["70368744177664"]}... | 100 | 100 | 100 | [{'input': '902\r\n', 'output': ['324625310542725120']}, {'input': '20\r\n', 'output': ['240']}, {'input': '7\r\n', 'output': ['64']}, {'input': '118\r\n', 'output': ['864691128455135232']}, {'input': '265\r\n', 'output': ['364791569817010176']}] | [{'input': '159\r\n', 'output': ['40532396646334464']}, {'input': '10\r\n', 'output': ['48']}, {'input': '265\r\n', 'output': ['364791569817010176']}, {'input': '720\r\n', 'output': ['61261200']}, {'input': '902\r\n', 'output': ['324625310542725120']}] | [{'input': '8\r\n', 'output': ['24']}, {'input': '7\r\n', 'output': ['64']}, {'input': '100\r\n', 'output': ['45360']}, {'input': '312\r\n', 'output': ['14192640']}, {'input': '720\r\n', 'output': ['61261200']}] | [{'input': '1000\r\n', 'output': ['810810000']}, {'input': '15\r\n', 'output': ['144']}, {'input': '10\r\n', 'output': ['48']}, {'input': '1\r\n', 'output': ['1']}, {'input': '9\r\n', 'output': ['36']}] | [{'input': '265\r\n', 'output': ['364791569817010176']}, {'input': '637\r\n', 'output': ['46656000000']}, {'input': '15\r\n', 'output': ['144']}, {'input': '10\r\n', 'output': ['48']}, {'input': '47\r\n', 'output': ['70368744177664']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 309 | 100 | 100 | 100 |
[".......A\n........\n........\n........\n........\n........\n........\nM.......", ".......A\n........\n........\n........\n........\n........\nSS......\nM.......", ".......A\n........\n........\n........\n........\n.S......\nS.......\nMS......"] | You are given the 8 strings whose length equals 8, describing the initial position on the board. The first line represents the top row of the board, the next one — for the second from the top, and so on, the last line represents the bottom row. Each character string matches a single cell board in the appropriate row, a... | f47e4ab041288ba9567c19930eb9a090 | r, s = [63], ''.join(input() + 'T' for i in range(8)) + 'T' * 9
for i in range(0, 72, 9):
t = set()
for x in r:
for y in (x, x - 1, x + 1, x - 9, x + 9, x - 10, x - 8, x + 10, x + 8):
if s[y] == 'T': continue
if (y < i or s[y - i] != 'S') and (y < i + 9 or s[y - i - 9] != 'S'): t... | ["WIN", "LOSE", "LOSE"] | Python | null | If Maria wins, print string "WIN". If the statues win, print string "LOSE". | In this task Anna and Maria play a game with a very unpleasant rival. Anna and Maria are in the opposite squares of a chessboard (8 × 8): Anna is in the upper right corner, and Maria is in the lower left one. Apart from them, the board has several statues. Each statue occupies exactly one square. A square that contains... | [{"input": ".......A\r\n........\r\n........\r\n........\r\n........\r\n........\r\n........\r\nM.......\r\n", "output": ["WIN"]}, {"input": ".......A\r\n........\r\n........\r\n........\r\n........\r\n........\r\nSS......\r\nM.......\r\n", "output": ["LOSE"]}, {"input": ".......A\r\n........\r\n........\r\n........\r\... | 100 | 100 | 100 | [{'input': 'SSSSSSSA\r\nSS.SSSSS\r\nSSSSSSSS\r\nSSSSSSSS\r\nS..SS.SS\r\nSSSS.SSS\r\nSSSS.SSS\r\nM.SSS.SS\r\n', 'output': ['LOSE']}, {'input': 'SSSSSSSA\r\nSSS.SSSS\r\nSSSSSSSS\r\nSSS.SSSS\r\nSSSSSSSS\r\nSSSSSSSS\r\nSSSSSSSS\r\nMSSSS.SS\r\n', 'output': ['LOSE']}, {'input': '.......A\r\n........\r\n........\r\n........\r... | [{'input': '.......A\r\n........\r\n........\r\n........\r\nS.......\r\n.SSSSSSS\r\nS.......\r\nM.......\r\n', 'output': ['LOSE']}, {'input': '.S.S.S.A\r\n.SS.S..S\r\n..S....S\r\n..S.....\r\nSSS.S...\r\n.S....S.\r\nSSSSSS..\r\nM..S....\r\n', 'output': ['LOSE']}, {'input': 'SSSSSSSA\r\nSSSSSSSS\r\nSSSSSSSS\r\nSSSSSSSS\r... | [{'input': '.......A\r\n........\r\n........\r\n........\r\n........\r\n.SSSSSSS\r\nS.......\r\nM.......\r\n', 'output': ['WIN']}, {'input': '...S...A\r\n........\r\n..S..S.S\r\n.S....S.\r\nS.......\r\n..S.S..S\r\n......S.\r\nM..SS..S\r\n', 'output': ['WIN']}, {'input': '.......A\r\nS.S.S.S.\r\n........\r\n.S.S.S.S\r\n... | [{'input': '.....S.A\r\n...S.S..\r\n.....S..\r\n........\r\n........\r\n........\r\n......S.\r\nM....S..\r\n', 'output': ['WIN']}, {'input': '.S.S..SA\r\n.S...S.S\r\nS....S..\r\n...S....\r\n.S.SSSSS\r\nS.....SS\r\n.S.S.SSS\r\nM....S.S\r\n', 'output': ['LOSE']}, {'input': '.......A\r\n...S...S\r\n...S....\r\n....S..S\r\... | [{'input': '.......A\r\n....S...\r\n........\r\n........\r\n........\r\n........\r\n.S......\r\nM.......\r\n', 'output': ['WIN']}, {'input': '.......A\r\nS.S.S.S.\r\n........\r\n.S.S.S.S\r\n........\r\nS.S.S.S.\r\n........\r\nMS.S.S.S\r\n', 'output': ['WIN']}, {'input': '.S.S.S.A\r\n.SS.S..S\r\n..S....S\r\n..S.....\r\n... | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 310 | 100 | 100 | 100 |
["2 2 1 1", "1 2 1 2"] | The only line contains four integers $$$n$$$, $$$m$$$, $$$L$$$ and $$$R$$$ ($$$1\le n,m,L,R \le 10^9$$$, $$$L \le R$$$, $$$n \cdot m \ge 2$$$). | ded299fa1cd010822c60f2389a3ba1a3 | n, m, L, R = map(int, input().split())
mod = 998244353
if n*m % 2:
print(pow(R-L+1, n*m, mod))
else:
print((pow(R-L+1, n*m, mod) + 1 - (R-L) % 2) * pow(2, mod-2, mod) % mod) | ["1", "2"] | Python | NoteIn the first sample, the only initial grid that satisfies the requirements is $$$a_{1,1}=a_{2,1}=a_{1,2}=a_{2,2}=1$$$. Thus the answer should be $$$1$$$.In the second sample, initial grids that satisfy the requirements are $$$a_{1,1}=a_{1,2}=1$$$ and $$$a_{1,1}=a_{1,2}=2$$$. Thus the answer should be $$$2$$$. | Output one integer, representing the desired answer modulo $$$998,244,353$$$. | Alice has got addicted to a game called Sirtet recently.In Sirtet, player is given an $$$n \times m$$$ grid. Initially $$$a_{i,j}$$$ cubes are stacked up in the cell $$$(i,j)$$$. Two cells are called adjacent if they share a side. Player can perform the following operations: stack up one cube in two adjacent cells; ... | [{"input": "2 2 1 1\r\n", "output": ["1"]}, {"input": "1 2 1 2\r\n", "output": ["2"]}, {"input": "485 117 386829368 748204956\r\n", "output": ["735420370"]}, {"input": "564 558 305171115 960941497\r\n", "output": ["880111542"]}, {"input": "692 210 44175861 843331069\r\n", "output": ["714028205"]}, {"input": "741 806 42... | 100 | 100 | 100 | [{'input': '3 2 2 5\r\n', 'output': ['2048']}, {'input': '646353335 282521795 600933409 772270276\r\n', 'output': ['13680108']}, {'input': '461 650 18427925 104278996\r\n', 'output': ['936348652']}, {'input': '999999999 999999999 1 998244353\r\n', 'output': ['0']}, {'input': '2 3 3 4\r\n', 'output': ['32']}] | [{'input': '268120620 443100795 102749301 604856694\r\n', 'output': ['834319192']}, {'input': '2 3 3 5\r\n', 'output': ['365']}, {'input': '795069900 869551950 803936044 964554424\r\n', 'output': ['884379548']}, {'input': '202669473 255300152 987865366 994537507\r\n', 'output': ['926661352']}, {'input': '124919287 5785... | [{'input': '824436759 415879151 194713963 293553316\r\n', 'output': ['453443939']}, {'input': '2 3 2 4\r\n', 'output': ['365']}, {'input': '63719735 431492981 971536712 994663491\r\n', 'output': ['97582142']}, {'input': '741 806 424647372 965259389\r\n', 'output': ['861647194']}, {'input': '1 1000000000 1 1000000000\r\... | [{'input': '564 558 305171115 960941497\r\n', 'output': ['880111542']}, {'input': '999999999 999999999 1 998244353\r\n', 'output': ['0']}, {'input': '3 3 3 4\r\n', 'output': ['512']}, {'input': '1 2 1 2\r\n', 'output': ['2']}, {'input': '2 2 1 998244353\r\n', 'output': ['499122177']}] | [{'input': '3 2 3 4\r\n', 'output': ['32']}, {'input': '3 2 2 4\r\n', 'output': ['365']}, {'input': '63719735 431492981 971536712 994663491\r\n', 'output': ['97582142']}, {'input': '3 3 3 4\r\n', 'output': ['512']}, {'input': '2 3 1 998244353\r\n', 'output': ['499122177']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 311 | 100 | 100 | 100 |
["0 1 1 0 0 0 0 0 0 7 0 0 0 0", "5 1 1 1 1 0 0 0 0 0 0 0 0 0"] | The only line contains 14 integers $$$a_1, a_2, \ldots, a_{14}$$$ ($$$0 \leq a_i \leq 10^9$$$) — the number of stones in each hole. It is guaranteed that for any $$$i$$$ ($$$1\leq i \leq 14$$$) $$$a_i$$$ is either zero or odd, and there is at least one stone in the board. | 1ac11153e35509e755ea15f1d57d156b | A=list(map(int,input().split()))
score=0
for i in range(14):
score=max(score,sum([j for j in [(A[j] if i!=j else 0)+A[i]//14+(1 if (j+13-i)%14<A[i]%14 else 0) for j in range(14)] if j%2==0]))
print(score)
| ["4", "8"] | Python | NoteIn the first test case the board after the move from the hole with $$$7$$$ stones will look like 1 2 2 0 0 0 0 0 0 0 1 1 1 1. Then the player collects the even numbers and ends up with a score equal to $$$4$$$. | Output one integer, the maximum possible score after one move. | Mancala is a game famous in the Middle East. It is played on a board that consists of 14 holes. Initially, each hole has $$$a_i$$$ stones. When a player makes a move, he chooses a hole which contains a positive number of stones. He takes all the stones inside it and then redistributes these stones one by one in the n... | [{"input": "0 1 1 0 0 0 0 0 0 7 0 0 0 0\r\n", "output": ["4"]}, {"input": "5 1 1 1 1 0 0 0 0 0 0 0 0 0\r\n", "output": ["8"]}, {"input": "10001 10001 10001 10001 10001 10001 10001 10001 10001 10001 10001 10001 10001 1\r\n", "output": ["54294"]}, {"input": "0 0 0 0 0 0 0 0 0 0 0 0 0 15\r\n", "output": ["2"]}, {"input": ... | 100 | 100 | 100 | [{'input': '475989857 930834747 786217439 927967137 489188151 869354161 276693267 56154399 131055697 509249443 143116853 426254423 44465165 105798821\r\n', 'output': ['6172339560']}, {'input': '360122921 409370351 226220005 604004145 85173909 600403773 624052991 138163383 729239967 189036661 619842883 270087537 7495004... | [{'input': '1 0 0 0 0 1 0 0 0 0 1 0 0 0\r\n', 'output': ['0']}, {'input': '590789361 636464947 404477303 337309187 476703809 426863069 120608741 703406277 645444697 761482231 996635839 33459441 677458865 483861751\r\n', 'output': ['7294965518']}, {'input': '170651077 730658441 824213789 583764177 129437345 717005779 67... | [{'input': '1 1 0 0 0 0 0 0 0 0 0 0 0 0\r\n', 'output': ['2']}, {'input': '0 1 1 0 0 0 0 0 0 7 0 0 0 0\r\n', 'output': ['4']}, {'input': '105413505 105413505 105413505 105413505 105413505 105413505 105413505 105413505 105413505 105413505 105413505 105413505 105413505 105413505\r\n', 'output': ['120472578']}, {'input': ... | [{'input': '787 393 649 463 803 365 81 961 989 531 303 407 579 915\r\n', 'output': ['7588']}, {'input': '590789361 636464947 404477303 337309187 476703809 426863069 120608741 703406277 645444697 761482231 996635839 33459441 677458865 483861751\r\n', 'output': ['7294965518']}, {'input': '105413505 105413505 105413505 10... | [{'input': '1 1 1 1 1 1 1 1 1 1 1 1 1 1\r\n', 'output': ['2']}, {'input': '0 0 0 0 0 0 0 0 0 0 0 0 1 1\r\n', 'output': ['2']}, {'input': '787 393 649 463 803 365 81 961 989 531 303 407 579 915\r\n', 'output': ['7588']}, {'input': '0 1 1 0 0 0 0 0 0 7 0 0 0 0\r\n', 'output': ['4']}, {'input': '5 1 1 1 1 0 0 0 0 0 0 0 0 ... | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 312 | 100 | 100 | 100 |
["abcd", "ababa", "zzz"] | The first input line contains the string. It's guaranteed, that the string is non-empty, consists of lower-case Latin letters, and its length doesn't exceed 100. | 13b5cf94f2fabd053375a5ccf3fd44c7 | S = input()
ans = 0
met = set()
for i in range(len(S)):
for j in range(i, -1, -1):
if S[j:i+1] in met:
ans = max(ans, i - j + 1)
else:
met.add(S[j:i+1])
print(ans) | ["0", "3", "2"] | Python | null | Output one number — length of the longest substring that can be met in the string at least twice. | You're given a string of lower-case Latin letters. Your task is to find the length of its longest substring that can be met in the string at least twice. These occurrences can overlap (see sample test 2). | [{"input": "abcd\r\n", "output": ["0"]}, {"input": "ababa\r\n", "output": ["3"]}, {"input": "zzz\r\n", "output": ["2"]}, {"input": "kmmm\r\n", "output": ["2"]}, {"input": "wzznz\r\n", "output": ["1"]}, {"input": "qlzazaaqll\r\n", "output": ["2"]}, {"input": "lzggglgpep\r\n", "output": ["2"]}, {"input": "iegdlraaidefgeg... | 100 | 100 | 100 | [{'input': 'abcd\r\n', 'output': ['0']}, {'input': 'rrrrrrrrrrrrrrrrrrrlhbrrrrrrrrurrrrrrrfrrqrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrewrrrrrrryrrxrrrrrrrrrrr\r\n', 'output': ['33']}, {'input': 'ababa\r\n', 'output': ['3']}, {'input': 'ikiikiikikiiikkkkkikkkkiiiiikkiiikkiikiikkkkikkkikikkikiiikkikikiiikikkkiiikkkikkikkikkkki... | [{'input': 'qlzazaaqll\r\n', 'output': ['2']}, {'input': 'kmmm\r\n', 'output': ['2']}, {'input': 'qqqmqqqsbteqqopsuqiqumrqzpqnqgqeniqqkyqqyqqqpxzqeqqquhdqquhqqqfqjirqaqqaquxqoqqjqqqqbjbgqcqqqqicnkqc\r\n', 'output': ['4']}, {'input': 'a\r\n', 'output': ['0']}, {'input': 'ipsrjylhpkjvlzncfixipstwcicxqygqcfrawpzzvckoveyqh... | [{'input': 'lrqrrrrrrrjrrrrrcdrrgrrmwvrrrrrrrrrxfzrmrmrryrrrurrrdrrrrrrrrrrererrrsrrrrrrrrrrrqrrrrcrrwjsrrlrrrrr\r\n', 'output': ['10']}, {'input': 'kkcckkccckkcckcccckcckkkkcckkkkckkkcckckkkkkckkkkkcckkccckkcckcccckcckkkkcckkkkckkkcckckkkkkckckckkc\r\n', 'output': ['46']}, {'input': 'jpkkgwklngwqcfzmwkkpcwkkkkkekkkekk... | [{'input': 'ipsrjylhpkjvlzncfixipstwcicxqygqcfrawpzzvckoveyqhathglblhpkjvlzncfixipfajaqobtzvthmhgbuawoxoknirclxg\r\n', 'output': ['15']}, {'input': 'tttttbttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttmttttttt\r\n', 'output': ['85']}, {'input': 'wzznz\r\n', 'output': ['1']}, {'in... | [{'input': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaasaaaavaaaaaaauaaeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n', 'output': ['44']}, {'input': 'cbubbbbbbbbbbfbbbbbbbbjbobbbbbbbbbbibbubbbbjbbbnzgbbzbbfbbbbbbbbbbbfbpbbbbbbbbbbygbbbgbabbbbbbbhibbb\r\n', 'output': ['12']}, {'input': 'qqqmqqqsbteqqopsuqiqumrqzpqnqgqeni... | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 313 | 100 | 100 | 100 |
["10 5", "-10 5"] | The first line contains two integers x, y ( - 109 ≤ x, y ≤ 109, x ≠ 0, y ≠ 0). | e2f15a9d9593eec2e19be3140a847712 | x,y = map(int,input().split())
if x > 0 and y > 0:
print(0, x + y, x + y, 0)
elif x < 0 and y > 0:
print(-y + x, 0, 0,-x + y)
elif x > 0 and y < 0:
print(0, y - x, x - y, 0)
else:
print(x + y, 0,0, x + y)
| ["0 15 15 0", "-15 0 0 15"] | Python | NoteFigure to the first sample | Print in the single line four integers x1, y1, x2, y2 — the coordinates of the required points. | Vasily the bear has a favorite rectangle, it has one vertex at point (0, 0), and the opposite vertex at point (x, y). Of course, the sides of Vasya's favorite rectangle are parallel to the coordinate axes. Vasya also loves triangles, if the triangles have one vertex at point B = (0, 0). That's why today he asks you to ... | [{"input": "10 5\r\n", "output": ["0 15 15 0"]}, {"input": "-10 5\r\n", "output": ["-15 0 0 15"]}, {"input": "20 -10\r\n", "output": ["0 -30 30 0"]}, {"input": "-10 -1000000000\r\n", "output": ["-1000000010 0 0 -1000000010"]}, {"input": "-1000000000 -1000000000\r\n", "output": ["-2000000000 0 0 -2000000000"]}, {"input"... | 100 | 100 | 100 | [{'input': '1000000000 1\r\n', 'output': ['0 1000000001 1000000001 0']}, {'input': '-10 5\r\n', 'output': ['-15 0 0 15']}, {'input': '1000000000 -1\r\n', 'output': ['0 -1000000001 1000000001 0']}, {'input': '42 -2\r\n', 'output': ['0 -44 44 0']}, {'input': '1 -1\r\n', 'output': ['0 -2 2 0']}] | [{'input': '-10 -1000000000\r\n', 'output': ['-1000000010 0 0 -1000000010']}, {'input': '-10 5\r\n', 'output': ['-15 0 0 15']}, {'input': '-999999999 1000000000\r\n', 'output': ['-1999999999 0 0 1999999999']}, {'input': '-1000000000 -999999999\r\n', 'output': ['-1999999999 0 0 -1999999999']}, {'input': '10 5\r\n', 'out... | [{'input': '-1000000000 -1\r\n', 'output': ['-1000000001 0 0 -1000000001']}, {'input': '-1 1\r\n', 'output': ['-2 0 0 2']}, {'input': '-10 -1000000000\r\n', 'output': ['-1000000010 0 0 -1000000010']}, {'input': '999999999 1000000000\r\n', 'output': ['0 1999999999 1999999999 0']}, {'input': '-1000000000 999999999\r\n', ... | [{'input': '2 -435\r\n', 'output': ['0 -437 437 0']}, {'input': '1000000000 1\r\n', 'output': ['0 1000000001 1000000001 0']}, {'input': '54543 432423\r\n', 'output': ['0 486966 486966 0']}, {'input': '20 -10\r\n', 'output': ['0 -30 30 0']}, {'input': '-1 1\r\n', 'output': ['-2 0 0 2']}] | [{'input': '76 -76\r\n', 'output': ['0 -152 152 0']}, {'input': '20 -10\r\n', 'output': ['0 -30 30 0']}, {'input': '-123131 3123141\r\n', 'output': ['-3246272 0 0 3246272']}, {'input': '1000000000 999999999\r\n', 'output': ['0 1999999999 1999999999 0']}, {'input': '1321 -23131\r\n', 'output': ['0 -24452 24452 0']}] | 100 | 100 | 100 | 100 | 100 | 87.5 | 87.5 | 87.5 | 87.5 | 87.5 | 83.33 | 83.33 | 83.33 | 83.33 | 83.33 | 314 | 100 | 87.5 | 83.33 |
["4 4 0\n2 1 2", "5 6 1\n2 7 2", "3 3 3\n2 2 2"] | The first line of the input contains three integers a, b and c (0 ≤ a, b, c ≤ 1 000 000) — the number of blue, violet and orange spheres that are in the magician's disposal. The second line of the input contains three integers, x, y and z (0 ≤ x, y, z ≤ 1 000 000) — the number of blue, violet and orange spheres that he... | 1db4ba9dc1000e26532bb73336cf12c3 | a, b, c =[int(q) for q in input().split()]
x, y, z =[int(q) for q in input().split()]
if a>=x:
a -=x
x=0
else:
x -=a
a=0
if b>=y:
b -=y
y=0
else:
y -=b
b=0
if c>=z:
c -=z
z=0
else:
z -=c
c=0
if x+y+z<=a//2+b//2+c//2:
print("Yes")
else:
print("No") | ["Yes", "No", "Yes"] | Python | NoteIn the first sample the wizard has 4 blue and 4 violet spheres. In his first action he can turn two blue spheres into one violet one. After that he will have 2 blue and 5 violet spheres. Then he turns 4 violet spheres into 2 orange spheres and he ends up with 2 blue, 1 violet and 2 orange spheres, which is exactly ... | If the wizard is able to obtain the required numbers of spheres, print "Yes". Otherwise, print "No". | Carl is a beginner magician. He has a blue, b violet and c orange magic spheres. In one move he can transform two spheres of the same color into one sphere of any other color. To make a spell that has never been seen before, he needs at least x blue, y violet and z orange spheres. Can he get them (possible, in multiple... | [{"input": "4 4 0\r\n2 1 2\r\n", "output": ["YES", "Yes"]}, {"input": "5 6 1\r\n2 7 2\r\n", "output": ["No", "NO"]}, {"input": "3 3 3\r\n2 2 2\r\n", "output": ["YES", "Yes"]}, {"input": "0 0 0\r\n0 0 0\r\n", "output": ["YES", "Yes"]}, {"input": "0 0 0\r\n0 0 1\r\n", "output": ["No", "NO"]}, {"input": "0 1 0\r\n0 0 0\r\... | 100 | 100 | 100 | [{'input': '438332 298094 225324\r\n194220 400244 245231\r\n', 'output': ['No', 'NO']}, {'input': '438576 124465 629784\r\n375118 276028 390116\r\n', 'output': ['YES', 'Yes']}, {'input': '0 10 10\r\n10 0 0\r\n', 'output': ['YES', 'Yes']}, {'input': '1 3 1\r\n2 1 1\r\n', 'output': ['YES', 'Yes']}, {'input': '2 2 1\r\n1 ... | [{'input': '4 0 3\r\n2 2 1\r\n', 'output': ['YES', 'Yes']}, {'input': '6 3 3\r\n3 3 3\r\n', 'output': ['YES', 'Yes']}, {'input': '14 9 8\r\n12 5 10\r\n', 'output': ['YES', 'Yes']}, {'input': '293792 300060 511272\r\n400687 382150 133304\r\n', 'output': ['No', 'NO']}, {'input': '286845 704749 266526\r\n392296 104421 461... | [{'input': '348369 104625 525203\r\n285621 215396 366411\r\n', 'output': ['No', 'NO']}, {'input': '6 6 0\r\n2 2 2\r\n', 'output': ['YES', 'Yes']}, {'input': '0 2 4\r\n2 0 2\r\n', 'output': ['YES', 'Yes']}, {'input': '404239 359124 133292\r\n180069 184791 332544\r\n', 'output': ['No', 'NO']}, {'input': '41 17 34\r\n0 19... | [{'input': '500000 500000 1000000\r\n500001 1000000 0\r\n', 'output': ['No', 'NO']}, {'input': '0 9 9\r\n9 0 0\r\n', 'output': ['No', 'NO']}, {'input': '1000000 500000 1000000\r\n500000 1000000 500000\r\n', 'output': ['YES', 'Yes']}, {'input': '4 4 0\r\n1 1 3\r\n', 'output': ['No', 'NO']}, {'input': '0 0 3\r\n1 0 1\r\n... | [{'input': '1 12 1\r\n4 0 4\r\n', 'output': ['YES', 'Yes']}, {'input': '4 0 0\r\n0 1 1\r\n', 'output': ['YES', 'Yes']}, {'input': '5 5 5\r\n2 2 2\r\n', 'output': ['YES', 'Yes']}, {'input': '500000 500000 1000000\r\n500001 1000000 0\r\n', 'output': ['No', 'NO']}, {'input': '0 0 0\r\n0 0 1\r\n', 'output': ['No', 'NO']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 315 | 100 | 100 | 100 |
["1 7 3 3", "7 7 7 7"] | The first line contains four space-separated integers s1, s2, s3, s4 (1 ≤ s1, s2, s3, s4 ≤ 109) — the colors of horseshoes Valera has. Consider all possible colors indexed with integers. | 38c4864937e57b35d3cce272f655e20f | s = [int(i) for i in input().split()]
m=0
for i in s:
if s.count(i) >= 2:
s = list(set(s))
m = len(s)
if m == 4:
print(0)
elif m == 3:
print(1)
elif m == 2:
print(2)
else:
print(3) | ["1", "3"] | Python | null | Print a single integer — the minimum number of horseshoes Valera needs to buy. | Valera the Horse is going to the party with friends. He has been following the fashion trends for a while, and he knows that it is very popular to wear all horseshoes of different color. Valera has got four horseshoes left from the last year, but maybe some of them have the same color. In this case he needs to go to th... | [{"input": "1 7 3 3\r\n", "output": ["1"]}, {"input": "7 7 7 7\r\n", "output": ["3"]}, {"input": "81170865 673572653 756938629 995577259\r\n", "output": ["0"]}, {"input": "3491663 217797045 522540872 715355328\r\n", "output": ["0"]}, {"input": "251590420 586975278 916631563 586975278\r\n", "output": ["1"]}, {"input": "... | 100 | 100 | 100 | [{'input': '133315691 265159773 734556507 265159773\r\n', 'output': ['1']}, {'input': '81170865 673572653 756938629 995577259\r\n', 'output': ['0']}, {'input': '251590420 586975278 916631563 586975278\r\n', 'output': ['1']}, {'input': '147784432 947653080 947653080 947653080\r\n', 'output': ['2']}, {'input': '1 1 2 5\r... | [{'input': '7 7 7 7\r\n', 'output': ['3']}, {'input': '551651653 551651653 551651653 551651653\r\n', 'output': ['3']}, {'input': '156630260 609654355 668943582 973622757\r\n', 'output': ['0']}, {'input': '3491663 217797045 522540872 715355328\r\n', 'output': ['0']}, {'input': '1 2 2 2\r\n', 'output': ['2']}] | [{'input': '81170865 673572653 756938629 995577259\r\n', 'output': ['0']}, {'input': '1 2 2 2\r\n', 'output': ['2']}, {'input': '1 1 3 5\r\n', 'output': ['1']}, {'input': '1 1 2 5\r\n', 'output': ['1']}, {'input': '3491663 217797045 522540872 715355328\r\n', 'output': ['0']}] | [{'input': '156630260 609654355 668943582 973622757\r\n', 'output': ['0']}, {'input': '255635360 732742923 798648949 883146723\r\n', 'output': ['0']}, {'input': '454961014 454961014 454961014 454961014\r\n', 'output': ['3']}, {'input': '915819430 915819430 915819430 915819430\r\n', 'output': ['3']}, {'input': '1 1 3 5\... | [{'input': '551651653 551651653 551651653 551651653\r\n', 'output': ['3']}, {'input': '1 1 3 3\r\n', 'output': ['2']}, {'input': '17061017 110313588 434481173 796661222\r\n', 'output': ['0']}, {'input': '391958720 651507265 391958720 651507265\r\n', 'output': ['2']}, {'input': '132503558 132503558 132503558 132503558\r... | 100 | 100 | 100 | 100 | 100 | 92.31 | 92.31 | 92.31 | 92.31 | 92.31 | 91.67 | 91.67 | 91.67 | 91.67 | 91.67 | 316 | 100 | 92.31 | 91.67 |
["code\nedoc", "abb\naba", "code\ncode"] | The first line contains word s, the second line contains word t. The words consist of lowercase Latin letters. The input data do not consist unnecessary spaces. The words are not empty and their lengths do not exceed 100 symbols. | 35a4be326690b58bf9add547fb63a5a5 | word1 = input()
word2 = input()
w1len = len(word1)
w2len = len(word2)
if w1len != w2len:
print('NO')
else:
if (w1len % 2) == 0: # ES
index = w1len - 1
cant = w1len
i = 0
while cant != 0:
a = word1[i]
b = word2[index]
if a == b:
... | ["YES", "NO", "NO"] | Python | null | If the word t is a word s, written reversely, print YES, otherwise print NO. | The translation from the Berland language into the Birland language is not an easy task. Those languages are very similar: a berlandish word differs from a birlandish word with the same meaning a little: it is spelled (and pronounced) reversely. For example, a Berlandish word code corresponds to a Birlandish word edoc.... | [{"input": "code\r\nedoc\r\n", "output": ["YES"]}, {"input": "abb\r\naba\r\n", "output": ["NO"]}, {"input": "code\r\ncode\r\n", "output": ["NO"]}, {"input": "abacaba\r\nabacaba\r\n", "output": ["YES"]}, {"input": "q\r\nq\r\n", "output": ["YES"]}, {"input": "asrgdfngfnmfgnhweratgjkk\r\nasrgdfngfnmfgnhweratgjkk\r\n", "ou... | 100 | 100 | 100 | [{'input': 'abcdef\r\nfecdba\r\n', 'output': ['NO']}, {'input': 'umeszdawsvgkjhlqwzents\r\nhxqhdungbylhnikwviuh\r\n', 'output': ['NO']}, {'input': 'code\r\nedoc\r\n', 'output': ['YES']}, {'input': 'q\r\nq\r\n', 'output': ['YES']}, {'input': 'bnbnemvybqizywlnghlykniaxxxlkhftppbdeqpesrtgkcpoeqowjwhrylpsziiwcldodcoonpimud... | [{'input': 'z\r\na\r\n', 'output': ['NO']}, {'input': 'mfrmqxtzvgaeuleubcmcxcfqyruwzenguhgrmkuhdgnhgtgkdszwqyd\r\nmfxufheiperjnhyczclkmzyhcxntdfskzkzdwzzujdinf\r\n', 'output': ['NO']}, {'input': 'abcdef\r\nfecdba\r\n', 'output': ['NO']}, {'input': 'gxoixiecetohtgjgbqzvlaobkhstejxdklghowtvwunnnvauriohuspsdmpzckprwajyxld... | [{'input': 'asrgdfngfnmfgnhweratgjkk\r\nasrgdfngfnmfgnhweratgjkk\r\n', 'output': ['NO']}, {'input': 'abacaba\r\nabacaba\r\n', 'output': ['YES']}, {'input': 'kudl\r\nldku\r\n', 'output': ['NO']}, {'input': 'sihxuwvmaambplxvjfoskinghzicyfqebjtkysotattkahssumfcgrkheotdxwjckpvapbkaepqrxseyfrwtyaycmrzsrsngkh\r\nhkgnsrszrmcy... | [{'input': 'w\r\nw\r\n', 'output': ['YES']}, {'input': 'abacaba\r\nabacaba\r\n', 'output': ['YES']}, {'input': 'muooqttvrrljcxbroizkymuidvfmhhsjtumksdkcbwwpfqdyvxtrlymofendqvznzlmim\r\nmimlznzvqdnefomylrtxvydqfpwwbckdskmutjshhmfvdiumykziorbxcjlrrvttqooum\r\n', 'output': ['YES']}, {'input': 'z\r\na\r\n', 'output': ['NO'... | [{'input': 'ywjjbirapvskozubvxoemscfwl\r\ngnduubaogtfaiowjizlvjcu\r\n', 'output': ['NO']}, {'input': 'vzzgicnzqooejpjzads\r\nsdazjpjeooqzncigzzv\r\n', 'output': ['YES']}, {'input': 'abb\r\naba\r\n', 'output': ['NO']}, {'input': 'abacaba\r\nabacaba\r\n', 'output': ['YES']}, {'input': 'mnhaxtaopjzrkqlbroiyipitndczpunwygs... | 100 | 100 | 100 | 100 | 100 | 94.29 | 97.14 | 91.43 | 60 | 97.14 | 87.5 | 87.5 | 81.25 | 56.25 | 87.5 | 317 | 100 | 88 | 80 |
["3000"] | The only line of the input contains one integer n (1 ≤ n ≤ 1018) — the prediction on the number of people who will buy the game. | 8551308e5ff435e0fc507b89a912408a | print(int(int(input())/2520)) | ["1"] | Python | null | Output one integer showing how many numbers from 1 to n are divisible by all numbers from 2 to 10. | IT City company developing computer games invented a new way to reward its employees. After a new game release users start buying it actively, and the company tracks the number of sales with precision to each transaction. Every time when the next number of sales is divisible by all numbers from 2 to 10 every developer ... | [{"input": "3000\r\n", "output": ["1"]}, {"input": "2520\r\n", "output": ["1"]}, {"input": "2519\r\n", "output": ["0"]}, {"input": "2521\r\n", "output": ["1"]}, {"input": "1\r\n", "output": ["0"]}, {"input": "314159265\r\n", "output": ["124666"]}, {"input": "718281828459045235\r\n", "output": ["285032471610732"]}, {"in... | 100 | 100 | 100 | [{'input': '3628800\r\n', 'output': ['1440']}, {'input': '1000000000000000000\r\n', 'output': ['396825396825396']}, {'input': '314159265\r\n', 'output': ['124666']}, {'input': '504000000000000000\r\n', 'output': ['200000000000000']}, {'input': '2520\r\n', 'output': ['1']}] | [{'input': '1000000000000000000\r\n', 'output': ['396825396825396']}, {'input': '314159265\r\n', 'output': ['124666']}, {'input': '3000\r\n', 'output': ['1']}, {'input': '1\r\n', 'output': ['0']}, {'input': '2521\r\n', 'output': ['1']}] | [{'input': '1000000000000000000\r\n', 'output': ['396825396825396']}, {'input': '314159265\r\n', 'output': ['124666']}, {'input': '2519\r\n', 'output': ['0']}, {'input': '3628800\r\n', 'output': ['1440']}, {'input': '2521\r\n', 'output': ['1']}] | [{'input': '718281828459045235\r\n', 'output': ['285032471610732']}, {'input': '1\r\n', 'output': ['0']}, {'input': '1000000000000000000\r\n', 'output': ['396825396825396']}, {'input': '3000\r\n', 'output': ['1']}, {'input': '2520\r\n', 'output': ['1']}] | [{'input': '1000000000000000000\r\n', 'output': ['396825396825396']}, {'input': '2520\r\n', 'output': ['1']}, {'input': '718281828459045235\r\n', 'output': ['285032471610732']}, {'input': '2521\r\n', 'output': ['1']}, {'input': '2519\r\n', 'output': ['0']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 318 | 100 | 100 | 100 |
["1", "2", "3"] | The first line contains a single integer n (1 ≤ n ≤ 40). | c2cbc35012c6ff7ab0d6899e6015e4e7 | # I've proven, that z takes form of 2 ** (k - 1) - 1,
# where 2 ** k - 1 is prime, which are called 'Mersenne primes'.
p = [2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127,\
521, 607, 1279, 2203, 2281, 3217, 4253, 4423, 9689,\
9941, 11213, 19937, 21701, 23209, 44497, 86243, 110503,\
132049, 216091, 756839, 85... | ["1", "3", "15"] | Python | null | Print a single integer — the number zn modulo 1000000007 (109 + 7). It is guaranteed that the answer exists. | Consider the following equation: where sign [a] represents the integer part of number a.Let's find all integer z (z > 0), for which this equation is unsolvable in positive integers. The phrase "unsolvable in positive integers" means that there are no such positive integers x and y (x, y > 0), for which the given... | [{"input": "1\r\n", "output": ["1"]}, {"input": "2\r\n", "output": ["3"]}, {"input": "3\r\n", "output": ["15"]}, {"input": "4\r\n", "output": ["63"]}, {"input": "5\r\n", "output": ["4095"]}, {"input": "6\r\n", "output": ["65535"]}, {"input": "7\r\n", "output": ["262143"]}, {"input": "8\r\n", "output": ["73741816"]}, {"... | 100 | 100 | 100 | [{'input': '37\r\n', 'output': ['876153853']}, {'input': '22\r\n', 'output': ['532737550']}, {'input': '26\r\n', 'output': ['642578561']}, {'input': '15\r\n', 'output': ['317758023']}, {'input': '36\r\n', 'output': ['411696552']}] | [{'input': '15\r\n', 'output': ['317758023']}, {'input': '29\r\n', 'output': ['419990027']}, {'input': '7\r\n', 'output': ['262143']}, {'input': '39\r\n', 'output': ['828945523']}, {'input': '35\r\n', 'output': ['853092282']}] | [{'input': '24\r\n', 'output': ['923450985']}, {'input': '2\r\n', 'output': ['3']}, {'input': '13\r\n', 'output': ['106681874']}, {'input': '5\r\n', 'output': ['4095']}, {'input': '18\r\n', 'output': ['110940209']}] | [{'input': '28\r\n', 'output': ['485739298']}, {'input': '21\r\n', 'output': ['910358878']}, {'input': '13\r\n', 'output': ['106681874']}, {'input': '7\r\n', 'output': ['262143']}, {'input': '35\r\n', 'output': ['853092282']}] | [{'input': '30\r\n', 'output': ['287292016']}, {'input': '12\r\n', 'output': ['319908070']}, {'input': '31\r\n', 'output': ['202484167']}, {'input': '17\r\n', 'output': ['416292236']}, {'input': '1\r\n', 'output': ['1']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 319 | 100 | 100 | 100 |
["1 2 1000", "2 2 1000", "5 3 1103"] | Input consists of three integers n, k, m (1 ≤ n ≤ 1000, 1 ≤ k ≤ 100, 1 ≤ m ≤ 109). | 656bf8df1e79499aa2ab2c28712851f0 | def get_input():
hahaha=input()
(n,k,m)=hahaha.split(sep=None, maxsplit=1000)
return (int(n),int(k),int(m))
(n,k,m)=get_input()
f=[0 for i in range(k)]
s=0
for v in range(n):
tens = 10**v%k
f=[ (sum( [f[(j+k-(x+1)*tens)%k] for x in range(9)] )+f[j])%m for j in range(k)]
for x in rang... | ["4", "45", "590"] | Python | NoteA suffix of a string S is a non-empty string that can be obtained by removing some number (possibly, zero) of first characters from S. | Print the required number modulo m. | Amr doesn't like Maths as he finds it really boring, so he usually sleeps in Maths lectures. But one day the teacher suspected that Amr is sleeping and asked him a question to make sure he wasn't.First he gave Amr two positive integers n and k. Then he asked Amr, how many integer numbers x > 0 exist such that: Deci... | [{"input": "1 2 1000\r\n", "output": ["4"]}, {"input": "2 2 1000\r\n", "output": ["45"]}, {"input": "5 3 1103\r\n", "output": ["590"]}, {"input": "2 17 10000\r\n", "output": ["5"]}, {"input": "3 9 10000\r\n", "output": ["252"]}, {"input": "6 64 941761822\r\n", "output": ["46530"]}, {"input": "183 3 46847167\r\n", "outp... | 100 | 100 | 100 | [{'input': '674 22 494819681\r\n', 'output': ['19590614']}, {'input': '900 84 526417573\r\n', 'output': ['281234824']}, {'input': '767 27 364988776\r\n', 'output': ['259490746']}, {'input': '520 94 712232167\r\n', 'output': ['199435818']}, {'input': '998 85 501663165\r\n', 'output': ['145180249']}] | [{'input': '2 2 1000\r\n', 'output': ['45']}, {'input': '1 1 1\r\n', 'output': ['0']}, {'input': '20 96 238661639\r\n', 'output': ['198761428']}, {'input': '561 69 310141994\r\n', 'output': ['245538618']}, {'input': '462 35 144751085\r\n', 'output': ['79931198']}] | [{'input': '712 53 592302770\r\n', 'output': ['147693148']}, {'input': '561 69 310141994\r\n', 'output': ['245538618']}, {'input': '429 45 103817253\r\n', 'output': ['41335161']}, {'input': '355 3 945669623\r\n', 'output': ['219132384']}, {'input': '20 96 238661639\r\n', 'output': ['198761428']}] | [{'input': '510 76 811693420\r\n', 'output': ['546301720']}, {'input': '426 72 589297447\r\n', 'output': ['316207784']}, {'input': '993 26 108974437\r\n', 'output': ['87469631']}, {'input': '1 1 1\r\n', 'output': ['0']}, {'input': '712 53 592302770\r\n', 'output': ['147693148']}] | [{'input': '170 94 82742818\r\n', 'output': ['1117330']}, {'input': '510 76 811693420\r\n', 'output': ['546301720']}, {'input': '998 85 501663165\r\n', 'output': ['145180249']}, {'input': '905 71 999142682\r\n', 'output': ['825882209']}, {'input': '56 48 961996131\r\n', 'output': ['199203510']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 320 | 100 | 100 | 100 |
["42", "5"] | The only line contains an integer n (1 ≤ n ≤ 10000). | 5d4f38ffd1849862623325fdbe06cd00 | n=int(input())
a=n//3
b=n%3
if b==2:
a=a+1
p=a//12
q=a%12
print(p,q) | ["1 2", "0 2"] | Python | null | Print two non-negative space-separated integers a and b, where a is the numbers of feet and b is the number of inches. | Lengths are measures in Baden in inches and feet. To a length from centimeters it is enough to know that an inch equals three centimeters in Baden and one foot contains 12 inches.You are given a length equal to n centimeters. Your task is to convert it to feet and inches so that the number of feet was maximum. The resu... | [{"input": "42\r\n", "output": ["1 2"]}, {"input": "5\r\n", "output": ["0 2"]}, {"input": "24\r\n", "output": ["0 8"]}, {"input": "1\r\n", "output": ["0 0"]}, {"input": "2\r\n", "output": ["0 1"]}, {"input": "3\r\n", "output": ["0 1"]}, {"input": "4\r\n", "output": ["0 1"]}, {"input": "8\r\n", "output": ["0 3"]}, {"inp... | 100 | 100 | 100 | [{'input': '199\r\n', 'output': ['5 6']}, {'input': '10000\r\n', 'output': ['277 9']}, {'input': '1\r\n', 'output': ['0 0']}, {'input': '1233\r\n', 'output': ['34 3']}, {'input': '120\r\n', 'output': ['3 4']}] | [{'input': '1000\r\n', 'output': ['27 9']}, {'input': '3\r\n', 'output': ['0 1']}, {'input': '1\r\n', 'output': ['0 0']}, {'input': '100\r\n', 'output': ['2 9']}, {'input': '10\r\n', 'output': ['0 3']}] | [{'input': '120\r\n', 'output': ['3 4']}, {'input': '501\r\n', 'output': ['13 11']}, {'input': '1\r\n', 'output': ['0 0']}, {'input': '1233\r\n', 'output': ['34 3']}, {'input': '8\r\n', 'output': ['0 3']}] | [{'input': '100\r\n', 'output': ['2 9']}, {'input': '199\r\n', 'output': ['5 6']}, {'input': '3\r\n', 'output': ['0 1']}, {'input': '10\r\n', 'output': ['0 3']}, {'input': '35\r\n', 'output': ['1 0']}] | [{'input': '35\r\n', 'output': ['1 0']}, {'input': '10\r\n', 'output': ['0 3']}, {'input': '199\r\n', 'output': ['5 6']}, {'input': '10000\r\n', 'output': ['277 9']}, {'input': '13\r\n', 'output': ['0 4']}] | 100 | 100 | 100 | 100 | 100 | 87.5 | 87.5 | 100 | 100 | 100 | 50 | 50 | 100 | 100 | 100 | 321 | 100 | 95 | 80 |
["4", "5"] | The single line contains the positive integer n (1 ≤ n ≤ 1015). | 689e7876048ee4eb7479e838c981f068 | x=int(input())
if x%2==0:
print(int(x/2))
else:
print(-(int(x/2)+1)) | ["2", "-3"] | Python | Notef(4) = - 1 + 2 - 3 + 4 = 2f(5) = - 1 + 2 - 3 + 4 - 5 = - 3 | Print f(n) in a single line. | For a positive integer n let's define a function f:f(n) = - 1 + 2 - 3 + .. + ( - 1)nn Your task is to calculate f(n) for a given integer n. | [{"input": "4\r\n", "output": ["2"]}, {"input": "5\r\n", "output": ["-3"]}, {"input": "1000000000\r\n", "output": ["500000000"]}, {"input": "1000000001\r\n", "output": ["-500000001"]}, {"input": "1000000000000000\r\n", "output": ["500000000000000"]}, {"input": "100\r\n", "output": ["50"]}, {"input": "101\r\n", "output"... | 100 | 100 | 100 | [{'input': '101\r\n', 'output': ['-51']}, {'input': '100\r\n', 'output': ['50']}, {'input': '288565475053\r\n', 'output': ['-144282737527']}, {'input': '100000017040846\r\n', 'output': ['50000008520423']}, {'input': '145645214654154\r\n', 'output': ['72822607327077']}] | [{'input': '1\r\n', 'output': ['-1']}, {'input': '999999999999999\r\n', 'output': ['-500000000000000']}, {'input': '103\r\n', 'output': ['-52']}, {'input': '98979894985999\r\n', 'output': ['-49489947493000']}, {'input': '4294967296\r\n', 'output': ['2147483648']}] | [{'input': '3052460231\r\n', 'output': ['-1526230116']}, {'input': '105\r\n', 'output': ['-53']}, {'input': '999999999999999\r\n', 'output': ['-500000000000000']}, {'input': '103\r\n', 'output': ['-52']}, {'input': '99999999999999\r\n', 'output': ['-50000000000000']}] | [{'input': '100000017040846\r\n', 'output': ['50000008520423']}, {'input': '101\r\n', 'output': ['-51']}, {'input': '1000000000000\r\n', 'output': ['500000000000']}, {'input': '103\r\n', 'output': ['-52']}, {'input': '107\r\n', 'output': ['-54']}] | [{'input': '98979894985999\r\n', 'output': ['-49489947493000']}, {'input': '1000000000\r\n', 'output': ['500000000']}, {'input': '3037000499\r\n', 'output': ['-1518500250']}, {'input': '5\r\n', 'output': ['-3']}, {'input': '62\r\n', 'output': ['31']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 75 | 100 | 100 | 100 | 100 | 50 | 100 | 100 | 322 | 100 | 95 | 90 |
["21", "20"] | The first line contains integer n (1 ≤ n ≤ 109). | ae20ae2a16273a0d379932d6e973f878 | n = int(input())
m = str(n)
g = len(m)
l = [int(m[0])-1]+[9]*(g-1)
h = 0
less = 0
while(h<len(l)):
less = less + l[h]
h = h + 1
a = n - less
r = []
i = 0
while(a<n):
j = 0
s = str(a)
c = a
while j<len(s):
c = c + int(s[j])
j = j + 1
if(c==n):
i +=1
r = r + [a]... | ["1\n15", "0"] | Python | NoteIn the first test case x = 15 there is only one variant: 15 + 1 + 5 = 21.In the second test case there are no such x. | In the first line print one integer k — number of different values of x satisfying the condition. In next k lines print these values in ascending order. | Eighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on it the number n. He asked what is this number and the teacher of mathematics Inna Petrovna answered Vova that n is the answer to the arithmetic task for first-graders. In the textbook, a certain posi... | [{"input": "21\r\n", "output": ["1\r\n15"]}, {"input": "20\r\n", "output": ["0"]}, {"input": "1\r\n", "output": ["0"]}, {"input": "2\r\n", "output": ["1\r\n1"]}, {"input": "3\r\n", "output": ["0"]}, {"input": "100000001\r\n", "output": ["2\r\n99999937\r\n 100000000", "2\r\n99999937 100000000", "2\r\n99999937\r\n1000000... | 100 | 100 | 100 | [{'input': '100000001\r\n', 'output': ['2\r\n99999937\r\n 100000000', '2\r\n99999937 100000000', '2\r\n99999937\r\n100000000']}, {'input': '100\r\n', 'output': ['1\r\n86']}, {'input': '999999994\r\n', 'output': ['0']}, {'input': '21\r\n', 'output': ['1\r\n15']}, {'input': '1000000000\r\n', 'output': ['1\r\n999999932']}... | [{'input': '75\r\n', 'output': ['0']}, {'input': '11\r\n', 'output': ['1\r\n10']}, {'input': '2014\r\n', 'output': ['2\r\n1988\r\n2006', '2\r\n1988 2006', '2\r\n1988\r\n 2006']}, {'input': '999999979\r\n', 'output': ['2\r\n999999899\r\n 999999908', '2\r\n999999899 999999908', '2\r\n999999899\r\n999999908']}, {'input': ... | [{'input': '3\r\n', 'output': ['0']}, {'input': '39\r\n', 'output': ['1\r\n33']}, {'input': '1000000000\r\n', 'output': ['1\r\n999999932']}, {'input': '21\r\n', 'output': ['1\r\n15']}, {'input': '11\r\n', 'output': ['1\r\n10']}] | [{'input': '100\r\n', 'output': ['1\r\n86']}, {'input': '3\r\n', 'output': ['0']}, {'input': '1\r\n', 'output': ['0']}, {'input': '2014\r\n', 'output': ['2\r\n1988\r\n2006', '2\r\n1988 2006', '2\r\n1988\r\n 2006']}, {'input': '101\r\n', 'output': ['2\r\n91\r\n100', '2\r\n91\r\n 100', '2\r\n91 100']}] | [{'input': '9\r\n', 'output': ['0']}, {'input': '999999979\r\n', 'output': ['2\r\n999999899\r\n 999999908', '2\r\n999999899 999999908', '2\r\n999999899\r\n999999908']}, {'input': '66\r\n', 'output': ['1\r\n60']}, {'input': '2014\r\n', 'output': ['2\r\n1988\r\n2006', '2\r\n1988 2006', '2\r\n1988\r\n 2006']}, {'input': '... | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 323 | 100 | 100 | 100 |
["48", "6"] | The only line of the input contains one integer m (1 ≤ m ≤ 1015), meaning that Limak wants you to choose X between 1 and m, inclusive. | 385cf3c40c96f0879788b766eeb25139 | #D razbor 1
def func(n):
if n<8:
return n,n
max_a = int(n**(1/3))
if (max_a+1)**3<=n:
max_a += 1
v1=func(n-max_a**3)
v1=(v1[0]+1,v1[1]+max_a**3)
v2=func(max_a**3-1-(max_a-1)**3)
v2=(v2[0]+1,v2[1]+(max_a-1)**3)
if v2>v1:
return v2
else:
... | ["9 42", "6 6"] | Python | NoteIn the first sample test, there will be 9 blocks if you choose X = 23 or X = 42. Limak wants to maximize X secondarily so you should choose 42.In more detail, after choosing X = 42 the process of building a tower is: Limak takes a block with side 3 because it's the biggest block with volume not greater than 42. Th... | Print two integers — the maximum number of blocks in the tower and the maximum required total volume X, resulting in the maximum number of blocks. | Limak is a little polar bear. He plays by building towers from blocks. Every block is a cube with positive integer length of side. Limak has infinitely many blocks of each side length.A block with side a has volume a3. A tower consisting of blocks with sides a1, a2, ..., ak has the total volume a13 + a23 + ... + ak3.Li... | [{"input": "48\r\n", "output": ["9 42"]}, {"input": "6\r\n", "output": ["6 6"]}, {"input": "1\r\n", "output": ["1 1"]}, {"input": "994\r\n", "output": ["12 941"]}, {"input": "567000123\r\n", "output": ["16 566998782"]}, {"input": "123830583943\r\n", "output": ["17 123830561521"]}, {"input": "3842529393411\r\n", "output... | 100 | 100 | 100 | [{'input': '123830583943\r\n', 'output': ['17 123830561521']}, {'input': '995\r\n', 'output': ['12 995']}, {'input': '114\r\n', 'output': ['11 114']}, {'input': '1000000000000000\r\n', 'output': ['18 999999993541753']}, {'input': '112\r\n', 'output': ['10 106']}] | [{'input': '999998169714888\r\n', 'output': ['18 999998150030846']}, {'input': '415000000238718\r\n', 'output': ['18 414993991790735']}, {'input': '108000000057\r\n', 'output': ['17 107986074062']}, {'input': '990000000000000\r\n', 'output': ['18 989983621692990']}, {'input': '114\r\n', 'output': ['11 114']}] | [{'input': '108000000057\r\n', 'output': ['17 107986074062']}, {'input': '780869426483087\r\n', 'output': ['18 780869407920631']}, {'input': '8\r\n', 'output': ['7 7']}, {'input': '1000000000000000\r\n', 'output': ['18 999999993541753']}, {'input': '114\r\n', 'output': ['11 114']}] | [{'input': '909383000\r\n', 'output': ['16 909381874']}, {'input': '994\r\n', 'output': ['12 941']}, {'input': '567000123\r\n', 'output': ['16 566998782']}, {'input': '999998169714888\r\n', 'output': ['18 999998150030846']}, {'input': '999999999999999\r\n', 'output': ['18 999999993541753']}] | [{'input': '850085504652042\r\n', 'output': ['18 850085504652042']}, {'input': '6\r\n', 'output': ['6 6']}, {'input': '112\r\n', 'output': ['10 106']}, {'input': '999971000299999\r\n', 'output': ['18 999969994441746']}, {'input': '567000123\r\n', 'output': ['16 566998782']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 324 | 100 | 100 | 100 |
["1 50\n50", "3 100\n50 50 100", "2 50\n50 50"] | The first line contains two integers n, k (1 ≤ n ≤ 50, 1 ≤ k ≤ 5000) — the number of people, including Greg, and the boat's weight limit. The next line contains n integers — the people's weights. A person's weight is either 50 kilos or 100 kilos. You can consider Greg and his friends indexed in some way. | ebb0323a854e19794c79ab559792a1f7 | from collections import deque
n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
c50 = sum([1 for i in a if i == 50])
c100 = sum([1 for i in a if i == 100])
c = [[0] * 51 for i in range(51)]
c[0][0] = 1
c[1][0] = 1
c[1][1] = 1
for x in range(2, 51):
for y in range(x + 1):
c[x][y... | ["1\n1", "5\n2", "-1\n0"] | Python | NoteIn the first test Greg walks alone and consequently, he needs only one ride across the river.In the second test you should follow the plan: transport two 50 kg. people; transport one 50 kg. person back; transport one 100 kg. person; transport one 50 kg. person back; transport two 50 kg. people. That totals to ... | In the first line print an integer — the minimum number of rides. If transporting everyone to the other bank is impossible, print an integer -1. In the second line print the remainder after dividing the number of ways to transport the people in the minimum number of rides by number 1000000007 (109 + 7). If transporting... | One day Greg and his friends were walking in the forest. Overall there were n people walking, including Greg. Soon he found himself in front of a river. The guys immediately decided to get across the river. Luckily, there was a boat by the river bank, just where the guys were standing. We know that the boat can hold pe... | [{"input": "1 50\r\n50\r\n", "output": ["1\r\n1"]}, {"input": "3 100\r\n50 50 100\r\n", "output": ["5\r\n2"]}, {"input": "2 50\r\n50 50\r\n", "output": ["-1\r\n0"]}, {"input": "5 258\r\n100 100 50 50 50\r\n", "output": ["3\r\n72"]}, {"input": "8 191\r\n50 100 50 100 50 100 100 50\r\n", "output": ["11\r\n19318272"]}, {"... | 100 | 100 | 100 | [{'input': '49 290\r\n100 100 100 100 100 100 100 100 50 100 50 100 100 100 50 50 100 50 50 100 100 100 100 100 100 50 100 100 50 100 50 50 100 100 100 50 50 50 50 50 100 100 100 50 100 50 100 50 50\r\n', 'output': ['39\r\n99624366']}, {'input': '11 4668\r\n50 100 100 100 50 100 50 50 100 100 100\r\n', 'output': ['1\r\... | [{'input': '50 207\r\n50 100 100 100 100 50 100 100 100 50 100 100 100 50 100 100 50 100 50 100 50 100 100 100 50 100 50 50 100 50 100 100 50 100 100 100 100 50 100 100 100 100 50 50 50 100 100 50 100 100\r\n', 'output': ['55\r\n833060250']}, {'input': '3 121\r\n100 100 50\r\n', 'output': ['-1\r\n0']}, {'input': '31 16... | [{'input': '50 2263\r\n50 100 50 100 50 100 100 100 50 50 50 100 100 100 100 100 100 50 50 100 50 100 50 50 100 50 50 100 100 50 100 100 100 50 50 50 100 50 100 50 50 50 50 50 100 100 50 50 100 50\r\n', 'output': ['3\r\n211048352']}, {'input': '5 123\r\n50 100 50 50 50\r\n', 'output': ['9\r\n4536']}, {'input': '8 271\r... | [{'input': '29 129\r\n50 50 50 100 100 100 50 100 50 50 50 100 50 100 100 100 50 100 100 100 50 50 50 50 50 50 50 50 50\r\n', 'output': ['77\r\n37050209']}, {'input': '31 161\r\n100 50 50 50 50 100 50 100 50 100 100 50 50 100 100 50 100 50 50 100 50 100 100 50 50 100 50 50 100 50 100\r\n', 'output': ['43\r\n670669365']... | [{'input': '43 178\r\n50 50 100 100 100 50 100 100 50 100 100 100 50 100 50 100 50 50 100 100 50 100 100 50 50 50 100 50 50 50 100 50 100 100 100 50 100 50 50 50 50 100 100\r\n', 'output': ['63\r\n503334985']}, {'input': '3 121\r\n100 100 50\r\n', 'output': ['-1\r\n0']}, {'input': '34 2964\r\n50 50 50 50 50 100 50 100 ... | 100 | 100 | 100 | 100 | 100 | 94.87 | 100 | 94.87 | 94.87 | 100 | 96.67 | 100 | 96.67 | 96.67 | 100 | 325 | 100 | 96.922 | 98.002 |
["1 2 1 2", "1 12 1 12", "50 100 3 30"] | The only line contains four integers l, r, x, y (1 ≤ l ≤ r ≤ 109, 1 ≤ x ≤ y ≤ 109). | d37dde5841116352c9b37538631d0b15 | import math
def gcd(a, b):
while b != 0:
a, b = b, a % b
return a
def lcm(a, b):
return a * b // (gcd(a, b))
def f(d):
d = str(d)
if d[len(d) - 2:] == '.0':
return True
return False
l, r, x, y = [int(i) for i in input().split()]
count = 0
for c in range(1, int(math.sqrt(y /... | ["2", "4", "0"] | Python | NoteIn the first example there are two suitable good pairs of integers (a, b): (1, 2) and (2, 1).In the second example there are four suitable good pairs of integers (a, b): (1, 12), (12, 1), (3, 4) and (4, 3).In the third example there are good pairs of integers, for example, (3, 30), but none of them fits the conditi... | In the only line print the only integer — the answer for the problem. | Today on Informatics class Nastya learned about GCD and LCM (see links below). Nastya is very intelligent, so she solved all the tasks momentarily and now suggests you to solve one of them as well.We define a pair of integers (a, b) good, if GCD(a, b) = x and LCM(a, b) = y, where GCD(a, b) denotes the greatest common d... | [{"input": "1 2 1 2\r\n", "output": ["2"]}, {"input": "1 12 1 12\r\n", "output": ["4"]}, {"input": "50 100 3 30\r\n", "output": ["0"]}, {"input": "1 1000000000 1 1000000000\r\n", "output": ["4"]}, {"input": "1 1000000000 158260522 200224287\r\n", "output": ["0"]}, {"input": "1 1000000000 2 755829150\r\n", "output": ["8... | 100 | 100 | 100 | [{'input': '1 1000000000 24967 470827686\r\n', 'output': ['16']}, {'input': '29259607 69772909 2250739 907047817\r\n', 'output': ['2']}, {'input': '100 1000000000 877914575 877914575\r\n', 'output': ['1']}, {'input': '6 111 3 222\r\n', 'output': ['2']}, {'input': '5 10 3 3\r\n', 'output': ['0']}] | [{'input': '1 2993 1 2993\r\n', 'output': ['4']}, {'input': '1 1000000000 100000000 1000000000\r\n', 'output': ['4']}, {'input': '1 100 2 4\r\n', 'output': ['2']}, {'input': '3 3 3 9\r\n', 'output': ['0']}, {'input': '2672374 422235092 1336187 844470184\r\n', 'output': ['2']}] | [{'input': '29259607 69772909 2250739 907047817\r\n', 'output': ['2']}, {'input': '1 1000000000 33409 694005157\r\n', 'output': ['2']}, {'input': '1 1000000000 24190 400949250\r\n', 'output': ['16']}, {'input': '1032 8756124 12 753026664\r\n', 'output': ['18']}, {'input': '5 10 3 3\r\n', 'output': ['0']}] | [{'input': '13266 1606792 22 968895576\r\n', 'output': ['14']}, {'input': '6 111 3 222\r\n', 'output': ['2']}, {'input': '1 2993 1 2993\r\n', 'output': ['4']}, {'input': '47259 3393570 267 600661890\r\n', 'output': ['30']}, {'input': '26 82 2 1066\r\n', 'output': ['2']}] | [{'input': '2672374 422235092 1336187 844470184\r\n', 'output': ['2']}, {'input': '1 1000000000 1 7198102\r\n', 'output': ['8']}, {'input': '1 10000 2 455\r\n', 'output': ['0']}, {'input': '1 1000000000 499999993 999999986\r\n', 'output': ['2']}, {'input': '398520 1481490 810 728893080\r\n', 'output': ['4']}] | 100 | 100 | 100 | 100 | 100 | 100 | 95.45 | 95.45 | 95.45 | 95.45 | 100 | 92.86 | 92.86 | 92.86 | 92.86 | 326 | 100 | 96.36 | 94.288 |
["5 2 2", "5 4 7", "6 2 3"] | The single line contains three integers T, S, q (2 ≤ q ≤ 104, 1 ≤ S < T ≤ 105). | 0d01bf286fb2c7950ce5d5fa59a17dd9 | t,s,q=map(int,input().split())
res=0
while s<t:s*=q;res+=1
print(res) | ["2", "1", "1"] | Python | NoteIn the first test, the song is played twice faster than it is downloaded, which means that during four first seconds Lesha reaches the moment that has not been downloaded, and starts the song again. After another two seconds, the song is downloaded completely, and thus, Lesha starts the song twice.In the second tes... | Print a single integer — the number of times the song will be restarted. | Little Lesha loves listening to music via his smartphone. But the smartphone doesn't have much memory, so Lesha listens to his favorite songs in a well-known social network InTalk.Unfortunately, internet is not that fast in the city of Ekaterinozavodsk and the song takes a lot of time to download. But Lesha is quite im... | [{"input": "5 2 2\r\n", "output": ["2"]}, {"input": "5 4 7\r\n", "output": ["1"]}, {"input": "6 2 3\r\n", "output": ["1"]}, {"input": "2 1 2\r\n", "output": ["1"]}, {"input": "2 1 3\r\n", "output": ["1"]}, {"input": "2 1 10000\r\n", "output": ["1"]}, {"input": "12326 6163 2\r\n", "output": ["1"]}, {"input": "10000 2500... | 100 | 100 | 100 | [{'input': '100000 1 5\r\n', 'output': ['8']}, {'input': '25 2 2\r\n', 'output': ['4']}, {'input': '10033 3 8\r\n', 'output': ['4']}, {'input': '100000 1 10\r\n', 'output': ['5']}, {'input': '356 2 3\r\n', 'output': ['5']}] | [{'input': '2 1 10000\r\n', 'output': ['1']}, {'input': '64 1 8\r\n', 'output': ['2']}, {'input': '10000 2500 4\r\n', 'output': ['1']}, {'input': '2 1 3\r\n', 'output': ['1']}, {'input': '100000 1 5\r\n', 'output': ['8']}] | [{'input': '50 2 2\r\n', 'output': ['5']}, {'input': '65465 12 3\r\n', 'output': ['8']}, {'input': '10000 9 2\r\n', 'output': ['11']}, {'input': '100000 1 10000\r\n', 'output': ['2']}, {'input': '5 4 7\r\n', 'output': ['1']}] | [{'input': '5 4 7\r\n', 'output': ['1']}, {'input': '5 2 2\r\n', 'output': ['2']}, {'input': '100000 99999 4\r\n', 'output': ['1']}, {'input': '356 2 3\r\n', 'output': ['5']}, {'input': '2 1 2\r\n', 'output': ['1']}] | [{'input': '6562 1 3\r\n', 'output': ['9']}, {'input': '2 1 10000\r\n', 'output': ['1']}, {'input': '12628 1804 7\r\n', 'output': ['1']}, {'input': '100000 99999 3\r\n', 'output': ['1']}, {'input': '25 2 2\r\n', 'output': ['4']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 327 | 100 | 100 | 100 |
["3\n2014 2016 2015", "1\n2050"] | The first line contains the positive odd integer n (1 ≤ n ≤ 5) — the number of groups which Igor joined. The next line contains n distinct integers a1, a2, ..., an (2010 ≤ ai ≤ 2100) — years of student's university entrance for each group in which Igor is the member. It is guaranteed that the input data is correct and... | f03773118cca29ff8d5b4281d39e7c63 | count = int(input())
sum = 0
years = input().split(' ')
for y in years:
sum += int(y)
print(int(sum/count)) | ["2015", "2050"] | Python | NoteIn the first test the value x = 1. Igor entered the university in 2015. So he joined groups members of which are students who entered the university in 2014, 2015 and 2016.In the second test the value x = 0. Igor entered only the group which corresponds to the year of his university entrance. | Print the year of Igor's university entrance. | There is the faculty of Computer Science in Berland. In the social net "TheContact!" for each course of this faculty there is the special group whose name equals the year of university entrance of corresponding course of students at the university. Each of students joins the group of his course and joins all groups for... | [{"input": "3\r\n2014 2016 2015\r\n", "output": ["2015"]}, {"input": "1\r\n2050\r\n", "output": ["2050"]}, {"input": "1\r\n2010\r\n", "output": ["2010"]}, {"input": "1\r\n2011\r\n", "output": ["2011"]}, {"input": "3\r\n2010 2011 2012\r\n", "output": ["2011"]}, {"input": "3\r\n2049 2047 2048\r\n", "output": ["2048"]}, {... | 100 | 100 | 100 | [{'input': '1\r\n2099\r\n', 'output': ['2099']}, {'input': '5\r\n2077 2078 2080 2079 2081\r\n', 'output': ['2079']}, {'input': '3\r\n2012 2011 2010\r\n', 'output': ['2011']}, {'input': '5\r\n2099 2096 2095 2097 2098\r\n', 'output': ['2097']}, {'input': '1\r\n2045\r\n', 'output': ['2045']}] | [{'input': '5\r\n2081 2079 2078 2080 2077\r\n', 'output': ['2079']}, {'input': '1\r\n2045\r\n', 'output': ['2045']}, {'input': '3\r\n2047 2048 2049\r\n', 'output': ['2048']}, {'input': '5\r\n2012 2013 2014 2015 2016\r\n', 'output': ['2014']}, {'input': '5\r\n2024 2020 2021 2023 2022\r\n', 'output': ['2022']}] | [{'input': '3\r\n2049 2047 2048\r\n', 'output': ['2048']}, {'input': '1\r\n2100\r\n', 'output': ['2100']}, {'input': '5\r\n2056 2057 2058 2059 2060\r\n', 'output': ['2058']}, {'input': '3\r\n2049 2048 2047\r\n', 'output': ['2048']}, {'input': '5\r\n2011 2014 2013 2010 2012\r\n', 'output': ['2012']}] | [{'input': '5\r\n2030 2031 2033 2032 2029\r\n', 'output': ['2031']}, {'input': '3\r\n2048 2049 2047\r\n', 'output': ['2048']}, {'input': '5\r\n2079 2080 2077 2081 2078\r\n', 'output': ['2079']}, {'input': '5\r\n2097 2099 2100 2098 2096\r\n', 'output': ['2098']}, {'input': '3\r\n2010 2012 2011\r\n', 'output': ['2011']}] | [{'input': '5\r\n2024 2020 2021 2023 2022\r\n', 'output': ['2022']}, {'input': '3\r\n2049 2047 2048\r\n', 'output': ['2048']}, {'input': '5\r\n2043 2042 2041 2044 2040\r\n', 'output': ['2042']}, {'input': '5\r\n2093 2092 2094 2096 2095\r\n', 'output': ['2094']}, {'input': '1\r\n2011\r\n', 'output': ['2011']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 328 | 100 | 100 | 100 |
["........\n........\n.B....B.\n....W...\n........\n..W.....\n........\n........", "..B.....\n..W.....\n......B.\n........\n.....W..\n......B.\n........\n........"] | The input consists of the board description given in eight lines, each line contains eight characters. Character 'B' is used to denote a black pawn, and character 'W' represents a white pawn. Empty cell is marked with '.'. It's guaranteed that there will not be white pawns on the first row neither black pawns on the l... | 0ddc839e17dee20e1a954c1289de7fbd | a = [input() for i in range(8)]
ra, rb = 8, 8
for j in range(8) :
for i in range(8) :
if a[i][j] == 'W' :
ra = min(ra, i)
if a[i][j] != '.' :
break
for j in range(8) :
for i in range(7,-1,-1) :
if a[i][j] == 'B' :
rb = min(rb, 7 - i)
if a[i][j]... | ["A", "B"] | Python | NoteIn the first sample player A is able to complete his goal in 3 steps by always moving a pawn initially located at (4, 5). Player B needs at least 5 steps for any of his pawns to reach the row 8. Hence, player A will be the winner. | Print 'A' if player A wins the game on the given board, and 'B' if player B will claim the victory. Again, it's guaranteed that there will always be a winner on the given board. | Galois is one of the strongest chess players of Byteforces. He has even invented a new variant of chess, which he named «PawnChess».This new game is played on a board consisting of 8 rows and 8 columns. At the beginning of every game some black and white pawns are placed on the board. The number of black pawns placed i... | [{"input": "........\r\n........\r\n.B....B.\r\n....W...\r\n........\r\n..W.....\r\n........\r\n........\r\n", "output": ["A"]}, {"input": "..B.....\r\n..W.....\r\n......B.\r\n........\r\n.....W..\r\n......B.\r\n........\r\n........\r\n", "output": ["B"]}, {"input": ".BB.B.B.\r\nB..B..B.\r\n.B.BB...\r\nBB.....B\r\nBBB.... | 100 | 100 | 100 | [{'input': 'BB....B.\r\nB.....B.\r\n.....B..\r\n..B...BB\r\n.W.BWBWB\r\n....W...\r\nWW.WWW..\r\n....W...\r\n', 'output': ['B']}, {'input': '......B.\r\nB....B..\r\n...B.BB.\r\n...B....\r\n........\r\n..W....W\r\nWW......\r\n.W....W.\r\n', 'output': ['B']}, {'input': '..B..BBB\r\n........\r\n........\r\n........\r\n...W... | [{'input': 'B...BBBB\r\n...BBB..\r\nBBWBWW.W\r\n.B..BB.B\r\nW..W..WW\r\nW.WW....\r\n........\r\nWW.....W\r\n', 'output': ['A']}, {'input': '........\r\n........\r\n........\r\n........\r\nW.......\r\nB.......\r\n........\r\n........\r\n', 'output': ['B']}, {'input': '........\r\n..B.....\r\n..W...B.\r\n........\r\n....... | [{'input': 'BB..BB..\r\nBW.W.W.B\r\n..B.....\r\n.....BB.\r\n.B..B..B\r\n........\r\n...BB.B.\r\nW.WWWW.W\r\n', 'output': ['A']}, {'input': 'B...BB..\r\nWWBBW.BB\r\n.W.W....\r\nWWWW....\r\nW....W..\r\nW..WW...\r\n...W....\r\nWW.W....\r\n', 'output': ['A']}, {'input': 'B.B...B.\r\n........\r\n.......B\r\n.BB....B\r\n....... | [{'input': '........\r\n.B.B....\r\n...B..BB\r\n........\r\n........\r\nW...W...\r\nW...W...\r\nW.WW.W..\r\n', 'output': ['A']}, {'input': '.BBB....\r\nB.B.B...\r\nB.BB.B..\r\nB.BB.B.B\r\n........\r\n........\r\nW.....W.\r\n..WW..W.\r\n', 'output': ['B']}, {'input': 'B...BB..\r\nWWBBW.BB\r\n.W.W....\r\nWWWW....\r\nW...... | [{'input': 'BB....B.\r\nB.....B.\r\n.....B..\r\n..B...BB\r\n.W.BWBWB\r\n....W...\r\nWW.WWW..\r\n....W...\r\n', 'output': ['B']}, {'input': '........\r\n.B.B....\r\n...B..BB\r\n........\r\n........\r\nW...W...\r\nW...W...\r\nW.WW.W..\r\n', 'output': ['A']}, {'input': '........\r\n........\r\n.B....B.\r\n....W...\r\n....... | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 88.89 | 88.89 | 100 | 329 | 100 | 100 | 95.556 |
["1 1 -1", "1 3 1", "3 3 -1"] | The only line contains three integers n, m and k (1 ≤ n, m ≤ 1018, k is either 1 or -1). | 6b9eff690fae14725885cbc891ff7243 | mod=1000000007
n,m,k=list(map(int,input().split()))
if k==-1:
co=n+m
if co%2!=0:
print("0")
else:
n=n-1
m=m-1
n=n*m
co=pow(2,n,mod)
co%=1000000007
print(co)
else:
n=n-1
m=m-1
n=n*m
co=pow(2,n,mod)
co%=1000000007
print(co) | ["1", "1", "16"] | Python | NoteIn the first example the only way is to put -1 into the only block.In the second example the only way is to put 1 into every block. | Print a single number denoting the answer modulo 1000000007. | Ralph has a magic field which is divided into n × m blocks. That is to say, there are n rows and m columns on the field. Ralph can put an integer in each block. However, the magic field doesn't always work properly. It works only if the product of integers in each row and each column equals to k, where k is either 1 or... | [{"input": "1 1 -1\r\n", "output": ["1"]}, {"input": "1 3 1\r\n", "output": ["1"]}, {"input": "3 3 -1\r\n", "output": ["16"]}, {"input": "2 7 1\r\n", "output": ["64"]}, {"input": "1 1 1\r\n", "output": ["1"]}, {"input": "2 4 -1\r\n", "output": ["8"]}, {"input": "173 69 -1\r\n", "output": ["814271739"]}, {"input": "110 ... | 100 | 100 | 100 | [{'input': '146 34 -1\r\n', 'output': ['742752757']}, {'input': '2886684369091916 3509787933422130 1\r\n', 'output': ['341476979']}, {'input': '987654321987654321 666666666666666666 1\r\n', 'output': ['279028602']}, {'input': '1000000006 100000000000000000 1\r\n', 'output': ['123624987']}, {'input': '173 69 -1\r\n', 'o... | [{'input': '2529756051797760 2682355969139391 -1\r\n', 'output': ['0']}, {'input': '3551499873841921 2512677762780671 -1\r\n', 'output': ['350058339']}, {'input': '3 3 -1\r\n', 'output': ['16']}, {'input': '1 1 1\r\n', 'output': ['1']}, {'input': '94 182 1\r\n', 'output': ['33590706']}] | [{'input': '2 2 1\r\n', 'output': ['2']}, {'input': '1 3 1\r\n', 'output': ['1']}, {'input': '94 182 1\r\n', 'output': ['33590706']}, {'input': '1 1 1\r\n', 'output': ['1']}, {'input': '3613456196418270 2872267429531501 1\r\n', 'output': ['223552863']}] | [{'input': '1 1 1\r\n', 'output': ['1']}, {'input': '173 69 -1\r\n', 'output': ['814271739']}, {'input': '3613456196418270 2872267429531501 1\r\n', 'output': ['223552863']}, {'input': '2 1 -1\r\n', 'output': ['0']}, {'input': '2273134852621270 2798005122439669 1\r\n', 'output': ['901406364']}] | [{'input': '987654321987654321 666666666666666666 1\r\n', 'output': ['279028602']}, {'input': '3536041043537343 2416093514489183 1\r\n', 'output': ['394974516']}, {'input': '1000000000000000000 1 1\r\n', 'output': ['1']}, {'input': '94 86 -1\r\n', 'output': ['476913727']}, {'input': '110 142 1\r\n', 'output': ['5370402... | 100 | 100 | 100 | 100 | 100 | 94.44 | 100 | 50 | 100 | 94.44 | 75 | 100 | 25 | 100 | 75 | 330 | 100 | 87.776 | 75 |
["3 2", "5 4"] | The input consists of two space-separated integers p and k (3 ≤ p ≤ 1 000 000, 0 ≤ k ≤ p - 1) on a single line. It is guaranteed that p is an odd prime number. | 580bf65af24fb7f08250ddbc4ca67e0e | __author__ = 'MoonBall'
import sys
# sys.stdin = open('data/D.in', 'r')
T = 1
M = 1000000007
def process():
P, K = list(map(int, input().split()))
k = [K * x % P for x in range(P)]
# print(k)
# f(0) = k[f(0)]
# f(1) = k[f(4)]
# f(2) = k[f(3)]
# f(3) = k[f(2)]
# f(4) = k[f(1)]
if ... | ["3", "25"] | Python | NoteIn the first sample, p = 3 and k = 2. The following functions work: f(0) = 0, f(1) = 1, f(2) = 2. f(0) = 0, f(1) = 2, f(2) = 1. f(0) = f(1) = f(2) = 0. | Print a single integer, the number of distinct functions f modulo 109 + 7. | As behooves any intelligent schoolboy, Kevin Sun is studying psycowlogy, cowculus, and cryptcowgraphy at the Bovinia State University (BGU) under Farmer Ivan. During his Mathematics of Olympiads (MoO) class, Kevin was confronted with a weird functional equation and needs your help. For two fixed integers k and p, where... | [{"input": "3 2\r\n", "output": ["3"]}, {"input": "5 4\r\n", "output": ["25"]}, {"input": "7 2\r\n", "output": ["49"]}, {"input": "7 6\r\n", "output": ["343"]}, {"input": "10007 25\r\n", "output": ["100140049"]}, {"input": "40037 4\r\n", "output": ["602961362"]}, {"input": "5 0\r\n", "output": ["625"]}, {"input": "5 3\... | 100 | 100 | 100 | [{'input': '337411 146419\r\n', 'output': ['532279245']}, {'input': '6907 2590\r\n', 'output': ['543643888']}, {'input': '5 2\r\n', 'output': ['5']}, {'input': '7 2\r\n', 'output': ['49']}, {'input': '999983 999982\r\n', 'output': ['794678399']}] | [{'input': '40867 37466\r\n', 'output': ['560078799']}, {'input': '6907 2590\r\n', 'output': ['543643888']}, {'input': '807689 9869\r\n', 'output': ['636680820']}, {'input': '203317 12108\r\n', 'output': ['374893480']}, {'input': '5 3\r\n', 'output': ['5']}] | [{'input': '7621 6195\r\n', 'output': ['501036626']}, {'input': '999983 999982\r\n', 'output': ['794678399']}, {'input': '203317 12108\r\n', 'output': ['374893480']}, {'input': '5 2\r\n', 'output': ['5']}, {'input': '450431 344107\r\n', 'output': ['450431']}] | [{'input': '4177 556\r\n', 'output': ['594173514']}, {'input': '5 3\r\n', 'output': ['5']}, {'input': '7 2\r\n', 'output': ['49']}, {'input': '115237 90311\r\n', 'output': ['355904974']}, {'input': '873781 51595\r\n', 'output': ['226847774']}] | [{'input': '999983 1\r\n', 'output': ['844765997']}, {'input': '999983 0\r\n', 'output': ['416606930']}, {'input': '203317 12108\r\n', 'output': ['374893480']}, {'input': '873781 51595\r\n', 'output': ['226847774']}, {'input': '4649 4648\r\n', 'output': ['460009811']}] | 100 | 100 | 100 | 100 | 100 | 87.88 | 87.88 | 87.88 | 87.88 | 100 | 88.89 | 88.89 | 88.89 | 88.89 | 100 | 331 | 100 | 90.304 | 91.112 |
["120 51840", "42 42", "48 72"] | The only line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le m \le 5\cdot10^8$$$). | 3f9980ad292185f63a80bce10705e806 | n2, n1 = (int(_) for _ in input().split())
if n1 % n2 == 0:
n = n1 // n2
k = 0
f = True
while n != 1:
if n % 3 == 0:
n //= 3
k += 1
elif n % 2 == 0:
n //= 2
k += 1
else:
print(-1)
f = False
break
... | ["7", "0", "-1"] | Python | NoteIn the first example, the possible sequence of moves is: $$$120 \rightarrow 240 \rightarrow 720 \rightarrow 1440 \rightarrow 4320 \rightarrow 12960 \rightarrow 25920 \rightarrow 51840.$$$ The are $$$7$$$ steps in total.In the second example, no moves are needed. Thus, the answer is $$$0$$$.In the third example, it ... | Print the number of moves to transform $$$n$$$ to $$$m$$$, or -1 if there is no solution. | Polycarp plays "Game 23". Initially he has a number $$$n$$$ and his goal is to transform it to $$$m$$$. In one move, he can multiply $$$n$$$ by $$$2$$$ or multiply $$$n$$$ by $$$3$$$. He can perform any number of moves.Print the number of moves needed to transform $$$n$$$ to $$$m$$$. Print -1 if it is impossible to do ... | [{"input": "120 51840\r\n", "output": ["7"]}, {"input": "42 42\r\n", "output": ["0"]}, {"input": "48 72\r\n", "output": ["-1"]}, {"input": "1 1\r\n", "output": ["0"]}, {"input": "1 2\r\n", "output": ["1"]}, {"input": "1 4\r\n", "output": ["2"]}, {"input": "1 5\r\n", "output": ["-1"]}, {"input": "1 6\r\n", "output": ["2... | 100 | 100 | 100 | [{'input': '10 61\r\n', 'output': ['-1']}, {'input': '1 16777216\r\n', 'output': ['24']}, {'input': '1 262144\r\n', 'output': ['18']}, {'input': '50 64800\r\n', 'output': ['8']}, {'input': '203 203\r\n', 'output': ['0']}] | [{'input': '201 201\r\n', 'output': ['0']}, {'input': '1 500000000\r\n', 'output': ['-1']}, {'input': '1 223092870\r\n', 'output': ['-1']}, {'input': '505 505\r\n', 'output': ['0']}, {'input': '10 24\r\n', 'output': ['-1']}] | [{'input': '5 7\r\n', 'output': ['-1']}, {'input': '1001 1001\r\n', 'output': ['0']}, {'input': '201 201\r\n', 'output': ['0']}, {'input': '1 22\r\n', 'output': ['-1']}, {'input': '1 2\r\n', 'output': ['1']}] | [{'input': '120 51841\r\n', 'output': ['-1']}, {'input': '1 500000000\r\n', 'output': ['-1']}, {'input': '5 12\r\n', 'output': ['-1']}, {'input': '120 1081\r\n', 'output': ['-1']}, {'input': '1 6\r\n', 'output': ['2']}] | [{'input': '1 223092870\r\n', 'output': ['-1']}, {'input': '9 24\r\n', 'output': ['-1']}, {'input': '404 404\r\n', 'output': ['0']}, {'input': '5 7\r\n', 'output': ['-1']}, {'input': '1 1\r\n', 'output': ['0']}] | 100 | 100 | 100 | 100 | 100 | 83.33 | 100 | 88.89 | 100 | 100 | 83.33 | 100 | 91.67 | 100 | 100 | 332 | 100 | 94.444 | 95 |
["25 3", "50 5"] | The only input line contains a pair of integers a, n (1 ≤ a, n ≤ 107; a + n - 1 ≤ 107). | 915081861e391958dce6ee2a117abd4e | F = {}
def f(k):
if not k in F:
s, i, j = 0, 4, 4
while i <= k:
s += i * f(k // i)
i += j + 1
j += 2
F[k] = (k * (k + 1)) // 2 - s
return F[k]
def g(k):
s, i, j = 0, 4, 4
while i <= k:
s += (i - 1) * f(k // i)
i += j + 1
... | ["30", "125"] | Python | NoteA note to the first sample test. A year of 25 days will consist of one month containing 25 days. A year of 26 days will consist of 26 months, one day each. A year of 27 days will have three months, 9 days each. | Print the required number p. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use cin, cout streams or the %I64d specifier. | Reforms have started in Berland again! At this time, the Parliament is discussing the reform of the calendar. To make the lives of citizens of Berland more varied, it was decided to change the calendar. As more and more people are complaining that "the years fly by...", it was decided that starting from the next year t... | [{"input": "25 3\r\n", "output": ["30"]}, {"input": "50 5\r\n", "output": ["125"]}, {"input": "1 1\r\n", "output": ["1"]}, {"input": "1 2\r\n", "output": ["3"]}, {"input": "1 10\r\n", "output": ["38"]}, {"input": "1 5000000\r\n", "output": ["8224640917276"]}, {"input": "5000000 5000000\r\n", "output": ["24674231279431"... | 100 | 100 | 100 | [{'input': '1 5000000\r\n', 'output': ['8224640917276']}, {'input': '25 3\r\n', 'output': ['30']}, {'input': '1 10\r\n', 'output': ['38']}, {'input': '3000000 5000000\r\n', 'output': ['18094224526592']}, {'input': '5000000 5000000\r\n', 'output': ['24674231279431']}] | [{'input': '4000000 5000000\r\n', 'output': ['21384022194564']}, {'input': '1 1\r\n', 'output': ['1']}, {'input': '1 2\r\n', 'output': ['3']}, {'input': '25 3\r\n', 'output': ['30']}, {'input': '1 5000000\r\n', 'output': ['8224640917276']}] | [{'input': '1 1\r\n', 'output': ['1']}, {'input': '1 2\r\n', 'output': ['3']}, {'input': '1 10\r\n', 'output': ['38']}, {'input': '1 10000000\r\n', 'output': ['32898872196712']}, {'input': '3000000 5000000\r\n', 'output': ['18094224526592']}] | [{'input': '3000000 5000000\r\n', 'output': ['18094224526592']}, {'input': '25 3\r\n', 'output': ['30']}, {'input': '1 10\r\n', 'output': ['38']}, {'input': '1 5000000\r\n', 'output': ['8224640917276']}, {'input': '1000000 5000000\r\n', 'output': ['11514506860120']}] | [{'input': '4000000 5000000\r\n', 'output': ['21384022194564']}, {'input': '1 2\r\n', 'output': ['3']}, {'input': '1000000 5000000\r\n', 'output': ['11514506860120']}, {'input': '5000000 5000000\r\n', 'output': ['24674231279431']}, {'input': '3000000 5000000\r\n', 'output': ['18094224526592']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 333 | 100 | 100 | 100 |
["4 2\naabb", "6 3\naacaab"] | The first line contains two integers n and k (1 ≤ n, k ≤ 100) — the number of baloons and friends. Next line contains string s — colors of baloons. | ceb3807aaffef60bcdbcc9a17a1391be | # -*- coding: utf-8 -*-
"""
Created on Sun Jun 30 16:47:42 2019
@author: avina
"""
n,m = map(int, input().split())
s = input()
d = []
w = set(s)
for i in w:
d.append(s.count(i))
if max(d) > m:
print('NO')
else:
print('YES') | ["YES", "NO"] | Python | NoteIn the first sample Kefa can give 1-st and 3-rd baloon to the first friend, and 2-nd and 4-th to the second.In the second sample Kefa needs to give to all his friends baloons of color a, but one baloon will stay, thats why answer is «NO». | Answer to the task — «YES» or «NO» in a single line. You can choose the case (lower or upper) for each letter arbitrary. | One day Kefa found n baloons. For convenience, we denote color of i-th baloon as si — lowercase letter of the Latin alphabet. Also Kefa has k friends. Friend will be upset, If he get two baloons of the same color. Kefa want to give out all baloons to his friends. Help Kefa to find out, can he give out all his baloons, ... | [{"input": "4 2\r\naabb\r\n", "output": ["YES"]}, {"input": "6 3\r\naacaab\r\n", "output": ["NO"]}, {"input": "2 2\r\nlu\r\n", "output": ["YES"]}, {"input": "5 3\r\novvoo\r\n", "output": ["YES"]}, {"input": "36 13\r\nbzbzcffczzcbcbzzfzbbfzfzzbfbbcbfccbf\r\n", "output": ["YES"]}, {"input": "81 3\r\nooycgmvvrophvcvpoupep... | 100 | 100 | 100 | [{'input': '5 2\r\nzzzzz\r\n', 'output': ['NO']}, {'input': '1 3\r\na\r\n', 'output': ['YES']}, {'input': '75 23\r\nittttiiuitutuiiuuututiuttiuiuutuuuiuiuuuuttuuttuutuiiuiuiiuiitttuututuiuuii\r\n', 'output': ['NO']}, {'input': '3 6\r\naaa\r\n', 'output': ['YES']}, {'input': '1 10\r\na\r\n', 'output': ['YES']}] | [{'input': '49 27\r\noxyorfnkzwsfllnyvdhdanppuzrnbxehugvmlkgeymqjlmfxd\r\n', 'output': ['YES']}, {'input': '100 100\r\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\r\n', 'output': ['YES']}, {'input': '53 26\r\naaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbb\... | [{'input': '3 6\r\naaa\r\n', 'output': ['YES']}, {'input': '7 1\r\nabcdeee\r\n', 'output': ['NO']}, {'input': '2 1\r\nhw\r\n', 'output': ['YES']}, {'input': '8 4\r\naaaaaaaa\r\n', 'output': ['NO']}, {'input': '100 100\r\nbbbbbbbtbbttbtbbbttbttbtbbttttbbbtbttbbbtbttbtbbttttbbbbbtbbttbtbbtbttbbbtbtbtbtbtbtbbbttbbtbtbtbbt... | [{'input': '100 50\r\nfffffttttttjjjuuuvvvvvdddxxxxwwwwgggbsssncccczzyyyyyhhhhhkrreeeeeeaaaaaiiillllllllooooqqqqqqmmpppppp\r\n', 'output': ['YES']}, {'input': '100 100\r\nbbbbbbbtbbttbtbbbttbttbtbbttttbbbtbttbbbtbttbtbbttttbbbbbtbbttbtbbtbttbbbtbtbtbtbtbtbbbttbbtbtbtbbtb\r\n', 'output': ['YES']}, {'input': '4 1\r\nabab... | [{'input': '6 2\r\naabbbc\r\n', 'output': ['NO']}, {'input': '3 2\r\naaa\r\n', 'output': ['NO']}, {'input': '4 6\r\naabb\r\n', 'output': ['YES']}, {'input': '32 22\r\ncduamsptaklqtxlyoutlzepxgyfkvngc\r\n', 'output': ['YES']}, {'input': '1 2\r\na\r\n', 'output': ['YES']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 334 | 100 | 100 | 100 |
["6\n4 1 7 8 3 8\n1"] | The first line of the input contains integer n (1 ≤ n ≤ 100), where n — the number of students shouted "Fly, freebie, fly!" The second line contains n positive integers ti (1 ≤ ti ≤ 1000). The last line contains integer T (1 ≤ T ≤ 1000) — the time interval during which the freebie was near the dormitory. | 086d07bd6f9031df09bd6a6e8fe8f25c | n, t = input(), [0] * 1002
for i in map(int, input().split()): t[i] += 1
T = int(input()) + 1
for i in range(1000): t[i + 1] += t[i]
print(max(t[i + T] - t[i] for i in range(-1, 1001 - T))) | ["3"] | Python | null | Print a single integer — the largest number of people who will pass exam tomorrow because of the freebie visit. | Everyone loves a freebie. Especially students.It is well-known that if in the night before exam a student opens window, opens the student's record-book and shouts loudly three times "Fly, freebie, fly!" — then flown freebie helps him to pass the upcoming exam.In the night before the exam on mathematical analysis n stud... | [{"input": "6\r\n4 1 7 8 3 8\r\n1\r\n", "output": ["3"]}, {"input": "4\r\n4 2 1 5\r\n2\r\n", "output": ["2"]}, {"input": "10\r\n4 7 1 3 8 5 2 1 8 4\r\n3\r\n", "output": ["6"]}, {"input": "8\r\n39 49 37 28 40 17 50 2\r\n10\r\n", "output": ["3"]}, {"input": "2\r\n1 1\r\n1\r\n", "output": ["2"]}, {"input": "2\r\n1 1\r\n2\... | 100 | 100 | 100 | [{'input': '1\r\n849\r\n1\r\n', 'output': ['1']}, {'input': '3\r\n3 1 1\r\n1\r\n', 'output': ['2']}, {'input': '100\r\n923 357 749 109 685 126 961 437 859 91 985 488 644 777 950 144 479 667 1 535 475 38 843 606 672 333 798 42 595 854 410 914 934 586 329 595 861 321 603 924 434 636 475 395 619 449 336 790 279 931 605 89... | [{'input': '2\r\n1 1\r\n1\r\n', 'output': ['2']}, {'input': '100\r\n30 74 20 6 3 63 48 45 36 26 33 24 60 71 45 5 19 37 74 100 98 82 67 76 37 46 68 48 56 29 33 19 15 84 76 92 50 53 42 19 5 91 23 38 93 50 39 45 89 17 57 14 86 81 31 6 16 5 80 6 86 49 18 75 30 30 85 94 38 33 50 76 72 32 73 96 28 3 18 20 96 84 89 48 71 64 6... | [{'input': '6\r\n4 1 7 8 3 8\r\n1\r\n', 'output': ['3']}, {'input': '100\r\n2 1 1 1 2 2 2 2 2 2 1 1 1 1 2 2 1 1 1 2 2 1 1 1 1 2 1 2 1 2 1 2 1 2 2 2 1 1 2 1 2 2 1 1 2 2 2 2 2 1 1 2 1 1 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 2 1 1 2 2 1 2 2 1 1 1 2 2 2 1 1 2 2 1 2 2 2 1 2 2 1 2 2\r\n1\r\n', 'output': ['100']}, {'input': '10... | [{'input': '2\r\n450 826\r\n1000\r\n', 'output': ['2']}, {'input': '2\r\n1 1\r\n1\r\n', 'output': ['2']}, {'input': '8\r\n39 49 37 28 40 17 50 2\r\n10\r\n', 'output': ['3']}, {'input': '3\r\n3 4 3\r\n1\r\n', 'output': ['3']}, {'input': '2\r\n1 1\r\n2\r\n', 'output': ['2']}] | [{'input': '100\r\n923 357 749 109 685 126 961 437 859 91 985 488 644 777 950 144 479 667 1 535 475 38 843 606 672 333 798 42 595 854 410 914 934 586 329 595 861 321 603 924 434 636 475 395 619 449 336 790 279 931 605 898 276 47 537 935 508 576 168 465 115 884 960 593 883 581 468 426 848 289 525 309 589 106 924 238 829... | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 335 | 100 | 100 | 100 |
["60 60 45 55\n80 80 8 32", "60 60 45 55\n80 60 15 25", "50 50 35 45\n90 50 35 45"] | The input contains two lines. Each line has four space-separated integers xi, yi, ri, Ri, that describe the i-th ring; xi and yi are coordinates of the ring's center, ri and Ri are the internal and external radii of the ring correspondingly ( - 100 ≤ xi, yi ≤ 100; 1 ≤ ri < Ri ≤ 100). It is guaranteed that the cent... | 4c2865e4742a29460ca64860740b84f4 | def is_intersect(r1, r2, R, x1, y1, x2, y2):
d = (x1 - x2)**2 + (y1 - y2)**2
return d >= (r1 + R)**2 or r1 < r2 and d <= (r2 - r1)**2 or R < r1 and d <= (r1 - R)**2
x1, y1, r1, R1 = map(int, input().split())
x2, y2, r2, R2 = map(int, input().split())
res1 = is_intersect(r1, r2, R2, x1, y1, x2, y2)
res2 = is_i... | ["1", "4", "0"] | Python | NoteFigures for test samples are given below. The possible cuts are marked with red dotted line. | A single integer — the number of ways to cut out a circle from the canvas. | A renowned abstract artist Sasha, drawing inspiration from nowhere, decided to paint a picture entitled "Special Olympics". He justly thought that, if the regular Olympic games have five rings, then the Special ones will do with exactly two rings just fine.Let us remind you that a ring is a region located between two c... | [{"input": "60 60 45 55\r\n80 80 8 32\r\n", "output": ["1"]}, {"input": "60 60 45 55\r\n80 60 15 25\r\n", "output": ["4"]}, {"input": "50 50 35 45\r\n90 50 35 45\r\n", "output": ["0"]}, {"input": "0 0 50 70\r\n1 0 60 80\r\n", "output": ["2"]}, {"input": "0 0 1 2\r\n10 0 2 20\r\n", "output": ["2"]}, {"input": "31 13 22 ... | 100 | 100 | 100 | [{'input': '-65 24 20 40\r\n-6 24 99 100\r\n', 'output': ['4']}, {'input': '31 40 37 76\r\n48 65 66 98\r\n', 'output': ['0']}, {'input': '-71 15 20 40\r\n29 90 85 100\r\n', 'output': ['2']}, {'input': '-20 78 20 40\r\n8 85 10 11\r\n', 'output': ['1']}, {'input': '49 -67 20 40\r\n57 -67 12 28\r\n', 'output': ['2']}] | [{'input': '19 96 20 40\r\n77 96 78 99\r\n', 'output': ['2']}, {'input': '-67 47 20 40\r\n-38 47 11 49\r\n', 'output': ['0']}, {'input': '-81 -55 20 40\r\n19 20 83 85\r\n', 'output': ['4']}, {'input': '-64 -47 20 40\r\n-5 -37 79 100\r\n', 'output': ['1']}, {'input': '8 -95 20 40\r\n36 -95 8 68\r\n', 'output': ['1']}] | [{'input': '1 44 20 40\r\n39 44 1 2\r\n', 'output': ['2']}, {'input': '-73 36 20 40\r\n-44 36 9 10\r\n', 'output': ['1']}, {'input': '-81 -55 20 40\r\n19 20 83 85\r\n', 'output': ['4']}, {'input': '-77 -16 20 40\r\n-18 -6 99 100\r\n', 'output': ['2']}, {'input': '28 -91 20 40\r\n58 -91 10 49\r\n', 'output': ['0']}] | [{'input': '19 96 20 40\r\n77 96 78 99\r\n', 'output': ['2']}, {'input': '41 -14 37 76\r\n48 65 66 98\r\n', 'output': ['0']}, {'input': '-67 47 20 40\r\n-38 47 11 49\r\n', 'output': ['0']}, {'input': '-100 -19 20 40\r\n-62 -19 1 18\r\n', 'output': ['1']}, {'input': '-86 -97 20 40\r\n14 -31 79 100\r\n', 'output': ['1']}... | [{'input': '57 -86 20 40\r\n75 -86 1 22\r\n', 'output': ['2']}, {'input': '1 44 20 40\r\n39 44 1 2\r\n', 'output': ['2']}, {'input': '31 40 37 76\r\n48 65 66 98\r\n', 'output': ['0']}, {'input': '-73 36 20 40\r\n-44 36 9 10\r\n', 'output': ['1']}, {'input': '-38 43 20 40\r\n-20 49 1 20\r\n', 'output': ['2']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 336 | 100 | 100 | 100 |
["5 3 2 3", "5 3 100 1"] | The only line contains four integers $$$k$$$, $$$n$$$, $$$s$$$, $$$p$$$ ($$$1 \le k, n, s, p \le 10^4$$$) — the number of people, the number of airplanes each should make, the number of airplanes that can be made using one sheet and the number of sheets in one pack, respectively. | 73f0c7cfc06a9b04e4766d6aa61fc780 | from math import *
k, n, s, p = map(int, input().split())
q = k * ceil(n / s)
w = ceil(q / p)
print(w)
| ["4", "5"] | Python | NoteIn the first sample they have to buy $$$4$$$ packs of paper: there will be $$$12$$$ sheets in total, and giving $$$2$$$ sheets to each person is enough to suit everyone's needs.In the second sample they have to buy a pack for each person as they can't share sheets. | Print a single integer — the minimum number of packs they should buy. | To make a paper airplane, one has to use a rectangular piece of paper. From a sheet of standard size you can make $$$s$$$ airplanes.A group of $$$k$$$ people decided to make $$$n$$$ airplanes each. They are going to buy several packs of paper, each of them containing $$$p$$$ sheets, and then distribute the sheets betwe... | [{"input": "5 3 2 3\r\n", "output": ["4"]}, {"input": "5 3 100 1\r\n", "output": ["5"]}, {"input": "10000 10000 1 1\r\n", "output": ["100000000"]}, {"input": "1 1 10000 10000\r\n", "output": ["1"]}, {"input": "300 300 21 23\r\n", "output": ["196"]}, {"input": "300 2 37 51\r\n", "output": ["6"]}, {"input": "2 400 23 57\... | 100 | 100 | 100 | [{'input': '1 1 2 2\r\n', 'output': ['1']}, {'input': '1 2 1 2\r\n', 'output': ['1']}, {'input': '9 20 5 7\r\n', 'output': ['6']}, {'input': '6246 8489 1227 9\r\n', 'output': ['4858']}, {'input': '10000 10000 3 2\r\n', 'output': ['16670000']}] | [{'input': '5 3 2 3\r\n', 'output': ['4']}, {'input': '10000 10000 1 1\r\n', 'output': ['100000000']}, {'input': '6246 8489 1227 9\r\n', 'output': ['4858']}, {'input': '5 3 100 1\r\n', 'output': ['5']}, {'input': '230 1234 9124 23\r\n', 'output': ['10']}] | [{'input': '300 2 37 51\r\n', 'output': ['6']}, {'input': '10000 10000 3 2\r\n', 'output': ['16670000']}, {'input': '5324 5439 32 13\r\n', 'output': ['69622']}, {'input': '1 1 10000 10000\r\n', 'output': ['1']}, {'input': '230 1234 9124 23\r\n', 'output': ['10']}] | [{'input': '1 2 1 2\r\n', 'output': ['1']}, {'input': '1 1 10000 10000\r\n', 'output': ['1']}, {'input': '300 2 37 51\r\n', 'output': ['6']}, {'input': '9 20 5 7\r\n', 'output': ['6']}, {'input': '10000 10000 3 2\r\n', 'output': ['16670000']}] | [{'input': '300 300 21 23\r\n', 'output': ['196']}, {'input': '6246 8489 1227 9\r\n', 'output': ['4858']}, {'input': '10000 10000 3 2\r\n', 'output': ['16670000']}, {'input': '1 1 1 1\r\n', 'output': ['1']}, {'input': '1 1 10 10\r\n', 'output': ['1']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 337 | 100 | 100 | 100 |
["30 5 20 20 3 5", "10 4 100 5 5 1"] | The single line of the input contains six integers x, t, a, b, da, db (0 ≤ x ≤ 600; 1 ≤ t, a, b, da, db ≤ 300) — Valera's result, the contest's duration, the initial cost of the first problem, the initial cost of the second problem, the number of points that the first and the second problem lose per minute, correspondi... | f98168cdd72369303b82b5a7ac45c3af | x,t,a,b,c,d=map(int,input().split())
R=range(t)
y=x==0
for i in R:
if x==a-c*i or x==b-d*i:y=1
for j in R:y|=x==a+b-c*i-d*j
print(['NO','YES'][y]) | ["YES", "NO"] | Python | NoteIn the first sample Valera could have acted like this: he could have submitted the first problem at minute 0 and the second problem — at minute 2. Then the first problem brings him 20 points and the second problem brings him 10 points, that in total gives the required 30 points. | If Valera could have earned exactly x points at a contest, print "YES", otherwise print "NO" (without the quotes). | A boy Valera registered on site Codeforces as Valera, and wrote his first Codeforces Round #300. He boasted to a friend Arkady about winning as much as x points for his first contest. But Arkady did not believe his friend's words and decided to check whether Valera could have shown such a result.He knows that the conte... | [{"input": "30 5 20 20 3 5\r\n", "output": ["YES"]}, {"input": "10 4 100 5 5 1\r\n", "output": ["NO"]}, {"input": "0 7 30 50 3 4\r\n", "output": ["YES"]}, {"input": "50 10 30 20 1 2\r\n", "output": ["YES"]}, {"input": "40 1 40 5 11 2\r\n", "output": ["YES"]}, {"input": "35 8 20 20 1 2\r\n", "output": ["YES"]}, {"input"... | 100 | 100 | 100 | [{'input': '17 10 10 20 1 2\r\n', 'output': ['YES']}, {'input': '80 5 39 40 1 1\r\n', 'output': ['NO']}, {'input': '30 5 20 20 3 5\r\n', 'output': ['YES']}, {'input': '5 4 11 80 2 4\r\n', 'output': ['YES']}, {'input': '0 35 208 98 6 2\r\n', 'output': ['YES']}] | [{'input': '80 5 39 40 1 1\r\n', 'output': ['NO']}, {'input': '10 4 100 5 5 1\r\n', 'output': ['NO']}, {'input': '543 4 31 69 6 5\r\n', 'output': ['NO']}, {'input': '1 21 178 20 1 1\r\n', 'output': ['YES']}, {'input': '142 1 66 76 18 39\r\n', 'output': ['YES']}] | [{'input': '363 2 280 239 5 231\r\n', 'output': ['NO']}, {'input': '50 10 30 20 1 2\r\n', 'output': ['YES']}, {'input': '41 77 96 145 1 1\r\n', 'output': ['YES']}, {'input': '27 45 44 169 1 2\r\n', 'output': ['YES']}, {'input': '5 4 11 80 2 4\r\n', 'output': ['YES']}] | [{'input': '2 5 29 36 5 6\r\n', 'output': ['NO']}, {'input': '360 5 215 4 52 1\r\n', 'output': ['NO']}, {'input': '74 72 104 71 1 1\r\n', 'output': ['YES']}, {'input': '223 92 123 118 1 1\r\n', 'output': ['YES']}, {'input': '16 24 26 23 1 1\r\n', 'output': ['YES']}] | [{'input': '6 2 11 1 11 1\r\n', 'output': ['NO']}, {'input': '38 100 99 245 1 1\r\n', 'output': ['YES']}, {'input': '2 5 29 36 5 6\r\n', 'output': ['NO']}, {'input': '46 7 18 6 3 1\r\n', 'output': ['NO']}, {'input': '3 1 20 15 17 5\r\n', 'output': ['NO']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 338 | 100 | 100 | 100 |
["6 4\n1 2 5 10 15 20", "4 10\n1 3 2 4", "6 100\n1 2 3 4 5 6"] | First line of the input contains an integer $$$n$$$ ($$$2 \le n \le 100$$$) and an integer $$$B$$$ ($$$1 \le B \le 100$$$) — the number of elements in the sequence and the number of bitcoins you have. Second line contains $$$n$$$ integers: $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ ($$$1 \le a_i \le 100$$$) — elements of the... | b3f8e769ee7719ea5c9f458428b16a4e | n, B = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
poss_Splits = []
ps = 0
ptlan = 0
for i in range(n - 1):
if arr[i] % 2 == 0:
ps += 1
else:
ptlan += 1
if ps == ptlan:
poss_Splits.append((abs(arr[i] - arr[i + 1]), i))
poss_Splits = sorted(poss_Splits)... | ["1", "0", "2"] | Python | NoteIn the first sample the optimal answer is to split sequence between $$$2$$$ and $$$5$$$. Price of this cut is equal to $$$3$$$ bitcoins.In the second sample it is not possible to make even one cut even with unlimited number of bitcoins.In the third sample the sequence should be cut between $$$2$$$ and $$$3$$$, and ... | Print the maximum possible number of cuts which can be made while spending no more than $$$B$$$ bitcoins. | There are a lot of things which could be cut — trees, paper, "the rope". In this problem you are going to cut a sequence of integers.There is a sequence of integers, which contains the equal number of even and odd numbers. Given a limited budget, you need to make maximum possible number of cuts such that each resulting... | [{"input": "6 4\r\n1 2 5 10 15 20\r\n", "output": ["1"]}, {"input": "4 10\r\n1 3 2 4\r\n", "output": ["0"]}, {"input": "6 100\r\n1 2 3 4 5 6\r\n", "output": ["2"]}, {"input": "2 100\r\n13 78\r\n", "output": ["0"]}, {"input": "10 1\r\n56 56 98 2 11 64 97 41 95 53\r\n", "output": ["0"]}, {"input": "10 100\r\n94 65 24 47 ... | 100 | 100 | 100 | [{'input': '10 10\r\n94 32 87 13 4 22 85 81 18 95\r\n', 'output': ['1']}, {'input': '100 10\r\n3 20 3 29 90 69 2 30 70 28 71 99 22 99 34 70 87 48 3 92 71 61 26 90 14 38 51 81 16 33 49 71 14 52 50 95 65 16 80 57 87 47 29 14 40 31 74 15 87 76 71 61 30 91 44 10 87 48 84 12 77 51 25 68 49 38 79 8 7 9 39 19 48 40 15 53 29 4... | [{'input': '100 50\r\n13 31 29 86 46 10 2 87 94 2 28 31 29 15 64 3 94 71 37 76 9 91 89 38 12 46 53 33 58 11 98 4 37 72 30 52 6 86 40 98 28 6 34 80 61 47 45 69 100 47 91 64 87 41 67 58 88 75 13 81 36 58 66 29 10 27 54 83 44 15 11 33 49 36 61 18 89 26 87 1 99 19 57 21 55 84 20 74 14 43 15 51 2 76 22 92 43 14 72 77\r\n', ... | [{'input': '100 30\r\n100 100 39 39 39 100 100 39 39 100 39 39 100 39 100 39 100 100 100 100 100 39 100 100 100 39 39 39 100 39 100 100 39 39 100 39 39 39 100 100 39 100 39 100 39 39 100 100 39 100 39 100 39 39 39 100 39 100 39 39 39 100 39 39 100 100 39 39 39 100 100 39 39 39 100 100 100 100 39 100 100 100 39 39 100 3... | [{'input': '6 1\r\n1 2 1 2 1 2\r\n', 'output': ['1']}, {'input': '100 10\r\n19 55 91 50 31 23 60 84 38 1 22 51 27 76 28 98 11 44 61 63 15 93 52 3 66 16 53 36 18 62 35 85 78 37 73 64 87 74 46 26 82 69 49 33 83 89 56 67 71 25 39 94 96 17 21 6 47 68 34 42 57 81 13 10 54 2 48 80 20 77 4 5 59 30 90 95 45 75 8 88 24 41 40 14... | [{'input': '4 10\r\n1 3 2 4\r\n', 'output': ['0']}, {'input': '6 4\r\n1 2 4 5 7 8\r\n', 'output': ['2']}, {'input': '100 80\r\n39 100 39 100 100 100 100 39 39 100 100 39 39 100 39 39 39 39 100 39 39 39 39 100 100 100 100 39 100 39 39 100 100 39 39 100 39 100 39 100 100 39 39 100 39 39 39 100 39 100 39 100 100 100 100 1... | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 339 | 100 | 100 | 100 |
["harry potter", "tom riddle"] | The input consists of a single line containing two space-separated strings: the first and the last names. Each character of each string is a lowercase English letter. The length of each string is between 1 and 10, inclusive. | aed892f2bda10b6aee10dcb834a63709 | first_name, last_name = input().split()
first_done = first_name.lower()
last_done = last_name.lower()
login = first_name[0]
for i in range(1, len(first_name)):
if ord(first_done[i]) < ord(last_done[0]):
login += first_name[i]
else:
break
login += last_name[0]
print(login) | ["hap", "tomr"] | Python | null | Output a single string — alphabetically earliest possible login formed from these names. The output should be given in lowercase as well. | The preferred way to generate user login in Polygon is to concatenate a prefix of the user's first name and a prefix of their last name, in that order. Each prefix must be non-empty, and any of the prefixes can be the full name. Typically there are multiple possible logins for each person.You are given the first and th... | [{"input": "harry potter\r\n", "output": ["hap"]}, {"input": "tom riddle\r\n", "output": ["tomr"]}, {"input": "a qdpinbmcrf\r\n", "output": ["aq"]}, {"input": "wixjzniiub ssdfodfgap\r\n", "output": ["wis"]}, {"input": "z z\r\n", "output": ["zz"]}, {"input": "ertuyivhfg v\r\n", "output": ["ertuv"]}, {"input": "asdfghjkl... | 100 | 100 | 100 | [{'input': 'h qart\r\n', 'output': ['hq']}, {'input': 'cgpegngs aufzxkyyrw\r\n', 'output': ['ca']}, {'input': 'bbb b\r\n', 'output': ['bb']}, {'input': 'lwli ewrpu\r\n', 'output': ['le']}, {'input': 'badkiln yort\r\n', 'output': ['badkilny']}] | [{'input': 'tom riddle\r\n', 'output': ['tomr']}, {'input': 'udggmyop ze\r\n', 'output': ['udggmyopz']}, {'input': 'amolfed pun\r\n', 'output': ['amolfedp']}, {'input': 'aaaaaaaaaz york\r\n', 'output': ['aaaaaaaaay']}, {'input': 'a b\r\n', 'output': ['ab']}] | [{'input': 'vugvblnzx kqdwdulm\r\n', 'output': ['vk']}, {'input': 'aaaaaaaaaa a\r\n', 'output': ['aa']}, {'input': 'd kgfpjsurfw\r\n', 'output': ['dk']}, {'input': 'obljndajv q\r\n', 'output': ['obljndajq']}, {'input': 'bgopsdfji uaps\r\n', 'output': ['bgopsdfjiu']}] | [{'input': 'z a\r\n', 'output': ['za']}, {'input': 'h qart\r\n', 'output': ['hq']}, {'input': 'aaaaaaaaaa aaaaaaaaaa\r\n', 'output': ['aa']}, {'input': 'aa ab\r\n', 'output': ['aa']}, {'input': 'aaaaaaa aaaaaa\r\n', 'output': ['aa']}] | [{'input': 'aaaaaaa aaaaaa\r\n', 'output': ['aa']}, {'input': 'aar raa\r\n', 'output': ['aar']}, {'input': 'a aaa\r\n', 'output': ['aa']}, {'input': 'wixjzniiub ssdfodfgap\r\n', 'output': ['wis']}, {'input': 'd kgfpjsurfw\r\n', 'output': ['dk']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 90 | 100 | 100 | 100 | 100 | 75 | 100 | 340 | 100 | 98 | 95 |
["7\nj......", "7\n...feon", "7\n.l.r.o."] | First line contains an integer n (6 ≤ n ≤ 8) – the length of the string. Next line contains a string consisting of n characters, each of which is either a lower case english letter (indicating a known letter) or a dot character (indicating an empty cell in the crossword). | ec3d15ff198d1e4ab9fd04dd3b12e6c0 | import re
input()
print(next(filter(re.compile(input()[:-3] + '$').match, ['vapor', 'jolt', 'flar', 'esp', 'umbr', 'leaf', 'glac', 'sylv'])) + 'eon')
| ["jolteon", "leafeon", "flareon"] | Python | NoteHere's a set of names in a form you can paste into your solution:["vaporeon", "jolteon", "flareon", "espeon", "umbreon", "leafeon", "glaceon", "sylveon"]{"vaporeon", "jolteon", "flareon", "espeon", "umbreon", "leafeon", "glaceon", "sylveon"} | Print a name of the pokemon that Eevee can evolve into that matches the pattern in the input. Use lower case letters only to print the name (in particular, do not capitalize the first letter). | You are solving the crossword problem K from IPSC 2014. You solved all the clues except for one: who does Eevee evolve into? You are not very into pokemons, but quick googling helped you find out, that Eevee can evolve into eight different pokemons: Vaporeon, Jolteon, Flareon, Espeon, Umbreon, Leafeon, Glaceon, and Syl... | [{"input": "7\r\nj......\r\n", "output": ["jolteon"]}, {"input": "7\r\n...feon\r\n", "output": ["leafeon"]}, {"input": "7\r\n.l.r.o.\r\n", "output": ["flareon"]}, {"input": "6\r\n.s..o.\r\n", "output": ["espeon"]}, {"input": "7\r\n.mb....\r\n", "output": ["umbreon"]}, {"input": "7\r\nglaceon\r\n", "output": ["glaceon"]... | 100 | 100 | 100 | [{'input': '7\r\n.l.c...\r\n', 'output': ['glaceon']}, {'input': '7\r\n.y.....\r\n', 'output': ['sylveon']}, {'input': '7\r\n..lveon\r\n', 'output': ['sylveon']}, {'input': '7\r\n.l.ceon\r\n', 'output': ['glaceon']}, {'input': '8\r\n........\r\n', 'output': ['vaporeon']}] | [{'input': '7\r\n..lveon\r\n', 'output': ['sylveon']}, {'input': '7\r\n.mb....\r\n', 'output': ['umbreon']}, {'input': '7\r\n.laceon\r\n', 'output': ['glaceon']}, {'input': '8\r\n..p.....\r\n', 'output': ['vaporeon']}, {'input': '7\r\n.l.c...\r\n', 'output': ['glaceon']}] | [{'input': '7\r\n.l.ceon\r\n', 'output': ['glaceon']}, {'input': '7\r\n.l.c...\r\n', 'output': ['glaceon']}, {'input': '7\r\n..lv...\r\n', 'output': ['sylveon']}, {'input': '8\r\n..p.....\r\n', 'output': ['vaporeon']}, {'input': '8\r\n........\r\n', 'output': ['vaporeon']}] | [{'input': '6\r\n......\r\n', 'output': ['espeon']}, {'input': '7\r\n..lv...\r\n', 'output': ['sylveon']}, {'input': '7\r\n.laceon\r\n', 'output': ['glaceon']}, {'input': '7\r\n..areon\r\n', 'output': ['flareon']}, {'input': '7\r\n.l.c...\r\n', 'output': ['glaceon']}] | [{'input': '8\r\n..p.....\r\n', 'output': ['vaporeon']}, {'input': '7\r\n..ar...\r\n', 'output': ['flareon']}, {'input': '8\r\n........\r\n', 'output': ['vaporeon']}, {'input': '7\r\n..lv...\r\n', 'output': ['sylveon']}, {'input': '6\r\n......\r\n', 'output': ['espeon']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 341 | 100 | 100 | 100 |
["-2 1", "2 1", "4 3"] | The first and single line contains two integers x and y — the coordinates of the hole made in the clock by the ball. Each of the numbers x and y has an absolute value that does not exceed 1000. | 8c92aac1bef5822848a136a1328346c6 | x, y = map(int, input().split())
p = x * x + y * y
d = int(p ** 0.5)
if d * d == p: print('black')
else:
if x * y < 0: print('black' if d % 2 else 'white')
else: print('white' if d % 2 else 'black') | ["white", "black", "black"] | Python | null | Find the required color. All the points between which and the origin of coordinates the distance is integral-value are painted black. | Not so long ago as a result of combat operations the main Berland place of interest — the magic clock — was damaged. The cannon's balls made several holes in the clock, that's why the residents are concerned about the repair. The magic clock can be represented as an infinite Cartesian plane, where the origin correspond... | [{"input": "-2 1\r\n", "output": ["white"]}, {"input": "2 1\r\n", "output": ["black"]}, {"input": "4 3\r\n", "output": ["black"]}, {"input": "3 3\r\n", "output": ["black"]}, {"input": "4 4\r\n", "output": ["white"]}, {"input": "-4 4\r\n", "output": ["black"]}, {"input": "4 -4\r\n", "output": ["black"]}, {"input": "-4 -... | 100 | 100 | 100 | [{'input': '253 -204\r\n', 'output': ['black']}, {'input': '-469 -36\r\n', 'output': ['black']}, {'input': '351 -280\r\n', 'output': ['black']}, {'input': '132 224\r\n', 'output': ['black']}, {'input': '4 4\r\n', 'output': ['white']}] | [{'input': '-589 952\r\n', 'output': ['black']}, {'input': '72 -154\r\n', 'output': ['black']}, {'input': '-40 198\r\n', 'output': ['black']}, {'input': '0 2\r\n', 'output': ['black']}, {'input': '0 0\r\n', 'output': ['black']}] | [{'input': '-1000 0\r\n', 'output': ['black']}, {'input': '-211 243\r\n', 'output': ['black']}, {'input': '-206 -518\r\n', 'output': ['white']}, {'input': '902 479\r\n', 'output': ['white']}, {'input': '-4 -4\r\n', 'output': ['white']}] | [{'input': '-4 4\r\n', 'output': ['black']}, {'input': '-668 970\r\n', 'output': ['black']}, {'input': '-215 -996\r\n', 'output': ['black']}, {'input': '555 319\r\n', 'output': ['black']}, {'input': '72 -154\r\n', 'output': ['black']}] | [{'input': '17 144\r\n', 'output': ['black']}, {'input': '875 -129\r\n', 'output': ['white']}, {'input': '-40 198\r\n', 'output': ['black']}, {'input': '-180 -432\r\n', 'output': ['black']}, {'input': '8 882\r\n', 'output': ['black']}] | 100 | 100 | 100 | 100 | 100 | 100 | 83.33 | 100 | 100 | 100 | 75 | 75 | 100 | 100 | 100 | 342 | 100 | 96.666 | 90 |
["78 87", "1 1"] | The first letter contains two space-separated numbers a and b (1 ≤ a, b ≤ 1000) which represent the given summands. | 8ccfb9b1fef6a992177cc49bd56fab7b | a, b = input().split()
x = int(max(a + b)) + 1
s, v = int(a, x) + int(b, x), 0
while s:
s, v = s // x, v + 1
print(v) | ["3", "2"] | Python | null | Print a single number — the length of the longest answer. | Vasya studies positional numeral systems. Unfortunately, he often forgets to write the base of notation in which the expression is written. Once he saw a note in his notebook saying a + b = ?, and that the base of the positional notation wasn’t written anywhere. Now Vasya has to choose a base p and regard the expressio... | [{"input": "78 87\r\n", "output": ["3"]}, {"input": "1 1\r\n", "output": ["2"]}, {"input": "9 7\r\n", "output": ["2"]}, {"input": "11 11\r\n", "output": ["3"]}, {"input": "43 21\r\n", "output": ["3"]}, {"input": "84 89\r\n", "output": ["3"]}, {"input": "12 34\r\n", "output": ["3"]}, {"input": "99 11\r\n", "output": ["3... | 100 | 100 | 100 | [{'input': '1000 1000\r\n', 'output': ['5']}, {'input': '986 216\r\n', 'output': ['4']}, {'input': '262 685\r\n', 'output': ['4']}, {'input': '1 999\r\n', 'output': ['4']}, {'input': '99 11\r\n', 'output': ['3']}] | [{'input': '87 8\r\n', 'output': ['3']}, {'input': '78 87\r\n', 'output': ['3']}, {'input': '2 1\r\n', 'output': ['2']}, {'input': '11 99\r\n', 'output': ['3']}, {'input': '1000 1000\r\n', 'output': ['5']}] | [{'input': '2 2\r\n', 'output': ['2']}, {'input': '890 789\r\n', 'output': ['4']}, {'input': '262 685\r\n', 'output': ['4']}, {'input': '999 1000\r\n', 'output': ['4']}, {'input': '3 3\r\n', 'output': ['2']}] | [{'input': '9 7\r\n', 'output': ['2']}, {'input': '998 1000\r\n', 'output': ['4']}, {'input': '208 997\r\n', 'output': ['4']}, {'input': '999 998\r\n', 'output': ['4']}, {'input': '104 938\r\n', 'output': ['4']}] | [{'input': '43 21\r\n', 'output': ['3']}, {'input': '1 466\r\n', 'output': ['3']}, {'input': '3 2\r\n', 'output': ['2']}, {'input': '79 1\r\n', 'output': ['2']}, {'input': '667 373\r\n', 'output': ['4']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 343 | 100 | 100 | 100 |
["4\n1 1 0 1", "6\n0 1 0 0 1 0", "1\n0"] | The first line contains one integer number n (1 ≤ n ≤ 100). The second line contains n space-separated integer numbers s1, s2, ..., sn (0 ≤ si ≤ 1). 0 corresponds to an unsuccessful game, 1 — to a successful one. | c7b1f0b40e310f99936d1c33e4816b95 | n = int(input())
t = -1
an = 0
a = list(map(int, input().split()))
while a.count(1):
an = max(a.index(1) + a.count(1), an)
del a[a.index(1)]
print(max(an, len(a)))
| ["3", "4", "1"] | Python | null | Print one integer — the maximum number of games Hideo can leave in his CV so that no unsuccessful game comes after a successful one. | Hideo Kojima has just quit his job at Konami. Now he is going to find a new place to work. Despite being such a well-known person, he still needs a CV to apply for a job.During all his career Hideo has produced n games. Some of them were successful, some were not. Hideo wants to remove several of them (possibly zero) f... | [{"input": "4\r\n1 1 0 1\r\n", "output": ["3"]}, {"input": "6\r\n0 1 0 0 1 0\r\n", "output": ["4"]}, {"input": "1\r\n0\r\n", "output": ["1"]}, {"input": "100\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0... | 100 | 100 | 100 | [{'input': '6\r\n0 1 0 0 1 0\r\n', 'output': ['4']}, {'input': '78\r\n0 0 1 0 1 0 1 1 0 0 0 1 1 1 1 0 0 0 1 0 1 1 1 0 1 0 0 0 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 0 1 0 0 0 0 0 1 0 0 1 0 1 0 1 0 1 0 1 1 1 0 0 1 0 0 0 0 1 0 1 0 0 1 0\r\n', 'output': ['42']}, {'input': '16\r\n1 1 1 1 1 0 0 0 0 0 1 0 1 0 0 1\r\n', 'output': ['9'... | [{'input': '3\r\n1 0 0\r\n', 'output': ['2']}, {'input': '4\r\n1 1 0 1\r\n', 'output': ['3']}, {'input': '5\r\n0 1 0 0 1\r\n', 'output': ['4']}, {'input': '1\r\n1\r\n', 'output': ['1']}, {'input': '100\r\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1... | [{'input': '3\r\n1 0 1\r\n', 'output': ['2']}, {'input': '100\r\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\r\n', 'output': ['100']}, {'input': '100\r\n0 0 0 0 0 0... | [{'input': '90\r\n1 0 0 1 1 0 0 1 0 0 0 0 1 1 1 0 1 0 1 0 0 0 0 1 0 0 1 1 1 1 1 0 0 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 0 1 0 0 1 1 0 0 1 0 0 0 0 1 1 1 0 1 0 1 0 0 0 0 1 0 0 1 1 1 1 1 0 0 0 1 0\r\n', 'output': ['52']}, {'input': '5\r\n0 1 0 0 1\r\n', 'output': ['4']}, {'input': '4\r\n1 0 0 1\r\n', 'output': ['3']},... | [{'input': '4\r\n1 0 0 1\r\n', 'output': ['3']}, {'input': '90\r\n1 0 0 1 1 0 0 1 0 0 0 0 1 1 1 0 1 0 1 0 0 0 0 1 0 0 1 1 1 1 1 0 0 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 0 1 0 0 1 1 0 0 1 0 0 0 0 1 1 1 0 1 0 1 0 0 0 0 1 0 0 1 1 1 1 1 0 0 0 1 0\r\n', 'output': ['52']}, {'input': '100\r\n0 0 1 1 1 0 0 0 0 1 0 0 0 0 0 0... | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 344 | 100 | 100 | 100 |
["3 1", "2 3", "7 3"] | The single line of the input contains two positive integers a and b (1 ≤ a, b ≤ 100) — the number of red and blue socks that Vasya's got. | 775766790e91e539c1cfaa5030e5b955 | a, b = map(int, input().split())
k = 0
k2 = 0
while a > 0 and b > 0:
a -= 1
b -= 1
k += 1
if a > 0:
k2 = int(a//2)
elif b > 0:
k2 = int(b//2)
print(k, k2) | ["1 1", "2 0", "3 2"] | Python | NoteIn the first sample Vasya can first put on one pair of different socks, after that he has two red socks left to wear on the second day. | Print two space-separated integers — the maximum number of days when Vasya can wear different socks and the number of days when he can wear the same socks until he either runs out of socks or cannot make a single pair from the socks he's got. Keep in mind that at the end of the day Vasya throws away the socks that he's... | One day Vasya the Hipster decided to count how many socks he had. It turned out that he had a red socks and b blue socks.According to the latest fashion, hipsters should wear the socks of different colors: a red one on the left foot, a blue one on the right foot.Every day Vasya puts on new socks in the morning and thro... | [{"input": "3 1\r\n", "output": ["1 1", "1 1", "1\r\n1"]}, {"input": "2 3\r\n", "output": ["2 0", "2 0", "2\r\n0"]}, {"input": "7 3\r\n", "output": ["3\r\n2", "3 2", "3 2"]}, {"input": "100 100\r\n", "output": ["100 0", "100 0", "100\r\n0"]}, {"input": "4 10\r\n", "output": ["4\r\n3", "4 3", "4 3"]}, {"input": "6 ... | 100 | 100 | 100 | [{'input': '45 99\r\n', 'output': ['45\r\n27', '45 27', '45 27']}, {'input': '100 1\r\n', 'output': ['1 49', '1 49', '1\r\n49']}, {'input': '68 21\r\n', 'output': ['21 23', '21 23', '21\r\n23']}, {'input': '100 10\r\n', 'output': ['10 45', '10\r\n45', '10 45']}, {'input': '11 32\r\n', 'output': ['11\r\n10', '11 10'... | [{'input': '2 3\r\n', 'output': ['2 0', '2 0', '2\r\n0']}, {'input': '15 45\r\n', 'output': ['15\r\n15', '15 15', '15 15']}, {'input': '68 59\r\n', 'output': ['59 4', '59\r\n4', '59 4']}, {'input': '11 56\r\n', 'output': ['11 22', '11\r\n22', '11 22']}, {'input': '100 10\r\n', 'output': ['10 45', '10\r\n45', '10 4... | [{'input': '10 40\r\n', 'output': ['10\r\n15', '10 15', '10 15']}, {'input': '1 100\r\n', 'output': ['1 49', '1 49', '1\r\n49']}, {'input': '100 98\r\n', 'output': ['98 1', '98\r\n1', '98 1']}, {'input': '33 33\r\n', 'output': ['33 0', '33\r\n0', '33 0']}, {'input': '11 32\r\n', 'output': ['11\r\n10', '11 10', '11 ... | [{'input': '10 40\r\n', 'output': ['10\r\n15', '10 15', '10 15']}, {'input': '100 98\r\n', 'output': ['98 1', '98\r\n1', '98 1']}, {'input': '4 10\r\n', 'output': ['4\r\n3', '4 3', '4 3']}, {'input': '100 10\r\n', 'output': ['10 45', '10\r\n45', '10 45']}, {'input': '100 1\r\n', 'output': ['1 49', '1 49', '1\r\n49... | [{'input': '100 45\r\n', 'output': ['45\r\n27', '45 27', '45 27']}, {'input': '7 3\r\n', 'output': ['3\r\n2', '3 2', '3 2']}, {'input': '10 40\r\n', 'output': ['10\r\n15', '10 15', '10 15']}, {'input': '34 30\r\n', 'output': ['30\r\n2', '30 2', '30 2']}, {'input': '100 1\r\n', 'output': ['1 49', '1 49', '1\r\n49']... | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 83.33 | 83.33 | 100 | 83.33 | 83.33 | 345 | 100 | 100 | 86.664 |
["4 3 9", "4 3 24", "2 4 4"] | The only line contains three integers n, m and k (1 ≤ n, m ≤ 10 000, 1 ≤ k ≤ 2nm) — the number of lanes, the number of desks in each lane and the number of Santa Claus' place. | d6929926b44c2d5b1a8e6b7f965ca1bb | n, m, k = map(int, input().split())
l = (k - 1) // (2 * m) + 1
print(l, ((k - 1) % (2 * m)) // 2 + 1, 'L' if k & 1 else 'R') | ["2 2 L", "4 3 R", "1 2 R"] | Python | NoteThe first and the second samples are shown on the picture. The green place corresponds to Santa Claus' place in the first example, the blue place corresponds to Santa Claus' place in the second example.In the third sample there are two lanes with four desks in each, and Santa Claus has the fourth place. Thus, his p... | Print two integers: the number of lane r, the number of desk d, and a character s, which stands for the side of the desk Santa Claus. The character s should be "L", if Santa Clause should sit on the left, and "R" if his place is on the right. | Santa Claus is the first who came to the Christmas Olympiad, and he is going to be the first to take his place at a desk! In the classroom there are n lanes of m desks each, and there are two working places at each of the desks. The lanes are numbered from 1 to n from the left to the right, the desks in a lane are numb... | [{"input": "4 3 9\r\n", "output": ["2 2 L"]}, {"input": "4 3 24\r\n", "output": ["4 3 R"]}, {"input": "2 4 4\r\n", "output": ["1 2 R"]}, {"input": "3 10 24\r\n", "output": ["2 2 R"]}, {"input": "10 3 59\r\n", "output": ["10 3 L"]}, {"input": "10000 10000 160845880\r\n", "output": ["8043 2940 R"]}, {"input": "1 1 1\r\n"... | 100 | 100 | 100 | [{'input': '3 2 8\r\n', 'output': ['2 2 R']}, {'input': '1 2 4\r\n', 'output': ['1 2 R']}, {'input': '3 2 12\r\n', 'output': ['3 2 R']}, {'input': '10000 1 20000\r\n', 'output': ['10000 1 R']}, {'input': '10000 9999 197114268\r\n', 'output': ['9857 6990 R']}] | [{'input': '1 2 2\r\n', 'output': ['1 1 R']}, {'input': '10000 10000 1\r\n', 'output': ['1 1 L']}, {'input': '3 2 9\r\n', 'output': ['3 1 L']}, {'input': '3 2 7\r\n', 'output': ['2 2 L']}, {'input': '2 4 4\r\n', 'output': ['1 2 R']}] | [{'input': '1 10000 1\r\n', 'output': ['1 1 L']}, {'input': '3 2 5\r\n', 'output': ['2 1 L']}, {'input': '300 2000 1068628\r\n', 'output': ['268 314 R']}, {'input': '1 1 1\r\n', 'output': ['1 1 L']}, {'input': '2 1 2\r\n', 'output': ['1 1 R']}] | [{'input': '10000 10000 2\r\n', 'output': ['1 1 R']}, {'input': '1 10000 20000\r\n', 'output': ['1 10000 R']}, {'input': '1 2 1\r\n', 'output': ['1 1 L']}, {'input': '10 3 59\r\n', 'output': ['10 3 L']}, {'input': '10000 10000 1\r\n', 'output': ['1 1 L']}] | [{'input': '4 3 7\r\n', 'output': ['2 1 L']}, {'input': '10000 1 1\r\n', 'output': ['1 1 L']}, {'input': '10000 9999 112390396\r\n', 'output': ['5621 818 R']}, {'input': '3 2 11\r\n', 'output': ['3 2 L']}, {'input': '1 2 1\r\n', 'output': ['1 1 L']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 346 | 100 | 100 | 100 |
["5"] | The only line of the input contains one integer n (5 ≤ n ≤ 100) — the number of east to west paths and north to south paths. | 92db14325cd8aee06b502c12d2e3dd81 | n = int(input())
print(((n*(n-1)*(n-2)*(n-3)*(n-4))**2)//120) | ["120"] | Python | null | Output one integer — the number of ways to place the benches. | The city park of IT City contains n east to west paths and n north to south paths. Each east to west path crosses each north to south path, so there are n2 intersections.The city funded purchase of five benches. To make it seems that there are many benches it was decided to place them on as many paths as possible. Obvi... | [{"input": "5\r\n", "output": ["120"]}, {"input": "6\r\n", "output": ["4320"]}, {"input": "7\r\n", "output": ["52920"]}, {"input": "15\r\n", "output": ["1082161080"]}, {"input": "17\r\n", "output": ["4594961280"]}, {"input": "72\r\n", "output": ["23491596420472320"]}, {"input": "83\r\n", "output": ["101159538130177920"... | 100 | 100 | 100 | [{'input': '6\r\n', 'output': ['4320']}, {'input': '95\r\n', 'output': ['402852449038723320']}, {'input': '72\r\n', 'output': ['23491596420472320']}, {'input': '17\r\n', 'output': ['4594961280']}, {'input': '83\r\n', 'output': ['101159538130177920']}] | [{'input': '83\r\n', 'output': ['101159538130177920']}, {'input': '5\r\n', 'output': ['120']}, {'input': '72\r\n', 'output': ['23491596420472320']}, {'input': '100\r\n', 'output': ['680185280130048000']}, {'input': '6\r\n', 'output': ['4320']}] | [{'input': '15\r\n', 'output': ['1082161080']}, {'input': '95\r\n', 'output': ['402852449038723320']}, {'input': '5\r\n', 'output': ['120']}, {'input': '100\r\n', 'output': ['680185280130048000']}, {'input': '17\r\n', 'output': ['4594961280']}] | [{'input': '17\r\n', 'output': ['4594961280']}, {'input': '83\r\n', 'output': ['101159538130177920']}, {'input': '6\r\n', 'output': ['4320']}, {'input': '5\r\n', 'output': ['120']}, {'input': '100\r\n', 'output': ['680185280130048000']}] | [{'input': '95\r\n', 'output': ['402852449038723320']}, {'input': '100\r\n', 'output': ['680185280130048000']}, {'input': '72\r\n', 'output': ['23491596420472320']}, {'input': '15\r\n', 'output': ['1082161080']}, {'input': '5\r\n', 'output': ['120']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 347 | 100 | 100 | 100 |
["3 3\n0 0\n2 0\n3 1\n-2 1\n0 3\n2 2", "2 1\n1 0\n2 2\n3 1"] | The first line contains two space-separated integers R, B(1 ≤ R, B ≤ 10). For 1 ≤ i ≤ R, the i + 1-th line contains two space-separated integers xi and yi (|xi|, |yi| ≤ 10000) denoting the coordinates of the i-th Rebel spaceship. The following B lines have the same format, denoting the position of bases. It is guarante... | 65f81f621c228c09915adcb05256c634 | n,m=[int(x) for x in input().split()]
for i in range(n+m):
s=input()
if n==m:
print('Yes')
else:
print('No') | ["Yes", "No"] | Python | NoteFor the first example, one possible way is to connect the Rebels and bases in order.For the second example, there is no perfect matching between Rebels and bases. | If it is possible to connect Rebel spaceships and bases so as satisfy the constraint, output Yes, otherwise output No (without quote). | The Rebel fleet is afraid that the Empire might want to strike back again. Princess Heidi needs to know if it is possible to assign R Rebel spaceships to guard B bases so that every base has exactly one guardian and each spaceship has exactly one assigned base (in other words, the assignment is a perfect matching). Sin... | [{"input": "3 3\r\n0 0\r\n2 0\r\n3 1\r\n-2 1\r\n0 3\r\n2 2\r\n", "output": ["YES", "Yes"]}, {"input": "2 1\r\n1 0\r\n2 2\r\n3 1\r\n", "output": ["No", "NO"]}, {"input": "1 1\r\n3686 4362\r\n-7485 5112\r\n", "output": ["YES", "Yes"]}, {"input": "1 2\r\n1152 -7324\r\n-5137 -35\r\n-6045 -5271\r\n", "output": ["No", "NO"]}... | 100 | 100 | 100 | [{'input': '8 1\r\n-796 -1\r\n3591 -2510\r\n-6330 4706\r\n-7422 -9093\r\n7860 -7002\r\n5375 -5310\r\n3538 3108\r\n-9851 -9798\r\n-8884 -170\r\n', 'output': ['No', 'NO']}, {'input': '10 5\r\n3460 5504\r\n529 -6744\r\n4075 9961\r\n-3961 4311\r\n-7871 9977\r\n7308 -4275\r\n-6928 7573\r\n-3114 -327\r\n-3046 -5461\r\n3953 4... | [{'input': '8 1\r\n-796 -1\r\n3591 -2510\r\n-6330 4706\r\n-7422 -9093\r\n7860 -7002\r\n5375 -5310\r\n3538 3108\r\n-9851 -9798\r\n-8884 -170\r\n', 'output': ['No', 'NO']}, {'input': '9 3\r\n8163 6185\r\n-4731 2757\r\n-4982 -4704\r\n3128 4684\r\n-8483 1132\r\n6807 2288\r\n4878 2311\r\n-6295 6299\r\n8882 -5992\r\n-195 473... | [{'input': '8 10\r\n5844 -8156\r\n9676 -8121\r\n-6302 -1050\r\n-4823 -8343\r\n4736 -3859\r\n9129 5920\r\n-3990 2792\r\n3615 -8930\r\n-7831 -8703\r\n-5542 931\r\n7599 -7930\r\n8705 -8735\r\n-6438 1724\r\n-7568 -8351\r\n5893 2316\r\n2574 -9723\r\n2416 3827\r\n856 -4877\r\n', 'output': ['No', 'NO']}, {'input': '5 5\r\n-28... | [{'input': '10 1\r\n3362 3137\r\n-6006 -2168\r\n-9207 8006\r\n-6284 -114\r\n4617 -4997\r\n-4360 3540\r\n-6423 2328\r\n-8768 8468\r\n2899 1032\r\n-7561 -3623\r\n6979 653\r\n', 'output': ['No', 'NO']}, {'input': '3 2\r\n9268 -9879\r\n4245 2515\r\n-9188 -3786\r\n-2458 -2165\r\n3420 463\r\n', 'output': ['No', 'NO']}, {'inp... | [{'input': '1 2\r\n1152 -7324\r\n-5137 -35\r\n-6045 -5271\r\n', 'output': ['No', 'NO']}, {'input': '10 2\r\n5945 8596\r\n-3658 -4459\r\n-7598 -7071\r\n3567 4132\r\n7060 -1835\r\n-6443 -4709\r\n4895 2211\r\n-4780 3546\r\n5266 7400\r\n2178 -472\r\n4922 -9643\r\n4163 6030\r\n', 'output': ['No', 'NO']}, {'input': '3 9\r\n6... | 100 | 100 | 100 | 100 | 100 | 83.33 | 83.33 | 100 | 100 | 83.33 | 83.33 | 83.33 | 100 | 100 | 83.33 | 348 | 100 | 89.998 | 89.998 |
["4 2 2", "5 1 5"] | The only input line contains three integers $$$n$$$, $$$l$$$ and $$$r$$$ ($$$1 \leq n \leq 1\,000$$$, $$$1 \leq l \leq r \leq \min(n, 20)$$$) — an array's size, the minimal number and the maximal number of distinct elements in an array. | ce220726392fb0cacf0ec44a7490084a | n,l,r=map(int,input().split())
m=n
a=1
x=0
A=[]
B=[]
while n>0:
if l==1:
A.append(1)
n-=1
else:
A.append(2**(l-1))
l-=1
n-=1
while x<m:
if a==r:
B.append(2**(a-1))
x+=1
else:
B.append(2**(a-1))
x+=1
a+=1
print(sum(A),sum(B))... | ["5 7", "5 31"] | Python | NoteIn the first example, an array could be the one of the following: $$$[1,1,1,2]$$$, $$$[1,1,2,2]$$$ or $$$[1,2,2,2]$$$. In the first case the minimal sum is reached and in the last case the maximal sum is reached.In the second example, the minimal sum is reached at the array $$$[1,1,1,1,1]$$$, and the maximal one is... | Output two numbers — the minimal and the maximal possible sums of all elements in an array. | Mislove had an array $$$a_1$$$, $$$a_2$$$, $$$\cdots$$$, $$$a_n$$$ of $$$n$$$ positive integers, but he has lost it. He only remembers the following facts about it: The number of different numbers in the array is not less than $$$l$$$ and is not greater than $$$r$$$; For each array's element $$$a_i$$$ either $$$a_i = 1... | [{"input": "4 2 2\r\n", "output": ["5 7"]}, {"input": "5 1 5\r\n", "output": ["5 31"]}, {"input": "106 16 18\r\n", "output": ["65625 11796479"]}, {"input": "114 18 19\r\n", "output": ["262239 25427967"]}, {"input": "655 3 18\r\n", "output": ["659 83755007"]}, {"input": "1000 1 20\r\n", "output": ["1000 514850815"]}, {"... | 100 | 100 | 100 | [{'input': '655 3 18\r\n', 'output': ['659 83755007']}, {'input': '5 1 5\r\n', 'output': ['5 31']}, {'input': '879 17 17\r\n', 'output': ['131933 56623103']}, {'input': '17 2 14\r\n', 'output': ['18 40959']}, {'input': '1000 1 1\r\n', 'output': ['1000 1000']}] | [{'input': '1000 1 1\r\n', 'output': ['1000 1000']}, {'input': '106 16 18\r\n', 'output': ['65625 11796479']}, {'input': '5 1 5\r\n', 'output': ['5 31']}, {'input': '408 13 13\r\n', 'output': ['8586 1626111']}, {'input': '879 17 17\r\n', 'output': ['131933 56623103']}] | [{'input': '17 2 14\r\n', 'output': ['18 40959']}, {'input': '588 13 15\r\n', 'output': ['8766 9420799']}, {'input': '655 3 18\r\n', 'output': ['659 83755007']}, {'input': '114 18 19\r\n', 'output': ['262239 25427967']}, {'input': '1000 1 20\r\n', 'output': ['1000 514850815']}] | [{'input': '1000 1 1\r\n', 'output': ['1000 1000']}, {'input': '17 2 14\r\n', 'output': ['18 40959']}, {'input': '588 13 15\r\n', 'output': ['8766 9420799']}, {'input': '408 13 13\r\n', 'output': ['8586 1626111']}, {'input': '4 2 2\r\n', 'output': ['5 7']}] | [{'input': '1000 1 20\r\n', 'output': ['1000 514850815']}, {'input': '4 2 2\r\n', 'output': ['5 7']}, {'input': '114 18 19\r\n', 'output': ['262239 25427967']}, {'input': '655 3 18\r\n', 'output': ['659 83755007']}, {'input': '408 13 13\r\n', 'output': ['8586 1626111']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 349 | 100 | 100 | 100 |
["2 2\n5 8", "1 2\n7 1", "1 2\n4 4", "1 4\n2 2 1 2"] | The first line contains two integers n and k (1 ≤ n ≤ 10000, 1 ≤ k ≤ 100) — the number of rows and the number of groups of soldiers, respectively. The second line contains k integers a1, a2, a3, ..., ak (1 ≤ ai ≤ 10000), where ai denotes the number of soldiers in the i-th group. It is guaranteed that a1 + a2 + ... + ak... | d1f88a97714d6c13309c88fcf7d86821 | n,k = map(int, input().split())
a = list(map(int,input().split()))
all_sum = sum(a)
r4,r2 = n,n*2
for v in range(len(a)):
mid = a[v] // 4
a[v] = a[v] % 4
if mid <= r4:
r4 -= mid
else:
a[v] += 4 * (mid - r4)
r4 = 0
if r4 == 0:
break
mid = 0
r22 = 0
for v in a:
if v % 2 == 1:
mid += 1
r22 += v // 2
#pri... | ["YES", "NO", "YES", "YES"] | Python | NoteIn the first sample, Daenerys can place the soldiers like in the figure below: In the second sample, there is no way to place the soldiers in the plane since the second group soldier will always have a seat neighboring to someone from the first group.In the third example Daenerys can place the first group on seats... | If we can place the soldiers in the airplane print "YES" (without quotes). Otherwise print "NO" (without quotes). You can choose the case (lower or upper) for each letter arbitrary. | Daenerys Targaryen has an army consisting of k groups of soldiers, the i-th group contains ai soldiers. She wants to bring her army to the other side of the sea to get the Iron Throne. She has recently bought an airplane to carry her army through the sea. The airplane has n rows, each of them has 8 seats. We call two s... | [{"input": "2 2\r\n5 8\r\n", "output": ["YES"]}, {"input": "1 2\r\n7 1\r\n", "output": ["NO"]}, {"input": "1 2\r\n4 4\r\n", "output": ["YES"]}, {"input": "1 4\r\n2 2 1 2\r\n", "output": ["YES"]}, {"input": "10000 100\r\n749 2244 949 2439 2703 44 2394 124 285 3694 3609 717 1413 155 974 1778 1448 1327 1487 3458 319 1395 ... | 100 | 100 | 100 | [{'input': '1 4\r\n2 1 2 2\r\n', 'output': ['YES']}, {'input': '1 3\r\n2 2 1\r\n', 'output': ['YES']}, {'input': '10000 100\r\n800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 8... | [{'input': '10000 100\r\n749 2244 949 2439 2703 44 2394 124 285 3694 3609 717 1413 155 974 1778 1448 1327 1487 3458 319 1395 3783 2184 2062 43 826 38 3276 807 1837 4635 171 1386 1768 1128 2020 2536 800 782 3058 174 455 83 647 595 658 109 33 23 70 39 38 1 6 35 94 9 22 12 6 1 2 2 4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1... | [{'input': '541 31\r\n607 204 308 298 398 213 1182 58 162 46 64 12 38 91 29 2 4 12 19 3 7 9 3 6 1 1 2 1 3 1 529\r\n', 'output': ['YES']}, {'input': '5691 91\r\n6573 1666 2158 2591 4636 886 263 4217 389 29 1513 1172 617 2012 1855 798 1588 979 152 37 890 375 1091 839 385 382 1 255 117 289 119 224 182 69 19 71 115 13 4 22... | [{'input': '4 16\r\n1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2\r\n', 'output': ['YES']}, {'input': '2 6\r\n3 3 2 2 2 2\r\n', 'output': ['YES']}, {'input': '10000 100\r\n749 2244 949 2439 2703 44 2394 124 285 3694 3609 717 1413 155 974 1778 1448 1327 1487 3458 319 1395 3783 2184 2062 43 826 38 3276 807 1837 4635 171 1386 1768 1128... | [{'input': '2 7\r\n2 2 2 2 2 2 2\r\n', 'output': ['YES']}, {'input': '1 4\r\n2 2 2 1\r\n', 'output': ['YES']}, {'input': '2 6\r\n2 2 2 2 2 5\r\n', 'output': ['YES']}, {'input': '1 3\r\n2 2 4\r\n', 'output': ['YES']}, {'input': '5691 91\r\n6573 1666 2158 2591 4636 886 263 4217 389 29 1513 1172 617 2012 1855 798 1588 979... | 100 | 100 | 100 | 100 | 100 | 92.86 | 92.86 | 92.86 | 100 | 100 | 93.75 | 93.75 | 93.75 | 100 | 100 | 350 | 100 | 95.716 | 96.25 |
["5 1 2 1 2", "3 3 1 1 1", "4 5 3 1 5"] | The first line contains five integers s, v1, v2, t1, t2 (1 ≤ s, v1, v2, t1, t2 ≤ 1000) — the number of characters in the text, the time of typing one character for the first participant, the time of typing one character for the the second participant, the ping of the first participant and the ping of the second partici... | 10226b8efe9e3c473239d747b911a1ef |
def t(a,b,c,d,e):
#for i in range(5):
# v.append (int(input("podaj liczbe")))
gr1=0
gr2=0
gr1=(b*a)+(d*2)
gr2=(c*a)+(e*2)
#print(gr1)
#print(gr2)
if gr1>gr2:
print("Second")
if gr1<gr2:
print("First")
if gr1==gr2:
print("Friendship")
a,... | ["First", "Second", "Friendship"] | Python | NoteIn the first example, information on the success of the first participant comes in 7 milliseconds, of the second participant — in 14 milliseconds. So, the first wins.In the second example, information on the success of the first participant comes in 11 milliseconds, of the second participant — in 5 milliseconds. So... | If the first participant wins, print "First". If the second participant wins, print "Second". In case of a draw print "Friendship". | Two boys decided to compete in text typing on the site "Key races". During the competition, they have to type a text consisting of s characters. The first participant types one character in v1 milliseconds and has ping t1 milliseconds. The second participant types one character in v2 milliseconds and has ping t2 millis... | [{"input": "5 1 2 1 2\r\n", "output": ["First"]}, {"input": "3 3 1 1 1\r\n", "output": ["Second"]}, {"input": "4 5 3 1 5\r\n", "output": ["Friendship"]}, {"input": "1000 1000 1000 1000 1000\r\n", "output": ["Friendship"]}, {"input": "1 1 1 1 1\r\n", "output": ["Friendship"]}, {"input": "8 8 1 1 1\r\n", "output": ["Seco... | 100 | 100 | 100 | [{'input': '6 5 7 10 4\r\n', 'output': ['Friendship']}, {'input': '894 197 325 232 902\r\n', 'output': ['First']}, {'input': '213 480 811 134 745\r\n', 'output': ['First']}, {'input': '5 1 2 1 2\r\n', 'output': ['First']}, {'input': '1 2 8 9 8\r\n', 'output': ['First']}] | [{'input': '424 41 41 909 909\r\n', 'output': ['Friendship']}, {'input': '641 31 29 161 802\r\n', 'output': ['Friendship']}, {'input': '1 10 2 6 10\r\n', 'output': ['Friendship']}, {'input': '2 313 856 964 421\r\n', 'output': ['Friendship']}, {'input': '894 197 325 232 902\r\n', 'output': ['First']}] | [{'input': '12 462 8 311 327\r\n', 'output': ['Second']}, {'input': '2 313 856 964 421\r\n', 'output': ['Friendship']}, {'input': '485 117 368 567 609\r\n', 'output': ['First']}, {'input': '6 5 7 10 4\r\n', 'output': ['Friendship']}, {'input': '1 10 2 6 10\r\n', 'output': ['Friendship']}] | [{'input': '1 1 1 1 1\r\n', 'output': ['Friendship']}, {'input': '1 2 8 9 8\r\n', 'output': ['First']}, {'input': '12 462 8 311 327\r\n', 'output': ['Second']}, {'input': '61 464 623 89 548\r\n', 'output': ['First']}, {'input': '641 31 29 161 802\r\n', 'output': ['Friendship']}] | [{'input': '485 117 368 567 609\r\n', 'output': ['First']}, {'input': '884 913 263 641 265\r\n', 'output': ['Second']}, {'input': '1 1 1 1 1\r\n', 'output': ['Friendship']}, {'input': '2 313 856 964 421\r\n', 'output': ['Friendship']}, {'input': '6 5 7 10 4\r\n', 'output': ['Friendship']}] | 100 | 100 | 100 | 100 | 100 | 92.31 | 92.31 | 100 | 100 | 100 | 83.33 | 83.33 | 100 | 100 | 100 | 351 | 100 | 96.924 | 93.332 |
["0 1 1 1 1 0", "1 1 0 0 1000 1000"] | The only line contains six integers ax, ay, bx, by, cx, cy (|ax|, |ay|, |bx|, |by|, |cx|, |cy| ≤ 109). It's guaranteed that the points are distinct. | 05ec6ec3e9ffcc0e856dc0d461e6eeab | ax,ay,bx,by,cx,cy=list(map(int,input().split()))
ax-=bx
ay-=by
cx-=bx
cy-=by
print('No'if ax*cy-ay*cx==0 or ax**2+ay**2!=cx**2+cy**2 else'Yes')
| ["Yes", "No"] | Python | NoteIn the first sample test, rotate the page around (0.5, 0.5) by .In the second sample test, you can't find any solution. | Print "Yes" if the problem has a solution, "No" otherwise. You can print each letter in any case (upper or lower). | Arpa is taking a geometry exam. Here is the last problem of the exam.You are given three points a, b, c.Find a point and an angle such that if we rotate the page around the point by the angle, the new position of a is the same as the old position of b, and the new position of b is the same as the old position of c.Arpa... | [{"input": "0 1 1 1 1 0\r\n", "output": ["YES", "Yes"]}, {"input": "1 1 0 0 1000 1000\r\n", "output": ["No", "NO"]}, {"input": "1 0 2 0 3 0\r\n", "output": ["No", "NO"]}, {"input": "3 4 0 0 4 3\r\n", "output": ["YES", "Yes"]}, {"input": "-1000000000 1 0 0 1000000000 1\r\n", "output": ["YES", "Yes"]}, {"input": "49152 0... | 100 | 100 | 100 | [{'input': '-1000000000 -1000000000 0 1000000000 1000000000 -1000000000\r\n', 'output': ['YES', 'Yes']}, {'input': '0 1000000000 0 0 0 -1000000000\r\n', 'output': ['No', 'NO']}, {'input': '419578772 -125025887 169314071 89851312 961404059 21419450\r\n', 'output': ['No', 'NO']}, {'input': '-607353321 -620687860 24802939... | [{'input': '-3 -3 5 2 3 -1\r\n', 'output': ['No', 'NO']}, {'input': '1 1 0 0 1000 1000\r\n', 'output': ['No', 'NO']}, {'input': '48517753 416240699 7672672 272460100 -917845051 199790781\r\n', 'output': ['No', 'NO']}, {'input': '0 0 1000000000 1 1000000000 -999999999\r\n', 'output': ['No', 'NO']}, {'input': '-100000000... | [{'input': '5 0 4 -2 0 1\r\n', 'output': ['No', 'NO']}, {'input': '589824 196608 262144 196608 0 0\r\n', 'output': ['YES', 'Yes']}, {'input': '0 0 1 1 2 0\r\n', 'output': ['YES', 'Yes']}, {'input': '-947393823 -495674431 211535284 -877153626 -522763219 -778236665\r\n', 'output': ['No', 'NO']}, {'input': '-1000000000 -1... | [{'input': '0 2 0 3 0 4\r\n', 'output': ['No', 'NO']}, {'input': '49152 0 0 0 0 81920\r\n', 'output': ['No', 'NO']}, {'input': '264193194 -448876521 736684426 -633906160 -328597212 -47935734\r\n', 'output': ['No', 'NO']}, {'input': '0 1000000000 1 0 0 -1000000000\r\n', 'output': ['YES', 'Yes']}, {'input': '-1000000000 ... | [{'input': '-326038504 547872194 49630307 713863100 303770000 -556852524\r\n', 'output': ['No', 'NO']}, {'input': '-4 -3 2 -1 -3 4\r\n', 'output': ['No', 'NO']}, {'input': '0 2 0 3 0 4\r\n', 'output': ['No', 'NO']}, {'input': '999999999 1000000000 0 0 -1000000000 -999999999\r\n', 'output': ['YES', 'Yes']}, {'input': '1... | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 352 | 100 | 100 | 100 |
["3 1\n2 1 4", "3 0\n7 7 7", "6 3\n1 3 4 6 9 10"] | The first line contains two integers n and d (1 ≤ n ≤ 100, 0 ≤ d ≤ 100) — the amount of points and the maximum allowed diameter respectively. The second line contains n space separated integers (1 ≤ xi ≤ 100) — the coordinates of the points. | 6bcb324c072f796f4d50bafea5f624b2 | x=input()
x=x.split(' ')
n=int(x[0])
d=int(x[1])
x=input()
x=x.split(' ')
for i in range(n):
x[i]=int(x[i])
x.sort()
l = []
for i in range(0, n):
for j in range(i+1, n):
if (x[j]-x[i])<=d:
l.append(i + (n - j) - 1)
if l == []:
print(n-1)
else:
print(min(l))
| ["1", "0", "3"] | Python | NoteIn the first test case the optimal strategy is to remove the point with coordinate 4. The remaining points will have coordinates 1 and 2, so the diameter will be equal to 2 - 1 = 1.In the second test case the diameter is equal to 0, so its is unnecessary to remove any points. In the third test case the optimal stra... | Output a single integer — the minimum number of points you have to remove. | We've got no test cases. A big olympiad is coming up. But the problemsetters' number one priority should be adding another problem to the round. The diameter of a multiset of points on the line is the largest distance between two points from this set. For example, the diameter of the multiset {1, 3, 2, 1} is 2.Diameter... | [{"input": "3 1\r\n2 1 4\r\n", "output": ["1"]}, {"input": "3 0\r\n7 7 7\r\n", "output": ["0"]}, {"input": "6 3\r\n1 3 4 6 9 10\r\n", "output": ["3"]}, {"input": "11 5\r\n10 11 12 13 14 15 16 17 18 19 20\r\n", "output": ["5"]}, {"input": "1 100\r\n1\r\n", "output": ["0"]}, {"input": "100 10\r\n22 75 26 45 72 81 47 29 9... | 100 | 100 | 100 | [{'input': '100 5\r\n51 56 52 60 52 53 52 60 56 54 55 50 53 51 57 53 52 54 54 52 51 55 50 56 60 51 58 50 60 59 50 54 60 55 55 57 54 59 59 55 55 52 56 57 59 54 53 57 52 50 50 55 59 54 54 56 51 58 52 51 56 56 58 56 54 54 57 52 51 58 56 57 54 59 58 53 50 52 50 60 57 51 54 59 54 54 52 55 53 55 51 53 52 54 51 56 55 53 58 56... | [{'input': '100 0\r\n14 17 18 22 19 18 19 21 19 19 22 22 19 21 24 23 24 19 25 24 24 21 20 13 26 18 17 15 25 13 17 20 20 21 13 22 27 15 18 27 19 15 16 25 18 17 18 22 19 17 18 24 14 16 18 16 22 16 17 27 18 17 18 24 22 13 14 20 23 19 16 21 19 13 14 14 25 15 27 24 26 22 16 20 16 14 21 27 15 23 23 24 27 14 24 17 19 24 15 27... | [{'input': '1 100\r\n1\r\n', 'output': ['0']}, {'input': '4 2\r\n1 4 7 9\r\n', 'output': ['2']}, {'input': '2 5\r\n67 23\r\n', 'output': ['1']}, {'input': '1 0\r\n22\r\n', 'output': ['0']}, {'input': '11 5\r\n10 11 12 13 14 15 16 17 18 19 20\r\n', 'output': ['5']}] | [{'input': '3 1\r\n10 20 30\r\n', 'output': ['2']}, {'input': '100 11\r\n44 89 57 64 94 96 73 96 55 52 91 73 73 93 51 62 63 85 43 75 60 78 98 55 80 84 65 75 61 88 62 71 53 57 94 85 60 96 66 96 61 72 97 64 51 44 63 82 67 86 60 57 74 85 57 79 61 94 86 78 84 56 60 75 91 91 92 62 89 85 79 57 76 97 65 56 46 78 51 69 50 52 8... | [{'input': '3 0\r\n7 7 7\r\n', 'output': ['0']}, {'input': '2 5\r\n67 23\r\n', 'output': ['1']}, {'input': '100 1\r\n22 75 26 45 72 81 47 29 97 2 75 25 82 84 17 56 32 2 28 37 57 39 18 11 79 6 40 68 68 16 40 63 93 49 91 10 55 68 31 80 57 18 34 28 76 55 21 80 22 45 11 67 67 74 91 4 35 34 65 80 21 95 1 52 25 31 2 53 96 22... | 100 | 100 | 100 | 100 | 100 | 100 | 94.12 | 100 | 100 | 100 | 100 | 90 | 100 | 100 | 100 | 353 | 100 | 98.824 | 98 |
["3 10 3 3", "3 10 1 3", "100 100 1 1000"] | The first line contains four space-separated integers k, a, b, v (2 ≤ k ≤ 1000; 1 ≤ a, b, v ≤ 1000) — the maximum number of sections in the box, the number of nuts, the number of divisors and the capacity of each section of the box. | 7cff20b1c63a694baca69bdf4bdb2652 | k,a,b,v = map(int, input().split())
answ = 0
while a != 0 and b != 0:
a -= min(v*min(k,b+1),a)
b -= min(k-1,b)
answ+=1
answ += a//v + int(a%v != 0)
print(answ) | ["2", "3", "1"] | Python | NoteIn the first sample you can act like this: Put two divisors to the first box. Now the first box has three sections and we can put three nuts into each section. Overall, the first box will have nine nuts. Do not put any divisors into the second box. Thus, the second box has one section for the last nut. In the en... | Print a single integer — the answer to the problem. | You have a nuts and lots of boxes. The boxes have a wonderful feature: if you put x (x ≥ 0) divisors (the spacial bars that can divide a box) to it, you get a box, divided into x + 1 sections.You are minimalist. Therefore, on the one hand, you are against dividing some box into more than k sections. On the other hand, ... | [{"input": "3 10 3 3\r\n", "output": ["2"]}, {"input": "3 10 1 3\r\n", "output": ["3"]}, {"input": "100 100 1 1000\r\n", "output": ["1"]}, {"input": "5 347 20 1\r\n", "output": ["327"]}, {"input": "6 978 10 5\r\n", "output": ["186"]}, {"input": "6 856 50 35\r\n", "output": ["5"]}, {"input": "8 399 13 36\r\n", "output":... | 100 | 100 | 100 | [{'input': '634 993 9 3\r\n', 'output': ['322']}, {'input': '307 999 10 7\r\n', 'output': ['133']}, {'input': '8 399 13 36\r\n', 'output': ['2']}, {'input': '872 997 1 1\r\n', 'output': ['996']}, {'input': '763 193 388 346\r\n', 'output': ['1']}] | [{'input': '100 100 1 1000\r\n', 'output': ['1']}, {'input': '683 995 10 1\r\n', 'output': ['985']}, {'input': '2 990 1 1\r\n', 'output': ['989']}, {'input': '872 997 1 1\r\n', 'output': ['996']}, {'input': '7 915 12 24\r\n', 'output': ['27']}] | [{'input': '845 996 1 1\r\n', 'output': ['995']}, {'input': '8 399 13 36\r\n', 'output': ['2']}, {'input': '872 997 1 1\r\n', 'output': ['996']}, {'input': '638 1000 1 1\r\n', 'output': ['999']}, {'input': '7 915 12 24\r\n', 'output': ['27']}] | [{'input': '2 4 1000 1\r\n', 'output': ['2']}, {'input': '2 990 1 1\r\n', 'output': ['989']}, {'input': '306 993 9 9\r\n', 'output': ['102']}, {'input': '4 787 48 4\r\n', 'output': ['149']}, {'input': '7 915 12 24\r\n', 'output': ['27']}] | [{'input': '346 991 4 4\r\n', 'output': ['244']}, {'input': '10 849 3 28\r\n', 'output': ['28']}, {'input': '648 990 5 2\r\n', 'output': ['490']}, {'input': '2 4 1000 1\r\n', 'output': ['2']}, {'input': '763 193 388 346\r\n', 'output': ['1']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 354 | 100 | 100 | 100 |
["01.01.98\n01.01.80", "20.10.20\n10.02.30", "28.02.74\n28.02.64"] | The first line contains the date DD.MM.YY, the second line contains the date BD.BM.BY. It is guaranteed that both dates are correct, and YY and BY are always in [01;99]. It could be that by passport Bob was born after the finals. In this case, he can still change the order of numbers in date. | 5418c98fe362909f7b28f95225837d33 | import itertools as it
month_to_days_non_leap = {
1: 31,
2: 28,
3: 31,
4: 30,
5: 31,
6: 30,
7: 31,
8: 31,
9: 30,
10: 31,
11: 30,
12: 31,
}
def month_year_to_day(month, year):
if year % 4 == 0 and month == 2:
return 29
else:
return month_to_days_n... | ["YES", "NO", "NO"] | Python | null | If it is possible to rearrange the numbers in the date of birth so that Bob will be at least 18 years old on the DD.MM.YY, output YES. In the other case, output NO. Each number contains exactly two digits and stands for day, month or year in a date. Note that it is permitted to rearrange only numbers, not digits. | The king Copa often has been reported about the Codeforces site, which is rapidly getting more and more popular among the brightest minds of the humanity, who are using it for training and competing. Recently Copa understood that to conquer the world he needs to organize the world Codeforces tournament. He hopes that a... | [{"input": "01.01.98\r\n01.01.80\r\n", "output": ["YES"]}, {"input": "20.10.20\r\n10.02.30\r\n", "output": ["NO"]}, {"input": "28.02.74\r\n28.02.64\r\n", "output": ["NO"]}, {"input": "05.05.25\r\n06.02.71\r\n", "output": ["NO"]}, {"input": "19.11.54\r\n29.11.53\r\n", "output": ["NO"]}, {"input": "01.06.84\r\n24.04.87\r... | 100 | 100 | 100 | [{'input': '31.10.41\r\n27.12.13\r\n', 'output': ['YES']}, {'input': '20.10.20\r\n10.02.30\r\n', 'output': ['NO']}, {'input': '03.12.98\r\n11.12.80\r\n', 'output': ['YES']}, {'input': '05.04.99\r\n19.08.80\r\n', 'output': ['YES']}, {'input': '13.08.91\r\n01.05.26\r\n', 'output': ['YES']}] | [{'input': '08.04.64\r\n27.01.45\r\n', 'output': ['YES']}, {'input': '19.09.93\r\n17.05.74\r\n', 'output': ['YES']}, {'input': '30.08.83\r\n13.04.65\r\n', 'output': ['YES']}, {'input': '29.09.35\r\n21.07.17\r\n', 'output': ['YES']}, {'input': '29.02.80\r\n29.02.60\r\n', 'output': ['YES']}] | [{'input': '11.03.86\r\n20.08.81\r\n', 'output': ['NO']}, {'input': '30.08.83\r\n13.04.65\r\n', 'output': ['YES']}, {'input': '08.04.64\r\n27.01.45\r\n', 'output': ['YES']}, {'input': '05.04.99\r\n19.08.80\r\n', 'output': ['YES']}, {'input': '20.10.20\r\n10.02.30\r\n', 'output': ['NO']}] | [{'input': '19.11.36\r\n17.02.21\r\n', 'output': ['YES']}, {'input': '06.08.34\r\n16.02.29\r\n', 'output': ['YES']}, {'input': '13.11.88\r\n09.07.03\r\n', 'output': ['YES']}, {'input': '13.08.91\r\n01.05.26\r\n', 'output': ['YES']}, {'input': '10.02.37\r\n25.09.71\r\n', 'output': ['NO']}] | [{'input': '14.05.21\r\n02.01.88\r\n', 'output': ['NO']}, {'input': '05.04.73\r\n28.09.54\r\n', 'output': ['YES']}, {'input': '08.04.74\r\n18.03.60\r\n', 'output': ['NO']}, {'input': '02.06.59\r\n30.01.40\r\n', 'output': ['YES']}, {'input': '10.02.37\r\n25.09.71\r\n', 'output': ['NO']}] | 100 | 100 | 100 | 100 | 100 | 83.33 | 69.44 | 83.33 | 75 | 66.67 | 83.33 | 45.83 | 83.33 | 70.83 | 62.5 | 355 | 100 | 75.554 | 69.164 |
["2\nRB", "3\nGRG", "5\nBBBBB"] | The first line of the input contains a single integer n (1 ≤ n ≤ 200) — the total number of cards. The next line contains a string s of length n — the colors of the cards. s contains only the characters 'B', 'G', and 'R', representing blue, green, and red, respectively. | 4cedd3b70d793bc8ed4a93fc5a827f8f | from collections import Counter
def go(s):
ct = Counter(s)
pos = ''.join(c for c in 'BGR' if ct[c] > 0)
if len(pos) == 3 or len(pos) == 1:
return pos
one = ''.join(c for c in 'BGR' if ct[c] <= 1)
if len(one) == 1:
return 'BGR'
if len(one) == 2:
return one
... | ["G", "BR", "B"] | Python | NoteIn the first sample, Catherine has one red card and one blue card, which she must exchange for a green card.In the second sample, Catherine has two green cards and one red card. She has two options: she can exchange the two green cards for a green card, then exchange the new green card and the red card for a blue c... | Print a single string of up to three characters — the possible colors of the final card (using the same symbols as the input) in alphabetical order. | Catherine has a deck of n cards, each of which is either red, green, or blue. As long as there are at least two cards left, she can do one of two actions: take any two (not necessarily adjacent) cards with different colors and exchange them for a new card of the third color; take any two (not necessarily adjacent) c... | [{"input": "2\r\nRB\r\n", "output": ["G"]}, {"input": "3\r\nGRG\r\n", "output": ["BR"]}, {"input": "5\r\nBBBBB\r\n", "output": ["B"]}, {"input": "1\r\nR\r\n", "output": ["R"]}, {"input": "200\r\nBBRGRRBBRGGGBGBGBGRRGRGRGRBGRGRRBBGRGBGRRGRRRGGBBRGBGBGBRBBBBBBBGGBRGGRRRGGRGBGBGGBRRRRBRRRBRBBGGBGBRGRGBBBBGGBGBBBGBGRRBRRRG... | 100 | 100 | 100 | [{'input': '200\r\nRGRGRRRRRGRRGRRRGRGRRRGGRGRRGGGRRGGRRRRRRRRRRRGRRGRRRGRRRGRRRRRRRGRRRRRRRRRRRGGRRGGRRRRGGRRRRRRRRRGGGRGRGRGRRGRGGRGRGRRRGRRRRRRGGRGRRRRGRRGRGGRRRRRRRGRGGRRGRRRRRRRGGRRRRGRRRRRRRGRRRGGRRRRRRGRRGGGRRRGR\r\n', 'output': ['BGR']}, {'input': '4\r\nRGGR\r\n', 'output': ['BGR']}, {'input': '2\r\nRB\r\n', 'o... | [{'input': '5\r\nBBBBB\r\n', 'output': ['B']}, {'input': '4\r\nRBGB\r\n', 'output': ['BGR']}, {'input': '16\r\nRRGRRRRRRGGRGRRR\r\n', 'output': ['BGR']}, {'input': '3\r\nGGR\r\n', 'output': ['BR']}, {'input': '1\r\nG\r\n', 'output': ['G']}] | [{'input': '5\r\nGRRGR\r\n', 'output': ['BGR']}, {'input': '1\r\nG\r\n', 'output': ['G']}, {'input': '3\r\nGBG\r\n', 'output': ['BR']}, {'input': '5\r\nBGBGR\r\n', 'output': ['BGR']}, {'input': '2\r\nRB\r\n', 'output': ['G']}] | [{'input': '3\r\nGBG\r\n', 'output': ['BR']}, {'input': '16\r\nRRGRRRRRRGGRGRRR\r\n', 'output': ['BGR']}, {'input': '190\r\nBBBBBBBBBBBBBBBBBGBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\n',... | [{'input': '4\r\nRGGR\r\n', 'output': ['BGR']}, {'input': '200\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\n', 'output': ['G']}, {'input': '6\r\nGRRGBB\r\n', ... | 100 | 100 | 100 | 100 | 100 | 92.86 | 92.86 | 100 | 100 | 78.57 | 91.67 | 75 | 100 | 100 | 58.33 | 356 | 100 | 92.858 | 85 |
["3 3 3\n1 1 1\n2 2 3\n3 3 2", "4 10 2\n2 3 8\n3 4 7"] | The first line contains three integers $$$n$$$, $$$h$$$, and $$$m$$$ ($$$1 \leq n,h,m \leq 50$$$) — the number of spots, the maximum height, and the number of restrictions. Each of the next $$$m$$$ lines contains three integers $$$l_i$$$, $$$r_i$$$, and $$$x_i$$$ ($$$1 \leq l_i \leq r_i \leq n$$$, $$$0 \leq x_i \leq h$... | f22b6dab443f63fb8d2d288b702f20ad | (n,h,m) = [int(x) for x in input().split()]
houses= [h]*n
for i in range(m):
(l,r,x) = [int(x) for x in input().split()]
for j in range(l-1,r):
houses[j] = min(houses[j],x)
mx = 0
for j in range(n):
mx += houses[j]*houses[j]
print(mx)
| ["14", "262"] | Python | NoteIn the first example, there are $$$3$$$ houses, the maximum height of a house is $$$3$$$, and there are $$$3$$$ restrictions. The first restriction says the tallest house between $$$1$$$ and $$$1$$$ must be at most $$$1$$$. The second restriction says the tallest house between $$$2$$$ and $$$2$$$ must be at most $$... | Print a single integer, the maximum profit you can make. | You are planning to build housing on a street. There are $$$n$$$ spots available on the street on which you can build a house. The spots are labeled from $$$1$$$ to $$$n$$$ from left to right. In each spot, you can build a house with an integer height between $$$0$$$ and $$$h$$$.In each spot, if a house has height $$$a... | [{"input": "3 3 3\r\n1 1 1\r\n2 2 3\r\n3 3 2\r\n", "output": ["14"]}, {"input": "4 10 2\r\n2 3 8\r\n3 4 7\r\n", "output": ["262"]}, {"input": "50 50 1\r\n1 50 0\r\n", "output": ["0"]}, {"input": "50 50 50\r\n17 40 12\r\n33 36 47\r\n8 43 35\r\n25 29 42\r\n18 36 6\r\n25 35 18\r\n36 48 47\r\n17 40 13\r\n20 27 37\r\n32 32 ... | 100 | 100 | 100 | [{'input': '50 50 50\r\n14 39 43\r\n22 27 43\r\n9 11 0\r\n23 38 21\r\n13 32 23\r\n19 43 35\r\n27 29 15\r\n6 31 8\r\n19 20 35\r\n36 45 22\r\n20 26 34\r\n13 49 42\r\n13 37 40\r\n37 45 7\r\n16 41 19\r\n27 48 15\r\n15 41 8\r\n33 45 37\r\n6 33 45\r\n10 18 4\r\n12 35 27\r\n15 42 37\r\n25 28 50\r\n19 46 28\r\n7 19 12\r\n12 44... | [{'input': '50 50 50\r\n18 30 29\r\n39 40 46\r\n19 45 35\r\n13 32 26\r\n11 28 38\r\n15 19 18\r\n25 32 15\r\n15 15 1\r\n36 40 48\r\n15 48 18\r\n7 47 12\r\n26 49 37\r\n1 8 40\r\n5 38 4\r\n13 30 18\r\n5 21 0\r\n9 32 37\r\n14 16 44\r\n24 45 15\r\n18 19 36\r\n1 48 14\r\n46 49 11\r\n2 28 4\r\n2 6 21\r\n11 49 20\r\n22 27 34\r... | [{'input': '50 50 50\r\n17 17 39\r\n11 13 9\r\n9 43 39\r\n9 35 13\r\n23 39 31\r\n21 43 21\r\n16 17 43\r\n2 47 30\r\n23 49 9\r\n22 47 7\r\n20 34 48\r\n12 49 20\r\n13 29 12\r\n3 29 17\r\n4 30 42\r\n37 40 28\r\n16 50 24\r\n31 43 40\r\n6 26 26\r\n22 43 28\r\n7 41 24\r\n33 35 8\r\n17 23 43\r\n11 49 25\r\n21 42 37\r\n34 36 2... | [{'input': '20 50 20\r\n4 5 18\r\n14 15 32\r\n6 13 46\r\n13 19 39\r\n2 8 18\r\n15 16 29\r\n2 8 9\r\n1 2 23\r\n1 8 8\r\n18 18 11\r\n10 16 3\r\n9 18 44\r\n9 19 31\r\n2 3 19\r\n4 19 12\r\n10 17 24\r\n9 13 20\r\n4 7 10\r\n12 20 24\r\n3 19 19\r\n', 'output': ['1704']}, {'input': '50 50 50\r\n15 20 50\r\n11 36 39\r\n1 7 23\r... | [{'input': '50 50 50\r\n7 47 45\r\n22 24 8\r\n31 48 31\r\n36 47 13\r\n7 25 19\r\n2 2 17\r\n34 40 14\r\n27 33 50\r\n31 45 35\r\n4 7 4\r\n27 30 27\r\n4 41 27\r\n34 41 15\r\n2 12 17\r\n2 3 19\r\n25 47 47\r\n6 43 50\r\n4 47 23\r\n5 38 30\r\n12 43 18\r\n8 38 28\r\n6 11 13\r\n23 35 41\r\n2 39 41\r\n27 30 1\r\n28 49 46\r\n15 ... | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 357 | 100 | 100 | 100 |
["6 2\n2 1 2 2 2 1", "8 4\n1 1 2 1 1 1 2 1", "9 3\n2 1 1 1 2 1 1 1 2"] | The first line of the input contains a pair of integers n, k (1 ≤ k ≤ n ≤ 100), where n is the length of the array and the value n is divisible by k. The second line contains the sequence of elements of the given array a1, a2, ..., an (1 ≤ ai ≤ 2), ai is the i-th element of the array. | 5f94c2ecf1cf8fdbb6117cab801ed281 | a=int(input().split()[1])
*b,=map(int,input().split())
c=0
for i in range(a):
d=b[i::a]
c+=min(d.count(1),d.count(2))
print(c)
| ["1", "0", "3"] | Python | NoteIn the first sample it is enough to change the fourth element from 2 to 1, then the array changes to [2, 1, 2, 1, 2, 1].In the second sample, the given array already is 4-periodic.In the third sample it is enough to replace each occurrence of number two by number one. In this case the array will look as [1, 1, 1, 1... | Print the minimum number of array elements we need to change to make the array k-periodic. If the array already is k-periodic, then print 0. | This task will exclusively concentrate only on the arrays where all elements equal 1 and/or 2.Array a is k-period if its length is divisible by k and there is such array b of length k, that a is represented by array b written exactly times consecutively. In other words, array a is k-periodic, if it has period of lengt... | [{"input": "6 2\r\n2 1 2 2 2 1\r\n", "output": ["1"]}, {"input": "8 4\r\n1 1 2 1 1 1 2 1\r\n", "output": ["0"]}, {"input": "9 3\r\n2 1 1 1 2 1 1 1 2\r\n", "output": ["3"]}, {"input": "1 1\r\n2\r\n", "output": ["0"]}, {"input": "2 1\r\n1 1\r\n", "output": ["0"]}, {"input": "2 2\r\n2 2\r\n", "output": ["0"]}, {"input": "... | 100 | 100 | 100 | [{'input': '20 5\r\n2 2 1 1 1 2 1 1 1 1 2 2 1 1 2 2 2 1 1 2\r\n', 'output': ['3']}, {'input': '100 2\r\n2 2 1 2 1 2 1 2 1 2 1 2 1 2 2 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 2 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 1 1 2 1 2 1 1 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2\r\n', 'output': ... | [{'input': '20 10\r\n1 2 2 2 2 1 1 1 2 1 1 2 2 2 2 1 2 2 2 1\r\n', 'output': ['2']}, {'input': '100 5\r\n2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 1 2 1 2 1 2 2 2 2 2 2 1 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 1 2 2 2 2 2 1 2 1 2 2 2 2 1 2 2 2 1 1 2 1 2 2 2 2 2 2 2 1 2 2 2\r\n', 'output':... | [{'input': '100 4\r\n1 2 1 1 1 2 1 1 1 2 1 1 1 2 1 1 1 2 2 2 1 2 1 1 1 1 1 1 1 2 1 1 1 2 1 1 1 2 1 1 1 2 2 1 1 1 1 1 1 2 1 1 1 1 1 1 1 2 1 1 1 2 1 1 1 2 1 1 1 2 1 1 1 2 1 1 1 2 2 1 1 2 1 1 1 2 1 2 1 2 1 1 1 2 1 1 1 2 1 1\r\n', 'output': ['8']}, {'input': '2 1\r\n1 1\r\n', 'output': ['0']}, {'input': '1 1\r\n2\r\n', 'ou... | [{'input': '100 10\r\n2 2 2 2 2 1 2 1 2 1 2 2 2 2 2 1 2 1 2 1 2 2 2 2 2 1 2 1 2 1 2 2 2 2 2 1 2 1 2 1 2 2 2 2 2 1 2 1 2 1 2 2 2 2 2 1 2 1 2 1 2 2 2 2 2 1 2 1 2 1 2 2 2 2 2 1 2 1 2 1 2 2 2 2 2 1 2 1 2 1 2 2 2 2 2 1 2 1 2 1\r\n', 'output': ['0']}, {'input': '9 3\r\n2 1 1 1 2 1 1 1 2\r\n', 'output': ['3']}, {'input': '1 1... | [{'input': '6 2\r\n2 1 2 2 2 1\r\n', 'output': ['1']}, {'input': '10 2\r\n2 2 2 1 1 2 2 2 2 1\r\n', 'output': ['3']}, {'input': '4 2\r\n2 1 2 2\r\n', 'output': ['1']}, {'input': '20 5\r\n2 2 1 1 1 2 1 1 1 1 2 2 1 1 2 2 2 1 1 2\r\n', 'output': ['3']}, {'input': '2 2\r\n2 1\r\n', 'output': ['0']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 358 | 100 | 100 | 100 |
["5\n6\n3", "5\n3\n5"] | The first line contains an integer $$$b$$$ ($$$1 \le b \le 300$$$), the number of boys. The second line contains an integer $$$g$$$ ($$$1 \le g \le 300$$$), the number of girls. The third line contains an integer $$$n$$$ ($$$1 \le n \le b + g$$$), the number of the board games tournament participants. | 9266a69e767df299569986151852e7b1 | b = int(input())
g = int(input())
n = int(input())
minig = min(n,g)
minib = min(n,b)
print(minig - (n-minib) +1)
| ["4", "4"] | Python | NoteIn the first example, each of 4 decks should be taken: (0 blue, 3 red), (1 blue, 2 red), (2 blue, 1 red), (3 blue, 0 red).In the second example, 4 decks should be taken: (2 blue, 3 red), (3 blue, 2 red), (4 blue, 1 red), (5 blue, 0 red). Piles (0 blue, 5 red) and (1 blue, 4 red) can not be used. | Output the only integer, the minimum number of badge decks that Vasya could take. | There are $$$b$$$ boys and $$$g$$$ girls participating in Olympiad of Metropolises. There will be a board games tournament in the evening and $$$n$$$ participants have accepted the invitation. The organizers do not know how many boys and girls are among them.Organizers are preparing red badges for girls and blue ones f... | [{"input": "5\r\n6\r\n3\r\n", "output": ["4"]}, {"input": "5\r\n3\r\n5\r\n", "output": ["4"]}, {"input": "1\r\n200\r\n33\r\n", "output": ["2"]}, {"input": "100\r\n200\r\n150\r\n", "output": ["101"]}, {"input": "123\r\n55\r\n100\r\n", "output": ["56"]}, {"input": "300\r\n300\r\n600\r\n", "output": ["1"]}, {"input": "1\r... | 100 | 100 | 100 | [{'input': '100\r\n200\r\n300\r\n', 'output': ['1']}, {'input': '1\r\n1\r\n2\r\n', 'output': ['1']}, {'input': '4\r\n2\r\n5\r\n', 'output': ['2']}, {'input': '299\r\n259\r\n300\r\n', 'output': ['259']}, {'input': '297\r\n297\r\n298\r\n', 'output': ['297']}] | [{'input': '300\r\n300\r\n1\r\n', 'output': ['2']}, {'input': '199\r\n199\r\n199\r\n', 'output': ['200']}, {'input': '123\r\n222\r\n250\r\n', 'output': ['96']}, {'input': '299\r\n259\r\n300\r\n', 'output': ['259']}, {'input': '100\r\n200\r\n250\r\n', 'output': ['51']}] | [{'input': '1\r\n1\r\n1\r\n', 'output': ['2']}, {'input': '5\r\n3\r\n5\r\n', 'output': ['4']}, {'input': '2\r\n2\r\n3\r\n', 'output': ['2']}, {'input': '299\r\n259\r\n300\r\n', 'output': ['259']}, {'input': '4\r\n7\r\n10\r\n', 'output': ['2']}] | [{'input': '1\r\n1\r\n1\r\n', 'output': ['2']}, {'input': '3\r\n3\r\n4\r\n', 'output': ['3']}, {'input': '4\r\n2\r\n5\r\n', 'output': ['2']}, {'input': '5\r\n6\r\n10\r\n', 'output': ['2']}, {'input': '4\r\n7\r\n10\r\n', 'output': ['2']}] | [{'input': '299\r\n259\r\n300\r\n', 'output': ['259']}, {'input': '4\r\n7\r\n10\r\n', 'output': ['2']}, {'input': '5\r\n3\r\n5\r\n', 'output': ['4']}, {'input': '300\r\n300\r\n600\r\n', 'output': ['1']}, {'input': '1\r\n1\r\n2\r\n', 'output': ['1']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 359 | 100 | 100 | 100 |
["6 2\n1 0 1 1 1 1\n2 10\n4 7", "3 3\n1 0 2\n2 5\n2 4", "7 16\n15 15 4 0 0 7 10\n7 9\n4 8 0 3 1 5 0"] | The first line of the input contains two space-separated integers n and bx (1 ≤ n ≤ 10, 2 ≤ bx ≤ 40), where n is the number of digits in the bx-based representation of X. The second line contains n space-separated integers x1, x2, ..., xn (0 ≤ xi < bx) — the digits of X. They are given in the order from the most si... | d6ab5f75a7bee28f0af2bf168a0b2e67 | n, b = map(int, input().split())
curr = 1
c1 = 0
a = [int(i) for i in input().split()]
a = a[::-1]
for i in range(n):
c1 += a[i] * curr
curr *= b
n, b = map(int, input().split())
curr = 1
c2 = 0
a = [int(i) for i in input().split()]
a = a[::-1]
for i in range(n):
c2 += a[i] * curr
curr *= b
if (c1 < c2)... | ["=", "<", ">"] | Python | NoteIn the first sample, X = 1011112 = 4710 = Y.In the second sample, X = 1023 = 215 and Y = 245 = 1123, thus X < Y.In the third sample, and Y = 48031509. We may notice that X starts with much larger digits and bx is much larger than by, so X is clearly larger than Y. | Output a single character (quotes for clarity): '<' if X < Y '>' if X > Y '=' if X = Y | After seeing the "ALL YOUR BASE ARE BELONG TO US" meme for the first time, numbers X and Y realised that they have different bases, which complicated their relations.You're given a number X represented in base bx and a number Y represented in base by. Compare those two numbers. | [{"input": "6 2\r\n1 0 1 1 1 1\r\n2 10\r\n4 7\r\n", "output": ["="]}, {"input": "3 3\r\n1 0 2\r\n2 5\r\n2 4\r\n", "output": ["<"]}, {"input": "7 16\r\n15 15 4 0 0 7 10\r\n7 9\r\n4 8 0 3 1 5 0\r\n", "output": [">"]}, {"input": "2 2\r\n1 0\r\n2 3\r\n1 0\r\n", "output": ["<"]}, {"input": "2 2\r\n1 0\r\n1 3\r\n1\r\n", "out... | 100 | 100 | 100 | [{'input': '6 29\r\n1 1 1 1 1 1\r\n10 21\r\n1 1 1 1 1 1 1 1 1 1\r\n', 'output': ['<']}, {'input': '4 5\r\n1 4 2 0\r\n4 4\r\n3 2 2 3\r\n', 'output': ['=']}, {'input': '2 2\r\n1 0\r\n2 3\r\n1 0\r\n', 'output': ['<']}, {'input': '6 5\r\n4 4 4 3 1 3\r\n7 6\r\n4 2 2 2 5 0 4\r\n', 'output': ['<']}, {'input': '1 36\r\n35\r\n4... | [{'input': '2 8\r\n1 0\r\n4 2\r\n1 0 0 0\r\n', 'output': ['=']}, {'input': '10 16\r\n15 15 4 0 0 0 0 7 10 9\r\n7 9\r\n4 8 0 3 1 5 0\r\n', 'output': ['>']}, {'input': '2 5\r\n3 3\r\n5 2\r\n1 0 0 1 0\r\n', 'output': ['=']}, {'input': '5 3\r\n1 0 0 0 0\r\n4 27\r\n1 0 0 0\r\n', 'output': ['<']}, {'input': '2 24\r\n4 18\r\n... | [{'input': '10 40\r\n39 39 39 39 39 39 39 39 39 39\r\n10 39\r\n38 38 38 38 38 38 38 38 38 38\r\n', 'output': ['>']}, {'input': '2 40\r\n2 0\r\n5 13\r\n4 0 0 0 0\r\n', 'output': ['<']}, {'input': '2 37\r\n25 2\r\n3 26\r\n13 13 12\r\n', 'output': ['<']}, {'input': '10 29\r\n15 22 0 5 11 12 17 22 4 27\r\n4 22\r\n9 2 8 14\... | [{'input': '1 8\r\n5\r\n9 27\r\n23 23 23 23 23 23 23 23 23\r\n', 'output': ['<']}, {'input': '8 18\r\n1 1 4 15 7 4 9 3\r\n8 17\r\n1 10 2 10 3 11 14 10\r\n', 'output': ['=']}, {'input': '2 8\r\n4 1\r\n1 7\r\n1\r\n', 'output': ['>']}, {'input': '2 5\r\n3 3\r\n5 2\r\n1 0 0 1 0\r\n', 'output': ['=']}, {'input': '9 35\r\n34... | [{'input': '7 31\r\n14 6 16 6 26 18 17\r\n7 24\r\n22 10 4 5 14 6 9\r\n', 'output': ['>']}, {'input': '2 24\r\n20 9\r\n10 23\r\n21 10 15 11 6 8 20 16 14 11\r\n', 'output': ['<']}, {'input': '9 34\r\n5 8 4 4 26 1 30 5 24\r\n10 27\r\n1 6 3 10 8 13 22 3 12 8\r\n', 'output': ['=']}, {'input': '2 12\r\n1 4\r\n8 16\r\n4 4 10 ... | 100 | 100 | 100 | 100 | 100 | 95.24 | 100 | 95.24 | 100 | 100 | 91.67 | 100 | 91.67 | 100 | 100 | 360 | 100 | 98.096 | 96.668 |
["1", "8", "10"] | The single line of input contains the integer m (1 ≤ m ≤ 1015) — the number of ways the thieves might steal the chocolates, as rumours say. | 602deaad5c66e264997249457d555129 | cubes = [i**3.0 for i in range(2, int(1.8e5+5))]
def valid(mid):
return sum([mid//i for i in cubes if i <= mid])
def binary_search(k):
l = int(4.8 * k)
r = min(8.0 * k, 5.0 * (10**15))
while (l+1 < r):
mid = (l+r) / 2.0
res = valid(mid)
if (res < k):
l = mid
... | ["8", "54", "-1"] | Python | NoteIn the first sample case the smallest n that leads to exactly one way of stealing chocolates is n = 8, whereas the amounts of stealed chocolates are (1, 2, 4, 8) (the number of chocolates stolen by each of the thieves).In the second sample case the smallest n that leads to exactly 8 ways is n = 54 with the possibil... | Print the only integer n — the maximum amount of chocolates that thieves' bags can carry. If there are more than one n satisfying the rumors, print the smallest one. If there is no such n for a false-rumoured m, print - 1. | Bad news came to Mike's village, some thieves stole a bunch of chocolates from the local factory! Horrible! Aside from loving sweet things, thieves from this area are known to be very greedy. So after a thief takes his number of chocolates for himself, the next thief will take exactly k times more than the previous one... | [{"input": "1\r\n", "output": ["8"]}, {"input": "8\r\n", "output": ["54"]}, {"input": "10\r\n", "output": ["-1"]}, {"input": "27\r\n", "output": ["152"]}, {"input": "28206\r\n", "output": ["139840"]}, {"input": "32\r\n", "output": ["184"]}, {"input": "115\r\n", "output": ["608"]}, {"input": "81258\r\n", "output": ["402... | 100 | 100 | 100 | [{'input': '550368702711851\r\n', 'output': ['-1']}, {'input': '121463490731834\r\n', 'output': ['601135070936200']}, {'input': '49729446417673\r\n', 'output': ['246116048009288']}, {'input': '196071196742\r\n', 'output': ['970376182648']}, {'input': '999999999999997\r\n', 'output': ['4949100894494440']}] | [{'input': '999999999999995\r\n', 'output': ['4949100894494424']}, {'input': '999999999999997\r\n', 'output': ['4949100894494440']}, {'input': '8\r\n', 'output': ['54']}, {'input': '181023403153\r\n', 'output': ['895903132760']}, {'input': '151269640772354\r\n', 'output': ['748648714769352']}] | [{'input': '106559547884220\r\n', 'output': ['527373954052328']}, {'input': '2\r\n', 'output': ['16']}, {'input': '99999\r\n', 'output': ['-1']}, {'input': '999999999999992\r\n', 'output': ['4949100894494408']}, {'input': '999999999999995\r\n', 'output': ['4949100894494424']}] | [{'input': '999999999999994\r\n', 'output': ['4949100894494421']}, {'input': '184061307002930\r\n', 'output': ['910937979445720']}, {'input': '550368702711851\r\n', 'output': ['-1']}, {'input': '7\r\n', 'output': ['48']}, {'input': '49729446417673\r\n', 'output': ['246116048009288']}] | [{'input': '2\r\n', 'output': ['16']}, {'input': '106559547884220\r\n', 'output': ['527373954052328']}, {'input': '121463490731834\r\n', 'output': ['601135070936200']}, {'input': '999999999999996\r\n', 'output': ['4949100894494432']}, {'input': '4235246\r\n', 'output': ['-1']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 361 | 100 | 100 | 100 |
["5 2\n1 3 1 4 2", "6 4\n1 1 2 2 3 3"] | The first line contains two integers n, m (1 ≤ n ≤ 100; 1 ≤ m ≤ 100). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 100). | c0ef1e4d7df360c5c1e52bc6f16ca87c | # http://codeforces.com/problemset/problem/450/A
from collections import deque
from math import ceil
# n, m = [int(x) for x in input().split()]
n, m = map(int, input().split())
candies = [int(x) for x in input().split()]
children = deque([int(x) for x in range(1, n + 1)])
home = []
max_num = 0
counter = 0
candies_di... | ["4", "6"] | Python | NoteLet's consider the first sample. Firstly child 1 gets 2 candies and go home. Then child 2 gets 2 candies and go to the end of the line. Currently the line looks like [3, 4, 5, 2] (indices of the children in order of the line). Then child 3 gets 2 candies and go home, and then child 4 gets 2 candies and goes to the ... | Output a single integer, representing the number of the last child. | There are n children in Jzzhu's school. Jzzhu is going to give some candies to them. Let's number all the children from 1 to n. The i-th child wants to get at least ai candies.Jzzhu asks children to line up. Initially, the i-th child stands at the i-th place of the line. Then Jzzhu start distribution of the candies. He... | [{"input": "5 2\r\n1 3 1 4 2\r\n", "output": ["4"]}, {"input": "6 4\r\n1 1 2 2 3 3\r\n", "output": ["6"]}, {"input": "7 3\r\n6 1 5 4 2 3 1\r\n", "output": ["4"]}, {"input": "10 5\r\n2 7 3 6 2 5 1 3 4 5\r\n", "output": ["4"]}, {"input": "100 1\r\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28... | 100 | 100 | 100 | [{'input': '100 2\r\n1 51 76 62 34 93 90 43 57 59 52 78 3 48 11 60 57 48 5 54 28 81 87 23 44 77 67 61 14 73 29 53 21 89 67 41 47 9 63 37 1 71 40 85 4 14 77 40 78 75 89 74 4 70 32 65 81 95 49 90 72 41 76 55 69 83 73 84 85 93 46 6 74 90 62 37 97 7 7 37 83 30 37 88 34 16 11 59 85 19 57 63 85 20 63 97 97 65 61 48\r\n', 'ou... | [{'input': '100 3\r\n30 83 14 55 61 66 34 98 90 62 89 74 45 93 33 31 75 35 82 100 63 69 48 18 99 2 36 71 14 30 70 76 96 85 97 90 49 36 6 76 37 94 70 3 63 73 75 48 39 29 13 2 46 26 9 56 1 18 54 53 85 34 2 12 1 93 75 67 77 77 14 26 33 25 55 9 57 70 75 6 87 66 18 3 41 69 73 24 49 2 20 72 39 58 91 54 74 56 66 78\r\n', 'out... | [{'input': '100 2\r\n1 51 76 62 34 93 90 43 57 59 52 78 3 48 11 60 57 48 5 54 28 81 87 23 44 77 67 61 14 73 29 53 21 89 67 41 47 9 63 37 1 71 40 85 4 14 77 40 78 75 89 74 4 70 32 65 81 95 49 90 72 41 76 55 69 83 73 84 85 93 46 6 74 90 62 37 97 7 7 37 83 30 37 88 34 16 11 59 85 19 57 63 85 20 63 97 97 65 61 48\r\n', 'ou... | [{'input': '2 2\r\n6 4\r\n', 'output': ['1']}, {'input': '100 2\r\n1 51 76 62 34 93 90 43 57 59 52 78 3 48 11 60 57 48 5 54 28 81 87 23 44 77 67 61 14 73 29 53 21 89 67 41 47 9 63 37 1 71 40 85 4 14 77 40 78 75 89 74 4 70 32 65 81 95 49 90 72 41 76 55 69 83 73 84 85 93 46 6 74 90 62 37 97 7 7 37 83 30 37 88 34 16 11 59... | [{'input': '9 3\r\n9 5 2 3 7 1 8 4 6\r\n', 'output': ['7']}, {'input': '2 5\r\n99 97\r\n', 'output': ['2']}, {'input': '100 1\r\n58 94 18 50 17 14 96 62 83 80 75 5 9 22 25 41 3 96 74 45 66 37 2 37 13 85 68 54 77 11 85 19 25 21 52 59 90 61 72 89 82 22 10 16 3 68 61 29 55 76 28 85 65 76 27 3 14 10 56 37 86 18 35 38 56 68... | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 362 | 100 | 100 | 100 |
["0 0", "1 0", "0 1", "-1 -1"] | The first line contains two space-separated integers x and y (|x|, |y| ≤ 100). | 2fb2a129e01efc03cfc3ad91dac88382 | x = 0
y = 0
nx,ny = map(int,input().split())
if ((nx == 0 or nx == 1) and ny == 0):
print(0)
else:
x = 1
turn = 0
flag = 0
while True:
turn = turn + 1
while y != x:
y = y + 1
if(x == nx and y == ny):
flag = 1
break
i... | ["0", "0", "2", "3"] | Python | null | Print a single integer, showing how many times Valera has to turn. | Valera the horse lives on a plane. The Cartesian coordinate system is defined on this plane. Also an infinite spiral is painted on the plane. The spiral consists of segments: [(0, 0), (1, 0)], [(1, 0), (1, 1)], [(1, 1), ( - 1, 1)], [( - 1, 1), ( - 1, - 1)], [( - 1, - 1), (2, - 1)], [(2, - 1), (2, 2)] and so on. Thu... | [{"input": "0 0\r\n", "output": ["0"]}, {"input": "1 0\r\n", "output": ["0"]}, {"input": "0 1\r\n", "output": ["2"]}, {"input": "-1 -1\r\n", "output": ["3"]}, {"input": "10 10\r\n", "output": ["37"]}, {"input": "0 6\r\n", "output": ["22"]}, {"input": "-7 -13\r\n", "output": ["52"]}, {"input": "37 -100\r\n", "output": [... | 100 | 100 | 100 | [{'input': '100 100\r\n', 'output': ['397']}, {'input': '-97 0\r\n', 'output': ['387']}, {'input': '1 1\r\n', 'output': ['1']}, {'input': '93 0\r\n', 'output': ['369']}, {'input': '0 0\r\n', 'output': ['0']}] | [{'input': '-7 -13\r\n', 'output': ['52']}, {'input': '-97 0\r\n', 'output': ['387']}, {'input': '0 6\r\n', 'output': ['22']}, {'input': '1 -84\r\n', 'output': ['336']}, {'input': '3 -5\r\n', 'output': ['20']}] | [{'input': '11 -15\r\n', 'output': ['60']}, {'input': '2 -1\r\n', 'output': ['4']}, {'input': '42 9\r\n', 'output': ['165']}, {'input': '1 -1\r\n', 'output': ['4']}, {'input': '16 -32\r\n', 'output': ['128']}] | [{'input': '94 -94\r\n', 'output': ['376']}, {'input': '99 100\r\n', 'output': ['398']}, {'input': '3 -5\r\n', 'output': ['20']}, {'input': '1 1\r\n', 'output': ['1']}, {'input': '1 0\r\n', 'output': ['0']}] | [{'input': '2 -1\r\n', 'output': ['4']}, {'input': '0 0\r\n', 'output': ['0']}, {'input': '0 1\r\n', 'output': ['2']}, {'input': '1 0\r\n', 'output': ['0']}, {'input': '93 0\r\n', 'output': ['369']}] | 100 | 100 | 100 | 100 | 100 | 86.05 | 90.7 | 83.72 | 93.02 | 93.02 | 84.62 | 88.46 | 80.77 | 92.31 | 92.31 | 363 | 100 | 89.302 | 87.694 |
["1 0", "2 1", "3 2", "4 1", "7 4"] | The single line contains two space-separated integers n and k (1 ≤ n ≤ 1000, 0 ≤ k ≤ n). | 1243e98fe2ebd6e6d1de851984b96079 | mod=10**9+7
n,k=map(int,input().split())
A=[0]*(n+1)
B=[0]*(n+1)
C=[0]*(n+1)
F=[0]*(n+1)
G=[0]*(n+1)
F[0]=G[0]=1
for i in range(1,n+1):
G[i]=F[i]=F[i-1]*i%mod
G[i]=pow(F[i],(mod-2),mod)
for i in range(0,n):
if i*2>n:
break
B[i]=(F[n-i]*G[i]*G[n-i*2])%mod
for i in range(0,n//2+1):
for j in range(0,n//2+1):
A... | ["1", "0", "4", "6", "328"] | Python | NoteThe only permutation of size 1 has 0 good positions.Permutation (1, 2) has 0 good positions, and permutation (2, 1) has 2 positions.Permutations of size 3: (1, 2, 3) — 0 positions — 2 positions — 2 positions — 2 positions — 2 positions (3, 2, 1) — 0 positions | Print the number of permutations of length n with exactly k good positions modulo 1000000007 (109 + 7). | Permutation p is an ordered set of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutation p1, p2, ..., pn.We'll call position i (1 ≤ i ≤ n) in permutation p... | [{"input": "1 0\r\n", "output": ["1"]}, {"input": "2 1\r\n", "output": ["0"]}, {"input": "3 2\r\n", "output": ["4"]}, {"input": "4 1\r\n", "output": ["6"]}, {"input": "7 4\r\n", "output": ["328"]}, {"input": "7 7\r\n", "output": ["0"]}, {"input": "8 4\r\n", "output": ["2658"]}, {"input": "8 5\r\n", "output": ["688"]}, ... | 100 | 100 | 100 | [{'input': '999 998\r\n', 'output': ['250000']}, {'input': '1000 0\r\n', 'output': ['845393494']}, {'input': '5 3\r\n', 'output': ['12']}, {'input': '5 0\r\n', 'output': ['21']}, {'input': '999 999\r\n', 'output': ['0']}] | [{'input': '3 3\r\n', 'output': ['0']}, {'input': '999 0\r\n', 'output': ['184907578']}, {'input': '2 0\r\n', 'output': ['1']}, {'input': '999 998\r\n', 'output': ['250000']}, {'input': '20 0\r\n', 'output': ['111008677']}] | [{'input': '20 0\r\n', 'output': ['111008677']}, {'input': '999 998\r\n', 'output': ['250000']}, {'input': '13 13\r\n', 'output': ['0']}, {'input': '8 5\r\n', 'output': ['688']}, {'input': '10 3\r\n', 'output': ['614420']}] | [{'input': '999 13\r\n', 'output': ['740892203']}, {'input': '3 0\r\n', 'output': ['2']}, {'input': '999 999\r\n', 'output': ['0']}, {'input': '1000 10\r\n', 'output': ['305545369']}, {'input': '8 4\r\n', 'output': ['2658']}] | [{'input': '1000 1\r\n', 'output': ['418947603']}, {'input': '1 1\r\n', 'output': ['0']}, {'input': '1000 99\r\n', 'output': ['115316732']}, {'input': '999 998\r\n', 'output': ['250000']}, {'input': '10 3\r\n', 'output': ['614420']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 93.75 | 100 | 93.75 | 93.75 | 100 | 364 | 100 | 100 | 96.25 |
["WUBWUBABCWUB", "WUBWEWUBAREWUBWUBTHEWUBCHAMPIONSWUBMYWUBFRIENDWUB"] | The input consists of a single non-empty string, consisting only of uppercase English letters, the string's length doesn't exceed 200 characters. It is guaranteed that before Vasya remixed the song, no word contained substring "WUB" in it; Vasya didn't change the word order. It is also guaranteed that initially the son... | edede580da1395fe459a480f6a0a548d | n = input()
n = list(n)
space = 1
s = []
i = 0
for _ in range(0,len(n), 1):
if i == len(n):
break
elif i + 2 < len(n) and n[i] == 'W' and n[i+1] == 'U' and n[i+2] == 'B':
i += 3
if space == 0:
s.append(" ")
space = 1
else:
s.append(n[i])
i += 1
... | ["ABC", "WE ARE THE CHAMPIONS MY FRIEND"] | Python | NoteIn the first sample: "WUBWUBABCWUB" = "WUB" + "WUB" + "ABC" + "WUB". That means that the song originally consisted of a single word "ABC", and all words "WUB" were added by Vasya.In the second sample Vasya added a single word "WUB" between all neighbouring words, in the beginning and in the end, except for words "A... | Print the words of the initial song that Vasya used to make a dubsteb remix. Separate the words with a space. | Vasya works as a DJ in the best Berland nightclub, and he often uses dubstep music in his performance. Recently, he has decided to take a couple of old songs and make dubstep remixes from them.Let's assume that a song consists of some number of words. To make the dubstep remix of this song, Vasya inserts a certain numb... | [{"input": "WUBWUBABCWUB\r\n", "output": ["ABC"]}, {"input": "WUBWEWUBAREWUBWUBTHEWUBCHAMPIONSWUBMYWUBFRIENDWUB\r\n", "output": ["WE ARE THE CHAMPIONS MY FRIEND", "WE ARE THE CHAMPIONS MY FRIEND"]}, {"input": "WUBWUBWUBSR\r\n", "output": ["SR"]}, {"input": "RWUBWUBWUBLWUB\r\n", "output": ["R L", "R L"]}, {"input": "... | 100 | 100 | 100 | [{'input': 'WUBWUBZBKOKHQLGKRVIMZQMQNRWUBWUBWUBDACWUBWUBNZHFJMPEYKRVSWUBWUBWUBPPHGAVVPRZWUBWUBWUBQWUBWUBAWUBG\r\n', 'output': ['ZBKOKHQLGKRVIMZQMQNR DAC NZHFJMPEYKRVS PPHGAVVPRZ Q A G', 'ZBKOKHQLGKRVIMZQMQNR DAC NZHFJMPEYKRVS PPHGAVVPRZ Q A G']}, {'input': 'WPPNMSQOQIWUBWUBWUBPNQXWUBWUBWUBHWUBWUBWUBNFLWUBWUBWUB... | [{'input': 'WUBWUBWSPLAYSZSAUDSWUBWUBWUBUWUBWUBWUBKRWUBWUBWUBRSOKQMZFIYZQUWUBWUBWUBELSHUWUBWUBWUBUKHWUBWUBWUBQXEUHQWUBWUBWUBBWUBWUBWUBR\r\n', 'output': ['WSPLAYSZSAUDS U KR RSOKQMZFIYZQU ELSHU UKH QXEUHQ B R', 'WSPLAYSZSAUDS U KR RSOKQMZFIYZQU ELSHU UKH QXEUHQ B R']}, {'input': 'TOWUBWUBWUBGBTBNWUBWUBWU... | [{'input': 'WUBWUBWUBSR\r\n', 'output': ['SR']}, {'input': 'WUWUBUBWUBUWUB\r\n', 'output': ['WU UB U']}, {'input': 'WUBXEMWWVUHLSUUGRWUBWUBWUBAWUBXEGILZUNKWUBWUBWUBJDHHKSWUBWUBWUBDTSUYSJHWUBWUBWUBPXFWUBMOHNJWUBWUBWUBZFXVMDWUBWUBWUBZMWUBWUB\r\n', 'output': ['XEMWWVUHLSUUGR A XEGILZUNK JDHHKS DTSUYSJH PXF MOHNJ ZFXVMD ZM... | [{'input': 'QWUBQQWUBWUBWUBIWUBWUBWWWUBWUBWUBJOPJPBRH\r\n', 'output': ['Q QQ I WW JOPJPBRH', 'Q QQ I WW JOPJPBRH']}, {'input': 'ZJWUBWUBWUBJWUBWUBWUBL\r\n', 'output': ['ZJ J L', 'ZJ J L']}, {'input': 'WUBWUBEWUBWUBWUBIQMJNIQWUBWUBWUBGZZBQZAUHYPWUBWUBWUBPMRWUBWUBWUBDCV\r\n', 'output': ['E IQMJNIQ GZZBQZAUHYP PM... | [{'input': 'WU\r\n', 'output': ['WU']}, {'input': 'WUBWUBWUBIWUBWUBLIKNQVWUBWUBWUBPWUBWUBWUBHWUBWUBWUBMWUBWUBWUBDPRSWUBWUBWUBBSAGYLQEENWXXVWUBWUBWUBXMHOWUBWUBWUBUWUBWUBWUBYRYWUBWUBWUBCWUBWUBWUBY\r\n', 'output': ['I LIKNQV P H M DPRS BSAGYLQEENWXXV XMHO U YRY C Y', 'I LIKNQV P H M DPRS BSAGYLQEENWXXV XMHO ... | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 90 | 100 | 100 | 90 | 100 | 365 | 100 | 100 | 96 |
["3 7 0", "2 0 1", "1 1 0", "0 0 1"] | The only line contains three integers $$$x$$$, $$$y$$$, $$$z$$$ ($$$0\le x,y,z\le100$$$), corresponding to the number of persons who would upvote, downvote or unknown. | 66398694a4a142b4a4e709d059aca0fa | a,b,c=map(int,input().split())
x=a-b
if(c>=abs(x) and c!=0):
print("?")
elif(x==0):
print("0")
elif(x<0):
print("-")
else:
print("+") | ["-", "+", "0", "?"] | Python | NoteIn the first example, Nauuo would definitely get three upvotes and seven downvotes, so the only possible result is "-".In the second example, no matter the person unknown downvotes or upvotes, Nauuo would get more upvotes than downvotes. So the only possible result is "+".In the third example, Nauuo would definitel... | If there is only one possible result, print the result : "+", "-" or "0". Otherwise, print "?" to report that the result is uncertain. | Nauuo is a girl who loves writing comments.One day, she posted a comment on Codeforces, wondering whether she would get upvotes or downvotes.It's known that there were $$$x$$$ persons who would upvote, $$$y$$$ persons who would downvote, and there were also another $$$z$$$ persons who would vote, but you don't know whe... | [{"input": "3 7 0\r\n", "output": ["-"]}, {"input": "2 0 1\r\n", "output": ["+"]}, {"input": "1 1 0\r\n", "output": ["0"]}, {"input": "0 0 1\r\n", "output": ["?"]}, {"input": "12 1 11\r\n", "output": ["?"]}, {"input": "22 99 77\r\n", "output": ["?"]}, {"input": "28 99 70\r\n", "output": ["-"]}, {"input": "73 29 43\r\n"... | 100 | 100 | 100 | [{'input': '7 4 3\r\n', 'output': ['?']}, {'input': '0 0 100\r\n', 'output': ['?']}, {'input': '2 0 1\r\n', 'output': ['+']}, {'input': '89 41 36\r\n', 'output': ['+']}, {'input': '52 14 10\r\n', 'output': ['+']}] | [{'input': '96 71 19\r\n', 'output': ['+']}, {'input': '100 100 100\r\n', 'output': ['?']}, {'input': '62 63 12\r\n', 'output': ['?']}, {'input': '42 43 16\r\n', 'output': ['?']}, {'input': '28 99 70\r\n', 'output': ['-']}] | [{'input': '0 0 0\r\n', 'output': ['0']}, {'input': '19 90 4\r\n', 'output': ['-']}, {'input': '78 95 14\r\n', 'output': ['-']}, {'input': '58 97 4\r\n', 'output': ['-']}, {'input': '60 33 15\r\n', 'output': ['+']}] | [{'input': '8 87 7\r\n', 'output': ['-']}, {'input': '5 3 2\r\n', 'output': ['?']}, {'input': '3 4 5\r\n', 'output': ['?']}, {'input': '12 1 11\r\n', 'output': ['?']}, {'input': '58 83 39\r\n', 'output': ['?']}] | [{'input': '74 2 16\r\n', 'output': ['+']}, {'input': '0 0 1\r\n', 'output': ['?']}, {'input': '100 48 48\r\n', 'output': ['+']}, {'input': '28 99 70\r\n', 'output': ['-']}, {'input': '82 84 16\r\n', 'output': ['?']}] | 100 | 100 | 100 | 100 | 100 | 77.78 | 88.89 | 88.89 | 77.78 | 88.89 | 66.67 | 83.33 | 83.33 | 66.67 | 83.33 | 366 | 100 | 84.446 | 76.666 |
["6\n1 5\n2 6\n3 7", "10\n1 2\n1 3\n1 5", "6\n1 3\n2 2\n2 2"] | The first line of the input contains a single integer n (3 ≤ n ≤ 3·106) — the number of schoolchildren who will participate in the Olympiad. The next line of the input contains two integers min1 and max1 (1 ≤ min1 ≤ max1 ≤ 106) — the minimum and maximum limits on the number of diplomas of the first degree that can be d... | 3cd092b6507079518cf206deab21cf97 | n=int(input())
a=[None]*3
a[0]=list(map(int,input().split()))
a[1]=list(map(int,input().split()))
a[2]=list(map(int,input().split()))
total=0
b=[None]*3
for i in range(3):
total+=a[i][0]
b[i]=a[i][0]
while total<n:
if b[0]<a[0][1]:
k=a[0][1]-b[0]
if total+k>n:
... | ["1 2 3", "2 3 5", "2 2 2"] | Python | null | In the first line of the output print three numbers, showing how many diplomas of the first, second and third degree will be given to students in the optimal variant of distributing diplomas. The optimal variant of distributing diplomas is the one that maximizes the number of students who receive diplomas of the first ... | Soon a school Olympiad in Informatics will be held in Berland, n schoolchildren will participate there.At a meeting of the jury of the Olympiad it was decided that each of the n participants, depending on the results, will get a diploma of the first, second or third degree. Thus, each student will receive exactly one d... | [{"input": "6\r\n1 5\r\n2 6\r\n3 7\r\n", "output": ["1 2 3"]}, {"input": "10\r\n1 2\r\n1 3\r\n1 5\r\n", "output": ["2 3 5"]}, {"input": "6\r\n1 3\r\n2 2\r\n2 2\r\n", "output": ["2 2 2"]}, {"input": "55\r\n1 1000000\r\n40 50\r\n10 200\r\n", "output": ["5 40 10"]}, {"input": "3\r\n1 1\r\n1 1\r\n1 1\r\n", "output": ["1 1 ... | 100 | 100 | 100 | [{'input': '300\r\n200 400\r\n50 100\r\n40 80\r\n', 'output': ['210 50 40']}, {'input': '1107\r\n471 849\r\n360 741\r\n71 473\r\n', 'output': ['676 360 71']}, {'input': '1233589\r\n2850 555444\r\n500608 921442\r\n208610 607343\r\n', 'output': ['524371 500608 208610']}, {'input': '1702543\r\n405042 832833\r\n50931 74775... | [{'input': '2065529\r\n43217 891429\r\n434379 952871\r\n650231 855105\r\n', 'output': ['891429 523869 650231']}, {'input': '1000\r\n100 400\r\n300 500\r\n400 1200\r\n', 'output': ['300 300 400']}, {'input': '17\r\n3 6\r\n3 6\r\n3 6\r\n', 'output': ['6 6 5']}, {'input': '1529\r\n515 515\r\n563 869\r\n169 451\r\n', 'outp... | [{'input': '1529\r\n515 515\r\n563 869\r\n169 451\r\n', 'output': ['515 845 169']}, {'input': '1702543\r\n405042 832833\r\n50931 747750\r\n381818 796831\r\n', 'output': ['832833 487892 381818']}, {'input': '1652707\r\n266774 638522\r\n65688 235422\r\n924898 992826\r\n', 'output': ['638522 89287 924898']}, {'input': '17... | [{'input': '1655\r\n539 539\r\n10 425\r\n605 895\r\n', 'output': ['539 425 691']}, {'input': '3\r\n1 1000000\r\n1 1000000\r\n1 1000000\r\n', 'output': ['1 1 1']}, {'input': '6\r\n1 5\r\n2 6\r\n3 7\r\n', 'output': ['1 2 3']}, {'input': '761655\r\n88152 620061\r\n60403 688549\r\n79370 125321\r\n', 'output': ['620061 6222... | [{'input': '679115\r\n112687 183628\r\n101770 982823\r\n81226 781340\r\n', 'output': ['183628 414261 81226']}, {'input': '1000000\r\n300000 600000\r\n300000 600000\r\n300000 600000\r\n', 'output': ['400000 300000 300000']}, {'input': '2065529\r\n608515 608515\r\n751563 864337\r\n614898 705451\r\n', 'output': ['608515 8... | 100 | 100 | 100 | 100 | 100 | 87.88 | 93.94 | 93.94 | 93.94 | 93.94 | 68.75 | 81.25 | 81.25 | 81.25 | 81.25 | 367 | 100 | 92.728 | 78.75 |
["1 1 10", "1 2 5", "2 3 9"] | The only string contains three integers — n, m and z (1 ≤ n, m, z ≤ 104). | e7ad55ce26fc8610639323af1de36c2d | n = list(map(int, input().split()))
a = set()
b = set()
for i in range(n[2]//n[0]):
a.add((i+1)*n[0])
for i in range(n[2]//n[1]):
b.add((i+1)*n[1])
print(len(a & b)) | ["10", "2", "1"] | Python | NoteTaymyr is a place in the north of Russia.In the first test the artists come each minute, as well as the calls, so we need to kill all of them.In the second test we need to kill artists which come on the second and the fourth minutes.In the third test — only the artist which comes on the sixth minute. | Print single integer — the minimum number of artists that should be killed so that there are no artists in the room when Ilia calls. | Comrade Dujikov is busy choosing artists for Timofey's birthday and is recieving calls from Taymyr from Ilia-alpinist.Ilia-alpinist calls every n minutes, i.e. in minutes n, 2n, 3n and so on. Artists come to the comrade every m minutes, i.e. in minutes m, 2m, 3m and so on. The day is z minutes long, i.e. the day consis... | [{"input": "1 1 10\r\n", "output": ["10"]}, {"input": "1 2 5\r\n", "output": ["2"]}, {"input": "2 3 9\r\n", "output": ["1"]}, {"input": "4 8 9\r\n", "output": ["1"]}, {"input": "7 9 2\r\n", "output": ["0"]}, {"input": "10000 10000 10000\r\n", "output": ["1"]}, {"input": "24 22 9235\r\n", "output": ["34"]}, {"input": "7... | 100 | 100 | 100 | [{'input': '1 1 1\r\n', 'output': ['1']}, {'input': '1 2 5\r\n', 'output': ['2']}, {'input': '2 3 9\r\n', 'output': ['1']}, {'input': '550 1 754\r\n', 'output': ['1']}, {'input': '5 1 20\r\n', 'output': ['4']}] | [{'input': '2940 1 9311\r\n', 'output': ['3']}, {'input': '2 2 9999\r\n', 'output': ['4999']}, {'input': '1 1 1\r\n', 'output': ['1']}, {'input': '1 2 5\r\n', 'output': ['2']}, {'input': '24 22 9235\r\n', 'output': ['34']}] | [{'input': '1 2 5\r\n', 'output': ['2']}, {'input': '6 4 36\r\n', 'output': ['3']}, {'input': '1 1 10\r\n', 'output': ['10']}, {'input': '1 1 10000\r\n', 'output': ['10000']}, {'input': '8 12 12\r\n', 'output': ['0']}] | [{'input': '6 4 36\r\n', 'output': ['3']}, {'input': '4624 1 1953\r\n', 'output': ['0']}, {'input': '358 2 809\r\n', 'output': ['2']}, {'input': '2940 1 9311\r\n', 'output': ['3']}, {'input': '2 3 9\r\n', 'output': ['1']}] | [{'input': '4 8 9\r\n', 'output': ['1']}, {'input': '550 1 754\r\n', 'output': ['1']}, {'input': '10 20 10000\r\n', 'output': ['500']}, {'input': '10000 10000 10000\r\n', 'output': ['1']}, {'input': '1 2 10\r\n', 'output': ['5']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 368 | 100 | 100 | 100 |
["17 15 5 3", "14 16 7 22", "4 2 6 4", "1000000000000000000 1000000000000000000 999999866000004473 999999822000007597"] | The first line contains four integers $$$a$$$, $$$b$$$, $$$x$$$, $$$y$$$ ($$$1 \le a, b, x, y \le 10^{18}$$$) — the constraints on the screen width and height, and on the aspect ratio. | 907ac56260e84dbb6d98a271bcb2d62d | from math import gcd
x, y, a, b = [int(x) for x in input().split()]
gc = gcd(a, b)
a = a // gc
b = b // gc
print(min(x//a, y//b)) | ["3", "0", "1", "1000000063"] | Python | NoteIn the first example, there are $$$3$$$ possible variants: $$$(5, 3)$$$, $$$(10, 6)$$$, $$$(15, 9)$$$.In the second example, there is no TV set meeting the constraints.In the third example, there is only one variant: $$$(3, 2)$$$. | Print one integer — the number of different variants to choose TV screen width and screen height so that they meet the aforementioned constraints. | Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than $$$a$$$ and screen height not greater than $$$b$$$. Monocarp is also used to TV sets with a certain aspect ratio: formally, if the width of the scr... | [{"input": "17 15 5 3\r\n", "output": ["3"]}, {"input": "14 16 7 22\r\n", "output": ["0"]}, {"input": "4 2 6 4\r\n", "output": ["1"]}, {"input": "1000000000000000000 1000000000000000000 999999866000004473 999999822000007597\r\n", "output": ["1000000063"]}, {"input": "1 1 1 1\r\n", "output": ["1"]}, {"input": "100000000... | 100 | 100 | 100 | [{'input': '3 3 2 6\r\n', 'output': ['1']}, {'input': '162 86 200 332\r\n', 'output': ['1']}, {'input': '1 1 1 100000000000000000\r\n', 'output': ['0']}, {'input': '405 55 194 58\r\n', 'output': ['1']}, {'input': '165 108 114 184\r\n', 'output': ['1']}] | [{'input': '1561742222476 104898922608 1477225799720 2031291351072\r\n', 'output': ['0']}, {'input': '4 2 4 3\r\n', 'output': ['0']}, {'input': '147006920825755769 542505368524532032 208073625707521517 14411087792522426\r\n', 'output': ['0']}, {'input': '1000000000000000000 1000000000000000000 999999866000004473 999999... | [{'input': '72 72 312 64\r\n', 'output': ['1']}, {'input': '20 5 10 7\r\n', 'output': ['0']}, {'input': '2023521027270 3298933358415 137370252990 2592814018030\r\n', 'output': ['12']}, {'input': '84 231 70 145\r\n', 'output': ['6']}, {'input': '500 500 1000000000000000000 1\r\n', 'output': ['0']}] | [{'input': '1760355542088 1044709015401 1674331546848 2647835033212\r\n', 'output': ['1']}, {'input': '162 86 200 332\r\n', 'output': ['1']}, {'input': '405 55 194 58\r\n', 'output': ['1']}, {'input': '225 276 42 210\r\n', 'output': ['55']}, {'input': '100000 1 3 2\r\n', 'output': ['0']}] | [{'input': '27 68 94 30\r\n', 'output': ['0']}, {'input': '1000000000000000000 1000000000000000000 999999866000004473 999999822000007597\r\n', 'output': ['1000000063']}, {'input': '149485641770071450 851192235245178565 874621826044152778 488378180096620703\r\n', 'output': ['0']}, {'input': '25 260 129 285\r\n', 'output... | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 369 | 100 | 100 | 100 |
["0 0\n4 5", "3 4\n6 1"] | The first line contains two integers x1, y1 ( - 109 ≤ x1, y1 ≤ 109) — the start position of the robot. The second line contains two integers x2, y2 ( - 109 ≤ x2, y2 ≤ 109) — the finish position of the robot. | a6e9405bc3d4847fe962446bc1c457b4 | a, b=map(int, input().split())
c, d=map(int, input().split())
g=abs(c-a)
h=abs(d-b)
x=max(g, h)
y=min(g, h)
z=abs(x-y)
if g==h:
print(g)
else:
print(y+z) | ["5", "3"] | Python | NoteIn the first example robot should increase both of its coordinates by one four times, so it will be in position (4, 4). After that robot should simply increase its y coordinate and get the finish position.In the second example robot should simultaneously increase x coordinate and decrease y coordinate by one three ... | Print the only integer d — the minimal number of steps to get the finish position. | Professor GukiZ makes a new robot. The robot are in the point with coordinates (x1, y1) and should go to the point (x2, y2). In a single step the robot can change any of its coordinates (maybe both of them) by one (decrease or increase). So the robot can move in one of the 8 directions. Find the minimal number of steps... | [{"input": "0 0\r\n4 5\r\n", "output": ["5"]}, {"input": "3 4\r\n6 1\r\n", "output": ["3"]}, {"input": "0 0\r\n4 6\r\n", "output": ["6"]}, {"input": "1 1\r\n-3 -5\r\n", "output": ["6"]}, {"input": "-1 -1\r\n-10 100\r\n", "output": ["101"]}, {"input": "1 -1\r\n100 -100\r\n", "output": ["99"]}, {"input": "-1000000000 -10... | 100 | 100 | 100 | [{'input': '0 0\r\n4 6\r\n', 'output': ['6']}, {'input': '9 1\r\n1 1\r\n', 'output': ['8']}, {'input': '-11 0\r\n0 0\r\n', 'output': ['11']}, {'input': '0 0\r\n4 0\r\n', 'output': ['4']}, {'input': '93097194 -48405232\r\n-716984003 -428596062\r\n', 'output': ['810081197']}] | [{'input': '5 6\r\n5 7\r\n', 'output': ['1']}, {'input': '10 90\r\n90 10\r\n', 'output': ['80']}, {'input': '9 9\r\n9 9\r\n', 'output': ['0']}, {'input': '-5 -4\r\n-3 -3\r\n', 'output': ['2']}, {'input': '-1000000000 -1000000000\r\n1000000000 -1000000000\r\n', 'output': ['2000000000']}] | [{'input': '1000 1000\r\n-1000 1000\r\n', 'output': ['2000']}, {'input': '-44602634 913365223\r\n-572368780 933284951\r\n', 'output': ['527766146']}, {'input': '-1 0\r\n0 0\r\n', 'output': ['1']}, {'input': '2 4\r\n5 2\r\n', 'output': ['3']}, {'input': '1 2\r\n45 1\r\n', 'output': ['44']}] | [{'input': '0 0\r\n4 5\r\n', 'output': ['5']}, {'input': '-463154699 -654742385\r\n-699179052 -789004997\r\n', 'output': ['236024353']}, {'input': '1 1\r\n4 3\r\n', 'output': ['3']}, {'input': '-1 -1\r\n-10 100\r\n', 'output': ['101']}, {'input': '207558188 -313753260\r\n-211535387 -721675423\r\n', 'output': ['41909357... | [{'input': '1 2\r\n45 1\r\n', 'output': ['44']}, {'input': '0 0\r\n-1 1\r\n', 'output': ['1']}, {'input': '0 0\r\n1 -1\r\n', 'output': ['1']}, {'input': '-637204864 -280290367\r\n-119020929 153679771\r\n', 'output': ['518183935']}, {'input': '0 81\r\n18 90\r\n', 'output': ['18']}] | 100 | 100 | 100 | 100 | 100 | 90 | 100 | 90 | 90 | 100 | 50 | 100 | 50 | 50 | 100 | 370 | 100 | 94 | 70 |
["6 10", "21 31", "5 10"] | The only line contains two integers $$$a$$$ and $$$b$$$ ($$$1 \le a, b \le 10^9$$$). | 414149fadebe25ab6097fc67663177c3 | a, b = input().split()
a, b = int(a), int(b)
a, b = min(a, b), max(a, b)
def eu(a, b):
if a == 0:
return b
if b == 0:
return a
if a > b:
return eu(a%b, b)
return eu(a, b%a)
opt = b - a
factor = []
i = 1
while i**2 < opt+1:
if opt % i == 0:
factor.append(i)
f... | ["2", "9", "0"] | Python | NoteIn the first test, one should choose $$$k = 2$$$, as the least common multiple of $$$6 + 2$$$ and $$$10 + 2$$$ is $$$24$$$, which is the smallest least common multiple possible. | Print the smallest non-negative integer $$$k$$$ ($$$k \ge 0$$$) such that the lowest common multiple of $$$a+k$$$ and $$$b+k$$$ is the smallest possible. If there are many possible integers $$$k$$$ giving the same value of the least common multiple, print the smallest one. | Neko loves divisors. During the latest number theory lesson, he got an interesting exercise from his math teacher.Neko has two integers $$$a$$$ and $$$b$$$. His goal is to find a non-negative integer $$$k$$$ such that the least common multiple of $$$a+k$$$ and $$$b+k$$$ is the smallest possible. If there are multiple o... | [{"input": "6 10\r\n", "output": ["2"]}, {"input": "21 31\r\n", "output": ["9"]}, {"input": "5 10\r\n", "output": ["0"]}, {"input": "1924 5834\r\n", "output": ["31"]}, {"input": "9911 666013\r\n", "output": ["318140"]}, {"input": "1 1\r\n", "output": ["0"]}, {"input": "69 4295\r\n", "output": ["2044"]}, {"input": "9482... | 100 | 100 | 100 | [{'input': '1 113\r\n', 'output': ['0']}, {'input': '851187514 983401693\r\n', 'output': ['74311739']}, {'input': '456039936 216657167\r\n', 'output': ['22725602']}, {'input': '152408121 368230838\r\n', 'output': ['63414596']}, {'input': '10 12\r\n', 'output': ['0']}] | [{'input': '898985699 25761857\r\n', 'output': ['12204397']}, {'input': '18 102\r\n', 'output': ['3']}, {'input': '89598 155519475\r\n', 'output': ['1581691']}, {'input': '584924132 27895\r\n', 'output': ['34377766']}, {'input': '5 10\r\n', 'output': ['0']}] | [{'input': '526157284 30640\r\n', 'output': ['8006']}, {'input': '391320363 805801085\r\n', 'output': ['23160359']}, {'input': '890747621 58942406\r\n', 'output': ['107418637']}, {'input': '179237079 691088384\r\n', 'output': ['332614226']}, {'input': '22 51\r\n', 'output': ['7']}] | [{'input': '861681496 158472265\r\n', 'output': ['75930812']}, {'input': '51783 5491\r\n', 'output': ['6082']}, {'input': '89229 680338802\r\n', 'output': ['16502224']}, {'input': '997908364 240589278\r\n', 'output': ['138070265']}, {'input': '199999973 99999937\r\n', 'output': ['99']}] | [{'input': '13911 866384789\r\n', 'output': ['488042']}, {'input': '39204 15357\r\n', 'output': ['8490']}, {'input': '1 113\r\n', 'output': ['0']}, {'input': '43736 145490995\r\n', 'output': ['242015']}, {'input': '55138 453739731\r\n', 'output': ['26632191']}] | 100 | 100 | 100 | 100 | 100 | 96.77 | 100 | 100 | 100 | 96.77 | 93.75 | 100 | 100 | 100 | 93.75 | 371 | 100 | 98.708 | 97.5 |
["QAQAQYSYIOIWIN", "QAQQQZZYNOIWIN"] | The only line contains a string of length n (1 ≤ n ≤ 100). It's guaranteed that the string only contains uppercase English letters. | 8aef4947322438664bd8610632fe0947 | import itertools
print(sum(map(lambda x:(x==('Q','A','Q')), itertools.combinations(input(),3)))) | ["4", "3"] | Python | NoteIn the first example there are 4 subsequences "QAQ": "QAQAQYSYIOIWIN", "QAQAQYSYIOIWIN", "QAQAQYSYIOIWIN", "QAQAQYSYIOIWIN". | Print a single integer — the number of subsequences "QAQ" in the string. | "QAQ" is a word to denote an expression of crying. Imagine "Q" as eyes with tears and "A" as a mouth.Now Diamond has given Bort a string consisting of only uppercase English letters of length n. There is a great number of "QAQ" in the string (Diamond is so cute!). illustration by 猫屋 https://twitter.com/nekoyaliu Bort ... | [{"input": "QAQAQYSYIOIWIN\r\n", "output": ["4"]}, {"input": "QAQQQZZYNOIWIN\r\n", "output": ["3"]}, {"input": "QA\r\n", "output": ["0"]}, {"input": "IAQVAQZLQBQVQFTQQQADAQJA\r\n", "output": ["24"]}, {"input": "QQAAQASGAYAAAAKAKAQIQEAQAIAAIAQQQQQ\r\n", "output": ["378"]}, {"input": "AMVFNFJIAVNQJWIVONQOAOOQSNQSONOASONA... | 100 | 100 | 100 | [{'input': 'QQAAQASGAYAAAAKAKAQIQEAQAIAAIAQQQQQ\r\n', 'output': ['378']}, {'input': 'AQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQ\r\n', 'output': ['20825']}, {'input': 'W\r\n', 'output': ['0']}, {'input': 'LQMAQQARQAQBJQQQAGAAZQQXALQQAARQAQQQQAAQQAQQQAQQCAQQAQQAYQ... | [{'input': 'FFF\r\n', 'output': ['0']}, {'input': 'QQWAQQGQQUZQQQLZAAQYQXQVAQFQUAQZUQZZQUKBHSHTQYLQAOQXAQQGAQQTQOAQARQADAJRAAQPQAQQUQAUAMAUVQAAAQQAWQ\r\n', 'output': ['4527']}, {'input': 'QQAAQASGAYAAAAKAKAQIQEAQAIAAIAQQQQQ\r\n', 'output': ['378']}, {'input': 'QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQAAAAAAAAAAAAAAAAAAAAAAAAAA... | [{'input': 'W\r\n', 'output': ['0']}, {'input': 'QQUMQAYAUAAGWAAAQSDAVAAQAAAASKQJJQQQQMAWAYYAAAAAAEAJAXWQQ\r\n', 'output': ['625']}, {'input': 'QNQKQQQLASQBAVQQQQAAQQOQRJQQAQQQEQZUOANAADAAQQJAQAQARAAAQQQEQBHTQAAQAAAAQQMKQQQIAOJJQQAQAAADADQUQQQA\r\n', 'output': ['9114']}, {'input': 'KAZXAVLPJQBQVQQQQQAPAQQGQTQVZQAAAOYA\... | [{'input': 'FFF\r\n', 'output': ['0']}, {'input': 'AQQQQAQAAQQAQAQAAAAAAAAAQAQAAAAAQAQAQQQAQQQAAAQQQAAAAAAAQAAAAQQQQQQQAQQQQAQAAAQAAAAAQAQAAAAAQ\r\n', 'output': ['13136']}, {'input': 'QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ\r\n', 'output': ['35937']}, {'input'... | [{'input': 'QJAWZAAOAAGIAAAAAOQATASQAEAAAAQFQQHPA\r\n', 'output': ['111']}, {'input': 'AQQQQAQAAQQAQAQAAAAAAAAAQAQAAAAAQAQAQQQAQQQAAAQQQAAAAAAAQAAAAQQQQQQQAQQQQAQAAAQAAAAAQAQAAAAAQ\r\n', 'output': ['13136']}, {'input': 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ... | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 372 | 100 | 100 | 100 |
["2 2", "9 3"] | The single line contains two integers n and m (1 ≤ n ≤ 100; 2 ≤ m ≤ 100), separated by a space. | 42b25b7335ec01794fbb1d4086aa9dd0 | def gogo(n, m):
return n + ((n-1)//(m-1))
def main():
pairs, bought = map(int, input().split())
print(gogo(pairs, bought))
main()
| ["3", "13"] | Python | NoteIn the first sample Vasya spends the first two days wearing the socks that he had initially. Then on day three he puts on the socks that were bought on day two.In the second sample Vasya spends the first nine days wearing the socks that he had initially. Then he spends three days wearing the socks that were bought ... | Print a single integer — the answer to the problem. | Vasya has n pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When he comes home in the evening, Vasya takes off the used socks and throws them away. Every m-th day (at days with numbers m, 2m, 3m, ...) mom buys a pair of socks to Vasya. She does it late in the eve... | [{"input": "2 2\r\n", "output": ["3"]}, {"input": "9 3\r\n", "output": ["13"]}, {"input": "1 2\r\n", "output": ["1"]}, {"input": "2 3\r\n", "output": ["2"]}, {"input": "1 99\r\n", "output": ["1"]}, {"input": "4 4\r\n", "output": ["5"]}, {"input": "10 2\r\n", "output": ["19"]}, {"input": "10 9\r\n", "output": ["11"]}, {... | 100 | 100 | 100 | [{'input': '2 3\r\n', 'output': ['2']}, {'input': '99 10\r\n', 'output': ['109']}, {'input': '98 3\r\n', 'output': ['146']}, {'input': '99 2\r\n', 'output': ['197']}, {'input': '24 5\r\n', 'output': ['29']}] | [{'input': '10 2\r\n', 'output': ['19']}, {'input': '99 74\r\n', 'output': ['100']}, {'input': '100 3\r\n', 'output': ['149']}, {'input': '20 21\r\n', 'output': ['20']}, {'input': '100 2\r\n', 'output': ['199']}] | [{'input': '99 2\r\n', 'output': ['197']}, {'input': '10 9\r\n', 'output': ['11']}, {'input': '9 3\r\n', 'output': ['13']}, {'input': '100 3\r\n', 'output': ['149']}, {'input': '10 2\r\n', 'output': ['19']}] | [{'input': '99 2\r\n', 'output': ['197']}, {'input': '99 74\r\n', 'output': ['100']}, {'input': '100 100\r\n', 'output': ['101']}, {'input': '100 5\r\n', 'output': ['124']}, {'input': '1 2\r\n', 'output': ['1']}] | [{'input': '52 96\r\n', 'output': ['52']}, {'input': '9 3\r\n', 'output': ['13']}, {'input': '2 2\r\n', 'output': ['3']}, {'input': '95 16\r\n', 'output': ['101']}, {'input': '100 5\r\n', 'output': ['124']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 373 | 100 | 100 | 100 |
["1098", "10"] | The first line contains one integer $$$n$$$ ($$$1 \le n \le 10^9$$$). | 055fbbde4b9ffd4473e6e716da6da899 | def f(x):
x+=1
while not x % 10:
x //=10
return x
previous = set()
n = int(input())
while n not in previous:
previous.add(n)
n = f(n)
print(len(previous)) | ["20", "19"] | Python | NoteThe numbers that are reachable from $$$1098$$$ are:$$$1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1098, 1099$$$. | Print one integer: the number of different numbers that are reachable from $$$n$$$. | Let's denote a function $$$f(x)$$$ in such a way: we add $$$1$$$ to $$$x$$$, then, while there is at least one trailing zero in the resulting number, we remove that zero. For example, $$$f(599) = 6$$$: $$$599 + 1 = 600 \rightarrow 60 \rightarrow 6$$$; $$$f(7) = 8$$$: $$$7 + 1 = 8$$$; $$$f(9) = 1$$$: $$$9 + 1 = 10 \... | [{"input": "1098\r\n", "output": ["20\n", "20", "20\r\n"]}, {"input": "10\r\n", "output": ["19", "19\r\n", "19\n"]}, {"input": "1000000000\r\n", "output": ["91\n", "91\r\n", "91"]}, {"input": "1\r\n", "output": ["9", "9\r\n", "9\n"]}, {"input": "9\r\n", "output": ["9", "9\r\n", "9\n"]}, {"input": "10119\r\n", "output":... | 100 | 100 | 100 | [{'input': '24\r\n', 'output': ['15', '15\n', '15\r\n']}, {'input': '69\r\n', 'output': ['10\r\n', '10\n', '10']}, {'input': '920\r\n', 'output': ['26\r\n', '26\n', '26']}, {'input': '9169813\r\n', 'output': ['36', '36\n', '36\r\n']}, {'input': '123123124\r\n', 'output': ['64\n', '64\r\n', '64']}] | [{'input': '1000000000\r\n', 'output': ['91\n', '91\r\n', '91']}, {'input': '189070\r\n', 'output': ['31\n', '31', '31\r\n']}, {'input': '90\r\n', 'output': ['19', '19\r\n', '19\n']}, {'input': '19909590\r\n', 'output': ['32\n', '32', '32\r\n']}, {'input': '869667992\r\n', 'output': ['28', '28\n', '28\r\n']}] | [{'input': '439674440\r\n', 'output': ['45\n', '45\r\n', '45']}, {'input': '23\r\n', 'output': ['16\n', '16', '16\r\n']}, {'input': '9392\r\n', 'output': ['23', '23\r\n', '23\n']}, {'input': '81\r\n', 'output': ['18\n', '18', '18\r\n']}, {'input': '90\r\n', 'output': ['19', '19\r\n', '19\n']}] | [{'input': '55\r\n', 'output': ['14', '14\r\n', '14\n']}, {'input': '96\r\n', 'output': ['13\n', '13\r\n', '13']}, {'input': '50\r\n', 'output': ['19', '19\r\n', '19\n']}, {'input': '990\r\n', 'output': ['19', '19\r\n', '19\n']}, {'input': '45\r\n', 'output': ['14', '14\r\n', '14\n']}] | [{'input': '5932\r\n', 'output': ['23', '23\r\n', '23\n']}, {'input': '98\r\n', 'output': ['11', '11\n', '11\r\n']}, {'input': '990\r\n', 'output': ['19', '19\r\n', '19\n']}, {'input': '38\r\n', 'output': ['11', '11\n', '11\r\n']}, {'input': '841480\r\n', 'output': ['38\n', '38\r\n', '38']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 374 | 100 | 100 | 100 |
["12"] | The only line of the input contains one integer n (1 ≤ n ≤ 1018) — the prediction on the number of people who will buy the game. | e392be5411ffccc1df50e65ec1f5c589 | def main():
n = int(input())
print(solver(n))
def solver(n):
factors = [2, 3, 5, 7]
singles = n // 2 + n // 3 + n // 5 + n // 7
pairs = n // (2 * 3) + n // (2 * 5) + n // (2 * 7) + \
n // (3 * 5) + n // (3 * 7) + n // (5 * 7)
triples = n // (2 * 3 * 5) + n // (2 * 3 * 7) + \
n // (2 * 5 * 7) + n // (3 * 5 * 7)... | ["2"] | Python | null | Output one integer showing how many numbers from 1 to n are not divisible by any number from 2 to 10. | IT City company developing computer games decided to upgrade its way to reward its employees. Now it looks the following way. After a new game release users start buying it actively, and the company tracks the number of sales with precision to each transaction. Every time when the next number of sales is not divisible ... | [{"input": "12\r\n", "output": ["2"]}, {"input": "2519\r\n", "output": ["576"]}, {"input": "2521\r\n", "output": ["577"]}, {"input": "1\r\n", "output": ["1"]}, {"input": "314159265\r\n", "output": ["71807832"]}, {"input": "718281828459045235\r\n", "output": ["164178703647781768"]}, {"input": "1000000000000000000\r\n", ... | 100 | 100 | 100 | [{'input': '314159265\r\n', 'output': ['71807832']}, {'input': '504000000000000000\r\n', 'output': ['115200000000000000']}, {'input': '987654321234567890\r\n', 'output': ['225749559139329804']}, {'input': '2521\r\n', 'output': ['577']}, {'input': '3628800\r\n', 'output': ['829440']}] | [{'input': '1000000000000000000\r\n', 'output': ['228571428571428571']}, {'input': '1\r\n', 'output': ['1']}, {'input': '504000000000000000\r\n', 'output': ['115200000000000000']}, {'input': '2519\r\n', 'output': ['576']}, {'input': '987654321234567890\r\n', 'output': ['225749559139329804']}] | [{'input': '718281828459045235\r\n', 'output': ['164178703647781768']}, {'input': '3628800\r\n', 'output': ['829440']}, {'input': '1000000000000000000\r\n', 'output': ['228571428571428571']}, {'input': '2521\r\n', 'output': ['577']}, {'input': '504000000000000000\r\n', 'output': ['115200000000000000']}] | [{'input': '718281828459045235\r\n', 'output': ['164178703647781768']}, {'input': '504000000000000000\r\n', 'output': ['115200000000000000']}, {'input': '987654321234567890\r\n', 'output': ['225749559139329804']}, {'input': '2521\r\n', 'output': ['577']}, {'input': '12\r\n', 'output': ['2']}] | [{'input': '2521\r\n', 'output': ['577']}, {'input': '1\r\n', 'output': ['1']}, {'input': '1000000000000000000\r\n', 'output': ['228571428571428571']}, {'input': '12\r\n', 'output': ['2']}, {'input': '2519\r\n', 'output': ['576']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 375 | 100 | 100 | 100 |
["5 1 4 4 2 1", "1 6 6 2 1 1", "4 1 7 4 1 2"] | The only line contains six integers $$$x$$$, $$$y$$$, $$$z$$$, $$$t_1$$$, $$$t_2$$$, $$$t_3$$$ ($$$1 \leq x, y, z, t_1, t_2, t_3 \leq 1000$$$) — the floor Masha is at, the floor Masha wants to get to, the floor the elevator is located on, the time it takes Masha to pass between two floors by stairs, the time it takes t... | 05cffd59b28b9e026ca3203718b2e6ca | x,y,z,t1,t2,t3 = map(int,input().split())
y=abs(y-x)
if abs(z-x)*t2+y*t2+3*t3 <= y*t1 :
print('YES')
else:
print('NO')
| ["YES", "NO", "YES"] | Python | NoteIn the first example:If Masha goes by the stairs, the time she spends is $$$4 \cdot 4 = 16$$$, because she has to go $$$4$$$ times between adjacent floors and each time she spends $$$4$$$ seconds. If she chooses the elevator, she will have to wait $$$2$$$ seconds while the elevator leaves the $$$4$$$-th floor and g... | If the time it will take to use the elevator is not greater than the time it will take to use the stairs, print «YES» (without quotes), otherwise print «NO> (without quotes). You can print each letter in any case (upper or lower). | Masha lives in a multi-storey building, where floors are numbered with positive integers. Two floors are called adjacent if their numbers differ by one. Masha decided to visit Egor. Masha lives on the floor $$$x$$$, Egor on the floor $$$y$$$ (not on the same floor with Masha).The house has a staircase and an elevator. ... | [{"input": "5 1 4 4 2 1\r\n", "output": ["YES"]}, {"input": "1 6 6 2 1 1\r\n", "output": ["NO"]}, {"input": "4 1 7 4 1 2\r\n", "output": ["YES"]}, {"input": "749 864 931 266 94 891\r\n", "output": ["NO"]}, {"input": "719 137 307 244 724 777\r\n", "output": ["NO"]}, {"input": "608 11 980 338 208 78\r\n", "output": ["YES... | 100 | 100 | 100 | [{'input': '5 100 10 100 1 1\r\n', 'output': ['YES']}, {'input': '1 2 1 10 5 2\r\n', 'output': ['NO']}, {'input': '1 2 1 10 2 3\r\n', 'output': ['NO']}, {'input': '301 300 300 338 152 13\r\n', 'output': ['NO']}, {'input': '1 1000 1000 1 1000 1\r\n', 'output': ['NO']}] | [{'input': '1 2 1 1 1 1\r\n', 'output': ['NO']}, {'input': '1 5 1 5 4 2\r\n', 'output': ['NO']}, {'input': '385 943 507 478 389 735\r\n', 'output': ['NO']}, {'input': '571 695 153 288 64 421\r\n', 'output': ['NO']}, {'input': '256 45 584 731 281 927\r\n', 'output': ['YES']}] | [{'input': '188 288 112 595 331 414\r\n', 'output': ['YES']}, {'input': '1 3 1 669 68 401\r\n', 'output': ['NO']}, {'input': '85 931 66 464 683 497\r\n', 'output': ['NO']}, {'input': '1 2 1 10 2 3\r\n', 'output': ['NO']}, {'input': '56 33 8 263 58 644\r\n', 'output': ['NO']}] | [{'input': '5 10 6 873 640 175\r\n', 'output': ['YES']}, {'input': '1 2 1 13 2 4\r\n', 'output': ['NO']}, {'input': '1 6 6 2 1 1\r\n', 'output': ['NO']}, {'input': '1 3 1 10 5 4\r\n', 'output': ['NO']}, {'input': '608 11 980 338 208 78\r\n', 'output': ['YES']}] | [{'input': '2 3 2 3 1 1\r\n', 'output': ['NO']}, {'input': '1 6 6 2 1 1\r\n', 'output': ['NO']}, {'input': '1 2 1 25 1 10\r\n', 'output': ['NO']}, {'input': '56 33 8 263 58 644\r\n', 'output': ['NO']}, {'input': '213 264 205 94 70 221\r\n', 'output': ['YES']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 376 | 100 | 100 | 100 |
["5 5 3 2", "7 5 5 2"] | The first line contains four space-separated integers n, a, b and c (1 ≤ n, a, b, c ≤ 4000) — the length of the original ribbon and the acceptable lengths of the ribbon pieces after the cutting, correspondingly. The numbers a, b and c can coincide. | 062a171cc3ea717ea95ede9d7a1c3a43 | def f(n):
# Build maximum number of pieces for
#length 1 upto n in bottom up manner
dp = [float("-inf")] * (n + 1)
# Base Case
dp[0] = 0
# dp[i] gives maximum number of pieces that can
# be obtained by cutting ribbon of length i into pieces
# of length a, b or c
# dp[i] = -inf i... | ["2", "2"] | Python | NoteIn the first example Polycarpus can cut the ribbon in such way: the first piece has length 2, the second piece has length 3.In the second example Polycarpus can cut the ribbon in such way: the first piece has length 5, the second piece has length 2. | Print a single number — the maximum possible number of ribbon pieces. It is guaranteed that at least one correct ribbon cutting exists. | Polycarpus has a ribbon, its length is n. He wants to cut the ribbon in a way that fulfils the following two conditions: After the cutting each ribbon piece should have length a, b or c. After the cutting the number of ribbon pieces should be maximum. Help Polycarpus and find the number of ribbon pieces after the re... | [{"input": "5 5 3 2\r\n", "output": ["2"]}, {"input": "7 5 5 2\r\n", "output": ["2"]}, {"input": "4 4 4 4\r\n", "output": ["1"]}, {"input": "1 1 1 1\r\n", "output": ["1"]}, {"input": "4000 1 2 3\r\n", "output": ["4000"]}, {"input": "4000 3 4 5\r\n", "output": ["1333"]}, {"input": "10 3 4 5\r\n", "output": ["3"]}, {"inp... | 100 | 100 | 100 | [{'input': '27 23 4 3\r\n', 'output': ['9']}, {'input': '595 2263 3625 1\r\n', 'output': ['595']}, {'input': '370 2 1 15\r\n', 'output': ['370']}, {'input': '4000 5 2 2\r\n', 'output': ['2000']}, {'input': '7 5 5 2\r\n', 'output': ['2']}] | [{'input': '5 17 26 5\r\n', 'output': ['1']}, {'input': '2 2 9 6\r\n', 'output': ['1']}, {'input': '3999 2 2 3\r\n', 'output': ['1999']}, {'input': '5 14 5 2\r\n', 'output': ['1']}, {'input': '3399 2035 2 3334\r\n', 'output': ['683']}] | [{'input': '13 4 6 7\r\n', 'output': ['2']}, {'input': '5 5 3 2\r\n', 'output': ['2']}, {'input': '595 2263 3625 1\r\n', 'output': ['595']}, {'input': '4 6 4 9\r\n', 'output': ['1']}, {'input': '100 100 1 1\r\n', 'output': ['100']}] | [{'input': '13 4 6 7\r\n', 'output': ['2']}, {'input': '4000 3 4 5\r\n', 'output': ['1333']}, {'input': '17 3 4 10\r\n', 'output': ['5']}, {'input': '3999 2 2 3\r\n', 'output': ['1999']}, {'input': '60 33 20 9\r\n', 'output': ['4']}] | [{'input': '14 6 2 17\r\n', 'output': ['7']}, {'input': '2 2 9 6\r\n', 'output': ['1']}, {'input': '2683 83 26 2709\r\n', 'output': ['101']}, {'input': '8 3 8 4\r\n', 'output': ['2']}, {'input': '4000 3 4 5\r\n', 'output': ['1333']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 377 | 100 | 100 | 100 |
["3 4", "2 1"] | The only line contains two integers $$$N$$$ and $$$M$$$ ($$$1 \leq N, M \leq 10^9$$$) — the number of rows and columns in the grid. | a91aab4c0618d036c81022232814ef44 | G = list(map(int, input().split()))
N = G[0]
M = G[1]
if M > 1:
print(N * (M - 1))
else:
print(M * (N - 1))
| ["9", "1"] | Python | NoteThe picture below is the grid that Pak Chanek has in the first example. The picture below is an example of a tight domino in the grid. | An integer representing the number of distinct tight dominoes in the grid. | Pak Chanek has a grid that has $$$N$$$ rows and $$$M$$$ columns. Each row is numbered from $$$1$$$ to $$$N$$$ from top to bottom. Each column is numbered from $$$1$$$ to $$$M$$$ from left to right.Each tile in the grid contains a number. The numbers are arranged as follows: Row $$$1$$$ contains integers from $$$1$$$ ... | [{"input": "3 4\n", "output": ["\n9", "9", "9\n\n", "9\n\n", "\n\n\n9\n", "9\n", "\n9\n", "\n\n\n\n\n\n\n\n9\n", "9\n"]}, {"input": "2 1\n", "output": ["\n1", "1\n", "1", "1\n\n", "\n1\n", "1\n\n", "\n\n1\n", "1\n", "\n\n\n\n\n1\n"]}, {"input": "1 1\n", "output": ["\n0\n", "\n0", "0\n\n", "0\n\n", "0\n", "0\n", "\n\n0\... | 100 | 100 | 100 | [{'input': '1000000000 1000000000\n', 'output': ['999999999000000000\n', '999999999000000000\n\n', '999999999000000000\n\n', '999999999000000000\n', '999999999000000000']}, {'input': '2 1\n', 'output': ['\n1', '1\n', '1', '1\n\n', '\n1\n', '1\n\n', '\n\n1\n', '1\n', '\n\n\n\n\n1\n']}, {'input': '647242241 921242095\n',... | [{'input': '1 1\n', 'output': ['\n0\n', '\n0', '0\n\n', '0\n\n', '0\n', '0\n', '\n\n0\n', '0']}, {'input': '1 2\n', 'output': ['\n1', '1\n', '1', '1\n\n', '\n1\n', '1\n\n', '\n\n1\n', '1\n']}, {'input': '647242241 921242095\n', 'output': ['596266797424092654\n', '596266797424092654\n\n', '596266797424092654\n', '596266... | [{'input': '1000000000 906523442\n', 'output': ['906523441000000000\n\n', '906523441000000000', '906523441000000000\n', '906523441000000000\n\n', '906523441000000000\n']}, {'input': '2 2\n', 'output': ['2\n', '2', '\n\n\n\n\n2\n', '2\n\n', '\n\n2\n', '\n2', '2\n\n', '\n2\n', '2\n']}, {'input': '767928735 1000000000\n',... | [{'input': '1 1000000000\n', 'output': ['999999999\n', '\n999999999\n', '\n999999999', '999999999\n', '999999999\n\n', '999999999', '999999999\n\n']}, {'input': '30001 30001\n', 'output': ['900030000\n', '\n900030000\n', '900030000', '\n900030000', '900030000\n\n', '900030000\n\n', '900030000\n']}, {'input': '999999999... | [{'input': '2 1000000000\n', 'output': ['1999999998\n\n', '\n1999999998\n', '1999999998\n', '1999999998', '1999999998\n', '\n1999999998', '1999999998\n\n']}, {'input': '767928735 1000000000\n', 'output': ['767928734232071265\n\n', '767928734232071265\n', '767928734232071265\n\n', '767928734232071265\n', '76792873423207... | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 378 | 100 | 100 | 100 |
["3", "11"] | The only line of the input contains a single integer n (1 ≤ n ≤ 1000) — the position of the digit you need to print. | 2d46e34839261eda822f0c23c6e19121 | n=int(input())
st=""
for i in range(1,1000):
st=st+str(i)
print(st[n-1] )
| ["3", "0"] | Python | NoteIn the first sample the digit at position 3 is '3', as both integers 1 and 2 consist on one digit.In the second sample, the digit at position 11 is '0', it belongs to the integer 10. | Print the n-th digit of the line. | Every year, hundreds of people come to summer camps, they learn new algorithms and solve hard problems.This is your first year at summer camp, and you are asked to solve the following problem. All integers starting with 1 are written in one line. The prefix of these line is "123456789101112131415...". Your task is to p... | [{"input": "3\r\n", "output": ["3"]}, {"input": "11\r\n", "output": ["0"]}, {"input": "12\r\n", "output": ["1"]}, {"input": "13\r\n", "output": ["1"]}, {"input": "29\r\n", "output": ["9"]}, {"input": "30\r\n", "output": ["2"]}, {"input": "1000\r\n", "output": ["3"]}, {"input": "999\r\n", "output": ["9"]}, {"input": "10... | 100 | 100 | 100 | [{'input': '3\r\n', 'output': ['3']}, {'input': '270\r\n', 'output': ['6']}, {'input': '945\r\n', 'output': ['1']}, {'input': '952\r\n', 'output': ['3']}, {'input': '423\r\n', 'output': ['7']}] | [{'input': '100\r\n', 'output': ['5']}, {'input': '500\r\n', 'output': ['0']}, {'input': '29\r\n', 'output': ['9']}, {'input': '394\r\n', 'output': ['1']}, {'input': '157\r\n', 'output': ['3']}] | [{'input': '8\r\n', 'output': ['8']}, {'input': '394\r\n', 'output': ['1']}, {'input': '121\r\n', 'output': ['5']}, {'input': '750\r\n', 'output': ['6']}, {'input': '11\r\n', 'output': ['0']}] | [{'input': '270\r\n', 'output': ['6']}, {'input': '13\r\n', 'output': ['1']}, {'input': '29\r\n', 'output': ['9']}, {'input': '289\r\n', 'output': ['1']}, {'input': '121\r\n', 'output': ['5']}] | [{'input': '100\r\n', 'output': ['5']}, {'input': '500\r\n', 'output': ['0']}, {'input': '191\r\n', 'output': ['0']}, {'input': '491\r\n', 'output': ['0']}, {'input': '8\r\n', 'output': ['8']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 379 | 100 | 100 | 100 |
["3\n0 0 1\n2 0 1\n4 0 1", "3\n0 0 2\n3 0 2\n6 0 2", "3\n0 0 2\n2 0 2\n1 1 2"] | The first line of input contains one integer n (1 ≤ n ≤ 3), denoting the number of circles. The following n lines each contains three space-separated integers x, y and r ( - 10 ≤ x, y ≤ 10, 1 ≤ r ≤ 10), describing a circle whose center is (x, y) and the radius is r. No two circles have the same x, y and r at the same t... | bda5879e94a82c6fd499796f258c4691 | from math import sqrt
pt = lambda *a, **k: print(*a, **k, flush=True)
rd = lambda: map(int, input().split())
n = int(input())
def f(x1, y1, r1, x2, y2, r2):
a = (r1 + r2) ** 2
b = (r1 - r2) ** 2
d = (x1 - x2) ** 2 + (y1 - y2) ** 2
if d > a:
return 1
elif d == a:
return 4
elif d <... | ["4", "6", "8"] | Python | NoteFor the first example, For the second example, For the third example, | Print a single integer — the number of regions on the plane. | Firecrackers scare Nian the monster, but they're wayyyyy too noisy! Maybe fireworks make a nice complement.Little Tommy is watching a firework show. As circular shapes spread across the sky, a splendid view unfolds on the night of Lunar New Year's eve.A wonder strikes Tommy. How many regions are formed by the circles o... | [{"input": "3\r\n0 0 1\r\n2 0 1\r\n4 0 1\r\n", "output": ["4"]}, {"input": "3\r\n0 0 2\r\n3 0 2\r\n6 0 2\r\n", "output": ["6"]}, {"input": "3\r\n0 0 2\r\n2 0 2\r\n1 1 2\r\n", "output": ["8"]}, {"input": "1\r\n0 0 10\r\n", "output": ["2"]}, {"input": "2\r\n-10 10 1\r\n10 -10 1\r\n", "output": ["3"]}, {"input": "2\r\n-6 ... | 100 | 100 | 100 | [{'input': '3\r\n-4 -5 7\r\n2 -3 6\r\n-2 0 1\r\n', 'output': ['5']}, {'input': '3\r\n-4 1 1\r\n-2 -6 7\r\n-6 -3 2\r\n', 'output': ['5']}, {'input': '3\r\n-6 -2 1\r\n-3 -1 1\r\n-2 1 4\r\n', 'output': ['4']}, {'input': '3\r\n-4 -5 4\r\n6 5 2\r\n-6 -6 7\r\n', 'output': ['4']}, {'input': '3\r\n2 2 4\r\n8 2 4\r\n5 10 5\r\n'... | [{'input': '3\r\n0 0 1\r\n2 0 1\r\n4 0 1\r\n', 'output': ['4']}, {'input': '3\r\n0 0 2\r\n2 0 2\r\n1 1 2\r\n', 'output': ['8']}, {'input': '3\r\n1 3 1\r\n2 -6 7\r\n-3 6 6\r\n', 'output': ['4']}, {'input': '3\r\n1 -1 2\r\n-6 -3 10\r\n-1 3 1\r\n', 'output': ['4']}, {'input': '3\r\n-4 -2 9\r\n8 4 9\r\n-10 10 10\r\n', 'out... | [{'input': '3\r\n0 0 2\r\n1 0 1\r\n-1 0 1\r\n', 'output': ['5']}, {'input': '3\r\n0 0 6\r\n-4 -3 1\r\n-3 4 1\r\n', 'output': ['4']}, {'input': '3\r\n3 -2 7\r\n-1 2 5\r\n-4 1 3\r\n', 'output': ['7']}, {'input': '3\r\n-6 -6 9\r\n4 -3 4\r\n-3 -1 1\r\n', 'output': ['5']}, {'input': '3\r\n-4 3 4\r\n0 0 1\r\n-5 -4 3\r\n', 'o... | [{'input': '3\r\n1 8 2\r\n3 8 1\r\n3 -2 9\r\n', 'output': ['7']}, {'input': '3\r\n0 0 2\r\n2 0 2\r\n1 1 2\r\n', 'output': ['8']}, {'input': '3\r\n-5 3 6\r\n4 -3 2\r\n-2 -1 1\r\n', 'output': ['4']}, {'input': '3\r\n5 -4 1\r\n3 -5 5\r\n-3 3 5\r\n', 'output': ['4']}, {'input': '3\r\n-1 0 5\r\n-2 1 5\r\n-5 4 7\r\n', 'outpu... | [{'input': '3\r\n-4 3 4\r\n0 0 1\r\n-5 -4 3\r\n', 'output': ['4']}, {'input': '3\r\n0 4 4\r\n-6 -4 6\r\n-4 -2 4\r\n', 'output': ['7']}, {'input': '3\r\n-1 5 6\r\n-3 -4 5\r\n-6 -6 6\r\n', 'output': ['6']}, {'input': '3\r\n-2 -5 4\r\n-5 -1 5\r\n-6 -2 9\r\n', 'output': ['5']}, {'input': '3\r\n-2 0 2\r\n2 0 2\r\n0 0 4\r\n'... | 100 | 100 | 100 | 100 | 100 | 76.47 | 72.94 | 77.65 | 80 | 74.12 | 68.52 | 62.96 | 68.52 | 72.22 | 66.67 | 380 | 100 | 76.236 | 67.778 |
["10 5", "6 12", "5 13"] | The single line contains numbers n and x (1 ≤ n ≤ 105, 1 ≤ x ≤ 109) — the size of the table and the number that we are looking for in the table. | c4b139eadca94201596f1305b2f76496 | n, x = map(int, input().split())
count = 0
i = 1
while i * i <= x:
if x % i == 0 and i <= n and x // i <= n:
if i != x // i:
count += 2
else:
count += 1
i += 1
print(count) | ["2", "4", "0"] | Python | NoteA table for the second sample test is given below. The occurrences of number 12 are marked bold. | Print a single number: the number of times x occurs in the table. | Let's consider a table consisting of n rows and n columns. The cell located at the intersection of i-th row and j-th column contains number i × j. The rows and columns are numbered starting from 1.You are given a positive integer x. Your task is to count the number of cells in a table that contain number x. | [{"input": "10 5\r\n", "output": ["2"]}, {"input": "6 12\r\n", "output": ["4"]}, {"input": "5 13\r\n", "output": ["0"]}, {"input": "1 1\r\n", "output": ["1"]}, {"input": "2 1\r\n", "output": ["1"]}, {"input": "100000 1\r\n", "output": ["1"]}, {"input": "1 1000000000\r\n", "output": ["0"]}, {"input": "100000 1000000000\... | 100 | 100 | 100 | [{'input': '58942 936593001\r\n', 'output': ['0']}, {'input': '6 12\r\n', 'output': ['4']}, {'input': '22740 989460910\r\n', 'output': ['0']}, {'input': '100000 479001600\r\n', 'output': ['254']}, {'input': '100000 362880\r\n', 'output': ['154']}] | [{'input': '31621 999887641\r\n', 'output': ['1']}, {'input': '22741 989460910\r\n', 'output': ['0']}, {'input': '10 3\r\n', 'output': ['2']}, {'input': '100000 25\r\n', 'output': ['3']}, {'input': '5 13\r\n', 'output': ['0']}] | [{'input': '58942 936593001\r\n', 'output': ['0']}, {'input': '20 100\r\n', 'output': ['3']}, {'input': '1 1\r\n', 'output': ['1']}, {'input': '100000 989460910\r\n', 'output': ['4']}, {'input': '19999 399960001\r\n', 'output': ['1']}] | [{'input': '20000 400000000\r\n', 'output': ['1']}, {'input': '2 4\r\n', 'output': ['1']}, {'input': '10 3\r\n', 'output': ['2']}, {'input': '100000 183783600\r\n', 'output': ['438']}, {'input': '22740 989460910\r\n', 'output': ['0']}] | [{'input': '19999 399960001\r\n', 'output': ['1']}, {'input': '100000 999887641\r\n', 'output': ['3']}, {'input': '1 1\r\n', 'output': ['1']}, {'input': '100000 551350800\r\n', 'output': ['392']}, {'input': '50000 989460910\r\n', 'output': ['4']}] | 100 | 100 | 100 | 100 | 100 | 90 | 100 | 100 | 100 | 100 | 83.33 | 100 | 100 | 100 | 100 | 381 | 100 | 98 | 96.666 |
["5 2", "8 1"] | The only line of the input contains two integers n and m (1 ≤ n, m ≤ 1018) — the capacity of the barn and the number of grains that are brought every day. | 3b585ea852ffc41034ef6804b6aebbd8 | (n, m) = map(int, input().split())
if n <= m:
print(n)
else:
aM = m
n -= m
(l, r) = (0, int(2e9))
while l < r:
m = (l + r) // 2;
val = m * (m+1) // 2;
if val >= n:
r = m
else:
l = m+1
print(l + aM) | ["4", "5"] | Python | NoteIn the first sample the capacity of the barn is five grains and two grains are brought every day. The following happens: At the beginning of the first day grain is brought to the barn. It's full, so nothing happens. At the end of the first day one sparrow comes and eats one grain, so 5 - 1 = 4 grains remain. At ... | Output one integer — the number of the day when the barn will become empty for the first time. Days are numbered starting with one. | Anton likes to listen to fairy tales, especially when Danik, Anton's best friend, tells them. Right now Danik tells Anton a fairy tale:"Once upon a time, there lived an emperor. He was very rich and had much grain. One day he ordered to build a huge barn to put there all his grain. Best builders were building that barn... | [{"input": "5 2\r\n", "output": ["4"]}, {"input": "8 1\r\n", "output": ["5"]}, {"input": "32 5\r\n", "output": ["12"]}, {"input": "1024 1024\r\n", "output": ["1024"]}, {"input": "58044 52909\r\n", "output": ["53010"]}, {"input": "996478063 658866858\r\n", "output": ["658892843"]}, {"input": "570441179141911871 51146705... | 100 | 100 | 100 | [{'input': '762078938126917523 107528\r\n', 'output': ['1234675418']}, {'input': '200 9999999999\r\n', 'output': ['200']}, {'input': '882178982422953366 1792038785005\r\n', 'output': ['1793367075026']}, {'input': '10836 16097\r\n', 'output': ['10836']}, {'input': '262133108160 256256256256\r\n', 'output': ['25625636467... | [{'input': '831613653237860272 154\r\n', 'output': ['1289661856']}, {'input': '5000 123456789\r\n', 'output': ['5000']}, {'input': '1 100000000\r\n', 'output': ['1']}, {'input': '762078938126917525 107528\r\n', 'output': ['1234675419']}, {'input': '861953807629839929 1299632\r\n', 'output': ['1314276256']}] | [{'input': '2 1000\r\n', 'output': ['2']}, {'input': '1000000000000000000 2\r\n', 'output': ['1414213564']}, {'input': '762078938126917525 107528\r\n', 'output': ['1234675419']}, {'input': '1 99999\r\n', 'output': ['1']}, {'input': '982926487795873985 19357888587\r\n', 'output': ['20759977363']}] | [{'input': '262133108160 256256256256\r\n', 'output': ['256256364670']}, {'input': '999999999999999999 123456789\r\n', 'output': ['1537670351']}, {'input': '163162808800191208 163162808800191206\r\n', 'output': ['163162808800191208']}, {'input': '4 6\r\n', 'output': ['4']}, {'input': '5 16\r\n', 'output': ['5']}] | [{'input': '1 100000000000\r\n', 'output': ['1']}, {'input': '500000000500004240 4242\r\n', 'output': ['1000004242']}, {'input': '100000000000000000 1000000000000000000\r\n', 'output': ['100000000000000000']}, {'input': '10 10000000\r\n', 'output': ['10']}, {'input': '992316381103677158 1849603453\r\n', 'output': ['325... | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 382 | 100 | 100 | 100 |
["6 9", "38 11", "5 2", "5 10"] | The only line of the input contains two integers $$$n$$$ and $$$b$$$ ($$$1 \le n \le 10^{18}$$$, $$$2 \le b \le 10^{12}$$$). | 491748694c1a53771be69c212a5e0e25 | # Python3 code to find largest prime
# factor of number
from collections import Counter
import math
# A function to print all prime factors of
# a given number n
def primeFactors(n):
# Print the number of two's that divide n
list=[]
while n % 2 == 0:
list.append(2)
... | ["1", "3", "3", "1"] | Python | NoteIn the first example, $$$6!_{(10)} = 720_{(10)} = 880_{(9)}$$$.In the third and fourth example, $$$5!_{(10)} = 120_{(10)} = 1111000_{(2)}$$$.The representation of the number $$$x$$$ in the $$$b$$$-ary base is $$$d_1, d_2, \ldots, d_k$$$ if $$$x = d_1 b^{k - 1} + d_2 b^{k - 2} + \ldots + d_k b^0$$$, where $$$d_i$$$ ... | Print an only integer — the number of trailing zero digits in the $$$b$$$-ary representation of $$$n!$$$ | The number "zero" is called "love" (or "l'oeuf" to be precise, literally means "egg" in French), for example when denoting the zero score in a game of tennis. Aki is fond of numbers, especially those with trailing zeros. For example, the number $$$9200$$$ has two trailing zeros. Aki thinks the more trailing zero digit... | [{"input": "6 9\r\n", "output": ["1"]}, {"input": "38 11\r\n", "output": ["3"]}, {"input": "5 2\r\n", "output": ["3"]}, {"input": "5 10\r\n", "output": ["1"]}, {"input": "1000000000000000000 1000000000000\r\n", "output": ["20833333333333332"]}, {"input": "1000000000000000000 999999999989\r\n", "output": ["1000000"]}, {... | 100 | 100 | 100 | [{'input': '83143260522 250880942892\r\n', 'output': ['3']}, {'input': '7 10080\r\n', 'output': ['0']}, {'input': '72 30\r\n', 'output': ['16']}, {'input': '83143260522 999999998141\r\n', 'output': ['0']}, {'input': '946248652637759690 834034807997\r\n', 'output': ['33512135310870']}] | [{'input': '83143260522 193773\r\n', 'output': ['1287245']}, {'input': '72 193773\r\n', 'output': ['0']}, {'input': '4294967296 999999999958\r\n', 'output': ['0']}, {'input': '1 2\r\n', 'output': ['0']}, {'input': '4294967296 999999999989\r\n', 'output': ['0']}] | [{'input': '1000000000000000000 1000000000000\r\n', 'output': ['20833333333333332']}, {'input': '13 373621248000\r\n', 'output': ['0']}, {'input': '912222 398273\r\n', 'output': ['2']}, {'input': '445422409459676274 999922001521\r\n', 'output': ['222720113534']}, {'input': '883457908461157525 863363187787\r\n', 'output... | [{'input': '446248652637759698 972358665643\r\n', 'output': ['15016106488920']}, {'input': '237201990843960076 973532640023\r\n', 'output': ['11953335559561']}, {'input': '62 45\r\n', 'output': ['14']}, {'input': '984242296072308866 826202217433\r\n', 'output': ['99923075743380']}, {'input': '38 11\r\n', 'output': ['3'... | [{'input': '720471251645857727 800266614341\r\n', 'output': ['380798758798020']}, {'input': '36 110075314176\r\n', 'output': ['1']}, {'input': '83143260522 193773\r\n', 'output': ['1287245']}, {'input': '947074895815843114 12897917761\r\n', 'output': ['704668821291548']}, {'input': '6 13\r\n', 'output': ['0']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 93.33 | 100 | 100 | 100 | 100 | 92.86 | 100 | 383 | 100 | 98.666 | 98.572 |
["4 6\n10 12 10 7 5 22"] | The first line contains space-separated integers n and m (2 ≤ n ≤ m ≤ 50). The second line contains m space-separated integers f1, f2, ..., fm (4 ≤ fi ≤ 1000) — the quantities of pieces in the puzzles sold in the shop. | 7830aabb0663e645d54004063746e47f | n,m = input().split()
m=int(m)
n=int(n)
arr = sorted(map(int,input().split()))
mini=999999999
for j in range(m-n+1):
if (arr[j+n-1]-arr[j]<mini):
mini=arr[j+n-1]-arr[j]
print (mini) | ["5"] | Python | NoteSample 1. The class has 4 students. The shop sells 6 puzzles. If Ms. Manana buys the first four puzzles consisting of 10, 12, 10 and 7 pieces correspondingly, then the difference between the sizes of the largest and the smallest puzzle will be equal to 5. It is impossible to obtain a smaller difference. Note that t... | Print a single integer — the least possible difference the teacher can obtain. | The end of the school year is near and Ms. Manana, the teacher, will soon have to say goodbye to a yet another class. She decided to prepare a goodbye present for her n students and give each of them a jigsaw puzzle (which, as wikipedia states, is a tiling puzzle that requires the assembly of numerous small, often oddl... | [{"input": "4 6\r\n10 12 10 7 5 22\r\n", "output": ["5"]}, {"input": "2 2\r\n4 4\r\n", "output": ["0"]}, {"input": "2 10\r\n4 5 6 7 8 9 10 11 12 12\r\n", "output": ["0"]}, {"input": "4 5\r\n818 136 713 59 946\r\n", "output": ["759"]}, {"input": "3 20\r\n446 852 783 313 549 965 40 88 86 617 479 118 768 34 47 826 366 957... | 100 | 100 | 100 | [{'input': '4 6\r\n10 12 10 7 5 22\r\n', 'output': ['5']}, {'input': '4 25\r\n226 790 628 528 114 64 239 279 619 39 894 763 763 847 525 93 882 697 999 643 650 244 159 884 190\r\n', 'output': ['31']}, {'input': '2 25\r\n782 633 152 416 432 825 115 97 386 357 836 310 530 413 354 373 847 882 913 682 729 582 671 674 94\r\n... | [{'input': '3 20\r\n446 852 783 313 549 965 40 88 86 617 479 118 768 34 47 826 366 957 463 903\r\n', 'output': ['13']}, {'input': '25 50\r\n582 146 750 905 313 509 402 21 488 512 32 898 282 64 579 869 37 996 377 929 975 697 666 837 311 205 116 992 533 298 648 268 54 479 792 595 152 69 267 417 184 433 894 603 988 712 24... | [{'input': '3 3\r\n4 1000 4\r\n', 'output': ['996']}, {'input': '49 50\r\n58 820 826 960 271 294 473 102 925 318 729 672 244 914 796 646 868 6 893 882 726 203 528 498 271 195 355 459 721 680 547 147 631 116 169 804 145 996 133 559 110 257 771 476 576 251 607 314 427 886\r\n', 'output': ['938']}, {'input': '50 50\r\n374... | [{'input': '2 25\r\n782 633 152 416 432 825 115 97 386 357 836 310 530 413 354 373 847 882 913 682 729 582 671 674 94\r\n', 'output': ['3']}, {'input': '25 50\r\n582 146 750 905 313 509 402 21 488 512 32 898 282 64 579 869 37 996 377 929 975 697 666 837 311 205 116 992 533 298 648 268 54 479 792 595 152 69 267 417 184 ... | [{'input': '49 50\r\n58 820 826 960 271 294 473 102 925 318 729 672 244 914 796 646 868 6 893 882 726 203 528 498 271 195 355 459 721 680 547 147 631 116 169 804 145 996 133 559 110 257 771 476 576 251 607 314 427 886\r\n', 'output': ['938']}, {'input': '4 6\r\n10 12 10 7 5 22\r\n', 'output': ['5']}, {'input': '3 3\r\n... | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 384 | 100 | 100 | 100 |
["2 1 2 2", "4 7 7 4"] | The first line contains four integers: xp, yp, xv, yv (0 ≤ xp, yp, xv, yv ≤ 105) — Polycarp's and Vasiliy's starting coordinates. It is guaranteed that in the beginning the pawns are in different cells and none of them is in the cell (0, 0). | 2637d57f7809ff8f922549c617709074 | x1, y1, x2, y2 = map(int, input().split())
if (x1 > x2 or y1 > y2) and x1 + y1 > max(x2, y2):
print("Vasiliy")
else:
print("Polycarp")
| ["Polycarp", "Vasiliy"] | Python | NoteIn the first sample test Polycarp starts in (2, 1) and will move to (1, 1) in the first turn. No matter what his opponent is doing, in the second turn Polycarp can move to (1, 0) and finally to (0, 0) in the third turn. | Output the name of the winner: "Polycarp" or "Vasiliy". | Polycarp and Vasiliy love simple logical games. Today they play a game with infinite chessboard and one pawn for each player. Polycarp and Vasiliy move in turns, Polycarp starts. In each turn Polycarp can move his pawn from cell (x, y) to (x - 1, y) or (x, y - 1). Vasiliy can move his pawn from (x, y) to one of cells: ... | [{"input": "2 1 2 2\r\n", "output": ["Polycarp"]}, {"input": "4 7 7 4\r\n", "output": ["Vasiliy"]}, {"input": "20 0 7 22\r\n", "output": ["Polycarp"]}, {"input": "80 100 83 97\r\n", "output": ["Vasiliy"]}, {"input": "80 100 77 103\r\n", "output": ["Vasiliy"]}, {"input": "55000 60000 55003 60100\r\n", "output": ["Polyca... | 100 | 100 | 100 | [{'input': '0 2 1 1\r\n', 'output': ['Vasiliy']}, {'input': '0 2 0 1\r\n', 'output': ['Vasiliy']}, {'input': '2 0 1 2\r\n', 'output': ['Polycarp']}, {'input': '4 7 7 4\r\n', 'output': ['Vasiliy']}, {'input': '4 4 2 2\r\n', 'output': ['Vasiliy']}] | [{'input': '2 0 2 1\r\n', 'output': ['Polycarp']}, {'input': '9 0 8 0\r\n', 'output': ['Vasiliy']}, {'input': '43308 1372 53325 1370\r\n', 'output': ['Polycarp']}, {'input': '2 1 1 2\r\n', 'output': ['Vasiliy']}, {'input': '67603 35151 67603 39519\r\n', 'output': ['Polycarp']}] | [{'input': '80 100 77 103\r\n', 'output': ['Vasiliy']}, {'input': '2 2 2 0\r\n', 'output': ['Vasiliy']}, {'input': '3 0 0 10\r\n', 'output': ['Polycarp']}, {'input': '41150 1761 41152 1841\r\n', 'output': ['Polycarp']}, {'input': '43308 1372 53325 1370\r\n', 'output': ['Polycarp']}] | [{'input': '80 100 83 97\r\n', 'output': ['Vasiliy']}, {'input': '50042 34493 84536 17892\r\n', 'output': ['Polycarp']}, {'input': '1 2 2 1\r\n', 'output': ['Vasiliy']}, {'input': '0 1 1 2\r\n', 'output': ['Polycarp']}, {'input': '0 3 2 2\r\n', 'output': ['Vasiliy']}] | [{'input': '0 1 2 2\r\n', 'output': ['Polycarp']}, {'input': '1 0 1 1\r\n', 'output': ['Polycarp']}, {'input': '0 1 2 1\r\n', 'output': ['Polycarp']}, {'input': '55000 60000 55003 60100\r\n', 'output': ['Polycarp']}, {'input': '4075 33738 4561 33738\r\n', 'output': ['Polycarp']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 75 | 100 | 100 | 100 | 100 | 50 | 385 | 100 | 95 | 90 |
["4\nZCTH", "5\nZDATG", "6\nAFBAKC"] | The first line contains a single integer $$$n$$$ ($$$4 \leq n \leq 50$$$) — the length of the string $$$s$$$. The second line contains the string $$$s$$$, consisting of exactly $$$n$$$ uppercase letters of the Latin alphabet. | ee4f88abe4c9fa776abd15c5f3a94543 | def solve(a, b):
return min((26 + a - b) % 26, (26 + b - a) % 26)
def main():
n = int(input())
s = input().lower()
print(min((sum((solve(ord(a), ord(b)) for a, b in zip(s[i:i + 4], 'actg'))) for i in range(n - 3))))
main()
| ["2", "5", "16"] | Python | NoteIn the first example, you should replace the letter "Z" with "A" for one operation, the letter "H" — with the letter "G" for one operation. You will get the string "ACTG", in which the genome is present as a substring.In the second example, we replace the letter "A" with "C" for two operations, the letter "D" — wit... | Output the minimum number of operations that need to be applied to the string $$$s$$$ so that the genome appears as a substring in it. | Today in the scientific lyceum of the Kingdom of Kremland, there was a biology lesson. The topic of the lesson was the genomes. Let's call the genome the string "ACTG".Maxim was very boring to sit in class, so the teacher came up with a task for him: on a given string $$$s$$$ consisting of uppercase letters and length ... | [{"input": "4\r\nZCTH\r\n", "output": ["2"]}, {"input": "5\r\nZDATG\r\n", "output": ["5"]}, {"input": "6\r\nAFBAKC\r\n", "output": ["16"]}, {"input": "9\r\nAAABBBCCC\r\n", "output": ["14"]}, {"input": "8\r\nABCDABCD\r\n", "output": ["13"]}, {"input": "4\r\nNPGT\r\n", "output": ["52"]}, {"input": "10\r\nABABABABAB\r\n",... | 100 | 100 | 100 | [{'input': '4\r\nAZTG\r\n', 'output': ['3']}, {'input': '37\r\nINUZOUSGLBHKDEFTQANRPIYMIBFLRTYFNWIFQ\r\n', 'output': ['17']}, {'input': '33\r\nIQHJDOVAGCIAEBAIXQYQCDVZGVOYIIYPR\r\n', 'output': ['12']}, {'input': '4\r\nOCTG\r\n', 'output': ['12']}, {'input': '4\r\nANTG\r\n', 'output': ['11']}] | [{'input': '17\r\nGNPBRASKVPECJKECD\r\n', 'output': ['16']}, {'input': '32\r\nIWMQCTKRNXICANQUPLBOMDNRBOWWIXZB\r\n', 'output': ['14']}, {'input': '50\r\nMGDXLMPDPKUQOIMTLDUDTGTOMJCSYNRTSQSJANYDDPWQYTDTAW\r\n', 'output': ['7']}, {'input': '50\r\nYUPJIRNPTCFJIPODTHJXTWJUTLKCUYFNZKMJRBZZYBPEDYLKCY\r\n', 'output': ['9']}, ... | [{'input': '33\r\nIQHJDOVAGCIAEBAIXQYQCDVZGVOYIIYPR\r\n', 'output': ['12']}, {'input': '9\r\nAAABBBCCC\r\n', 'output': ['14']}, {'input': '32\r\nIWMQCTKRNXICANQUPLBOMDNRBOWWIXZB\r\n', 'output': ['14']}, {'input': '50\r\nZOMSHKIFVAMFATEIIEUJVITTYZGDWCGSOJMFQNYACRPOLGUZCM\r\n', 'output': ['9']}, {'input': '4\r\nOCTG\r\n'... | [{'input': '50\r\nGOHDHOWWPMZBSEKHDBDKLIYRFEPOUHIHOHPUMVDAQRZDJMUBWV\r\n', 'output': ['5']}, {'input': '8\r\nABCDABCD\r\n', 'output': ['13']}, {'input': '4\r\nACHG\r\n', 'output': ['12']}, {'input': '18\r\nKNGWZFHGQIADTBYWDC\r\n', 'output': ['6']}, {'input': '50\r\nMGDXLMPDPKUQOIMTLDUDTGTOMJCSYNRTSQSJANYDDPWQYTDTAW\r\n... | [{'input': '4\r\nYCTG\r\n', 'output': ['2']}, {'input': '4\r\nANTG\r\n', 'output': ['11']}, {'input': '50\r\nYUPJIRNPTCFJIPODTHJXTWJUTLKCUYFNZKMJRBZZYBPEDYLKCY\r\n', 'output': ['9']}, {'input': '50\r\nQFWWIROYKRLAYBPSEXATCWILUBAZPWSGSKLTBLZOLZPHJKQQGF\r\n', 'output': ['9']}, {'input': '39\r\nIHESTJHHSZRSHNUSPGMHDTKOJFE... | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 386 | 100 | 100 | 100 |
["1 10 9 20 1", "1 100 50 200 75"] | The only line of the input contains integers l1, r1, l2, r2 and k (1 ≤ l1, r1, l2, r2, k ≤ 1018, l1 ≤ r1, l2 ≤ r2), providing the segments of time for Sonya and Filya and the moment of time when Sonya prinks. | 9a74b3b0e9f3a351f2136842e9565a82 | data = [int(info) for info in input().split(' ')]
if data[0] == data[2] and data[1] == data[3]:
time = data[1] - data[0] + 1
if data[4] >= data[0] and data[4] <= data[1]:
time -= 1
elif (((data[2] < data[0]) and (data[2] < data[1])) and ((data[3] < data[0]) and (data[3] < data[1]))) or (((data[1] < data[2]) and (... | ["2", "50"] | Python | NoteIn the first sample, they will be together during minutes 9 and 10.In the second sample, they will be together from minute 50 to minute 74 and from minute 76 to minute 100. | Print one integer — the number of minutes Sonya and Filya will be able to spend together. | Today an outstanding event is going to happen in the forest — hedgehog Filya will come to his old fried Sonya!Sonya is an owl and she sleeps during the day and stay awake from minute l1 to minute r1 inclusive. Also, during the minute k she prinks and is unavailable for Filya.Filya works a lot and he plans to visit Sony... | [{"input": "1 10 9 20 1\r\n", "output": ["2"]}, {"input": "1 100 50 200 75\r\n", "output": ["50"]}, {"input": "6 6 5 8 9\r\n", "output": ["1"]}, {"input": "1 1000000000 1 1000000000 1\r\n", "output": ["999999999"]}, {"input": "5 100 8 8 8\r\n", "output": ["0"]}, {"input": "1 1000000000000000000 2 99999999999999999 1000... | 100 | 100 | 100 | [{'input': '1 4 4 10 11\r\n', 'output': ['1']}, {'input': '1 2 100 200 300\r\n', 'output': ['0']}, {'input': '1 1 1 1 1\r\n', 'output': ['0']}, {'input': '30 100 10 20 25\r\n', 'output': ['0']}, {'input': '2 4 8 10 1\r\n', 'output': ['0']}] | [{'input': '1 4 3 5 6\r\n', 'output': ['2']}, {'input': '1 5 7 9 6\r\n', 'output': ['0']}, {'input': '2 3 5 6 100\r\n', 'output': ['0']}, {'input': '2 4 1 2 5\r\n', 'output': ['1']}, {'input': '1 1000000000000000000 2 99999999999999999 1000000000\r\n', 'output': ['99999999999999997']}] | [{'input': '1 10 9 20 1\r\n', 'output': ['2']}, {'input': '1 5 10 10 100\r\n', 'output': ['0']}, {'input': '519325240668210886 776112702001665034 360568516809443669 875594219634943179 994594983925273138\r\n', 'output': ['256787461333454149']}, {'input': '50 100 1 20 3\r\n', 'output': ['0']}, {'input': '1 2 5 6 1\r\n', ... | [{'input': '2 8 12 16 9\r\n', 'output': ['0']}, {'input': '1 2 5 6 7\r\n', 'output': ['0']}, {'input': '1 2 3 4 5\r\n', 'output': ['0']}, {'input': '4722316546398 36672578279675 796716437180 33840047334985 13411035401708\r\n', 'output': ['29117730788587']}, {'input': '1 10 15 25 5\r\n', 'output': ['0']}] | [{'input': '59861796371397621 194872039092923459 668110259718450585 841148673332698972 928360292123223779\r\n', 'output': ['0']}, {'input': '1 2 5 6 1\r\n', 'output': ['0']}, {'input': '2 4 8 10 1\r\n', 'output': ['0']}, {'input': '5 6 1 2 5\r\n', 'output': ['0']}, {'input': '1 5 7 9 6\r\n', 'output': ['0']}] | 100 | 100 | 100 | 100 | 100 | 52.17 | 65.22 | 52.17 | 43.48 | 21.74 | 45.45 | 59.09 | 50 | 36.36 | 18.18 | 387 | 100 | 46.956 | 41.816 |
["1 1 1 1\n+ + *", "2 2 2 2\n* * +", "1 2 3 4\n* + +"] | First line contains four integers separated by space: 0 ≤ a, b, c, d ≤ 1000 — the original numbers. Second line contains three signs ('+' or '*' each) separated by space — the sequence of the operations in the order of performing. ('+' stands for addition, '*' — multiplication) | 7a66fae63d9b27e444d84447012e484c | I=input
a=I().split()
def f(s,z):
if not z:return int(s[0])
m=10**99
for i in s:
t=s[::];t.remove(i)
for j in t:k=t[::];k.remove(j);m=min(m,f(k+[str(eval(i+z[0]+j))],z[1:]))
return m
print(f(a,I().split())) | ["3", "8", "9"] | Python | null | Output one integer number — the minimal result which can be obtained. Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cin (also you may use %I64d). | Recently, Vladimir got bad mark in algebra again. To avoid such unpleasant events in future he decided to train his arithmetic skills. He wrote four integer numbers a, b, c, d on the blackboard. During each of the next three minutes he took two numbers from the blackboard (not necessarily adjacent) and replaced them wi... | [{"input": "1 1 1 1\r\n+ + *\r\n", "output": ["3"]}, {"input": "2 2 2 2\r\n* * +\r\n", "output": ["8"]}, {"input": "1 2 3 4\r\n* + +\r\n", "output": ["9"]}, {"input": "15 1 3 1\r\n* * +\r\n", "output": ["18"]}, {"input": "8 1 7 14\r\n+ + +\r\n", "output": ["30"]}, {"input": "7 17 3 25\r\n+ * +\r\n", "output": ["63"]}, ... | 100 | 100 | 100 | [{'input': '735 111 769 553\r\n+ * *\r\n', 'output': ['92320032']}, {'input': '209 206 34 67\r\n* + *\r\n', 'output': ['476374']}, {'input': '15 1 3 1\r\n* * +\r\n', 'output': ['18']}, {'input': '652 651 142 661\r\n+ + +\r\n', 'output': ['2106']}, {'input': '220 127 597 394\r\n* + +\r\n', 'output': ['28931']}] | [{'input': '944 398 288 986\r\n+ + *\r\n', 'output': ['670464']}, {'input': '663 163 339 76\r\n+ + +\r\n', 'output': ['1241']}, {'input': '883 954 804 352\r\n* * +\r\n', 'output': ['1045740']}, {'input': '975 785 753 224\r\n+ * +\r\n', 'output': ['170432']}, {'input': '105 238 316 265\r\n+ + +\r\n', 'output': ['924']}] | [{'input': '8 1 7 14\r\n+ + +\r\n', 'output': ['30']}, {'input': '944 398 288 986\r\n+ + *\r\n', 'output': ['670464']}, {'input': '105 238 316 265\r\n+ + +\r\n', 'output': ['924']}, {'input': '35 187 126 596\r\n+ + +\r\n', 'output': ['944']}, {'input': '901 884 426 451\r\n* + *\r\n', 'output': ['170223210']}] | [{'input': '622 919 896 120\r\n* * +\r\n', 'output': ['667592']}, {'input': '214 862 466 795\r\n+ + +\r\n', 'output': ['2337']}, {'input': '735 111 769 553\r\n+ * *\r\n', 'output': ['92320032']}, {'input': '40 734 948 202\r\n+ * *\r\n', 'output': ['13590560']}, {'input': '393 342 840 486\r\n+ * *\r\n', 'output': ['1782... | [{'input': '901 884 426 451\r\n* + *\r\n', 'output': ['170223210']}, {'input': '35 187 126 596\r\n+ + +\r\n', 'output': ['944']}, {'input': '652 651 142 661\r\n+ + +\r\n', 'output': ['2106']}, {'input': '944 398 288 986\r\n+ + *\r\n', 'output': ['670464']}, {'input': '720 903 589 804\r\n* * *\r\n', 'output': ['30788716... | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 388 | 100 | 100 | 100 |
["4\n3 2 1 2", "3\n2 3 8"] | The first line of input contains an integer n (1 ≤ n ≤ 100), the number of the columns in the box. The next line contains n space-separated integer numbers. The i-th number ai (1 ≤ ai ≤ 100) denotes the number of cubes in the i-th column. | ae20712265d4adf293e75d016b4b82d8 | number_of_columns = int(input())
box_p_column = [int(i) for i in input().split(' ')]
box_p_column = [str(i) for i in sorted(box_p_column)]
print(' '.join(box_p_column).strip())
| ["1 2 2 3", "2 3 8"] | Python | NoteThe first example case is shown on the figure. The top cube of the first column falls to the top of the last column; the top cube of the second column falls to the top of the third column; the middle cube of the first column falls to the top of the second column.In the second example case the gravity switch does no... | Output n integer numbers separated by spaces, where the i-th number is the amount of cubes in the i-th column after the gravity switch. | Little Chris is bored during his physics lessons (too easy), so he has built a toy box to keep himself occupied. The box is special, since it has the ability to change gravity.There are n columns of toy cubes in the box arranged in a line. The i-th column contains ai cubes. At first, the gravity in the box is pulling t... | [{"input": "4\r\n3 2 1 2\r\n", "output": ["1 2 2 3"]}, {"input": "3\r\n2 3 8\r\n", "output": ["2 3 8"]}, {"input": "5\r\n2 1 2 1 2\r\n", "output": ["1 1 2 2 2"]}, {"input": "1\r\n1\r\n", "output": ["1"]}, {"input": "2\r\n4 3\r\n", "output": ["3 4"]}, {"input": "6\r\n100 40 60 20 1 80\r\n", "output": ["1 20 40 60 80 100... | 100 | 100 | 100 | [{'input': '4\r\n3 2 1 2\r\n', 'output': ['1 2 2 3']}, {'input': '49\r\n1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97\r\n', 'output': ['1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 ... | [{'input': '40\r\n22 58 68 58 48 53 52 1 16 78 75 17 63 15 36 32 78 75 49 14 42 46 66 54 49 82 40 43 46 55 12 73 5 45 61 60 1 11 31 84\r\n', 'output': ['1 1 5 11 12 14 15 16 17 22 31 32 36 40 42 43 45 46 46 48 49 49 52 53 54 55 58 58 60 61 63 66 68 73 75 75 78 78 82 84']}, {'input': '5\r\n2 1 2 1 2\r\n', 'output': ['1 ... | [{'input': '100\r\n1 1 1 1 2 1 1 1 1 1 2 2 1 1 2 1 2 1 1 1 2 1 1 2 1 2 1 1 2 2 2 1 1 2 1 1 1 2 2 2 1 1 1 2 1 2 2 1 2 1 1 2 2 1 2 1 2 1 2 2 1 1 1 2 1 1 2 1 2 1 2 2 2 1 2 1 2 2 2 1 2 2 1 1 1 1 2 2 2 2 2 2 2 1 1 1 2 1 2 1\r\n', 'output': ['1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1... | [{'input': '4\r\n3 2 1 2\r\n', 'output': ['1 2 2 3']}, {'input': '100\r\n82 51 81 14 37 17 78 92 64 15 8 86 89 8 87 77 66 10 15 12 100 25 92 47 21 78 20 63 13 49 41 36 41 79 16 87 87 69 3 76 80 60 100 49 70 59 72 8 38 71 45 97 71 14 76 54 81 4 59 46 39 29 92 3 49 22 53 99 59 52 74 31 92 43 42 23 44 9 82 47 7 40 12 9 3 ... | [{'input': '100\r\n100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1\r\n', 'ou... | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 389 | 100 | 100 | 100 |
["4 1 2", "8 2 6", "8 7 5"] | The only line contains three integers n, a and b (2 ≤ n ≤ 256, 1 ≤ a, b ≤ n) — the total number of teams, and the ids of the teams that Arkady is interested in. It is guaranteed that n is such that in each round an even number of team advance, and that a and b are not equal. | a753bfa7bde157e108f34a28240f441f | total_teams,team1,team2 = map(int,input().split())
count = 1
while True:
if round((team1/2)+0.1)==round((team2/2)+0.1):
break
team1=round((team1/2)+0.1)
team2=round((team2/2)+0.1)
total_teams//=2
count+=1
if total_teams==2:
print('Final!')
else:
print(count)
| ["1", "Final!", "2"] | Python | NoteIn the first example teams 1 and 2 meet in the first round.In the second example teams 2 and 6 can only meet in the third round, which is the Final, if they win all their opponents in earlier rounds.In the third example the teams with ids 7 and 5 can meet in the second round, if they win their opponents in the firs... | In the only line print "Final!" (without quotes), if teams a and b can meet in the Final. Otherwise, print a single integer — the number of the round in which teams a and b can meet. The round are enumerated from 1. | The last stage of Football World Cup is played using the play-off system.There are n teams left in this stage, they are enumerated from 1 to n. Several rounds are held, in each round the remaining teams are sorted in the order of their ids, then the first in this order plays with the second, the third — with the fourth... | [{"input": "4 1 2\r\n", "output": ["1"]}, {"input": "8 2 6\r\n", "output": ["Final!"]}, {"input": "8 7 5\r\n", "output": ["2"]}, {"input": "128 30 98\r\n", "output": ["Final!"]}, {"input": "256 128 256\r\n", "output": ["Final!"]}, {"input": "256 2 127\r\n", "output": ["7"]}, {"input": "2 1 2\r\n", "output": ["Final!"]}... | 100 | 100 | 100 | [{'input': '16 4 3\r\n', 'output': ['1']}, {'input': '256 128 256\r\n', 'output': ['Final!']}, {'input': '8 8 5\r\n', 'output': ['2']}, {'input': '128 47 83\r\n', 'output': ['Final!']}, {'input': '64 60 58\r\n', 'output': ['2']}] | [{'input': '16 2 4\r\n', 'output': ['2']}, {'input': '16 14 11\r\n', 'output': ['3']}, {'input': '128 124 77\r\n', 'output': ['6']}, {'input': '128 116 115\r\n', 'output': ['1']}, {'input': '4 1 4\r\n', 'output': ['Final!']}] | [{'input': '256 255 129\r\n', 'output': ['7']}, {'input': '256 2 127\r\n', 'output': ['7']}, {'input': '32 17 25\r\n', 'output': ['4']}, {'input': '4 2 4\r\n', 'output': ['Final!']}, {'input': '16 4 3\r\n', 'output': ['1']}] | [{'input': '8 7 8\r\n', 'output': ['1']}, {'input': '4 1 4\r\n', 'output': ['Final!']}, {'input': '16 2 4\r\n', 'output': ['2']}, {'input': '128 116 115\r\n', 'output': ['1']}, {'input': '256 178 166\r\n', 'output': ['5']}] | [{'input': '256 128 129\r\n', 'output': ['Final!']}, {'input': '256 185 200\r\n', 'output': ['7']}, {'input': '256 178 166\r\n', 'output': ['5']}, {'input': '32 18 3\r\n', 'output': ['Final!']}, {'input': '4 2 4\r\n', 'output': ['Final!']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 390 | 100 | 100 | 100 |
["####\n.#..\n####\n....", "####\n....\n####\n...."] | Four lines contain four characters each: the j-th character of the i-th line equals "." if the cell in the i-th row and the j-th column of the square is painted white, and "#", if the cell is black. | 01b145e798bbdf0ca2ecc383676d79f3 | #!/usr/bin/env python
# coding: utf-8
# In[14]:
# # n = int(input())
# # line = list(map(int, input().split()))
# # line = list(str(input()))
# from tqdm import trange
# In[24]:
from collections import Counter
# In[13]:
matrix = []
for _ in range(4):
matrix.append(list(str(input())))
# In[29]:
ans =... | ["YES", "NO"] | Python | NoteIn the first test sample it is enough to repaint the first cell in the second row. After such repainting the required 2 × 2 square is on the intersection of the 1-st and 2-nd row with the 1-st and 2-nd column. | Print "YES" (without the quotes), if the test can be passed and "NO" (without the quotes) otherwise. | In the city of Ultima Thule job applicants are often offered an IQ test. The test is as follows: the person gets a piece of squared paper with a 4 × 4 square painted on it. Some of the square's cells are painted black and others are painted white. Your task is to repaint at most one cell the other color so that the pic... | [{"input": "####\r\n.#..\r\n####\r\n....\r\n", "output": ["YES"]}, {"input": "####\r\n....\r\n####\r\n....\r\n", "output": ["NO"]}, {"input": "....\r\n....\r\n....\r\n....\r\n", "output": ["YES"]}, {"input": "###.\r\n...#\r\n###.\r\n...#\r\n", "output": ["NO"]}, {"input": ".##.\r\n#..#\r\n.##.\r\n#..#\r\n", "output": [... | 100 | 100 | 100 | [{'input': '###.\r\n...#\r\n###.\r\n...#\r\n', 'output': ['NO']}, {'input': '####\r\n.#..\r\n####\r\n....\r\n', 'output': ['YES']}, {'input': '#..#\r\n.##.\r\n.##.\r\n#..#\r\n', 'output': ['YES']}, {'input': '.#..\r\n..##\r\n##..\r\n..##\r\n', 'output': ['YES']}, {'input': '.#..\r\n###.\r\n.#.#\r\n..#.\r\n', 'output': ... | [{'input': '....\r\n....\r\n....\r\n...#\r\n', 'output': ['YES']}, {'input': '.#.#\r\n#.#.\r\n#.#.\r\n#.#.\r\n', 'output': ['NO']}, {'input': '##..\r\n..##\r\n##..\r\n..##\r\n', 'output': ['NO']}, {'input': '.##.\r\n#..#\r\n.##.\r\n#..#\r\n', 'output': ['NO']}, {'input': '.##.\r\n##..\r\n#..#\r\n..##\r\n', 'output': ['... | [{'input': '##..\r\n...#\r\n##..\r\n...#\r\n', 'output': ['YES']}, {'input': '####\r\n#..#\r\n.##.\r\n....\r\n', 'output': ['YES']}, {'input': '#.#.\r\n.###\r\n#.#.\r\n.###\r\n', 'output': ['YES']}, {'input': '.##.\r\n##..\r\n#..#\r\n..##\r\n', 'output': ['YES']}, {'input': '#..#\r\n.##.\r\n####\r\n####\r\n', 'output':... | [{'input': '#..#\r\n.##.\r\n####\r\n####\r\n', 'output': ['YES']}, {'input': '#..#\r\n.##.\r\n.##.\r\n#..#\r\n', 'output': ['YES']}, {'input': '###.\r\n...#\r\n###.\r\n...#\r\n', 'output': ['NO']}, {'input': '###.\r\n###.\r\n...#\r\n...#\r\n', 'output': ['YES']}, {'input': '.#.#\r\n#.#.\r\n.#.#\r\n#.##\r\n', 'output': ... | [{'input': '.#.#\r\n#.#.\r\n#.#.\r\n.#.#\r\n', 'output': ['NO']}, {'input': '####\r\n....\r\n####\r\n....\r\n', 'output': ['NO']}, {'input': '####\r\n.#..\r\n####\r\n....\r\n', 'output': ['YES']}, {'input': '##..\r\n##..\r\n..##\r\n..##\r\n', 'output': ['YES']}, {'input': '.#..\r\n..#.\r\n.#..\r\n..#.\r\n', 'output': [... | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 391 | 100 | 100 | 100 |
["390", "7", "1000000000"] | The only input line contains the integer $$$n$$$ ($$$1 \le n \le 2\cdot10^9$$$). | 38690bd32e7d0b314f701f138ce19dfb | import math
i=int(input())
max=0
k=len(str(i))-1
if i<10:
print(i)
else:
list=[]
p=str(i)
for m in p:
list.append(int(m))
p=list
m=1
for j in p:
m*=j
if m>max:
max=m
m=1
for l in range(k,0,-1):
q=i
minus=i%10**l+1
q-=minus
l... | ["216", "7", "387420489"] | Python | NoteIn the first example the maximum product is achieved for $$$389$$$ (the product of digits is $$$3\cdot8\cdot9=216$$$).In the second example the maximum product is achieved for $$$7$$$ (the product of digits is $$$7$$$).In the third example the maximum product is achieved for $$$999999999$$$ (the product of digits i... | Print the maximum product of digits among all integers from $$$1$$$ to $$$n$$$. | Kurt reaches nirvana when he finds the product of all the digits of some positive integer. Greater value of the product makes the nirvana deeper.Help Kurt find the maximum possible product of digits among all integers from $$$1$$$ to $$$n$$$. | [{"input": "390\r\n", "output": ["216"]}, {"input": "7\r\n", "output": ["7"]}, {"input": "1000000000\r\n", "output": ["387420489"]}, {"input": "1\r\n", "output": ["1"]}, {"input": "9\r\n", "output": ["9"]}, {"input": "2000000000\r\n", "output": ["387420489"]}, {"input": "4876\r\n", "output": ["2268"]}, {"input": "88987... | 100 | 100 | 100 | [{'input': '1382011913\r\n', 'output': ['387420489']}, {'input': '480330141\r\n', 'output': ['133923132']}, {'input': '99\r\n', 'output': ['81']}, {'input': '1\r\n', 'output': ['1']}, {'input': '101\r\n', 'output': ['81']}] | [{'input': '1999999998\r\n', 'output': ['387420489']}, {'input': '19\r\n', 'output': ['9']}, {'input': '2\r\n', 'output': ['2']}, {'input': '288\r\n', 'output': ['128']}, {'input': '396579088\r\n', 'output': ['114791256']}] | [{'input': '691993260\r\n', 'output': ['229582512']}, {'input': '1382011913\r\n', 'output': ['387420489']}, {'input': '288\r\n', 'output': ['128']}, {'input': '1999999998\r\n', 'output': ['387420489']}, {'input': '282587478\r\n', 'output': ['66961566']}] | [{'input': '98\r\n', 'output': ['72']}, {'input': '1001\r\n', 'output': ['729']}, {'input': '1000\r\n', 'output': ['729']}, {'input': '4876\r\n', 'output': ['2268']}, {'input': '999999999\r\n', 'output': ['387420489']}] | [{'input': '3\r\n', 'output': ['3']}, {'input': '11\r\n', 'output': ['9']}, {'input': '2690\r\n', 'output': ['864']}, {'input': '98\r\n', 'output': ['72']}, {'input': '999999999\r\n', 'output': ['387420489']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 96.88 | 96.88 | 100 | 100 | 100 | 93.75 | 93.75 | 100 | 392 | 100 | 98.752 | 97.5 |
["500 1000 20 30", "1000 1000 1 1", "1500 1000 176 177"] | The first line contains four integers a, b, c, d (250 ≤ a, b ≤ 3500, 0 ≤ c, d ≤ 180). It is guaranteed that numbers a and b are divisible by 250 (just like on any real Codeforces round). | 95b19d7569d6b70bd97d46a8541060d0 |
a,b,c,d = map(int, input().split())
s1 = max(0.3 * a, int(a * (1 - c / 250)))
s2 = max(0.3 * b, int(b * (1 - d / 250)))
if s1 > s2:
print('Misha')
elif s1 == s2:
print('Tie')
else:
print('Vasya') | ["Vasya", "Tie", "Misha"] | Python | null | Output on a single line: "Misha" (without the quotes), if Misha got more points than Vasya. "Vasya" (without the quotes), if Vasya got more points than Misha. "Tie" (without the quotes), if both of them got the same number of points. | Misha and Vasya participated in a Codeforces contest. Unfortunately, each of them solved only one problem, though successfully submitted it at the first attempt. Misha solved the problem that costs a points and Vasya solved the problem that costs b points. Besides, Misha submitted the problem c minutes after the contes... | [{"input": "500 1000 20 30\r\n", "output": ["Vasya"]}, {"input": "1000 1000 1 1\r\n", "output": ["Tie"]}, {"input": "1500 1000 176 177\r\n", "output": ["Misha"]}, {"input": "1500 1000 74 177\r\n", "output": ["Misha"]}, {"input": "750 2500 175 178\r\n", "output": ["Vasya"]}, {"input": "750 1000 54 103\r\n", "output": ["... | 100 | 100 | 100 | [{'input': '2500 2750 73 179\r\n', 'output': ['Misha']}, {'input': '1500 1000 74 177\r\n', 'output': ['Misha']}, {'input': '3000 2000 162 118\r\n', 'output': ['Tie']}, {'input': '1500 1250 180 160\r\n', 'output': ['Tie']}, {'input': '250 250 0 0\r\n', 'output': ['Tie']}] | [{'input': '1500 1250 180 160\r\n', 'output': ['Tie']}, {'input': '3000 3000 176 78\r\n', 'output': ['Vasya']}, {'input': '3250 1000 160 138\r\n', 'output': ['Misha']}, {'input': '1000 3500 178 175\r\n', 'output': ['Vasya']}, {'input': '3500 250 0 180\r\n', 'output': ['Misha']}] | [{'input': '250 250 0 0\r\n', 'output': ['Tie']}, {'input': '500 1500 179 71\r\n', 'output': ['Vasya']}, {'input': '1500 1000 74 177\r\n', 'output': ['Misha']}, {'input': '3250 1000 160 138\r\n', 'output': ['Misha']}, {'input': '1750 3000 137 49\r\n', 'output': ['Vasya']}] | [{'input': '3000 3250 16 34\r\n', 'output': ['Tie']}, {'input': '3500 3500 177 178\r\n', 'output': ['Tie']}, {'input': '2000 2000 176 179\r\n', 'output': ['Tie']}, {'input': '3000 3000 176 78\r\n', 'output': ['Vasya']}, {'input': '2500 2750 73 179\r\n', 'output': ['Misha']}] | [{'input': '1000 1000 1 1\r\n', 'output': ['Tie']}, {'input': '1750 3000 137 49\r\n', 'output': ['Vasya']}, {'input': '1750 2250 178 53\r\n', 'output': ['Vasya']}, {'input': '250 3500 0 180\r\n', 'output': ['Vasya']}, {'input': '500 500 170 176\r\n', 'output': ['Misha']}] | 100 | 100 | 100 | 100 | 100 | 87.5 | 100 | 100 | 100 | 100 | 75 | 100 | 100 | 100 | 100 | 393 | 100 | 97.5 | 95 |
["19", "16"] | The first and only line contains an integer $$$r$$$ ($$$1 \le r \le 10^{12}$$$). | 3ff1c25a1026c90aeb14d148d7fb96ba | r = int(input())
y = int((r-3)/2)
if(r&1 and y > 0):
print("{} {}".format(1,y))
else :
print("NO") | ["1 8", "NO"] | Python | null | Output integers $$$x, y$$$ such that $$$H(x,y) = r$$$ and $$$x$$$ is smallest possible, or "NO" if no such pair exists. | Melody Pond was stolen from her parents as a newborn baby by Madame Kovarian, to become a weapon of the Silence in their crusade against the Doctor. Madame Kovarian changed Melody's name to River Song, giving her a new identity that allowed her to kill the Eleventh Doctor.Heidi figured out that Madame Kovarian uses a v... | [{"input": "19\r\n", "output": ["1 8"]}, {"input": "16\r\n", "output": ["NO"]}, {"input": "1\r\n", "output": ["NO"]}, {"input": "2\r\n", "output": ["NO"]}, {"input": "3\r\n", "output": ["NO"]}, {"input": "4\r\n", "output": ["NO"]}, {"input": "5\r\n", "output": ["1 1"]}, {"input": "6\r\n", "output": ["NO"]}, {"input": "... | 100 | 100 | 100 | [{'input': '2\r\n', 'output': ['NO']}, {'input': '3\r\n', 'output': ['NO']}, {'input': '240940299601\r\n', 'output': ['1 120470149799']}, {'input': '260158260522\r\n', 'output': ['NO']}, {'input': '185589070745\r\n', 'output': ['1 92794535371']}] | [{'input': '9\r\n', 'output': ['1 3']}, {'input': '14\r\n', 'output': ['NO']}, {'input': '963761198401\r\n', 'output': ['1 481880599199']}, {'input': '8\r\n', 'output': ['NO']}, {'input': '419450839\r\n', 'output': ['1 209725418']}] | [{'input': '962623690081\r\n', 'output': ['1 481311845039']}, {'input': '13\r\n', 'output': ['1 5']}, {'input': '215283472163\r\n', 'output': ['1 107641736080']}, {'input': '4\r\n', 'output': ['NO']}, {'input': '419450839\r\n', 'output': ['1 209725418']}] | [{'input': '3\r\n', 'output': ['NO']}, {'input': '768407398177\r\n', 'output': ['1 384203699087']}, {'input': '426262703497\r\n', 'output': ['1 213131351747']}, {'input': '688373050717\r\n', 'output': ['1 344186525357']}, {'input': '8\r\n', 'output': ['NO']}] | [{'input': '116602436426\r\n', 'output': ['NO']}, {'input': '10\r\n', 'output': ['NO']}, {'input': '1\r\n', 'output': ['NO']}, {'input': '963761198401\r\n', 'output': ['1 481880599199']}, {'input': '250877914575\r\n', 'output': ['1 125438957286']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 394 | 100 | 100 | 100 |
["3 1 1", "5 2 3"] | The only line contains three integers n, a and b (0 ≤ a, b < n ≤ 100). | 51a072916bff600922a77da0c4582180 | n,a,b = map(int, input().split(' '))
print(n-max(a+1,n-b)+1) | ["2", "3"] | Python | NoteThe possible positions in the first sample are: 2 and 3 (if we number the positions starting with 1).In the second sample they are 3, 4 and 5. | Print the single number — the number of the sought positions. | Petr stands in line of n people, but he doesn't know exactly which position he occupies. He can say that there are no less than a people standing in front of him and no more than b people standing behind him. Find the number of different positions Petr can occupy. | [{"input": "3 1 1\r\n", "output": ["2"]}, {"input": "5 2 3\r\n", "output": ["3"]}, {"input": "5 4 0\r\n", "output": ["1"]}, {"input": "6 5 5\r\n", "output": ["1"]}, {"input": "9 4 3\r\n", "output": ["4"]}, {"input": "11 4 6\r\n", "output": ["7"]}, {"input": "13 8 7\r\n", "output": ["5"]}, {"input": "14 5 5\r\n", "outpu... | 100 | 100 | 100 | [{'input': '5 2 3\r\n', 'output': ['3']}, {'input': '23 8 14\r\n', 'output': ['15']}, {'input': '71 33 53\r\n', 'output': ['38']}, {'input': '39 34 33\r\n', 'output': ['5']}, {'input': '62 9 52\r\n', 'output': ['53']}] | [{'input': '3 1 1\r\n', 'output': ['2']}, {'input': '23 8 14\r\n', 'output': ['15']}, {'input': '73 14 12\r\n', 'output': ['13']}, {'input': '62 9 52\r\n', 'output': ['53']}, {'input': '11 4 6\r\n', 'output': ['7']}] | [{'input': '59 12 39\r\n', 'output': ['40']}, {'input': '62 9 52\r\n', 'output': ['53']}, {'input': '58 57 28\r\n', 'output': ['1']}, {'input': '41 27 11\r\n', 'output': ['12']}, {'input': '66 27 38\r\n', 'output': ['39']}] | [{'input': '71 33 53\r\n', 'output': ['38']}, {'input': '56 43 12\r\n', 'output': ['13']}, {'input': '51 38 39\r\n', 'output': ['13']}, {'input': '62 9 52\r\n', 'output': ['53']}, {'input': '22 4 8\r\n', 'output': ['9']}] | [{'input': '5 4 0\r\n', 'output': ['1']}, {'input': '62 9 52\r\n', 'output': ['53']}, {'input': '100 81 91\r\n', 'output': ['19']}, {'input': '100 11 88\r\n', 'output': ['89']}, {'input': '14 5 5\r\n', 'output': ['6']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 395 | 100 | 100 | 100 |
["6 4\n5237\n2753\n7523\n5723\n5327\n2537", "3 3\n010\n909\n012", "7 5\n50808\n36603\n37198\n44911\n29994\n42543\n50156"] | The first line contains integers n and k — the number and digit capacity of numbers correspondingly (1 ≤ n, k ≤ 8). Next n lines contain k-digit positive integers. Leading zeroes are allowed both in the initial integers and the integers resulting from the rearranging of digits. | 08f85cd4ffbd135f0b630235209273a4 |
import itertools, sys
n, k = [int(x) for x in input().split()]
perms = zip(*[[int(''.join(p)) for p in itertools.permutations(input())] for y in range(n)])
perms = list(perms)
# print(perms)
minimum = float("inf")
for p in perms:
temp = max(p) - min(p)
if temp < minimum:
minimum = temp
print(minimum)
#... | ["2700", "3", "20522"] | Python | NoteIn the first sample, if we rearrange the digits in numbers as (3,1,4,2), then the 2-nd and the 4-th numbers will equal 5237 and 2537 correspondingly (they will be maximum and minimum for such order of digits).In the second sample, if we swap the second digits and the first ones, we get integers 100, 99 and 102. | Print a single number: the minimally possible difference between the largest and the smallest number after the digits are rearranged in all integers by the same rule. | You are given n k-digit integers. You have to rearrange the digits in the integers so that the difference between the largest and the smallest number was minimum. Digits should be rearranged by the same rule in all integers. | [{"input": "6 4\r\n5237\r\n2753\r\n7523\r\n5723\r\n5327\r\n2537\r\n", "output": ["2700"]}, {"input": "3 3\r\n010\r\n909\r\n012\r\n", "output": ["3"]}, {"input": "7 5\r\n50808\r\n36603\r\n37198\r\n44911\r\n29994\r\n42543\r\n50156\r\n", "output": ["20522"]}, {"input": "5 5\r\n61374\r\n74304\r\n41924\r\n46010\r\n09118\r\n... | 100 | 100 | 100 | [{'input': '4 1\r\n0\r\n7\r\n5\r\n1\r\n', 'output': ['7']}, {'input': '3 4\r\n0136\r\n4556\r\n4268\r\n', 'output': ['2134']}, {'input': '6 7\r\n9085507\r\n7716507\r\n1952887\r\n6569746\r\n1900754\r\n9212439\r\n', 'output': ['3180457']}, {'input': '4 4\r\n8851\r\n6190\r\n0521\r\n1659\r\n', 'output': ['6596']}, {'input':... | [{'input': '1 6\r\n430254\r\n', 'output': ['0']}, {'input': '8 7\r\n8112819\r\n8982110\r\n5457941\r\n4575033\r\n5203331\r\n7410823\r\n0532182\r\n8151054\r\n', 'output': ['6194602']}, {'input': '6 7\r\n4104025\r\n1370353\r\n3472874\r\n5258456\r\n5595923\r\n0279404\r\n', 'output': ['2790148']}, {'input': '3 3\r\n195\r\n8... | [{'input': '1 7\r\n4605461\r\n', 'output': ['0']}, {'input': '3 4\r\n3061\r\n3404\r\n6670\r\n', 'output': ['2916']}, {'input': '3 1\r\n5\r\n4\r\n2\r\n', 'output': ['3']}, {'input': '6 4\r\n0443\r\n7108\r\n7211\r\n4287\r\n6439\r\n7711\r\n', 'output': ['5301']}, {'input': '8 5\r\n07936\r\n07927\r\n46068\r\n99158\r\n90958... | [{'input': '6 8\r\n50157346\r\n63836375\r\n03176371\r\n83637145\r\n28631038\r\n18617159\r\n', 'output': ['24702445']}, {'input': '5 2\r\n01\r\n07\r\n63\r\n71\r\n99\r\n', 'output': ['89']}, {'input': '8 5\r\n07936\r\n07927\r\n46068\r\n99158\r\n90958\r\n41283\r\n59266\r\n87841\r\n', 'output': ['52364']}, {'input': '2 5\r... | [{'input': '7 7\r\n6575460\r\n6965366\r\n1912357\r\n7080608\r\n2561692\r\n5209630\r\n0439095\r\n', 'output': ['5917123']}, {'input': '6 4\r\n5237\r\n2753\r\n7523\r\n5723\r\n5327\r\n2537\r\n', 'output': ['2700']}, {'input': '4 1\r\n0\r\n7\r\n5\r\n1\r\n', 'output': ['7']}, {'input': '8 1\r\n9\r\n7\r\n6\r\n2\r\n9\r\n6\r\n... | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 396 | 100 | 100 | 100 |
["3 6\n2 3 5", "6 7\n1 2 3 4 5 6"] | The first line of input contains two integer numbers n and k (1 ≤ n, k ≤ 100) — the number of buckets and the length of the garden, respectively. The second line of input contains n integer numbers ai (1 ≤ ai ≤ 100) — the length of the segment that can be watered by the i-th bucket in one hour. It is guaranteed that th... | 80520be9916045aca3a7de7bc925af1f | import sys
n, k = sys.stdin.readline().strip().split(' ')
a = sys.stdin.readline().strip().split(' ')
a = list(map(int,a))
s=0
m=0
n = int(n)
k = int(k)
for i in range(n,0,-1):
r = k%a[i-1]
if r==0 and a[i-1]>m:
m=a[i-1]
s=k/m
print(int(s)) | ["2", "7"] | Python | NoteIn the first test the best option is to choose the bucket that allows to water the segment of length 3. We can't choose the bucket that allows to water the segment of length 5 because then we can't water the whole garden.In the second test we can choose only the bucket that allows us to water the segment of length ... | Print one integer number — the minimum number of hours required to water the garden. | Luba thinks about watering her garden. The garden can be represented as a segment of length k. Luba has got n buckets, the i-th bucket allows her to water some continuous subsegment of garden of length exactly ai each hour. Luba can't water any parts of the garden that were already watered, also she can't water the gro... | [{"input": "3 6\r\n2 3 5\r\n", "output": ["2"]}, {"input": "6 7\r\n1 2 3 4 5 6\r\n", "output": ["7"]}, {"input": "5 97\r\n1 10 50 97 2\r\n", "output": ["1"]}, {"input": "5 97\r\n1 10 50 100 2\r\n", "output": ["97"]}, {"input": "100 100\r\n2 46 24 18 86 90 31 38 84 49 58 28 15 80 14 24 87 56 62 87 41 87 55 71 87 32 41 5... | 100 | 100 | 100 | [{'input': '3 18\r\n1 9 6\r\n', 'output': ['2']}, {'input': '2 2\r\n2 1\r\n', 'output': ['1']}, {'input': '2 100\r\n99 1\r\n', 'output': ['100']}, {'input': '4 12\r\n1 3 4 2\r\n', 'output': ['3']}, {'input': '2 4\r\n4 1\r\n', 'output': ['1']}] | [{'input': '4 100\r\n2 50 4 1\r\n', 'output': ['2']}, {'input': '2 100\r\n99 1\r\n', 'output': ['100']}, {'input': '79 12\r\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 ... | [{'input': '3 8\r\n3 4 2\r\n', 'output': ['2']}, {'input': '3 8\r\n4 2 1\r\n', 'output': ['2']}, {'input': '5 25\r\n24 5 15 25 23\r\n', 'output': ['1']}, {'input': '4 12\r\n1 3 4 2\r\n', 'output': ['3']}, {'input': '4 21\r\n21 20 21 2\r\n', 'output': ['1']}] | [{'input': '7 24\r\n1 3 6 4 5 2 7\r\n', 'output': ['4']}, {'input': '3 10\r\n2 10 5\r\n', 'output': ['1']}, {'input': '4 32\r\n1 1 1 1\r\n', 'output': ['32']}, {'input': '3 6\r\n10 2 3\r\n', 'output': ['2']}, {'input': '2 16\r\n8 4\r\n', 'output': ['2']}] | [{'input': '3 8\r\n3 4 2\r\n', 'output': ['2']}, {'input': '100 100\r\n2 46 24 18 86 90 31 38 84 49 58 28 15 80 14 24 87 56 62 87 41 87 55 71 87 32 41 56 91 32 24 75 43 42 35 30 72 53 31 26 54 61 87 85 36 75 44 31 7 38 77 57 61 54 70 77 45 96 39 57 11 8 91 42 52 15 42 30 92 41 27 26 34 27 3 80 32 86 26 97 63 91 30 75 1... | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 397 | 100 | 100 | 100 |
["1f", "2d", "4a", "5e"] | The only line of input contains a description of Vasya's seat in the format ns, where n (1 ≤ n ≤ 1018) is the index of the row and s is the seat in this row, denoted as letter from 'a' to 'f'. The index of the row and the seat are not separated by a space. | 069d0cb9b7c798a81007fb5b63fa0f45 | import math
rows = [0, 1, 0, 1]
seats = ["f", "e", "d", "a", "b", "c"]
s = input()
a, b = int(s[:-1]), s[-1]
print((a - 1) // 4 * 16 + rows[a % 4 - 1] * 7 + seats.index(b) + 1) | ["1", "10", "11", "18"] | Python | NoteIn the first sample, the first flight attendant serves Vasya first, so Vasya gets his lunch after 1 second.In the second sample, the flight attendants will spend 6 seconds to serve everyone in the rows 1 and 3, then they will move one row forward in 1 second. As they first serve seats located to the right of the ai... | Print one integer — the number of seconds Vasya has to wait until he gets his lunch. | A new airplane SuperPuperJet has an infinite number of rows, numbered with positive integers starting with 1 from cockpit to tail. There are six seats in each row, denoted with letters from 'a' to 'f'. Seats 'a', 'b' and 'c' are located to the left of an aisle (if one looks in the direction of the cockpit), while seats... | [{"input": "1f\r\n", "output": ["1"]}, {"input": "2d\r\n", "output": ["10"]}, {"input": "4a\r\n", "output": ["11"]}, {"input": "5e\r\n", "output": ["18"]}, {"input": "2c\r\n", "output": ["13"]}, {"input": "1b\r\n", "output": ["5"]}, {"input": "1000000000000000000d\r\n", "output": ["3999999999999999994"]}, {"input": "99... | 100 | 100 | 100 | [{'input': '999999999999999997a\r\n', 'output': ['3999999999999999988']}, {'input': '999999999999999997e\r\n', 'output': ['3999999999999999986']}, {'input': '1000000000f\r\n', 'output': ['3999999992']}, {'input': '1b\r\n', 'output': ['5']}, {'input': '999999999999999998c\r\n', 'output': ['3999999999999999997']}] | [{'input': '999999999999999995a\r\n', 'output': ['3999999999999999972']}, {'input': '1a\r\n', 'output': ['4']}, {'input': '999999999f\r\n', 'output': ['3999999985']}, {'input': '999999999d\r\n', 'output': ['3999999987']}, {'input': '999999999999999999c\r\n', 'output': ['3999999999999999990']}] | [{'input': '3f\r\n', 'output': ['1']}, {'input': '999999999999999992d\r\n', 'output': ['3999999999999999962']}, {'input': '999999999999999997b\r\n', 'output': ['3999999999999999989']}, {'input': '2c\r\n', 'output': ['13']}, {'input': '999999999999999997c\r\n', 'output': ['3999999999999999990']}] | [{'input': '3a\r\n', 'output': ['4']}, {'input': '999999997c\r\n', 'output': ['3999999990']}, {'input': '999999999999999993e\r\n', 'output': ['3999999999999999970']}, {'input': '100000b\r\n', 'output': ['399996']}, {'input': '100001e\r\n', 'output': ['400002']}] | [{'input': '2c\r\n', 'output': ['13']}, {'input': '999999998f\r\n', 'output': ['3999999992']}, {'input': '1000000000b\r\n', 'output': ['3999999996']}, {'input': '100000f\r\n', 'output': ['399992']}, {'input': '1000000000e\r\n', 'output': ['3999999993']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 398 | 100 | 100 | 100 |
["10 3", "7 7"] | The only line of input contains integers n and k (1 ≤ k ≤ n ≤ 1012). Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier. | 1f8056884db00ad8294a7cc0be75fe97 | n,k=map(int,input().split())
if n%2==0 :
if (k > n//2) :
print((k-n//2)*2)
else :
print(2*k - 1)
else :
if (k > ((n-1)//2)+ 1) :
print((k-1-((n-1)//2))*2)
else :
print(2*k - 1) | ["5", "6"] | Python | NoteIn the first sample Volodya's sequence will look like this: {1, 3, 5, 7, 9, 2, 4, 6, 8, 10}. The third place in the sequence is therefore occupied by the number 5. | Print the number that will stand at the position number k after Volodya's manipulations. | 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 writes down the followin... | [{"input": "10 3\r\n", "output": ["5"]}, {"input": "7 7\r\n", "output": ["6"]}, {"input": "7 1\r\n", "output": ["1"]}, {"input": "7 2\r\n", "output": ["3"]}, {"input": "8 5\r\n", "output": ["2"]}, {"input": "8 3\r\n", "output": ["5"]}, {"input": "8 4\r\n", "output": ["7"]}, {"input": "1000000000000 500000000001\r\n", "... | 100 | 100 | 100 | [{'input': '8 4\r\n', 'output': ['7']}, {'input': '8 3\r\n', 'output': ['5']}, {'input': '999999999997 499999999999\r\n', 'output': ['999999999997']}, {'input': '1000000000000 1000000000000\r\n', 'output': ['1000000000000']}, {'input': '7 2\r\n', 'output': ['3']}] | [{'input': '999999999999 999999999999\r\n', 'output': ['999999999998']}, {'input': '7 1\r\n', 'output': ['1']}, {'input': '1000000000000 1\r\n', 'output': ['1']}, {'input': '619234238 556154835\r\n', 'output': ['493075432']}, {'input': '91028405 61435545\r\n', 'output': ['31842684']}] | [{'input': '91028405 61435545\r\n', 'output': ['31842684']}, {'input': '603701841 56038951\r\n', 'output': ['112077901']}, {'input': '1000000000000 1000000000000\r\n', 'output': ['1000000000000']}, {'input': '1000000000000 500000000001\r\n', 'output': ['2']}, {'input': '999999999997 499999999998\r\n', 'output': ['99999... | [{'input': '8 5\r\n', 'output': ['2']}, {'input': '999999999997 499999999999\r\n', 'output': ['999999999997']}, {'input': '8 3\r\n', 'output': ['5']}, {'input': '999999999999 1\r\n', 'output': ['1']}, {'input': '7 1\r\n', 'output': ['1']}] | [{'input': '1 1\r\n', 'output': ['1']}, {'input': '999999999997 499999999999\r\n', 'output': ['999999999997']}, {'input': '91028405 61435545\r\n', 'output': ['31842684']}, {'input': '7 1\r\n', 'output': ['1']}, {'input': '1000000000000 500000000001\r\n', 'output': ['2']}] | 100 | 100 | 100 | 100 | 100 | 87.5 | 100 | 87.5 | 87.5 | 87.5 | 83.33 | 100 | 83.33 | 83.33 | 83.33 | 399 | 100 | 90 | 86.664 |
["3 30\n2 2 1", "3 20\n2 1 1"] | The first line contains two space separated integers n, d (1 ≤ n ≤ 100; 1 ≤ d ≤ 10000). The second line contains n space-separated integers: t1, t2, ..., tn (1 ≤ ti ≤ 100). | b16f5f5c4eeed2a3700506003e8ea8ea | __author__ = 'myduomilia'
n, t = list(map(int, input().split()))
arr = list(map(int, input().split()))
s = sum(arr)
ans = 0
if s + (len(arr) - 1) * 10 > t:
print(-1)
else:
print((t - s) // 5) | ["5", "-1"] | Python | NoteConsider the first example. The duration of the event is 30 minutes. There could be maximum 5 jokes in the following way: First Churu cracks a joke in 5 minutes. Then Devu performs the first song for 2 minutes. Then Churu cracks 2 jokes in 10 minutes. Now Devu performs second song for 2 minutes. Then Churu cra... | If there is no way to conduct all the songs of Devu, output -1. Otherwise output the maximum number of jokes that Churu can crack in the grand event. | Devu is a renowned classical singer. He is invited to many big functions/festivals. Recently he was invited to "All World Classical Singing Festival". Other than Devu, comedian Churu was also invited.Devu has provided organizers a list of the songs and required time for singing them. He will sing n songs, ith song will... | [{"input": "3 30\r\n2 2 1\r\n", "output": ["5"]}, {"input": "3 20\r\n2 1 1\r\n", "output": ["-1"]}, {"input": "50 10000\r\n5 4 10 9 9 6 7 7 7 3 3 7 7 4 7 4 10 10 1 7 10 3 1 4 5 7 2 10 10 10 2 3 4 7 6 1 8 4 7 3 8 8 4 10 1 1 9 2 6 1\r\n", "output": ["1943"]}, {"input": "50 10000\r\n4 7 15 9 11 12 20 9 14 14 10 13 6 13 14... | 100 | 100 | 100 | [{'input': '100 10000\r\n54 46 72 94 79 83 91 54 73 3 24 55 54 31 28 20 19 6 25 19 47 23 1 70 15 87 51 39 54 77 55 5 60 3 15 99 56 88 22 78 79 21 38 27 28 86 7 88 12 59 55 70 25 1 70 49 1 45 69 72 50 17 4 56 8 100 90 34 35 20 61 76 88 79 4 74 65 68 75 26 40 72 59 94 10 67 96 85 29 90 47 24 44 1 66 93 55 36 1 99\r\n', '... | [{'input': '81 4131\r\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\r\n', 'output': ['807']}, {'input': '3 30\r\n2 2 1\r\n', 'output': ['5']}, {'input': '81 2200\r\n1 59 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... | [{'input': '81 6315\r\n1 1 67 100 1 99 36 1 92 5 1 96 42 12 1 57 91 1 1 66 41 30 74 95 1 37 1 39 91 69 1 52 77 47 65 1 1 93 96 74 90 35 85 76 71 92 92 1 1 67 92 74 1 1 86 76 35 1 56 16 27 57 37 95 1 40 20 100 51 1 80 60 45 79 95 1 46 1 25 100 96\r\n', 'output': ['490']}, {'input': '81 2577\r\n85 91 1 1 2 1 1 100 1 80 1... | [{'input': '1 1\r\n1\r\n', 'output': ['0']}, {'input': '50 10000\r\n4 7 15 9 11 12 20 9 14 14 10 13 6 13 14 17 6 8 20 12 10 15 13 17 5 12 13 11 7 5 5 2 3 15 13 7 14 14 19 2 13 14 5 15 3 19 15 16 4 1\r\n', 'output': ['1891']}, {'input': '81 4131\r\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... | [{'input': '3 24\r\n2 1 2\r\n', 'output': ['-1']}, {'input': '81 4131\r\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\r\n', 'output': ['807']}, {'input': '3 30\r\n2 2 1\r\n', 'output': ['5']}, {'input':... | 100 | 100 | 100 | 100 | 100 | 87.5 | 87.5 | 87.5 | 87.5 | 100 | 50 | 50 | 50 | 50 | 100 | 400 | 100 | 90 | 60 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.