contestId int64 0 1.01k | index stringclasses 55
values | name stringlengths 2 58 | type stringclasses 2
values | rating int64 0 3.5k | tags listlengths 0 7 | title stringclasses 495
values | time-limit stringclasses 8
values | memory-limit stringclasses 8
values | problem-description stringlengths 0 7.15k | input-specification stringlengths 0 2.05k | output-specification stringlengths 0 1.5k | demo-input listlengths 0 7 | demo-output listlengths 0 7 | note stringlengths 0 5.24k | points float64 0 425k | test_cases listlengths 0 402 | creationTimeSeconds int64 1.37B 1.7B | relativeTimeSeconds int64 8 2.15B | programmingLanguage stringclasses 3
values | verdict stringclasses 14
values | testset stringclasses 12
values | passedTestCount int64 0 1k | timeConsumedMillis int64 0 15k | memoryConsumedBytes int64 0 805M | code stringlengths 5 65.5k | instruction_seed stringlengths 262 8.2k | response stringlengths 19 65.5k | score float64 -1 3.99 | _source stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
622 | B | The Time | PROGRAMMING | 900 | [
"implementation"
] | null | null | You are given the current time in 24-hour format hh:mm. Find and print the time after *a* minutes.
Note that you should find only the time after *a* minutes, see the examples to clarify the problem statement.
You can read more about 24-hour format here [https://en.wikipedia.org/wiki/24-hour_clock](https://en.wikipedi... | The first line contains the current time in the format hh:mm (0<=≤<=*hh*<=<<=24,<=0<=≤<=*mm*<=<<=60). The hours and the minutes are given with two digits (the hours or the minutes less than 10 are given with the leading zeroes).
The second line contains integer *a* (0<=≤<=*a*<=≤<=104) — the number of the minutes... | The only line should contain the time after *a* minutes in the format described in the input. Note that you should print exactly two digits for the hours and the minutes (add leading zeroes to the numbers if needed).
See the examples to check the input/output format. | [
"23:59\n10\n",
"20:20\n121\n",
"10:10\n0\n"
] | [
"00:09\n",
"22:21\n",
"10:10\n"
] | none | 0 | [
{
"input": "23:59\n10",
"output": "00:09"
},
{
"input": "20:20\n121",
"output": "22:21"
},
{
"input": "10:10\n0",
"output": "10:10"
},
{
"input": "12:34\n10000",
"output": "11:14"
},
{
"input": "00:00\n10000",
"output": "22:40"
},
{
"input": "00:00\n14... | 1,459,880,858 | 2,147,483,647 | Python 3 | OK | TESTS | 59 | 62 | 4,608,000 | time = input()
more = int(input())
h, m = int(time[:time.index(":")]), int(time[time.index(":")+1:])
moreh = more//60
morem = more%60
h += moreh
m += morem
if m >= 60:
h += m//60
m = m%60
if h >= 24:
h = h%24
if len(str(h)) < 2:
h = "0"+str(h)
if len(str(m)) < 2:
m = "0" + str(m)
pri... | Title: The Time
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given the current time in 24-hour format hh:mm. Find and print the time after *a* minutes.
Note that you should find only the time after *a* minutes, see the examples to clarify the problem statement.
You can read mo... | ```python
time = input()
more = int(input())
h, m = int(time[:time.index(":")]), int(time[time.index(":")+1:])
moreh = more//60
morem = more%60
h += moreh
m += morem
if m >= 60:
h += m//60
m = m%60
if h >= 24:
h = h%24
if len(str(h)) < 2:
h = "0"+str(h)
if len(str(m)) < 2:
m = "0" + s... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
344 | A | Magnets | PROGRAMMING | 800 | [
"implementation"
] | null | null | Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together at a close distance, then the like poles will repel each other and the oppo... | The first line of the input contains an integer *n* (1<=≤<=*n*<=≤<=100000) — the number of magnets. Then *n* lines follow. The *i*-th line (1<=≤<=*i*<=≤<=*n*) contains either characters "01", if Mike put the *i*-th magnet in the "plus-minus" position, or characters "10", if Mike put the magnet in the "minus-plus" posit... | On the single line of the output print the number of groups of magnets. | [
"6\n10\n10\n10\n01\n10\n10\n",
"4\n01\n01\n10\n10\n"
] | [
"3\n",
"2\n"
] | The first testcase corresponds to the figure. The testcase has three groups consisting of three, one and two magnets.
The second testcase has two groups, each consisting of two magnets. | 500 | [
{
"input": "6\n10\n10\n10\n01\n10\n10",
"output": "3"
},
{
"input": "4\n01\n01\n10\n10",
"output": "2"
},
{
"input": "1\n10",
"output": "1"
},
{
"input": "2\n01\n10",
"output": "2"
},
{
"input": "2\n10\n10",
"output": "1"
},
{
"input": "3\n10\n01\n10",... | 1,697,956,586 | 2,147,483,647 | PyPy 3-64 | RUNTIME_ERROR | TESTS | 0 | 154 | 2,867,200 | n = int(input())
magnet_positions = ''
group_count = 0
i = 0
while i < n:
position = input()
if i == 0 or position[0] == magnet_positions[-1]:
magnet_positions += position
group_count += 1
else:
magnet_positions += position
print(group_count) | Title: Magnets
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets... | ```python
n = int(input())
magnet_positions = ''
group_count = 0
i = 0
while i < n:
position = input()
if i == 0 or position[0] == magnet_positions[-1]:
magnet_positions += position
group_count += 1
else:
magnet_positions += position
print(group_count)
``` | -1 | MatrixStudio/Codeforces-Python-Submissions | |
702 | F | T-Shirts | PROGRAMMING | 2,800 | [
"data structures"
] | null | null | The big consignment of t-shirts goes on sale in the shop before the beginning of the spring. In all *n* types of t-shirts go on sale. The t-shirt of the *i*-th type has two integer parameters — *c**i* and *q**i*, where *c**i* — is the price of the *i*-th type t-shirt, *q**i* — is the quality of the *i*-th type t-shirt.... | The first line contains the positive integer *n* (1<=≤<=*n*<=≤<=2·105) — the number of t-shirt types.
Each of the following *n* lines contains two integers *c**i* and *q**i* (1<=≤<=*c**i*,<=*q**i*<=≤<=109) — the price and the quality of the *i*-th type t-shirt.
The next line contains the positive integer *k* (1<=≤<=... | The first line of the input data should contain the sequence of *k* integers, where the *i*-th number should be equal to the number of t-shirts, which the *i*-th customer will buy. | [
"3\n7 5\n3 5\n4 3\n2\n13 14\n",
"2\n100 500\n50 499\n4\n50 200 150 100\n"
] | [
"2 3 \n",
"1 2 2 1 \n"
] | In the first example the first customer will buy the t-shirt of the second type, then the t-shirt of the first type. He will spend 10 and will not be able to buy the t-shirt of the third type because it costs 4, and the customer will owe only 3. The second customer will buy all three t-shirts (at first, the t-shirt of ... | 0 | [] | 1,692,967,327 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 30 | 0 | n = int(input())
shirts = []
for _ in range(n):
c, q = map(int, input().split())
shirts.append((q, c))
shirts.sort(reverse=True)
k = int(input())
budgets = list(map(int, input().split()))
for budget in budgets:
left = 0
right = n
while left < right:
mid = (left + rig... | Title: T-Shirts
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The big consignment of t-shirts goes on sale in the shop before the beginning of the spring. In all *n* types of t-shirts go on sale. The t-shirt of the *i*-th type has two integer parameters — *c**i* and *q**i*, where *c**i* ... | ```python
n = int(input())
shirts = []
for _ in range(n):
c, q = map(int, input().split())
shirts.append((q, c))
shirts.sort(reverse=True)
k = int(input())
budgets = list(map(int, input().split()))
for budget in budgets:
left = 0
right = n
while left < right:
mid = (... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
295 | A | Greg and Array | PROGRAMMING | 1,400 | [
"data structures",
"implementation"
] | null | null | Greg has an array *a*<==<=*a*1,<=*a*2,<=...,<=*a**n* and *m* operations. Each operation looks as: *l**i*, *r**i*, *d**i*, (1<=≤<=*l**i*<=≤<=*r**i*<=≤<=*n*). To apply operation *i* to the array means to increase all array elements with numbers *l**i*,<=*l**i*<=+<=1,<=...,<=*r**i* by value *d**i*.
Greg wrote down *k* qu... | The first line contains integers *n*, *m*, *k* (1<=≤<=*n*,<=*m*,<=*k*<=≤<=105). The second line contains *n* integers: *a*1,<=*a*2,<=...,<=*a**n* (0<=≤<=*a**i*<=≤<=105) — the initial array.
Next *m* lines contain operations, the operation number *i* is written as three integers: *l**i*, *r**i*, *d**i*, (1<=≤<=*l**i*<=... | On a single line print *n* integers *a*1,<=*a*2,<=...,<=*a**n* — the array after executing all the queries. Separate the printed numbers by spaces.
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 of the %I64d specifier. | [
"3 3 3\n1 2 3\n1 2 1\n1 3 2\n2 3 4\n1 2\n1 3\n2 3\n",
"1 1 1\n1\n1 1 1\n1 1\n",
"4 3 6\n1 2 3 4\n1 2 1\n2 3 2\n3 4 4\n1 2\n1 3\n2 3\n1 2\n1 3\n2 3\n"
] | [
"9 18 17\n",
"2\n",
"5 18 31 20\n"
] | none | 500 | [
{
"input": "3 3 3\n1 2 3\n1 2 1\n1 3 2\n2 3 4\n1 2\n1 3\n2 3",
"output": "9 18 17"
},
{
"input": "1 1 1\n1\n1 1 1\n1 1",
"output": "2"
},
{
"input": "4 3 6\n1 2 3 4\n1 2 1\n2 3 2\n3 4 4\n1 2\n1 3\n2 3\n1 2\n1 3\n2 3",
"output": "5 18 31 20"
},
{
"input": "1 1 1\n0\n1 1 0\n1 1... | 1,654,240,404 | 2,147,483,647 | Python 3 | COMPILATION_ERROR | TESTS | 0 | 0 | 0 | r=lambda:map(int,raw_input().split())
n,m,k=r()
a=r()
b=[0]*(n+1)
o=[0]*(m+1)
q=[r() for i in range(m)]
for i in range(k):
x,y=r()
o[x-1]+=1
o[y]-=1
f=0
for i,(x,y,d) in enumerate(q):
f+=o[i]
b[x-1]+=d*f
b[y]-=d*f
c=0
for i in range(n):
c+=b[i]
print a[i]+c, | Title: Greg and Array
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Greg has an array *a*<==<=*a*1,<=*a*2,<=...,<=*a**n* and *m* operations. Each operation looks as: *l**i*, *r**i*, *d**i*, (1<=≤<=*l**i*<=≤<=*r**i*<=≤<=*n*). To apply operation *i* to the array means to increase all array... | ```python
r=lambda:map(int,raw_input().split())
n,m,k=r()
a=r()
b=[0]*(n+1)
o=[0]*(m+1)
q=[r() for i in range(m)]
for i in range(k):
x,y=r()
o[x-1]+=1
o[y]-=1
f=0
for i,(x,y,d) in enumerate(q):
f+=o[i]
b[x-1]+=d*f
b[y]-=d*f
c=0
for i in range(n):
c+=b[i]
print a[i]+c,
`... | -1 | MatrixStudio/Codeforces-Python-Submissions | |
560 | B | Gerald is into Art | PROGRAMMING | 1,200 | [
"constructive algorithms",
"implementation"
] | null | null | Gerald bought two very rare paintings at the Sotheby's auction and he now wants to hang them on the wall. For that he bought a special board to attach it to the wall and place the paintings on the board. The board has shape of an *a*1<=×<=*b*1 rectangle, the paintings have shape of a *a*2<=×<=*b*2 and *a*3<=×<=*b*3 rec... | The first line contains two space-separated numbers *a*1 and *b*1 — the sides of the board. Next two lines contain numbers *a*2,<=*b*2,<=*a*3 and *b*3 — the sides of the paintings. All numbers *a**i*,<=*b**i* in the input are integers and fit into the range from 1 to 1000. | If the paintings can be placed on the wall, print "YES" (without the quotes), and if they cannot, print "NO" (without the quotes). | [
"3 2\n1 3\n2 1\n",
"5 5\n3 3\n3 3\n",
"4 2\n2 3\n1 2\n"
] | [
"YES\n",
"NO\n",
"YES\n"
] | That's how we can place the pictures in the first test:
<img class="tex-graphics" src="https://espresso.codeforces.com/b41bf40c649073c6d3dd62eb7ae7adfc4bd131bd.png" style="max-width: 100.0%;max-height: 100.0%;"/>
And that's how we can do it in the third one.
<img class="tex-graphics" src="https://espresso.codeforces... | 1,000 | [
{
"input": "3 2\n1 3\n2 1",
"output": "YES"
},
{
"input": "5 5\n3 3\n3 3",
"output": "NO"
},
{
"input": "4 2\n2 3\n1 2",
"output": "YES"
},
{
"input": "3 3\n1 1\n1 1",
"output": "YES"
},
{
"input": "1000 1000\n999 999\n1 1000",
"output": "YES"
},
{
"in... | 1,437,636,897 | 2,147,483,647 | Python 3 | OK | TESTS | 101 | 62 | 0 | [A,B] = map(int,input().split())
A,B = A+1,B+1
[a,b] = map(int,input().split())
[c,d] = map(int,input().split())
found = 0
for i in range(2):
for j in range(2):
if (a+c<A and b<B and d<B) or (b+d<B and a<A and c<A):
found = 1
a,b = b,a
c,d = d,c
print("YES" if found else "... | Title: Gerald is into Art
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Gerald bought two very rare paintings at the Sotheby's auction and he now wants to hang them on the wall. For that he bought a special board to attach it to the wall and place the paintings on the board. The board ha... | ```python
[A,B] = map(int,input().split())
A,B = A+1,B+1
[a,b] = map(int,input().split())
[c,d] = map(int,input().split())
found = 0
for i in range(2):
for j in range(2):
if (a+c<A and b<B and d<B) or (b+d<B and a<A and c<A):
found = 1
a,b = b,a
c,d = d,c
print("YES" if fo... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
25 | A | IQ test | PROGRAMMING | 1,300 | [
"brute force"
] | A. IQ test | 2 | 256 | Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given *n* numbers differs from the others. Bob observed that one number usually differs from the others in evenness. Help Bob — to check his answers, he needs a program that among the given *n* numbers finds one that i... | The first line contains integer *n* (3<=≤<=*n*<=≤<=100) — amount of numbers in the task. The second line contains *n* space-separated natural numbers, not exceeding 100. It is guaranteed, that exactly one of these numbers differs from the others in evenness. | Output index of number that differs from the others in evenness. Numbers are numbered from 1 in the input order. | [
"5\n2 4 7 8 10\n",
"4\n1 2 1 1\n"
] | [
"3\n",
"2\n"
] | none | 0 | [
{
"input": "5\n2 4 7 8 10",
"output": "3"
},
{
"input": "4\n1 2 1 1",
"output": "2"
},
{
"input": "3\n1 2 2",
"output": "1"
},
{
"input": "3\n100 99 100",
"output": "2"
},
{
"input": "3\n5 3 2",
"output": "3"
},
{
"input": "4\n43 28 1 91",
"output"... | 1,691,161,383 | 2,147,483,647 | Python 3 | OK | TESTS | 32 | 62 | 0 | n=int(input())
l1=list(map(int,input().split()))
cnt1=0
cnt2=0
for i in range(len(l1)):
if l1[i]%2!=0:
cnt1+=1
else:
cnt2+=1
if cnt1>cnt2:
for i in range(len(l1)):
if l1[i]%2==0:
print(i+1)
else:
for i in range(len(l1)):
if l1[i]%2!=0:
... | Title: IQ test
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given *n* numbers differs from the others. Bob observed that one number usually differs from the others in evenness. Help Bob — t... | ```python
n=int(input())
l1=list(map(int,input().split()))
cnt1=0
cnt2=0
for i in range(len(l1)):
if l1[i]%2!=0:
cnt1+=1
else:
cnt2+=1
if cnt1>cnt2:
for i in range(len(l1)):
if l1[i]%2==0:
print(i+1)
else:
for i in range(len(l1)):
if l1[i]%2!=0:... | 3.9845 | MatrixStudio/Codeforces-Python-Submissions |
931 | A | Friends Meeting | PROGRAMMING | 800 | [
"brute force",
"greedy",
"implementation",
"math"
] | null | null | Two friends are on the coordinate axis *Ox* in points with integer coordinates. One of them is in the point *x*1<==<=*a*, another one is in the point *x*2<==<=*b*.
Each of the friends can move by one along the line in any direction unlimited number of times. When a friend moves, the tiredness of a friend changes acco... | The first line contains a single integer *a* (1<=≤<=*a*<=≤<=1000) — the initial position of the first friend.
The second line contains a single integer *b* (1<=≤<=*b*<=≤<=1000) — the initial position of the second friend.
It is guaranteed that *a*<=≠<=*b*. | Print the minimum possible total tiredness if the friends meet in the same point. | [
"3\n4\n",
"101\n99\n",
"5\n10\n"
] | [
"1\n",
"2\n",
"9\n"
] | In the first example the first friend should move by one to the right (then the meeting happens at point 4), or the second friend should move by one to the left (then the meeting happens at point 3). In both cases, the total tiredness becomes 1.
In the second example the first friend should move by one to the left, an... | 500 | [
{
"input": "3\n4",
"output": "1"
},
{
"input": "101\n99",
"output": "2"
},
{
"input": "5\n10",
"output": "9"
},
{
"input": "1\n2",
"output": "1"
},
{
"input": "1\n1000",
"output": "250000"
},
{
"input": "999\n1000",
"output": "1"
},
{
"inpu... | 1,635,761,340 | 2,147,483,647 | PyPy 3-64 | COMPILATION_ERROR | TESTS | 0 | 0 | 0 | x,y=map(int,input().split())
if (x-y)=0:
print("0")
elif (x-y)=1:
print("1")
elif(x-y)=2:
print("2") | Title: Friends Meeting
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Two friends are on the coordinate axis *Ox* in points with integer coordinates. One of them is in the point *x*1<==<=*a*, another one is in the point *x*2<==<=*b*.
Each of the friends can move by one along the line in... | ```python
x,y=map(int,input().split())
if (x-y)=0:
print("0")
elif (x-y)=1:
print("1")
elif(x-y)=2:
print("2")
``` | -1 | MatrixStudio/Codeforces-Python-Submissions | |
66 | A | Petya and Java | PROGRAMMING | 1,300 | [
"implementation",
"strings"
] | A. Petya and Java | 2 | 256 | 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 h... | 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). | 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. | [
"127\n",
"130\n",
"123456789101112131415161718192021222324\n"
] | [
"byte\n",
"short\n",
"BigInteger\n"
] | none | 500 | [
{
"input": "127",
"output": "byte"
},
{
"input": "130",
"output": "short"
},
{
"input": "123456789101112131415161718192021222324",
"output": "BigInteger"
},
{
"input": "6",
"output": "byte"
},
{
"input": "16",
"output": "byte"
},
{
"input": "126",
... | 1,671,117,572 | 2,147,483,647 | PyPy 3-64 | COMPILATION_ERROR | TESTS | 0 | 0 | 0 | # Parse the input
n = int(input())
# Calculate the number of digits in the given number
num_digits = len(str(n))
# Check which data type can store the given number
if num_digits <= 3:
# The byte data type can store numbers with up to 3 digits
print("byte")
else if num_digits <= 5:
# The short data ty... | Title: Petya and Java
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
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 ... | ```python
# Parse the input
n = int(input())
# Calculate the number of digits in the given number
num_digits = len(str(n))
# Check which data type can store the given number
if num_digits <= 3:
# The byte data type can store numbers with up to 3 digits
print("byte")
else if num_digits <= 5:
# The sho... | -1 | MatrixStudio/Codeforces-Python-Submissions |
932 | A | Palindromic Supersequence | PROGRAMMING | 800 | [
"constructive algorithms"
] | null | null | You are given a string *A*. Find a string *B*, where *B* is a palindrome and *A* is a subsequence of *B*.
A subsequence of a string is a string that can be derived from it by deleting some (not necessarily consecutive) characters without changing the order of the remaining characters. For example, "cotst" is a subsequ... | First line contains a string *A* (1<=≤<=|*A*|<=≤<=103) consisting of lowercase Latin letters, where |*A*| is a length of *A*. | Output single line containing *B* consisting of only lowercase Latin letters. You do not need to find the shortest answer, the only restriction is that the length of string *B* should not exceed 104. If there are many possible *B*, print any of them. | [
"aba\n",
"ab\n"
] | [
"aba",
"aabaa"
] | In the first example, "aba" is a subsequence of "aba" which is a palindrome.
In the second example, "ab" is a subsequence of "aabaa" which is a palindrome. | 500 | [
{
"input": "aba",
"output": "abaaba"
},
{
"input": "ab",
"output": "abba"
},
{
"input": "krnyoixirslfszfqivgkaflgkctvbvksipwomqxlyqxhlbceuhbjbfnhofcgpgwdseffycthmlpcqejgskwjkbkbbmifnurnwyhevsoqzmtvzgfiqajfrgyuzxnrtxectcnlyoisbglpdbjbslxlpoymrcxmdtqhcnlvtqdwftuzgbdxsyscwbrguostbelnvtaqdmk... | 1,650,974,517 | 2,147,483,647 | Python 3 | OK | TESTS | 48 | 46 | 0 | def ishuiwen(x):
if x==x[::-1]:
return True
else:
return False
if __name__=='__main__':
a=input()
if ishuiwen(a)==True:
print(a)
else:
b=a+a[::-1]
print(b)
| Title: Palindromic Supersequence
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given a string *A*. Find a string *B*, where *B* is a palindrome and *A* is a subsequence of *B*.
A subsequence of a string is a string that can be derived from it by deleting some (not necessarily co... | ```python
def ishuiwen(x):
if x==x[::-1]:
return True
else:
return False
if __name__=='__main__':
a=input()
if ishuiwen(a)==True:
print(a)
else:
b=a+a[::-1]
print(b)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
591 | A | Wizards' Duel | PROGRAMMING | 900 | [
"implementation",
"math"
] | null | null | Harry Potter and He-Who-Must-Not-Be-Named engaged in a fight to the death once again. This time they are located at opposite ends of the corridor of length *l*. Two opponents simultaneously charge a deadly spell in the enemy. We know that the impulse of Harry's magic spell flies at a speed of *p* meters per second, and... | The first line of the input contains a single integer *l* (1<=≤<=*l*<=≤<=1<=000) — the length of the corridor where the fight takes place.
The second line contains integer *p*, the third line contains integer *q* (1<=≤<=*p*,<=*q*<=≤<=500) — the speeds of magical impulses for Harry Potter and He-Who-Must-Not-Be-Named, ... | Print a single real number — the distance from the end of the corridor, where Harry is located, to the place of the second meeting of the spell impulses. Your answer will be considered correct if its absolute or relative error will not exceed 10<=-<=4.
Namely: let's assume that your answer equals *a*, and the answer ... | [
"100\n50\n50\n",
"199\n60\n40\n"
] | [
"50\n",
"119.4\n"
] | In the first sample the speeds of the impulses are equal, so both of their meetings occur exactly in the middle of the corridor. | 500 | [
{
"input": "100\n50\n50",
"output": "50"
},
{
"input": "199\n60\n40",
"output": "119.4"
},
{
"input": "1\n1\n1",
"output": "0.5"
},
{
"input": "1\n1\n500",
"output": "0.001996007984"
},
{
"input": "1\n500\n1",
"output": "0.998003992"
},
{
"input": "1\n... | 1,698,610,018 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 15 | 0 | train_fare = int(get_text_from_image(image, "train_fare"))
bus_fare = int(get_text_from_image(image, "bus_fare"))
discounted_bus_fare = bus_fare // 2
total_cost = train_fare + discounted_bus_fare
print(total_cost)
| Title: Wizards' Duel
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Harry Potter and He-Who-Must-Not-Be-Named engaged in a fight to the death once again. This time they are located at opposite ends of the corridor of length *l*. Two opponents simultaneously charge a deadly spell in the en... | ```python
train_fare = int(get_text_from_image(image, "train_fare"))
bus_fare = int(get_text_from_image(image, "bus_fare"))
discounted_bus_fare = bus_fare // 2
total_cost = train_fare + discounted_bus_fare
print(total_cost)
``` | -1 | MatrixStudio/Codeforces-Python-Submissions | |
705 | A | Hulk | PROGRAMMING | 800 | [
"implementation"
] | null | null | Dr. Bruce Banner hates his enemies (like others don't). As we all know, he can barely talk when he turns into the incredible Hulk. That's why he asked you to help him to express his feelings.
Hulk likes the Inception so much, and like that his feelings are complicated. They have *n* layers. The first layer is hate, se... | The only line of the input contains a single integer *n* (1<=≤<=*n*<=≤<=100) — the number of layers of love and hate. | Print Dr.Banner's feeling in one line. | [
"1\n",
"2\n",
"3\n"
] | [
"I hate it\n",
"I hate that I love it\n",
"I hate that I love that I hate it\n"
] | none | 500 | [
{
"input": "1",
"output": "I hate it"
},
{
"input": "2",
"output": "I hate that I love it"
},
{
"input": "3",
"output": "I hate that I love that I hate it"
},
{
"input": "4",
"output": "I hate that I love that I hate that I love it"
},
{
"input": "5",
"output"... | 1,686,290,016 | 2,147,483,647 | Python 3 | OK | TESTS | 21 | 46 | 0 | a = int(input())
hate = 'I hate'
love = 'I love'
result = ''
for i in range(a):
if i%2 == 0:
if i == 0:
result += hate
else:
result += ' that ' + hate
else:
result += ' that ' + love
result += ' it'
print(result) | Title: Hulk
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Dr. Bruce Banner hates his enemies (like others don't). As we all know, he can barely talk when he turns into the incredible Hulk. That's why he asked you to help him to express his feelings.
Hulk likes the Inception so much, and... | ```python
a = int(input())
hate = 'I hate'
love = 'I love'
result = ''
for i in range(a):
if i%2 == 0:
if i == 0:
result += hate
else:
result += ' that ' + hate
else:
result += ' that ' + love
result += ' it'
print(result)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
764 | B | Timofey and cubes | PROGRAMMING | 900 | [
"constructive algorithms",
"implementation"
] | null | null | Young Timofey has a birthday today! He got kit of *n* cubes as a birthday present from his parents. Every cube has a number *a**i*, which is written on it. Timofey put all the cubes in a row and went to unpack other presents.
In this time, Timofey's elder brother, Dima reordered the cubes using the following rule. Sup... | The first line contains single integer *n* (1<=≤<=*n*<=≤<=2·105) — the number of cubes.
The second line contains *n* integers *a*1,<=*a*2,<=...,<=*a**n* (<=-<=109<=≤<=*a**i*<=≤<=109), where *a**i* is the number written on the *i*-th cube after Dima has changed their order. | Print *n* integers, separated by spaces — the numbers written on the cubes in their initial order.
It can be shown that the answer is unique. | [
"7\n4 3 7 6 9 1 2\n",
"8\n6 1 4 2 5 6 9 2\n"
] | [
"2 3 9 6 7 1 4",
"2 1 6 2 5 4 9 6"
] | Consider the first sample.
1. At the begining row was [2, 3, 9, 6, 7, 1, 4]. 1. After first operation row was [4, 1, 7, 6, 9, 3, 2]. 1. After second operation row was [4, 3, 9, 6, 7, 1, 2]. 1. After third operation row was [4, 3, 7, 6, 9, 1, 2]. 1. At fourth operation we reverse just middle element, so nothing ha... | 1,000 | [
{
"input": "7\n4 3 7 6 9 1 2",
"output": "2 3 9 6 7 1 4"
},
{
"input": "8\n6 1 4 2 5 6 9 2",
"output": "2 1 6 2 5 4 9 6"
},
{
"input": "1\n1424",
"output": "1424"
},
{
"input": "9\n-7 9 -4 9 -6 11 15 2 -10",
"output": "-10 9 15 9 -6 11 -4 2 -7"
},
{
"input": "2\n2... | 1,637,771,712 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 0 | 46 | 0 | # https://codeforces.com/problemset/problem/764/B
n = int(input())
cubes = list(map(int,input().split()))
if n % 2 == 0 :
i = n //2
j = i - 1
else:
i = j = n//2
def reverse1(arr):
return arr[::-1]
while i >= 0 and j < n :
cubes[i:j+1] = reverse1(cubes[i:j+1])
i -=1
... | Title: Timofey and cubes
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Young Timofey has a birthday today! He got kit of *n* cubes as a birthday present from his parents. Every cube has a number *a**i*, which is written on it. Timofey put all the cubes in a row and went to unpack other p... | ```python
# https://codeforces.com/problemset/problem/764/B
n = int(input())
cubes = list(map(int,input().split()))
if n % 2 == 0 :
i = n //2
j = i - 1
else:
i = j = n//2
def reverse1(arr):
return arr[::-1]
while i >= 0 and j < n :
cubes[i:j+1] = reverse1(cubes[i:j+1])
... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
764 | A | Taymyr is calling you | PROGRAMMING | 800 | [
"brute force",
"implementation",
"math"
] | null | null | 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*, 2*n*, 3*n* and so on. Artists come to the comrade every *m* minutes, i.e. in minutes *m*, 2*m*, 3*m* and so on. The day is *z* minutes long,... | The only string contains three integers — *n*, *m* and *z* (1<=≤<=*n*,<=*m*,<=*z*<=≤<=104). | Print single integer — the minimum number of artists that should be killed so that there are no artists in the room when Ilia calls. | [
"1 1 10\n",
"1 2 5\n",
"2 3 9\n"
] | [
"10\n",
"2\n",
"1\n"
] | Taymyr 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. | 500 | [
{
"input": "1 1 10",
"output": "10"
},
{
"input": "1 2 5",
"output": "2"
},
{
"input": "2 3 9",
"output": "1"
},
{
"input": "4 8 9",
"output": "1"
},
{
"input": "7 9 2",
"output": "0"
},
{
"input": "10000 10000 10000",
"output": "1"
},
{
"i... | 1,599,670,771 | 2,147,483,647 | PyPy 3 | OK | TESTS | 32 | 140 | 0 | from math import gcd
if __name__ == '__main__':
n,m,z = map(int, input().split())
print(z // (n*m // gcd(n,m)))
| Title: Taymyr is calling you
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
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*, 2*n*, 3*n* and so on. Artists com... | ```python
from math import gcd
if __name__ == '__main__':
n,m,z = map(int, input().split())
print(z // (n*m // gcd(n,m)))
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
496 | B | Secret Combination | PROGRAMMING | 1,500 | [
"brute force",
"constructive algorithms",
"implementation"
] | null | null | You got a box with a combination lock. The lock has a display showing *n* digits. There are two buttons on the box, each button changes digits on the display. You have quickly discovered that the first button adds 1 to all the digits (all digits 9 become digits 0), and the second button shifts all the digits on the dis... | The first line contains a single integer *n* (1<=≤<=*n*<=≤<=1000) — the number of digits on the display.
The second line contains *n* digits — the initial state of the display. | Print a single line containing *n* digits — the desired state of the display containing the smallest possible number. | [
"3\n579\n",
"4\n2014\n"
] | [
"024\n",
"0142\n"
] | none | 1,000 | [
{
"input": "3\n579",
"output": "024"
},
{
"input": "4\n2014",
"output": "0142"
},
{
"input": "1\n1",
"output": "0"
},
{
"input": "3\n039",
"output": "014"
},
{
"input": "4\n4444",
"output": "0000"
},
{
"input": "5\n46802",
"output": "02468"
},
... | 1,619,933,026 | 2,147,483,647 | PyPy 3 | OK | TESTS | 28 | 171 | 10,137,600 | R = lambda: map(int, input().split())
n = int(input())
nums = [int(c) for c in input()]
res = [9] * 1006
for i in range(n):
wnms = nums[i:] + nums[:i]
res = min([res] + [[(wnms[k] + j) % 10 for k in range(n)] for j in range(10)])
print(''.join(map(str, res))) | Title: Secret Combination
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You got a box with a combination lock. The lock has a display showing *n* digits. There are two buttons on the box, each button changes digits on the display. You have quickly discovered that the first button adds 1 ... | ```python
R = lambda: map(int, input().split())
n = int(input())
nums = [int(c) for c in input()]
res = [9] * 1006
for i in range(n):
wnms = nums[i:] + nums[:i]
res = min([res] + [[(wnms[k] + j) % 10 for k in range(n)] for j in range(10)])
print(''.join(map(str, res)))
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
730 | J | Bottles | PROGRAMMING | 1,900 | [
"dp"
] | null | null | Nick has *n* bottles of soda left after his birthday. Each bottle is described by two values: remaining amount of soda *a**i* and bottle volume *b**i* (*a**i*<=≤<=*b**i*).
Nick has decided to pour all remaining soda into minimal number of bottles, moreover he has to do it as soon as possible. Nick spends *x* seconds t... | The first line contains positive integer *n* (1<=≤<=*n*<=≤<=100) — the number of bottles.
The second line contains *n* positive integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=100), where *a**i* is the amount of soda remaining in the *i*-th bottle.
The third line contains *n* positive integers *b*1,<=*b*2,<=...... | The only line should contain two integers *k* and *t*, where *k* is the minimal number of bottles that can store all the soda and *t* is the minimal time to pour the soda into *k* bottles. | [
"4\n3 3 4 3\n4 7 6 5\n",
"2\n1 1\n100 100\n",
"5\n10 30 5 6 24\n10 41 7 8 24\n"
] | [
"2 6\n",
"1 1\n",
"3 11\n"
] | In the first example Nick can pour soda from the first bottle to the second bottle. It will take 3 seconds. After it the second bottle will contain 3 + 3 = 6 units of soda. Then he can pour soda from the fourth bottle to the second bottle and to the third bottle: one unit to the second and two units to the third. It wi... | 0 | [
{
"input": "4\n3 3 4 3\n4 7 6 5",
"output": "2 6"
},
{
"input": "2\n1 1\n100 100",
"output": "1 1"
},
{
"input": "5\n10 30 5 6 24\n10 41 7 8 24",
"output": "3 11"
},
{
"input": "1\n1\n100",
"output": "1 0"
},
{
"input": "1\n100\n100",
"output": "1 0"
},
{
... | 1,688,617,095 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 6 | 46 | 0 | import sys
# sys.stdin = open("input","r")
n = int(input())
arr = list(map(int, input().split()))
brr = list(map(int, input().split()))
idx = list(range(n))
idx.sort(key=lambda x: (brr[x],arr[x]))
empty = sum(brr)-sum(arr)
cur = 0
s = 0
while cur < n:
i = idx[cur]
if empty < brr[i]:
s += max(0,em... | Title: Bottles
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Nick has *n* bottles of soda left after his birthday. Each bottle is described by two values: remaining amount of soda *a**i* and bottle volume *b**i* (*a**i*<=≤<=*b**i*).
Nick has decided to pour all remaining soda into minim... | ```python
import sys
# sys.stdin = open("input","r")
n = int(input())
arr = list(map(int, input().split()))
brr = list(map(int, input().split()))
idx = list(range(n))
idx.sort(key=lambda x: (brr[x],arr[x]))
empty = sum(brr)-sum(arr)
cur = 0
s = 0
while cur < n:
i = idx[cur]
if empty < brr[i]:
s +... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
716 | A | Crazy Computer | PROGRAMMING | 800 | [
"implementation"
] | null | null | ZS the Coder is coding on a crazy computer. If you don't type in a word for a *c* consecutive seconds, everything you typed disappear!
More formally, if you typed a word at second *a* and then the next word at second *b*, then if *b*<=-<=*a*<=≤<=*c*, just the new word is appended to other words on the screen. If *b*<... | The first line contains two integers *n* and *c* (1<=≤<=*n*<=≤<=100<=000,<=1<=≤<=*c*<=≤<=109) — the number of words ZS the Coder typed and the crazy computer delay respectively.
The next line contains *n* integers *t*1,<=*t*2,<=...,<=*t**n* (1<=≤<=*t*1<=<<=*t*2<=<<=...<=<<=*t**n*<=≤<=109), where *t**i* denote... | Print a single positive integer, the number of words that remain on the screen after all *n* words was typed, in other words, at the second *t**n*. | [
"6 5\n1 3 8 14 19 20\n",
"6 1\n1 3 5 7 9 10\n"
] | [
"3",
"2"
] | The first sample is already explained in the problem statement.
For the second sample, after typing the first word at the second 1, it disappears because the next word is typed at the second 3 and 3 - 1 > 1. Similarly, only 1 word will remain at the second 9. Then, a word is typed at the second 10, so there will be... | 500 | [
{
"input": "6 5\n1 3 8 14 19 20",
"output": "3"
},
{
"input": "6 1\n1 3 5 7 9 10",
"output": "2"
},
{
"input": "1 1\n1000000000",
"output": "1"
},
{
"input": "5 5\n1 7 12 13 14",
"output": "4"
},
{
"input": "2 1000000000\n1 1000000000",
"output": "2"
},
{
... | 1,593,966,008 | 2,147,483,647 | Python 3 | OK | TESTS | 81 | 217 | 15,667,200 | n,c2=map(int,input().split())
l=list(map(int,input().split()))
i=1
c=l[0]
c1=0
while(i<len(l)):
if((l[i]-l[i-1])<=c2):
c1+=1
else:
c1=0
c=l[i]
i+=1
print(c1+1)
| Title: Crazy Computer
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
ZS the Coder is coding on a crazy computer. If you don't type in a word for a *c* consecutive seconds, everything you typed disappear!
More formally, if you typed a word at second *a* and then the next word at second *... | ```python
n,c2=map(int,input().split())
l=list(map(int,input().split()))
i=1
c=l[0]
c1=0
while(i<len(l)):
if((l[i]-l[i-1])<=c2):
c1+=1
else:
c1=0
c=l[i]
i+=1
print(c1+1)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
379 | A | New Year Candles | PROGRAMMING | 1,000 | [
"implementation"
] | null | null | Vasily the Programmer loves romance, so this year he decided to illuminate his room with candles.
Vasily has *a* candles.When Vasily lights up a new candle, it first burns for an hour and then it goes out. Vasily is smart, so he can make *b* went out candles into a new candle. As a result, this new candle can be used ... | The single line contains two integers, *a* and *b* (1<=≤<=*a*<=≤<=1000; 2<=≤<=*b*<=≤<=1000). | Print a single integer — the number of hours Vasily can light up the room for. | [
"4 2\n",
"6 3\n"
] | [
"7\n",
"8\n"
] | Consider the first sample. For the first four hours Vasily lights up new candles, then he uses four burned out candles to make two new ones and lights them up. When these candles go out (stop burning), Vasily can make another candle. Overall, Vasily can light up the room for 7 hours. | 500 | [
{
"input": "4 2",
"output": "7"
},
{
"input": "6 3",
"output": "8"
},
{
"input": "1000 1000",
"output": "1001"
},
{
"input": "123 5",
"output": "153"
},
{
"input": "1000 2",
"output": "1999"
},
{
"input": "1 2",
"output": "1"
},
{
"input": ... | 1,697,451,325 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 3 | 62 | 0 | candles, re = input().split(" ")
candles, re = int(candles), int(re)
hrs = 0
while candles >= re:
hrs += candles
dead = candles
candles = dead // re
dead -= candles
print(hrs+candles) | Title: New Year Candles
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vasily the Programmer loves romance, so this year he decided to illuminate his room with candles.
Vasily has *a* candles.When Vasily lights up a new candle, it first burns for an hour and then it goes out. Vasily is s... | ```python
candles, re = input().split(" ")
candles, re = int(candles), int(re)
hrs = 0
while candles >= re:
hrs += candles
dead = candles
candles = dead // re
dead -= candles
print(hrs+candles)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
499 | B | Lecture | PROGRAMMING | 1,000 | [
"implementation",
"strings"
] | null | null | You have a new professor of graph theory and he speaks very quickly. You come up with the following plan to keep up with his lecture and make notes.
You know two languages, and the professor is giving the lecture in the first one. The words in both languages consist of lowercase English characters, each language consi... | The first line contains two integers, *n* and *m* (1<=≤<=*n*<=≤<=3000, 1<=≤<=*m*<=≤<=3000) — the number of words in the professor's lecture and the number of words in each of these languages.
The following *m* lines contain the words. The *i*-th line contains two strings *a**i*, *b**i* meaning that the word *a**i* bel... | Output exactly *n* words: how you will record the lecture in your notebook. Output the words of the lecture in the same order as in the input. | [
"4 3\ncodeforces codesecrof\ncontest round\nletter message\ncodeforces contest letter contest\n",
"5 3\njoll wuqrd\neuzf un\nhbnyiyc rsoqqveh\nhbnyiyc joll joll euzf joll\n"
] | [
"codeforces round letter round\n",
"hbnyiyc joll joll un joll\n"
] | none | 500 | [
{
"input": "4 3\ncodeforces codesecrof\ncontest round\nletter message\ncodeforces contest letter contest",
"output": "codeforces round letter round"
},
{
"input": "5 3\njoll wuqrd\neuzf un\nhbnyiyc rsoqqveh\nhbnyiyc joll joll euzf joll",
"output": "hbnyiyc joll joll un joll"
},
{
"input"... | 1,623,414,305 | 2,147,483,647 | Python 3 | OK | TESTS | 37 | 62 | 409,600 | n, m = map(int,input().split())
d = {}
for i in range(m):
a, b = input().split()
d[a] = b
s = list(input().split())
r = []
for i in s:
if len(i)<=len(d[i]):
r.append(i)
else:
r.append(d[i])
print(*r)
| Title: Lecture
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You have a new professor of graph theory and he speaks very quickly. You come up with the following plan to keep up with his lecture and make notes.
You know two languages, and the professor is giving the lecture in the first ... | ```python
n, m = map(int,input().split())
d = {}
for i in range(m):
a, b = input().split()
d[a] = b
s = list(input().split())
r = []
for i in s:
if len(i)<=len(d[i]):
r.append(i)
else:
r.append(d[i])
print(*r)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
254 | B | Jury Size | PROGRAMMING | 1,500 | [
"brute force",
"implementation"
] | null | null | In 2013, the writers of Berland State University should prepare problems for *n* Olympiads. We will assume that the Olympiads are numbered with consecutive integers from 1 to *n*. For each Olympiad we know how many members of the jury must be involved in its preparation, as well as the time required to prepare the prob... | The first line contains integer *n* — the number of Olympiads in 2013 (1<=≤<=*n*<=≤<=100). Each of the following *n* lines contains four integers *m**i*, *d**i*, *p**i* and *t**i* — the month and day of the Olympiad (given without leading zeroes), the needed number of the jury members and the time needed to prepare the... | Print a single number — the minimum jury size. | [
"2\n5 23 1 2\n3 13 2 3\n",
"3\n12 9 2 1\n12 8 1 3\n12 8 2 2\n",
"1\n1 10 1 13\n"
] | [
"2\n",
"3\n",
"1\n"
] | none | 1,000 | [
{
"input": "2\n5 23 1 2\n3 13 2 3",
"output": "2"
},
{
"input": "3\n12 9 2 1\n12 8 1 3\n12 8 2 2",
"output": "3"
},
{
"input": "1\n1 10 1 13",
"output": "1"
},
{
"input": "3\n3 16 25 1\n3 15 9 34\n3 14 90 87",
"output": "99"
},
{
"input": "4\n2 15 52 53\n2 15 35 8... | 1,378,354,264 | 2,147,483,647 | Python 3 | COMPILATION_ERROR | TESTS | 0 | 0 | 0 | import sys
from heapq import *
months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
def convert(m, d):
r = 0
if (m == 1):
return d
for i in xrange(m-1):
r += months[i]
return r+d
inputs = sys.stdin.readline()
n = int(inputs[0])
l = [0] * n
for i in xrange(n):
inputs = sys.... | Title: Jury Size
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
In 2013, the writers of Berland State University should prepare problems for *n* Olympiads. We will assume that the Olympiads are numbered with consecutive integers from 1 to *n*. For each Olympiad we know how many members of... | ```python
import sys
from heapq import *
months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
def convert(m, d):
r = 0
if (m == 1):
return d
for i in xrange(m-1):
r += months[i]
return r+d
inputs = sys.stdin.readline()
n = int(inputs[0])
l = [0] * n
for i in xrange(n):
inp... | -1 | MatrixStudio/Codeforces-Python-Submissions | |
144 | A | Arrival of the General | PROGRAMMING | 800 | [
"implementation"
] | null | null | A Ministry for Defense sent a general to inspect the Super Secret Military Squad under the command of the Colonel SuperDuper. Having learned the news, the colonel ordered to all *n* squad soldiers to line up on the parade ground.
By the military charter the soldiers should stand in the order of non-increasing of their... | The first input line contains the only integer *n* (2<=≤<=*n*<=≤<=100) which represents the number of soldiers in the line. The second line contains integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=100) the values of the soldiers' heights in the order of soldiers' heights' increasing in the order from the beginnin... | Print the only integer — the minimum number of seconds the colonel will need to form a line-up the general will like. | [
"4\n33 44 11 22\n",
"7\n10 10 58 31 63 40 76\n"
] | [
"2\n",
"10\n"
] | In the first sample the colonel will need to swap the first and second soldier and then the third and fourth soldier. That will take 2 seconds. The resulting position of the soldiers is (44, 33, 22, 11).
In the second sample the colonel may swap the soldiers in the following sequence:
1. (10, 10, 58, 31, 63, 40, 76)... | 500 | [
{
"input": "4\n33 44 11 22",
"output": "2"
},
{
"input": "7\n10 10 58 31 63 40 76",
"output": "10"
},
{
"input": "2\n88 89",
"output": "1"
},
{
"input": "5\n100 95 100 100 88",
"output": "0"
},
{
"input": "7\n48 48 48 48 45 45 45",
"output": "0"
},
{
"... | 1,691,986,510 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 60 | 0 | def min_swaps_to_correct_lineup(n, heights):
max_height = heights[0]
min_height = heights[-1]
taller_than_first = sum(1 for height in heights if height > max_height)
shorter_than_last = sum(1 for height in heights if height < min_height)
return taller_than_first + shorter_than_last
n = int(inp... | Title: Arrival of the General
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
A Ministry for Defense sent a general to inspect the Super Secret Military Squad under the command of the Colonel SuperDuper. Having learned the news, the colonel ordered to all *n* squad soldiers to line up on t... | ```python
def min_swaps_to_correct_lineup(n, heights):
max_height = heights[0]
min_height = heights[-1]
taller_than_first = sum(1 for height in heights if height > max_height)
shorter_than_last = sum(1 for height in heights if height < min_height)
return taller_than_first + shorter_than_last
n... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
59 | A | Word | PROGRAMMING | 800 | [
"implementation",
"strings"
] | A. Word | 2 | 256 | Vasya is very upset that many people on the Net mix uppercase and lowercase letters in one word. That's why he decided to invent an extension for his favorite browser that would change the letters' register in every word so that it either only consisted of lowercase letters or, vice versa, only of uppercase ones. At th... | The first line contains a word *s* — it consists of uppercase and lowercase Latin letters and possesses the length from 1 to 100. | Print the corrected word *s*. If the given word *s* has strictly more uppercase letters, make the word written in the uppercase register, otherwise - in the lowercase one. | [
"HoUse\n",
"ViP\n",
"maTRIx\n"
] | [
"house\n",
"VIP\n",
"matrix\n"
] | none | 500 | [
{
"input": "HoUse",
"output": "house"
},
{
"input": "ViP",
"output": "VIP"
},
{
"input": "maTRIx",
"output": "matrix"
},
{
"input": "BNHWpnpawg",
"output": "bnhwpnpawg"
},
{
"input": "VTYGP",
"output": "VTYGP"
},
{
"input": "CHNenu",
"output": "chn... | 1,612,802,208 | 2,147,483,647 | Python 3 | OK | TESTS | 30 | 124 | 0 | s = input()
lower = ""
upper = ""
for i in s:
if i.isupper():
upper += i
elif i.islower():
lower += i
if len(lower)>=len(upper):
print(s.lower())
else:
print(s.upper())
| Title: Word
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Vasya is very upset that many people on the Net mix uppercase and lowercase letters in one word. That's why he decided to invent an extension for his favorite browser that would change the letters' register in every word so that it ei... | ```python
s = input()
lower = ""
upper = ""
for i in s:
if i.isupper():
upper += i
elif i.islower():
lower += i
if len(lower)>=len(upper):
print(s.lower())
else:
print(s.upper())
``` | 3.969 | MatrixStudio/Codeforces-Python-Submissions |
867 | A | Between the Offices | PROGRAMMING | 800 | [
"implementation"
] | null | null | As you may know, MemSQL has American offices in both San Francisco and Seattle. Being a manager in the company, you travel a lot between the two cities, always by plane.
You prefer flying from Seattle to San Francisco than in the other direction, because it's warmer in San Francisco. You are so busy that you don't rem... | The first line of input contains single integer *n* (2<=≤<=*n*<=≤<=100) — the number of days.
The second line contains a string of length *n* consisting of only capital 'S' and 'F' letters. If the *i*-th letter is 'S', then you were in Seattle office on that day. Otherwise you were in San Francisco. The days are given... | Print "YES" if you flew more times from Seattle to San Francisco, and "NO" otherwise.
You can print each letter in any case (upper or lower). | [
"4\nFSSF\n",
"2\nSF\n",
"10\nFFFFFFFFFF\n",
"10\nSSFFSFFSFF\n"
] | [
"NO\n",
"YES\n",
"NO\n",
"YES\n"
] | In the first example you were initially at San Francisco, then flew to Seattle, were there for two days and returned to San Francisco. You made one flight in each direction, so the answer is "NO".
In the second example you just flew from Seattle to San Francisco, so the answer is "YES".
In the third example you staye... | 500 | [
{
"input": "4\nFSSF",
"output": "NO"
},
{
"input": "2\nSF",
"output": "YES"
},
{
"input": "10\nFFFFFFFFFF",
"output": "NO"
},
{
"input": "10\nSSFFSFFSFF",
"output": "YES"
},
{
"input": "20\nSFSFFFFSSFFFFSSSSFSS",
"output": "NO"
},
{
"input": "20\nSSFFF... | 1,666,639,524 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 30 | 0 | n=int(input())
str=input()
fs=0
sf=0
for i in str:
if(i=="F" and i+1=="S"):
fs=fs+1
elif(i=="S" and i+1=="F"):
sf=sf+1
if(sf>fs):
print("YES")
else:
print("NO") | Title: Between the Offices
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
As you may know, MemSQL has American offices in both San Francisco and Seattle. Being a manager in the company, you travel a lot between the two cities, always by plane.
You prefer flying from Seattle to San Franci... | ```python
n=int(input())
str=input()
fs=0
sf=0
for i in str:
if(i=="F" and i+1=="S"):
fs=fs+1
elif(i=="S" and i+1=="F"):
sf=sf+1
if(sf>fs):
print("YES")
else:
print("NO")
``` | -1 | MatrixStudio/Codeforces-Python-Submissions | |
682 | C | Alyona and the Tree | PROGRAMMING | 1,600 | [
"dfs and similar",
"dp",
"graphs",
"trees"
] | null | null | Alyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on.
The girl noticed that some of the tree's vertices are sad, so she decided to play with them. Let's call ver... | In the first line of the input integer *n* (1<=≤<=*n*<=≤<=105) is given — the number of vertices in the tree.
In the second line the sequence of *n* integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=109) is given, where *a**i* is the number written on vertex *i*.
The next *n*<=-<=1 lines describe tree edges: *i**... | Print the only integer — the minimum number of leaves Alyona needs to remove such that there will be no any sad vertex left in the tree. | [
"9\n88 22 83 14 95 91 98 53 11\n3 24\n7 -8\n1 67\n1 64\n9 65\n5 12\n6 -80\n3 8\n"
] | [
"5\n"
] | The following image represents possible process of removing leaves from the tree: | 1,500 | [
{
"input": "9\n88 22 83 14 95 91 98 53 11\n3 24\n7 -8\n1 67\n1 64\n9 65\n5 12\n6 -80\n3 8",
"output": "5"
},
{
"input": "6\n53 82 15 77 71 23\n5 -77\n6 -73\n2 0\n1 26\n4 -92",
"output": "0"
},
{
"input": "10\n99 60 68 46 51 11 96 41 48 99\n4 50\n6 -97\n3 -92\n7 1\n9 99\n2 79\n1 -15\n8 -6... | 1,603,993,479 | 2,147,483,647 | Python 3 | OK | TESTS | 106 | 577 | 17,100,800 | from collections import deque
n = int(input())
val = [int(x) for x in input().split()]
dist = [0] * (n+1)
g = [[]for i in range(n+1)]
for i in range(2, n+1):
a, b = map(int, input().split())
g[a].append((i,b))
r = 0
retira = [False]*(n+1)
pilha = deque([1])
while pilha:
v = pilha.pop()
if retira[v]:
... | Title: Alyona and the Tree
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Alyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on.
Th... | ```python
from collections import deque
n = int(input())
val = [int(x) for x in input().split()]
dist = [0] * (n+1)
g = [[]for i in range(n+1)]
for i in range(2, n+1):
a, b = map(int, input().split())
g[a].append((i,b))
r = 0
retira = [False]*(n+1)
pilha = deque([1])
while pilha:
v = pilha.pop()
if re... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
722 | C | Destroying Array | PROGRAMMING | 1,600 | [
"data structures",
"dsu"
] | null | null | You are given an array consisting of *n* non-negative integers *a*1,<=*a*2,<=...,<=*a**n*.
You are going to destroy integers in the array one by one. Thus, you are given the permutation of integers from 1 to *n* defining the order elements of the array are destroyed.
After each element is destroyed you have to find o... | The first line of the input contains a single integer *n* (1<=≤<=*n*<=≤<=100<=000) — the length of the array.
The second line contains *n* integers *a*1,<=*a*2,<=...,<=*a**n* (0<=≤<=*a**i*<=≤<=109).
The third line contains a permutation of integers from 1 to *n* — the order used to destroy elements. | Print *n* lines. The *i*-th line should contain a single integer — the maximum possible sum of elements on the segment containing no destroyed elements, after first *i* operations are performed. | [
"4\n1 3 2 5\n3 4 1 2\n",
"5\n1 2 3 4 5\n4 2 3 5 1\n",
"8\n5 5 4 4 6 6 5 5\n5 2 8 7 1 3 4 6\n"
] | [
"5\n4\n3\n0\n",
"6\n5\n5\n1\n0\n",
"18\n16\n11\n8\n8\n6\n6\n0\n"
] | Consider the first sample:
1. Third element is destroyed. Array is now 1 3 * 5. Segment with maximum sum 5 consists of one integer 5. 1. Fourth element is destroyed. Array is now 1 3 * * . Segment with maximum sum 4 consists of two integers 1 3. 1. First element is destroyed. Array is now * 3 * * . Segme... | 1,000 | [
{
"input": "4\n1 3 2 5\n3 4 1 2",
"output": "5\n4\n3\n0"
},
{
"input": "5\n1 2 3 4 5\n4 2 3 5 1",
"output": "6\n5\n5\n1\n0"
},
{
"input": "8\n5 5 4 4 6 6 5 5\n5 2 8 7 1 3 4 6",
"output": "18\n16\n11\n8\n8\n6\n6\n0"
},
{
"input": "10\n3 3 3 5 6 9 3 1 7 3\n3 4 6 7 5 1 10 9 2 8"... | 1,617,359,716 | 2,147,483,647 | PyPy 3 | OK | TESTS | 49 | 592 | 27,852,800 | ###### ### ####### ####### ## # ##### ### #####
# # # # # # # # # # # # # ###
# # # # # # # # # # # # # ###
###### ######### # # # # # # ... | Title: Destroying Array
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given an array consisting of *n* non-negative integers *a*1,<=*a*2,<=...,<=*a**n*.
You are going to destroy integers in the array one by one. Thus, you are given the permutation of integers from 1 to *n* defin... | ```python
###### ### ####### ####### ## # ##### ### #####
# # # # # # # # # # # # # ###
# # # # # # # # # # # # # ###
###### ######### # # # #... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
320 | B | Ping-Pong (Easy Version) | PROGRAMMING | 1,500 | [
"dfs and similar",
"graphs"
] | null | null | In this problem at each moment you have a set of intervals. You can move from interval (*a*,<=*b*) from our set to interval (*c*,<=*d*) from our set if and only if *c*<=<<=*a*<=<<=*d* or *c*<=<<=*b*<=<<=*d*. Also there is a path from interval *I*1 from our set to interval *I*2 from our set if there is a seq... | The first line of the input contains integer *n* denoting the number of queries, (1<=≤<=*n*<=≤<=100). Each of the following lines contains a query as described above. All numbers in the input are integers and don't exceed 109 by their absolute value.
It's guaranteed that all queries are correct. | For each query of the second type print "YES" or "NO" on a separate line depending on the answer. | [
"5\n1 1 5\n1 5 11\n2 1 2\n1 2 9\n2 1 2\n"
] | [
"NO\nYES\n"
] | none | 1,000 | [
{
"input": "5\n1 1 5\n1 5 11\n2 1 2\n1 2 9\n2 1 2",
"output": "NO\nYES"
},
{
"input": "10\n1 -311 -186\n1 -1070 -341\n1 -1506 -634\n1 688 1698\n2 2 4\n1 70 1908\n2 1 2\n2 2 4\n1 -1053 1327\n2 5 4",
"output": "NO\nNO\nNO\nYES"
},
{
"input": "10\n1 -1365 -865\n1 1244 1834\n2 1 2\n1 -1508 -... | 1,645,047,143 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 3 | 62 | 0 | def DFS(a, b) -> bool:
visited = [False] * len(intervals)
return DFS_helper(a, b, visited)
def DFS_helper(a, b, visited) -> bool:
if visited[a]: return False
interval_a = intervals[a]
interval_b = intervals[b]
if interval_a == interval_b: return True
visited[a] = True
a_start, a_end = ... | Title: Ping-Pong (Easy Version)
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
In this problem at each moment you have a set of intervals. You can move from interval (*a*,<=*b*) from our set to interval (*c*,<=*d*) from our set if and only if *c*<=<<=*a*<=<<=*d* or *c*<=<<=*b*<=&... | ```python
def DFS(a, b) -> bool:
visited = [False] * len(intervals)
return DFS_helper(a, b, visited)
def DFS_helper(a, b, visited) -> bool:
if visited[a]: return False
interval_a = intervals[a]
interval_b = intervals[b]
if interval_a == interval_b: return True
visited[a] = True
a_start... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
20 | C | Dijkstra? | PROGRAMMING | 1,900 | [
"graphs",
"shortest paths"
] | C. Dijkstra? | 1 | 64 | You are given a weighted undirected graph. The vertices are enumerated from 1 to *n*. Your task is to find the shortest path between the vertex 1 and the vertex *n*. | The first line contains two integers *n* and *m* (2<=≤<=*n*<=≤<=105,<=0<=≤<=*m*<=≤<=105), where *n* is the number of vertices and *m* is the number of edges. Following *m* lines contain one edge each in form *a**i*, *b**i* and *w**i* (1<=≤<=*a**i*,<=*b**i*<=≤<=*n*,<=1<=≤<=*w**i*<=≤<=106), where *a**i*,<=*b**i* are edge... | Write the only integer -1 in case of no path. Write the shortest path in opposite case. If there are many solutions, print any of them. | [
"5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1\n",
"5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1\n"
] | [
"1 4 3 5 ",
"1 4 3 5 "
] | none | 1,500 | [
{
"input": "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1",
"output": "1 4 3 5 "
},
{
"input": "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1",
"output": "1 4 3 5 "
},
{
"input": "2 1\n1 2 1",
"output": "1 2 "
},
{
"input": "3 1\n1 2 1",
"output": "-1"
},
{
"input... | 1,567,445,652 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 18 | 1,000 | 3,379,200 | from collections import defaultdict
class Graph():
def __init__(self):
self.edges = defaultdict(list)
self.weights = {}
def add_edge(self, from_node, to_node, weight):
self.edges[from_node].append(to_node)
self.edges[to_node].append(from_node)
self.weights... | Title: Dijkstra?
Time Limit: 1 seconds
Memory Limit: 64 megabytes
Problem Description:
You are given a weighted undirected graph. The vertices are enumerated from 1 to *n*. Your task is to find the shortest path between the vertex 1 and the vertex *n*.
Input Specification:
The first line contains two integers *n* a... | ```python
from collections import defaultdict
class Graph():
def __init__(self):
self.edges = defaultdict(list)
self.weights = {}
def add_edge(self, from_node, to_node, weight):
self.edges[from_node].append(to_node)
self.edges[to_node].append(from_node)
se... | 0 | MatrixStudio/Codeforces-Python-Submissions |
952 | E | Cheese Board | PROGRAMMING | 2,000 | [] | null | null | Not to be confused with [chessboard](https://en.wikipedia.org/wiki/Chessboard). | The first line of input contains a single integer *N* (1<=≤<=*N*<=≤<=100) — the number of cheeses you have.
The next *N* lines describe the cheeses you have. Each line contains two space-separated strings: the name of the cheese and its type. The name is a string of lowercase English letters between 1 and 10 character... | Output a single number. | [
"9\nbrie soft\ncamembert soft\nfeta soft\ngoat soft\nmuenster soft\nasiago hard\ncheddar hard\ngouda hard\nswiss hard\n",
"6\nparmesan hard\nemmental hard\nedam hard\ncolby hard\ngruyere hard\nasiago hard\n"
] | [
"3\n",
"4\n"
] | none | 0 | [
{
"input": "9\nbrie soft\ncamembert soft\nfeta soft\ngoat soft\nmuenster soft\nasiago hard\ncheddar hard\ngouda hard\nswiss hard",
"output": "3"
},
{
"input": "6\nparmesan hard\nemmental hard\nedam hard\ncolby hard\ngruyere hard\nasiago hard",
"output": "4"
},
{
"input": "9\ngorgonzola s... | 1,554,094,655 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 0 | 140 | 0 | n=int(input())
ans=0
for i in range(0,n):
a,b=input().split()
if b=='hard':
ans+=1
print(ans) | Title: Cheese Board
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Not to be confused with [chessboard](https://en.wikipedia.org/wiki/Chessboard).
Input Specification:
The first line of input contains a single integer *N* (1<=≤<=*N*<=≤<=100) — the number of cheeses you have.
The next *N... | ```python
n=int(input())
ans=0
for i in range(0,n):
a,b=input().split()
if b=='hard':
ans+=1
print(ans)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
186 | A | Comparing Strings | PROGRAMMING | 1,100 | [
"implementation",
"strings"
] | null | null | Some dwarves that are finishing the StUDY (State University for Dwarven Youngsters) Bachelor courses, have been told "no genome, no degree". That means that all dwarves should write a thesis on genome. Dwarven genome is far from simple. It is represented by a string that consists of lowercase Latin letters.
Dwarf Mish... | The first line contains the first dwarf's genome: a non-empty string, consisting of lowercase Latin letters.
The second line contains the second dwarf's genome: a non-empty string, consisting of lowercase Latin letters.
The number of letters in each genome doesn't exceed 105. It is guaranteed that the strings that co... | Print "YES", if the dwarves belong to the same race. Otherwise, print "NO". | [
"ab\nba\n",
"aa\nab\n"
] | [
"YES\n",
"NO\n"
] | - First example: you can simply swap two letters in string "ab". So we get "ba". - Second example: we can't change string "aa" into string "ab", because "aa" does not contain letter "b". | 500 | [
{
"input": "ab\nba",
"output": "YES"
},
{
"input": "aa\nab",
"output": "NO"
},
{
"input": "a\nza",
"output": "NO"
},
{
"input": "vvea\nvvae",
"output": "YES"
},
{
"input": "rtfabanpc\natfabrnpc",
"output": "YES"
},
{
"input": "mt\ntm",
"output": "Y... | 1,590,887,168 | 2,147,483,647 | PyPy 3 | RUNTIME_ERROR | TESTS | 0 | 372 | 2,150,400 | def k(s1,s2):
s1len=len(s1)
if s1len==len(s2):
copy = s1
for i in range(s1len):
if i in s2:
s1 = s1.replace(s1[i],"")
else:
return "NO"
return "YES"
s1 = input()
s2 = input()
k(s1,s2) | Title: Comparing Strings
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Some dwarves that are finishing the StUDY (State University for Dwarven Youngsters) Bachelor courses, have been told "no genome, no degree". That means that all dwarves should write a thesis on genome. Dwarven genome ... | ```python
def k(s1,s2):
s1len=len(s1)
if s1len==len(s2):
copy = s1
for i in range(s1len):
if i in s2:
s1 = s1.replace(s1[i],"")
else:
return "NO"
return "YES"
s1 = input()
s2 = input()
k(s1,s2)
``` | -1 | MatrixStudio/Codeforces-Python-Submissions | |
651 | A | Joysticks | PROGRAMMING | 1,100 | [
"dp",
"greedy",
"implementation",
"math"
] | null | null | Friends are going to play console. They have two joysticks and only one charger for them. Initially first joystick is charged at *a*1 percent and second one is charged at *a*2 percent. You can connect charger to a joystick only at the beginning of each minute. In one minute joystick either discharges by 2 percent (if n... | The first line of the input contains two positive integers *a*1 and *a*2 (1<=≤<=*a*1,<=*a*2<=≤<=100), the initial charge level of first and second joystick respectively. | Output the only integer, the maximum number of minutes that the game can last. Game continues until some joystick is discharged. | [
"3 5\n",
"4 4\n"
] | [
"6\n",
"5\n"
] | In the first sample game lasts for 6 minute by using the following algorithm:
- at the beginning of the first minute connect first joystick to the charger, by the end of this minute first joystick is at 4%, second is at 3%; - continue the game without changing charger, by the end of the second minute the first joyst... | 500 | [
{
"input": "3 5",
"output": "6"
},
{
"input": "4 4",
"output": "5"
},
{
"input": "100 100",
"output": "197"
},
{
"input": "1 100",
"output": "98"
},
{
"input": "100 1",
"output": "98"
},
{
"input": "1 4",
"output": "2"
},
{
"input": "1 1",
... | 1,619,250,104 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 6 | 1,000 | 0 | a,b=map(int,input().split())
c=0
while a>0 and b>0:
if a<=b:
x=b//2
if b%2==0 and b>2:
x=b//2-1
a+=x
c+=x
b-=x*2
else:
x=a//2
if a%2==0 and a>2:
x=a//2-1
a-=x*2
c+=x
b+=x
print(c)
| Title: Joysticks
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Friends are going to play console. They have two joysticks and only one charger for them. Initially first joystick is charged at *a*1 percent and second one is charged at *a*2 percent. You can connect charger to a joystick on... | ```python
a,b=map(int,input().split())
c=0
while a>0 and b>0:
if a<=b:
x=b//2
if b%2==0 and b>2:
x=b//2-1
a+=x
c+=x
b-=x*2
else:
x=a//2
if a%2==0 and a>2:
x=a//2-1
a-=x*2
c+=x
b+=x
print(c)
... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
27 | A | Next Test | PROGRAMMING | 1,200 | [
"implementation",
"sortings"
] | A. Next Test | 2 | 256 | «Polygon» is a system which allows to create programming tasks in a simple and professional way. When you add a test to the problem, the corresponding form asks you for the test index. As in most cases it is clear which index the next test will have, the system suggests the default value of the index. It is calculated ... | The first line contains one integer *n* (1<=≤<=*n*<=≤<=3000) — the amount of previously added tests. The second line contains *n* distinct integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=3000) — indexes of these tests. | Output the required default value for the next test index. | [
"3\n1 7 2\n"
] | [
"3\n"
] | none | 500 | [
{
"input": "1\n1",
"output": "2"
},
{
"input": "2\n2 1",
"output": "3"
},
{
"input": "3\n3 4 1",
"output": "2"
},
{
"input": "4\n6 4 3 5",
"output": "1"
},
{
"input": "5\n3 2 1 7 4",
"output": "5"
},
{
"input": "6\n4 1 2 5 3 7",
"output": "6"
},
... | 1,607,085,190 | 2,147,483,647 | Python 3 | OK | TESTS | 30 | 218 | 307,200 | n = int(input())
arr = list(map(int, input().split()))
arr,f = sorted(arr),0
for i,j in enumerate(arr):
if i+1 != j:
print(i+1)
f = 1
break
if f == 0:
print(n+1) | Title: Next Test
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
«Polygon» is a system which allows to create programming tasks in a simple and professional way. When you add a test to the problem, the corresponding form asks you for the test index. As in most cases it is clear which index the... | ```python
n = int(input())
arr = list(map(int, input().split()))
arr,f = sorted(arr),0
for i,j in enumerate(arr):
if i+1 != j:
print(i+1)
f = 1
break
if f == 0:
print(n+1)
``` | 3.944928 | MatrixStudio/Codeforces-Python-Submissions |
652 | F | Ants on a Circle | PROGRAMMING | 2,800 | [
"constructive algorithms",
"math"
] | null | null | *n* ants are on a circle of length *m*. An ant travels one unit of distance per one unit of time. Initially, the ant number *i* is located at the position *s**i* and is facing in the direction *d**i* (which is either L or R). Positions are numbered in counterclockwise order starting from some point. Positions of the al... | The first line contains three integers *n*, *m* and *t* (2<=≤<=*n*<=≤<=3·105,<=2<=≤<=*m*<=≤<=109,<=0<=≤<=*t*<=≤<=1018) — the number of ants, the length of the circle and the number of time units.
Each of the next *n* lines contains integer *s**i* and symbol *d**i* (1<=≤<=*s**i*<=≤<=*m* and *d**i* is either L or R) — t... | Print *n* integers *x**j* — the position of the *j*-th ant after *t* units of time. The ants are numbered from 1 to *n* in order of their appearing in input. | [
"2 4 8\n1 R\n3 L\n",
"4 8 6\n6 R\n5 L\n1 R\n8 L\n",
"4 8 2\n1 R\n5 L\n6 L\n8 R\n"
] | [
"1 3\n",
"7 4 2 7\n",
"3 3 4 2\n"
] | none | 0 | [
{
"input": "2 4 8\n1 R\n3 L",
"output": "1 3"
},
{
"input": "4 8 6\n6 R\n5 L\n1 R\n8 L",
"output": "7 4 2 7"
},
{
"input": "4 8 2\n1 R\n5 L\n6 L\n8 R",
"output": "3 3 4 2"
},
{
"input": "10 10 90\n2 R\n1 R\n3 L\n4 R\n7 L\n8 L\n6 R\n9 R\n5 R\n10 L",
"output": "10 9 1 2 5 6... | 1,689,598,973 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 0 | 46 | 0 | print("_RANDOM_GUESS_1689598973.4299595")# 1689598973.4299798 | Title: Ants on a Circle
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
*n* ants are on a circle of length *m*. An ant travels one unit of distance per one unit of time. Initially, the ant number *i* is located at the position *s**i* and is facing in the direction *d**i* (which is either L... | ```python
print("_RANDOM_GUESS_1689598973.4299595")# 1689598973.4299798
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
721 | C | Journey | PROGRAMMING | 1,800 | [
"dp",
"graphs"
] | null | null | Recently Irina arrived to one of the most famous cities of Berland — the Berlatov city. There are *n* showplaces in the city, numbered from 1 to *n*, and some of them are connected by one-directional roads. The roads in Berlatov are designed in a way such that there are no cyclic routes between showplaces.
Initially I... | The first line of the input contains three integers *n*,<=*m* and *T* (2<=≤<=*n*<=≤<=5000,<=<=1<=≤<=*m*<=≤<=5000,<=<=1<=≤<=*T*<=≤<=109) — the number of showplaces, the number of roads between them and the time of Irina's stay in Berlatov respectively.
The next *m* lines describes roads in Berlatov. *i*-th of them cont... | Print the single integer *k* (2<=≤<=*k*<=≤<=*n*) — the maximum number of showplaces that Irina can visit during her journey from showplace 1 to showplace *n* within time not exceeding *T*, in the first line.
Print *k* distinct integers in the second line — indices of showplaces that Irina will visit on her route, in t... | [
"4 3 13\n1 2 5\n2 3 7\n2 4 8\n",
"6 6 7\n1 2 2\n1 3 3\n3 6 3\n2 4 2\n4 6 2\n6 5 1\n",
"5 5 6\n1 3 3\n3 5 3\n1 2 2\n2 4 3\n4 5 2\n"
] | [
"3\n1 2 4 \n",
"4\n1 2 4 6 \n",
"3\n1 3 5 \n"
] | none | 1,500 | [
{
"input": "4 3 13\n1 2 5\n2 3 7\n2 4 8",
"output": "3\n1 2 4 "
},
{
"input": "6 6 7\n1 2 2\n1 3 3\n3 6 3\n2 4 2\n4 6 2\n6 5 1",
"output": "4\n1 2 4 6 "
},
{
"input": "5 5 6\n1 3 3\n3 5 3\n1 2 2\n2 4 3\n4 5 2",
"output": "3\n1 3 5 "
},
{
"input": "10 10 100\n1 4 1\n6 4 1\n9 3... | 1,624,803,210 | 2,147,483,647 | PyPy 3 | OK | TESTS | 67 | 1,388 | 227,225,600 | n, m, T = map(int, input().split())
graph_a = [[] for _ in range(n+1)]
graph_b = [[] for _ in range(n+1)]
double_graph_a = [[0 for _ in range(n+1)] for _ in range(n+1)]
double_graph_b = [[0 for _ in range(n+1)] for _ in range(n+1)]
for i in range(m):
u, v, t = map(int, input().split())
graph_a[v].ap... | Title: Journey
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Recently Irina arrived to one of the most famous cities of Berland — the Berlatov city. There are *n* showplaces in the city, numbered from 1 to *n*, and some of them are connected by one-directional roads. The roads in Berlato... | ```python
n, m, T = map(int, input().split())
graph_a = [[] for _ in range(n+1)]
graph_b = [[] for _ in range(n+1)]
double_graph_a = [[0 for _ in range(n+1)] for _ in range(n+1)]
double_graph_b = [[0 for _ in range(n+1)] for _ in range(n+1)]
for i in range(m):
u, v, t = map(int, input().split())
gra... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
645 | A | Amity Assessment | PROGRAMMING | 1,200 | [
"brute force",
"constructive algorithms",
"implementation"
] | null | null | Bessie the cow and her best friend Elsie each received a sliding puzzle on Pi Day. Their puzzles consist of a 2<=×<=2 grid and three tiles labeled 'A', 'B', and 'C'. The three tiles sit on top of the grid, leaving one grid cell empty. To make a move, Bessie or Elsie can slide a tile adjacent to the empty cell into the ... | The first two lines of the input consist of a 2<=×<=2 grid describing the initial configuration of Bessie's puzzle. The next two lines contain a 2<=×<=2 grid describing the initial configuration of Elsie's puzzle. The positions of the tiles are labeled 'A', 'B', and 'C', while the empty cell is labeled 'X'. It's guaran... | Output "YES"(without quotes) if the puzzles can reach the same configuration (and Bessie and Elsie are truly BFFLs). Otherwise, print "NO" (without quotes). | [
"AB\nXC\nXB\nAC\n",
"AB\nXC\nAC\nBX\n"
] | [
"YES\n",
"NO\n"
] | The solution to the first sample is described by the image. All Bessie needs to do is slide her 'A' tile down.
In the second sample, the two puzzles can never be in the same configuration. Perhaps Bessie and Elsie are not meant to be friends after all... | 500 | [
{
"input": "AB\nXC\nXB\nAC",
"output": "YES"
},
{
"input": "AB\nXC\nAC\nBX",
"output": "NO"
},
{
"input": "XC\nBA\nCB\nAX",
"output": "NO"
},
{
"input": "AB\nXC\nAX\nCB",
"output": "YES"
},
{
"input": "CB\nAX\nXA\nBC",
"output": "YES"
},
{
"input": "BC... | 1,649,938,933 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 102 | 61 | 512,000 | # 0 = 4
# 1 = 5
# 2 = 6
# 3 = 7
flag = False
m_list = []
for i in range(0,4):
m_list += input()
newl = [m_list[0] + m_list[2],m_list[1] + m_list[0], m_list[3] + m_list[1], m_list[2] + m_list[3]]
lastl = [m_list[4] + m_list[5],m_list[5] + m_list[7], m_list[7] + m_list[6], m_list[6] + m_list[4]]
... | Title: Amity Assessment
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Bessie the cow and her best friend Elsie each received a sliding puzzle on Pi Day. Their puzzles consist of a 2<=×<=2 grid and three tiles labeled 'A', 'B', and 'C'. The three tiles sit on top of the grid, leaving one ... | ```python
# 0 = 4
# 1 = 5
# 2 = 6
# 3 = 7
flag = False
m_list = []
for i in range(0,4):
m_list += input()
newl = [m_list[0] + m_list[2],m_list[1] + m_list[0], m_list[3] + m_list[1], m_list[2] + m_list[3]]
lastl = [m_list[4] + m_list[5],m_list[5] + m_list[7], m_list[7] + m_list[6], m_list[6] + m_l... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
525 | A | Vitaliy and Pie | PROGRAMMING | 1,100 | [
"greedy",
"hashing",
"strings"
] | null | null | After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with *n* room located in a line and numbered starting from one from left to right. You can go from the first room to the second room, from the second room to the third ... | The first line of the input contains a positive integer *n* (2<=≤<=*n*<=≤<=105) — the number of rooms in the house.
The second line of the input contains string *s* of length 2·*n*<=-<=2. Let's number the elements of the string from left to right, starting from one.
The odd positions in the given string *s* contain ... | Print the only integer — the minimum number of keys that Vitaly needs to buy to surely get from room one to room *n*. | [
"3\naAbB\n",
"4\naBaCaB\n",
"5\nxYyXzZaZ\n"
] | [
"0\n",
"3\n",
"2\n"
] | none | 250 | [
{
"input": "3\naAbB",
"output": "0"
},
{
"input": "4\naBaCaB",
"output": "3"
},
{
"input": "5\nxYyXzZaZ",
"output": "2"
},
{
"input": "26\naAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyY",
"output": "0"
},
{
"input": "26\nzAyBxCwDvEuFtGsHrIqJpKoLnMmNlOkPjQiRhSg... | 1,621,709,100 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 7 | 202 | 2,969,600 | n = int(input())
string = input()
string = [char for char in string]
key = []
room = []
for i in range(len(string)):
if i % 2 == 0:
key.append(string[i])
else:
room.append(string[i])
# print(key,room)
count = 0
seq = 0
rem_key = []
for j,k in zip(key,room):
seq += 1
if ... | Title: Vitaliy and Pie
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with *n* room located in a line and numbered starting from one from... | ```python
n = int(input())
string = input()
string = [char for char in string]
key = []
room = []
for i in range(len(string)):
if i % 2 == 0:
key.append(string[i])
else:
room.append(string[i])
# print(key,room)
count = 0
seq = 0
rem_key = []
for j,k in zip(key,room):
seq += ... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
41 | A | Translation | PROGRAMMING | 800 | [
"implementation",
"strings"
] | A. Translation | 2 | 256 | 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.... | 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. | If the word *t* is a word *s*, written reversely, print YES, otherwise print NO. | [
"code\nedoc\n",
"abb\naba\n",
"code\ncode\n"
] | [
"YES\n",
"NO\n",
"NO\n"
] | none | 500 | [
{
"input": "code\nedoc",
"output": "YES"
},
{
"input": "abb\naba",
"output": "NO"
},
{
"input": "code\ncode",
"output": "NO"
},
{
"input": "abacaba\nabacaba",
"output": "YES"
},
{
"input": "q\nq",
"output": "YES"
},
{
"input": "asrgdfngfnmfgnhweratgjkk... | 1,621,839,935 | 2,147,483,647 | PyPy 3 | OK | TESTS | 40 | 186 | 0 | def solve(str_one,str_two):
str_two_reversed = ""
for i in range(len(str_two)-1,-1,-1):
str_two_reversed += str_two[i]
if str_two_reversed == str_one:
print("YES")
else:
print("NO")
solve(input(),input()) | Title: Translation
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
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 pron... | ```python
def solve(str_one,str_two):
str_two_reversed = ""
for i in range(len(str_two)-1,-1,-1):
str_two_reversed += str_two[i]
if str_two_reversed == str_one:
print("YES")
else:
print("NO")
solve(input(),input())
``` | 3.9535 | MatrixStudio/Codeforces-Python-Submissions |
807 | A | Is it rated? | PROGRAMMING | 900 | [
"implementation",
"sortings"
] | null | null | Is it rated?
Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.
Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before ... | The first line contains a single integer *n* (2<=≤<=*n*<=≤<=1000) — the number of round participants.
Each of the next *n* lines contains two integers *a**i* and *b**i* (1<=≤<=*a**i*,<=*b**i*<=≤<=4126) — the rating of the *i*-th participant before and after the round, respectively. The participants are listed in order... | If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe". | [
"6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884\n",
"4\n1500 1500\n1300 1300\n1200 1200\n1400 1400\n",
"5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699\n"
] | [
"rated\n",
"unrated\n",
"maybe\n"
] | In the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.
In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, som... | 500 | [
{
"input": "6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884",
"output": "rated"
},
{
"input": "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400",
"output": "unrated"
},
{
"input": "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699",
"output": "maybe"
},
{
... | 1,494,847,192 | 2,147,483,647 | Python 3 | OK | TESTS | 150 | 62 | 0 | n=int(input())
li1=[]
li2=[]
for i in range(n):
a,b=map(int,input().split())
li1.append(a)
li2.append(b)
if li1!=li2:
print("rated")
if li1==li2:
li3=sorted(li2,reverse=True)
if li1==li3:
print("maybe")
else:
print("unrated")
| Title: Is it rated?
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Is it rated?
Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.
Another Codeforces round has been conducted. No two participants have the same number ... | ```python
n=int(input())
li1=[]
li2=[]
for i in range(n):
a,b=map(int,input().split())
li1.append(a)
li2.append(b)
if li1!=li2:
print("rated")
if li1==li2:
li3=sorted(li2,reverse=True)
if li1==li3:
print("maybe")
else:
print("unrated")
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
20 | A | BerOS file system | PROGRAMMING | 1,700 | [
"implementation"
] | A. BerOS file system | 2 | 64 | The new operating system BerOS has a nice feature. It is possible to use any number of characters '/' as a delimiter in path instead of one traditional '/'. For example, strings //usr///local//nginx/sbin// and /usr/local/nginx///sbin are equivalent. The character '/' (or some sequence of such characters) at the end of ... | The first line of the input contains only lowercase Latin letters and character '/' — the path to some directory. All paths start with at least one character '/'. The length of the given line is no more than 100 characters, it is not empty. | The path in normalized form. | [
"//usr///local//nginx/sbin\n"
] | [
"/usr/local/nginx/sbin\n"
] | none | 500 | [
{
"input": "//usr///local//nginx/sbin",
"output": "/usr/local/nginx/sbin"
},
{
"input": "////a//b/////g",
"output": "/a/b/g"
},
{
"input": "/a/b/c",
"output": "/a/b/c"
},
{
"input": "/",
"output": "/"
},
{
"input": "////",
"output": "/"
},
{
"input": "... | 1,553,431,850 | 2,147,483,647 | Python 3 | OK | TESTS | 19 | 218 | 0 | print('/'+'/'.join([x for x in input().split('/') if x])) | Title: BerOS file system
Time Limit: 2 seconds
Memory Limit: 64 megabytes
Problem Description:
The new operating system BerOS has a nice feature. It is possible to use any number of characters '/' as a delimiter in path instead of one traditional '/'. For example, strings //usr///local//nginx/sbin// and /usr/local/n... | ```python
print('/'+'/'.join([x for x in input().split('/') if x]))
``` | 3.9455 | MatrixStudio/Codeforces-Python-Submissions |
868 | C | Qualification Rounds | PROGRAMMING | 1,500 | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp"
] | null | null | Snark and Philip are preparing the problemset for the upcoming pre-qualification round for semi-quarter-finals. They have a bank of *n* problems, and they want to select any non-empty subset of it as a problemset.
*k* experienced teams are participating in the contest. Some of these teams already know some of the prob... | The first line contains two integers *n*, *k* (1<=≤<=*n*<=≤<=105, 1<=≤<=*k*<=≤<=4) — the number of problems and the number of experienced teams.
Each of the next *n* lines contains *k* integers, each equal to 0 or 1. The *j*-th number in the *i*-th line is 1 if *j*-th team knows *i*-th problem and 0 otherwise. | Print "YES" (quotes for clarity), if it is possible to make an interesting problemset, and "NO" otherwise.
You can print each character either upper- or lowercase ("YeS" and "yes" are valid when the answer is "YES"). | [
"5 3\n1 0 1\n1 1 0\n1 0 0\n1 0 0\n1 0 0\n",
"3 2\n1 0\n1 1\n0 1\n"
] | [
"NO\n",
"YES\n"
] | In the first example you can't make any interesting problemset, because the first team knows all problems.
In the second example you can choose the first and the third problems. | 1,000 | [
{
"input": "5 3\n1 0 1\n1 1 0\n1 0 0\n1 0 0\n1 0 0",
"output": "NO"
},
{
"input": "3 2\n1 0\n1 1\n0 1",
"output": "YES"
},
{
"input": "10 2\n1 0\n1 0\n0 0\n1 1\n0 0\n1 1\n0 0\n1 1\n0 1\n0 1",
"output": "YES"
},
{
"input": "10 3\n1 0 0\n0 1 1\n1 0 0\n0 1 0\n0 0 1\n1 0 1\n0 1 1... | 1,687,711,021 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 143 | 124 | 3,891,200 | import sys
input = lambda: sys.stdin.readline().rstrip()
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations
from bisect import *
from heapq import *
from math import ceil,gcd,lcm,floor,comb
N,M = map(int,input().split())
s = set()
for _ in range(N):
S = input().split(... | Title: Qualification Rounds
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Snark and Philip are preparing the problemset for the upcoming pre-qualification round for semi-quarter-finals. They have a bank of *n* problems, and they want to select any non-empty subset of it as a problemset.
... | ```python
import sys
input = lambda: sys.stdin.readline().rstrip()
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations
from bisect import *
from heapq import *
from math import ceil,gcd,lcm,floor,comb
N,M = map(int,input().split())
s = set()
for _ in range(N):
S = inpu... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
699 | A | Launch of Collider | PROGRAMMING | 1,000 | [
"implementation"
] | null | null | There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. *n* particles will be launched inside it. All of them are located in a straight line and there can not be two or more particles located in the same point. The coordinates of the particles coincide with the dis... | The first line contains the positive integer *n* (1<=≤<=*n*<=≤<=200<=000) — the number of particles.
The second line contains *n* symbols "L" and "R". If the *i*-th symbol equals "L", then the *i*-th particle will move to the left, otherwise the *i*-th symbol equals "R" and the *i*-th particle will move to the right.... | In the first line print the only integer — the first moment (in microseconds) when two particles are at the same point and there will be an explosion.
Print the only integer -1, if the collision of particles doesn't happen. | [
"4\nRLRL\n2 4 6 10\n",
"3\nLLR\n40 50 60\n"
] | [
"1\n",
"-1\n"
] | In the first sample case the first explosion will happen in 1 microsecond because the particles number 1 and 2 will simultaneously be at the same point with the coordinate 3.
In the second sample case there will be no explosion because there are no particles which will simultaneously be at the same point. | 500 | [
{
"input": "4\nRLRL\n2 4 6 10",
"output": "1"
},
{
"input": "3\nLLR\n40 50 60",
"output": "-1"
},
{
"input": "4\nRLLR\n46 230 264 470",
"output": "92"
},
{
"input": "6\nLLRLLL\n446 492 650 844 930 970",
"output": "97"
},
{
"input": "8\nRRLLLLLL\n338 478 512 574 59... | 1,604,423,614 | 2,147,483,647 | Python 3 | OK | TESTS | 85 | 249 | 15,974,400 | n= int(input())
k = input()
arr =[int(x) for x in input().split()]
m=1000000001
for i in range(0,n-1):
# print(len(m),len(n))
if k[i]=='R' and k[i+1]=='L':
m=min(m,(arr[i+1]-arr[i])/2)
# n+=k[i]
# else:
# m+=k[i]
if m==1000000001:
print(str(-1))
else:
print(str(... | Title: Launch of Collider
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. *n* particles will be launched inside it. All of them are located in a straight line and there can not be... | ```python
n= int(input())
k = input()
arr =[int(x) for x in input().split()]
m=1000000001
for i in range(0,n-1):
# print(len(m),len(n))
if k[i]=='R' and k[i+1]=='L':
m=min(m,(arr[i+1]-arr[i])/2)
# n+=k[i]
# else:
# m+=k[i]
if m==1000000001:
print(str(-1))
else:
... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
760 | B | Frodo and pillows | PROGRAMMING | 1,500 | [
"binary search",
"greedy"
] | null | null | *n* hobbits are planning to spend the night at Frodo's house. Frodo has *n* beds standing in a row and *m* pillows (*n*<=≤<=*m*). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit ge... | The only line contain three integers *n*, *m* and *k* (1<=≤<=*n*<=≤<=*m*<=≤<=109, 1<=≤<=*k*<=≤<=*n*) — the number of hobbits, the number of pillows and the number of Frodo's bed. | Print single integer — the maximum number of pillows Frodo can have so that no one is hurt. | [
"4 6 2\n",
"3 10 3\n",
"3 6 1\n"
] | [
"2\n",
"4\n",
"3\n"
] | In the first example Frodo can have at most two pillows. In this case, he can give two pillows to the hobbit on the first bed, and one pillow to each of the hobbits on the third and the fourth beds.
In the second example Frodo can take at most four pillows, giving three pillows to each of the others.
In the third exa... | 1,000 | [
{
"input": "4 6 2",
"output": "2"
},
{
"input": "3 10 3",
"output": "4"
},
{
"input": "3 6 1",
"output": "3"
},
{
"input": "3 3 3",
"output": "1"
},
{
"input": "1 1 1",
"output": "1"
},
{
"input": "1 1000000000 1",
"output": "1000000000"
},
{
... | 1,485,112,996 | 4,096 | Python 3 | WRONG_ANSWER | PRETESTS | 3 | 46 | 4,608,000 | def countA1(p,h):
return (((2*p) // h) - h + 1) // 2
def bla():
(h, p, f) = tuple(map(int,input().split()))
if h == f or f == 1:
a1 = countA1(p,h)
an = a1 + h - 1
return an
else:
onehalfh = h - f
secondhalfh = f
onehalfp = (onehalfh * p) / h
... | Title: Frodo and pillows
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
*n* hobbits are planning to spend the night at Frodo's house. Frodo has *n* beds standing in a row and *m* pillows (*n*<=≤<=*m*). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as ma... | ```python
def countA1(p,h):
return (((2*p) // h) - h + 1) // 2
def bla():
(h, p, f) = tuple(map(int,input().split()))
if h == f or f == 1:
a1 = countA1(p,h)
an = a1 + h - 1
return an
else:
onehalfh = h - f
secondhalfh = f
onehalfp = (onehalfh... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
748 | F | Santa Clauses and a Soccer Championship | PROGRAMMING | 2,300 | [
"constructive algorithms",
"dfs and similar",
"graphs",
"trees"
] | null | null | The country Treeland consists of *n* cities connected with *n*<=-<=1 bidirectional roads in such a way that it's possible to reach every city starting from any other city using these roads. There will be a soccer championship next year, and all participants are Santa Clauses. There are exactly 2*k* teams from 2*k* diff... | The first line of input contains two integers *n* and *k* (2<=≤<=*n*<=≤<=2·105,<=2<=≤<=2*k*<=≤<=*n*) — the number of cities in Treeland and the number of pairs of teams, respectively.
The following *n*<=-<=1 lines describe roads in Treeland: each of these lines contains two integers *a* and *b* (1<=≤<=*a*,<=*b*<=≤<=*n... | The first line of output must contain the only positive integer *m* which should be equal to the minimum possible number of cities the teams can be settled in.
The second line should contain *m* distinct numbers *d*1,<=*d*2,<=...,<=*d**m* (1<=≤<=*d**i*<=≤<=*n*) denoting the indices of the cities where the teams should... | [
"6 2\n1 2\n1 3\n2 4\n2 5\n3 6\n2 5 4 6\n"
] | [
"1\n2\n5 4 2\n6 2 2\n"
] | In the first test the orginizers can settle all the teams in the city number 2. The way to divide all teams into pairs is not important, since all requirements are satisfied anyway, because the city 2 lies on the shortest path between every two cities from {2, 4, 5, 6}. | 2,500 | [
{
"input": "6 2\n1 2\n1 3\n2 4\n2 5\n3 6\n2 5 4 6",
"output": "1\n2\n5 4 2\n6 2 2"
},
{
"input": "2 1\n1 2\n1 2",
"output": "1\n1\n2 1 1"
},
{
"input": "6 2\n1 6\n6 2\n6 5\n5 3\n5 4\n1 3 4 2",
"output": "1\n6\n4 2 6\n3 1 6"
},
{
"input": "10 1\n4 2\n9 2\n1 4\n4 10\n2 3\n7 10\... | 1,689,351,541 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 0 | 61 | 0 | print("_RANDOM_GUESS_1689351540.8685281")# 1689351540.868547 | Title: Santa Clauses and a Soccer Championship
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The country Treeland consists of *n* cities connected with *n*<=-<=1 bidirectional roads in such a way that it's possible to reach every city starting from any other city using these roads. There... | ```python
print("_RANDOM_GUESS_1689351540.8685281")# 1689351540.868547
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
508 | A | Pasha and Pixels | PROGRAMMING | 1,100 | [
"brute force"
] | null | null | Pasha loves his phone and also putting his hair up... But the hair is now irrelevant.
Pasha has installed a new game to his phone. The goal of the game is following. There is a rectangular field consisting of *n* row with *m* pixels in each row. Initially, all the pixels are colored white. In one move, Pasha can choos... | The first line of the input contains three integers *n*,<=*m*,<=*k* (1<=≤<=*n*,<=*m*<=≤<=1000, 1<=≤<=*k*<=≤<=105) — the number of rows, the number of columns and the number of moves that Pasha is going to perform.
The next *k* lines contain Pasha's moves in the order he makes them. Each line contains two integers *i*... | If Pasha loses, print the number of the move when the 2<=×<=2 square consisting of black pixels is formed.
If Pasha doesn't lose, that is, no 2<=×<=2 square consisting of black pixels is formed during the given *k* moves, print 0. | [
"2 2 4\n1 1\n1 2\n2 1\n2 2\n",
"2 3 6\n2 3\n2 2\n1 3\n2 2\n1 2\n1 1\n",
"5 3 7\n2 3\n1 2\n1 1\n4 1\n3 1\n5 3\n3 2\n"
] | [
"4\n",
"5\n",
"0\n"
] | none | 500 | [
{
"input": "2 2 4\n1 1\n1 2\n2 1\n2 2",
"output": "4"
},
{
"input": "2 3 6\n2 3\n2 2\n1 3\n2 2\n1 2\n1 1",
"output": "5"
},
{
"input": "5 3 7\n2 3\n1 2\n1 1\n4 1\n3 1\n5 3\n3 2",
"output": "0"
},
{
"input": "3 3 11\n2 1\n3 1\n1 1\n1 3\n1 2\n2 3\n3 3\n3 2\n2 2\n1 3\n3 3",
... | 1,667,918,682 | 2,147,483,647 | PyPy 3 | TIME_LIMIT_EXCEEDED | TESTS | 4 | 2,000 | 3,993,600 | # -*- coding: utf-8 -*-
"""
Created on Tue Nov 8 22:12:08 2022
@author: lenovo
"""
n,m,k=map(int, input().split())
bl=[]
t=0
for _ in range(k):
i,j=map(int, input().split())
bl.append((i,j))
if _ >=3 and t==0:
if (i-1,j-1) in bl and (i,j-1) in bl and (i-1,j) in bl:
t=_+... | Title: Pasha and Pixels
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Pasha loves his phone and also putting his hair up... But the hair is now irrelevant.
Pasha has installed a new game to his phone. The goal of the game is following. There is a rectangular field consisting of *n* row ... | ```python
# -*- coding: utf-8 -*-
"""
Created on Tue Nov 8 22:12:08 2022
@author: lenovo
"""
n,m,k=map(int, input().split())
bl=[]
t=0
for _ in range(k):
i,j=map(int, input().split())
bl.append((i,j))
if _ >=3 and t==0:
if (i-1,j-1) in bl and (i,j-1) in bl and (i-1,j) in bl:
... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
92 | B | Binary Number | PROGRAMMING | 1,300 | [
"greedy"
] | B. Binary Number | 1 | 256 | Little walrus Fangy loves math very much. That's why when he is bored he plays with a number performing some operations.
Fangy takes some positive integer *x* and wants to get a number one from it. While *x* is not equal to 1, Fangy repeats the following action: if *x* is odd, then he adds 1 to it, otherwise he divide... | The first line contains a positive integer *x* in a binary system. It is guaranteed that the first digit of *x* is different from a zero and the number of its digits does not exceed 106. | Print the required number of actions. | [
"1\n",
"1001001\n",
"101110\n"
] | [
"0\n",
"12\n",
"8\n"
] | Let's consider the third sample. Number 101110 is even, which means that we should divide it by 2. After the dividing Fangy gets an odd number 10111 and adds one to it. Number 11000 can be divided by 2 three times in a row and get number 11. All that's left is to increase the number by one (we get 100), and then divide... | 1,000 | [
{
"input": "1",
"output": "0"
},
{
"input": "1001001",
"output": "12"
},
{
"input": "101110",
"output": "8"
},
{
"input": "11",
"output": "3"
},
{
"input": "11110001101",
"output": "16"
},
{
"input": "101010100100111100011111001111100001010101111110101... | 1,620,561,319 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 8 | 62 | 6,758,400 | import math
ans = 0;
a = int(str(input()), base = 2)
while a != 1:
if a % 2 == 0:
a /= 2
else:
a += 1
ans += 1
print(ans)
| Title: Binary Number
Time Limit: 1 seconds
Memory Limit: 256 megabytes
Problem Description:
Little walrus Fangy loves math very much. That's why when he is bored he plays with a number performing some operations.
Fangy takes some positive integer *x* and wants to get a number one from it. While *x* is not equal to ... | ```python
import math
ans = 0;
a = int(str(input()), base = 2)
while a != 1:
if a % 2 == 0:
a /= 2
else:
a += 1
ans += 1
print(ans)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions |
554 | A | Kyoya and Photobooks | PROGRAMMING | 900 | [
"brute force",
"math",
"strings"
] | null | null | Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He has 26 photos, labeled "a" to "z", and he has compiled them into a photo booklet with some photos in some order (possibly with some photos being duplicated). A photo booklet can be described as a string of lowercase letters, consisting of the pho... | The first line of input will be a single string *s* (1<=≤<=|*s*|<=≤<=20). String *s* consists only of lowercase English letters. | Output a single integer equal to the number of distinct photobooks Kyoya Ootori can make. | [
"a\n",
"hi\n"
] | [
"51\n",
"76\n"
] | In the first case, we can make 'ab','ac',...,'az','ba','ca',...,'za', and 'aa', producing a total of 51 distinct photo booklets. | 250 | [
{
"input": "a",
"output": "51"
},
{
"input": "hi",
"output": "76"
},
{
"input": "y",
"output": "51"
},
{
"input": "kgan",
"output": "126"
},
{
"input": "zoabkyuvus",
"output": "276"
},
{
"input": "spyemhyznjieyhhbk",
"output": "451"
},
{
"i... | 1,617,159,103 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 4 | 77 | 0 | print(25 * (len(set(list(input()))) + 1) + 1) | Title: Kyoya and Photobooks
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He has 26 photos, labeled "a" to "z", and he has compiled them into a photo booklet with some photos in some order (possibly with some photos b... | ```python
print(25 * (len(set(list(input()))) + 1) + 1)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
233 | A | Perfect Permutation | PROGRAMMING | 800 | [
"implementation",
"math"
] | null | null | A permutation is a sequence of integers *p*1,<=*p*2,<=...,<=*p**n*, consisting of *n* distinct positive integers, each of them doesn't exceed *n*. Let's denote the *i*-th element of permutation *p* as *p**i*. We'll call number *n* the size of permutation *p*1,<=*p*2,<=...,<=*p**n*.
Nickolas adores permutations. He lik... | A single line contains a single integer *n* (1<=≤<=*n*<=≤<=100) — the permutation size. | If a perfect permutation of size *n* doesn't exist, print a single integer -1. Otherwise print *n* distinct integers from 1 to *n*, *p*1,<=*p*2,<=...,<=*p**n* — permutation *p*, that is perfect. Separate printed numbers by whitespaces. | [
"1\n",
"2\n",
"4\n"
] | [
"-1\n",
"2 1 \n",
"2 1 4 3 \n"
] | none | 500 | [
{
"input": "1",
"output": "-1"
},
{
"input": "2",
"output": "2 1 "
},
{
"input": "4",
"output": "2 1 4 3 "
},
{
"input": "3",
"output": "-1"
},
{
"input": "5",
"output": "-1"
},
{
"input": "6",
"output": "2 1 4 3 6 5 "
},
{
"input": "7",
... | 1,666,544,530 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 62 | 0 | n = int(input())
if n % 2 == 0:
l = []
y = []
for i in range(1, n+1):
l.append(i)
for i in range(1, n+1, 2):
y.append(l[i])
y.append(i)
print(y)
else:
print("-1")
| Title: Perfect Permutation
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
A permutation is a sequence of integers *p*1,<=*p*2,<=...,<=*p**n*, consisting of *n* distinct positive integers, each of them doesn't exceed *n*. Let's denote the *i*-th element of permutation *p* as *p**i*. We'll ... | ```python
n = int(input())
if n % 2 == 0:
l = []
y = []
for i in range(1, n+1):
l.append(i)
for i in range(1, n+1, 2):
y.append(l[i])
y.append(i)
print(y)
else:
print("-1")
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
472 | A | Design Tutorial: Learn from Math | PROGRAMMING | 800 | [
"math",
"number theory"
] | null | null | One way to create a task is to learn from math. You can generate some random math statement or modify some theorems to get something new and build a new task from that.
For example, there is a statement called the "Goldbach's conjecture". It says: "each even number no less than four can be expressed as the sum of two ... | The only line contains an integer *n* (12<=≤<=*n*<=≤<=106). | Output two composite integers *x* and *y* (1<=<<=*x*,<=*y*<=<<=*n*) such that *x*<=+<=*y*<==<=*n*. If there are multiple solutions, you can output any of them. | [
"12\n",
"15\n",
"23\n",
"1000000\n"
] | [
"4 8\n",
"6 9\n",
"8 15\n",
"500000 500000\n"
] | In the first example, 12 = 4 + 8 and both 4, 8 are composite numbers. You can output "6 6" or "8 4" as well.
In the second example, 15 = 6 + 9. Note that you can't output "1 14" because 1 is not a composite number. | 500 | [
{
"input": "12",
"output": "4 8"
},
{
"input": "15",
"output": "6 9"
},
{
"input": "23",
"output": "8 15"
},
{
"input": "1000000",
"output": "500000 500000"
},
{
"input": "63874",
"output": "4 63870"
},
{
"input": "14568",
"output": "4 14564"
},
... | 1,676,867,099 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 7 | 77 | 0 | sum = int(input())
if sum % 2 == 0:
print(int(sum/2), int(sum/2))
else:
print(9, sum - 9) | Title: Design Tutorial: Learn from Math
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
One way to create a task is to learn from math. You can generate some random math statement or modify some theorems to get something new and build a new task from that.
For example, there is a statemen... | ```python
sum = int(input())
if sum % 2 == 0:
print(int(sum/2), int(sum/2))
else:
print(9, sum - 9)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
59 | A | Word | PROGRAMMING | 800 | [
"implementation",
"strings"
] | A. Word | 2 | 256 | Vasya is very upset that many people on the Net mix uppercase and lowercase letters in one word. That's why he decided to invent an extension for his favorite browser that would change the letters' register in every word so that it either only consisted of lowercase letters or, vice versa, only of uppercase ones. At th... | The first line contains a word *s* — it consists of uppercase and lowercase Latin letters and possesses the length from 1 to 100. | Print the corrected word *s*. If the given word *s* has strictly more uppercase letters, make the word written in the uppercase register, otherwise - in the lowercase one. | [
"HoUse\n",
"ViP\n",
"maTRIx\n"
] | [
"house\n",
"VIP\n",
"matrix\n"
] | none | 500 | [
{
"input": "HoUse",
"output": "house"
},
{
"input": "ViP",
"output": "VIP"
},
{
"input": "maTRIx",
"output": "matrix"
},
{
"input": "BNHWpnpawg",
"output": "bnhwpnpawg"
},
{
"input": "VTYGP",
"output": "VTYGP"
},
{
"input": "CHNenu",
"output": "chn... | 1,667,818,457 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 62 | 0 | s = input()
lower = ["q","w","e","r","t","y","u","i","o","p","a","s","d","f","g","h","j","k","l","m","n","b","v","c","x","z"]
upper = ["Q","W","E","R","T","Y","U","I","O","P","A","S","D","F","G","H","J","K","L","M","N","B","V","C","X","Z"]
l = 0
u = 0
for i in s:
if i in lower:
l = l + 1
if i in upper... | Title: Word
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Vasya is very upset that many people on the Net mix uppercase and lowercase letters in one word. That's why he decided to invent an extension for his favorite browser that would change the letters' register in every word so that it ei... | ```python
s = input()
lower = ["q","w","e","r","t","y","u","i","o","p","a","s","d","f","g","h","j","k","l","m","n","b","v","c","x","z"]
upper = ["Q","W","E","R","T","Y","U","I","O","P","A","S","D","F","G","H","J","K","L","M","N","B","V","C","X","Z"]
l = 0
u = 0
for i in s:
if i in lower:
l = l + 1
if ... | 0 | MatrixStudio/Codeforces-Python-Submissions |
750 | A | New Year and Hurry | PROGRAMMING | 800 | [
"binary search",
"brute force",
"implementation",
"math"
] | null | null | Limak is going to participate in a contest on the last day of the 2016. The contest will start at 20:00 and will last four hours, exactly until midnight. There will be *n* problems, sorted by difficulty, i.e. problem 1 is the easiest and problem *n* is the hardest. Limak knows it will take him 5·*i* minutes to solve th... | The only line of the input contains two integers *n* and *k* (1<=≤<=*n*<=≤<=10, 1<=≤<=*k*<=≤<=240) — the number of the problems in the contest and the number of minutes Limak needs to get to the party from his house. | Print one integer, denoting the maximum possible number of problems Limak can solve so that he could get to the party at midnight or earlier. | [
"3 222\n",
"4 190\n",
"7 1\n"
] | [
"2\n",
"4\n",
"7\n"
] | In the first sample, there are 3 problems and Limak needs 222 minutes to get to the party. The three problems require 5, 10 and 15 minutes respectively. Limak can spend 5 + 10 = 15 minutes to solve first two problems. Then, at 20:15 he can leave his house to get to the party at 23:57 (after 222 minutes). In this scenar... | 500 | [
{
"input": "3 222",
"output": "2"
},
{
"input": "4 190",
"output": "4"
},
{
"input": "7 1",
"output": "7"
},
{
"input": "10 135",
"output": "6"
},
{
"input": "10 136",
"output": "5"
},
{
"input": "1 1",
"output": "1"
},
{
"input": "1 240",
... | 1,688,994,348 | 2,147,483,647 | Python 3 | OK | TESTS | 52 | 46 | 0 | n, k = list(map(int, input().split()))
totalTime = 240
time = 240 - k
counter = 0
summ = 0
for i in range(1, n + 1):
if (5 * i) + summ <= time:
counter += 1
summ += 5 * i
else:
break
print(counter) | Title: New Year and Hurry
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Limak is going to participate in a contest on the last day of the 2016. The contest will start at 20:00 and will last four hours, exactly until midnight. There will be *n* problems, sorted by difficulty, i.e. problem... | ```python
n, k = list(map(int, input().split()))
totalTime = 240
time = 240 - k
counter = 0
summ = 0
for i in range(1, n + 1):
if (5 * i) + summ <= time:
counter += 1
summ += 5 * i
else:
break
print(counter)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
25 | A | IQ test | PROGRAMMING | 1,300 | [
"brute force"
] | A. IQ test | 2 | 256 | Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given *n* numbers differs from the others. Bob observed that one number usually differs from the others in evenness. Help Bob — to check his answers, he needs a program that among the given *n* numbers finds one that i... | The first line contains integer *n* (3<=≤<=*n*<=≤<=100) — amount of numbers in the task. The second line contains *n* space-separated natural numbers, not exceeding 100. It is guaranteed, that exactly one of these numbers differs from the others in evenness. | Output index of number that differs from the others in evenness. Numbers are numbered from 1 in the input order. | [
"5\n2 4 7 8 10\n",
"4\n1 2 1 1\n"
] | [
"3\n",
"2\n"
] | none | 0 | [
{
"input": "5\n2 4 7 8 10",
"output": "3"
},
{
"input": "4\n1 2 1 1",
"output": "2"
},
{
"input": "3\n1 2 2",
"output": "1"
},
{
"input": "3\n100 99 100",
"output": "2"
},
{
"input": "3\n5 3 2",
"output": "3"
},
{
"input": "4\n43 28 1 91",
"output"... | 1,690,811,480 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 62 | 0 | num = int(input())
array = []
evenCount = 0
oddCount = 0
for i in range(num):
array.append(int(input()))
if array[i] % 2 == 0:
evenCount += 1
else:
oddCount += 1
if evenCount == 1:
for j in range(num):
if array[j] % 2 == 0:
print(j + 1)
if oddCount... | Title: IQ test
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given *n* numbers differs from the others. Bob observed that one number usually differs from the others in evenness. Help Bob — t... | ```python
num = int(input())
array = []
evenCount = 0
oddCount = 0
for i in range(num):
array.append(int(input()))
if array[i] % 2 == 0:
evenCount += 1
else:
oddCount += 1
if evenCount == 1:
for j in range(num):
if array[j] % 2 == 0:
print(j + 1)
i... | -1 | MatrixStudio/Codeforces-Python-Submissions |
437 | D | The Child and Zoo | PROGRAMMING | 1,900 | [
"dsu",
"sortings"
] | null | null | Of course our child likes walking in a zoo. The zoo has *n* areas, that are numbered from 1 to *n*. The *i*-th area contains *a**i* animals in it. Also there are *m* roads in the zoo, and each road connects two distinct areas. Naturally the zoo is connected, so you can reach any area of the zoo from any other area usin... | The first line contains two integers *n* and *m* (2<=≤<=*n*<=≤<=105; 0<=≤<=*m*<=≤<=105). The second line contains *n* integers: *a*1,<=*a*2,<=...,<=*a**n* (0<=≤<=*a**i*<=≤<=105). Then follow *m* lines, each line contains two integers *x**i* and *y**i* (1<=≤<=*x**i*,<=*y**i*<=≤<=*n*; *x**i*<=≠<=*y**i*), denoting the roa... | Output a real number — the value of .
The answer will be considered correct if its relative or absolute error doesn't exceed 10<=-<=4. | [
"4 3\n10 20 30 40\n1 3\n2 3\n4 3\n",
"3 3\n10 20 30\n1 2\n2 3\n3 1\n",
"7 8\n40 20 10 30 20 50 40\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n1 4\n5 7\n"
] | [
"16.666667\n",
"13.333333\n",
"18.571429\n"
] | Consider the first sample. There are 12 possible situations:
- *p* = 1, *q* = 3, *f*(*p*, *q*) = 10. - *p* = 2, *q* = 3, *f*(*p*, *q*) = 20. - *p* = 4, *q* = 3, *f*(*p*, *q*) = 30. - *p* = 1, *q* = 2, *f*(*p*, *q*) = 10. - *p* = 2, *q* = 4, *f*(*p*, *q*) = 20. - *p* = 4, *q* = 1, *f*(*p*, *q*) = 10.
Another 6 c... | 2,000 | [
{
"input": "4 3\n10 20 30 40\n1 3\n2 3\n4 3",
"output": "16.666667"
},
{
"input": "3 3\n10 20 30\n1 2\n2 3\n3 1",
"output": "13.333333"
},
{
"input": "7 8\n40 20 10 30 20 50 40\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n1 4\n5 7",
"output": "18.571429"
},
{
"input": "10 14\n594 965 90 32... | 1,630,779,513 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 9 | 1,091 | 32,665,600 | import sys
import math
import heapq
import itertools
from sys import setrecursionlimit
from collections import deque, defaultdict
input = sys.stdin.readline
#
# ANALYSIS
#
# Let n be the number of areas and m be the number of roads. Assume union-find
# operations are constant time even though they are slightly wors... | Title: The Child and Zoo
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Of course our child likes walking in a zoo. The zoo has *n* areas, that are numbered from 1 to *n*. The *i*-th area contains *a**i* animals in it. Also there are *m* roads in the zoo, and each road connects two distin... | ```python
import sys
import math
import heapq
import itertools
from sys import setrecursionlimit
from collections import deque, defaultdict
input = sys.stdin.readline
#
# ANALYSIS
#
# Let n be the number of areas and m be the number of roads. Assume union-find
# operations are constant time even though they are sli... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
231 | A | Team | PROGRAMMING | 800 | [
"brute force",
"greedy"
] | null | null | One day three best friends Petya, Vasya and Tonya decided to form a team and take part in programming contests. Participants are usually offered several problems during programming contests. Long before the start the friends decided that they will implement a problem if at least two of them are sure about the solution.... | The first input line contains a single integer *n* (1<=≤<=*n*<=≤<=1000) — the number of problems in the contest. Then *n* lines contain three integers each, each integer is either 0 or 1. If the first number in the line equals 1, then Petya is sure about the problem's solution, otherwise he isn't sure. The second numbe... | Print a single integer — the number of problems the friends will implement on the contest. | [
"3\n1 1 0\n1 1 1\n1 0 0\n",
"2\n1 0 0\n0 1 1\n"
] | [
"2\n",
"1\n"
] | In the first sample Petya and Vasya are sure that they know how to solve the first problem and all three of them know how to solve the second problem. That means that they will write solutions for these problems. Only Petya is sure about the solution for the third problem, but that isn't enough, so the friends won't ta... | 500 | [
{
"input": "3\n1 1 0\n1 1 1\n1 0 0",
"output": "2"
},
{
"input": "2\n1 0 0\n0 1 1",
"output": "1"
},
{
"input": "1\n1 0 0",
"output": "0"
},
{
"input": "2\n1 0 0\n1 1 1",
"output": "1"
},
{
"input": "5\n1 0 0\n0 1 0\n1 1 1\n0 0 1\n0 0 0",
"output": "1"
},
... | 1,696,336,665 | 2,147,483,647 | Python 3 | OK | TESTS | 21 | 92 | 0 | n= int(input())
i=1
hasil= 0
while i <= n:
p,v,t= map(int, input().split())
i+=1
if p+v+t >= 2:
hasil += 1
print(hasil)
| Title: Team
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
One day three best friends Petya, Vasya and Tonya decided to form a team and take part in programming contests. Participants are usually offered several problems during programming contests. Long before the start the friends decid... | ```python
n= int(input())
i=1
hasil= 0
while i <= n:
p,v,t= map(int, input().split())
i+=1
if p+v+t >= 2:
hasil += 1
print(hasil)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
363 | B | Fence | PROGRAMMING | 1,100 | [
"brute force",
"dp"
] | null | null | There is a fence in front of Polycarpus's home. The fence consists of *n* planks of the same width which go one after another from left to right. The height of the *i*-th plank is *h**i* meters, distinct planks can have distinct heights.
Polycarpus has bought a posh piano and is thinking about how to get it into the h... | The first line of the input contains integers *n* and *k* (1<=≤<=*n*<=≤<=1.5·105,<=1<=≤<=*k*<=≤<=*n*) — the number of planks in the fence and the width of the hole for the piano. The second line contains the sequence of integers *h*1,<=*h*2,<=...,<=*h**n* (1<=≤<=*h**i*<=≤<=100), where *h**i* is the height of the *i*-th... | Print such integer *j* that the sum of the heights of planks *j*, *j*<=+<=1, ..., *j*<=+<=*k*<=-<=1 is the minimum possible. If there are multiple such *j*'s, print any of them. | [
"7 3\n1 2 6 1 1 7 1\n"
] | [
"3\n"
] | In the sample, your task is to find three consecutive planks with the minimum sum of heights. In the given case three planks with indexes 3, 4 and 5 have the required attribute, their total height is 8. | 1,000 | [
{
"input": "7 3\n1 2 6 1 1 7 1",
"output": "3"
},
{
"input": "1 1\n100",
"output": "1"
},
{
"input": "2 1\n10 20",
"output": "1"
},
{
"input": "10 5\n1 2 3 1 2 2 3 1 4 5",
"output": "1"
},
{
"input": "10 2\n3 1 4 1 4 6 2 1 4 6",
"output": "7"
},
{
"inp... | 1,677,850,484 | 2,147,483,647 | Python 3 | OK | TESTS | 51 | 139 | 8,499,200 | n,k = map(int,input().split(' '))
h = list(map(int,input().split(' ')))
sum = 0
for i in range (0,k):
sum += h[i]
min_sum = sum
index = 0
for i in range (1,n-k+1):
sum = sum - h[i-1] + h[i + (k-1)]
if min_sum > sum:
min_sum = sum
index = i
print(index + 1) | Title: Fence
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
There is a fence in front of Polycarpus's home. The fence consists of *n* planks of the same width which go one after another from left to right. The height of the *i*-th plank is *h**i* meters, distinct planks can have distinct ... | ```python
n,k = map(int,input().split(' '))
h = list(map(int,input().split(' ')))
sum = 0
for i in range (0,k):
sum += h[i]
min_sum = sum
index = 0
for i in range (1,n-k+1):
sum = sum - h[i-1] + h[i + (k-1)]
if min_sum > sum:
min_sum = sum
index = i
print(index + 1)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
727 | A | Transformation: from A to B | PROGRAMMING | 1,000 | [
"brute force",
"dfs and similar",
"math"
] | null | null | Vasily has a number *a*, which he wants to turn into a number *b*. For this purpose, he can do two types of operations:
- multiply the current number by 2 (that is, replace the number *x* by 2·*x*); - append the digit 1 to the right of current number (that is, replace the number *x* by 10·*x*<=+<=1).
You need to he... | The first line contains two positive integers *a* and *b* (1<=≤<=*a*<=<<=*b*<=≤<=109) — the number which Vasily has and the number he wants to have. | If there is no way to get *b* from *a*, print "NO" (without quotes).
Otherwise print three lines. On the first line print "YES" (without quotes). The second line should contain single integer *k* — the length of the transformation sequence. On the third line print the sequence of transformations *x*1,<=*x*2,<=...,<=*x... | [
"2 162\n",
"4 42\n",
"100 40021\n"
] | [
"YES\n5\n2 4 8 81 162 \n",
"NO\n",
"YES\n5\n100 200 2001 4002 40021 \n"
] | none | 1,000 | [
{
"input": "2 162",
"output": "YES\n5\n2 4 8 81 162 "
},
{
"input": "4 42",
"output": "NO"
},
{
"input": "100 40021",
"output": "YES\n5\n100 200 2001 4002 40021 "
},
{
"input": "1 111111111",
"output": "YES\n9\n1 11 111 1111 11111 111111 1111111 11111111 111111111 "
},
... | 1,613,017,242 | 1,242 | Python 3 | WRONG_ANSWER | TESTS | 0 | 46 | 204,800 | a, b = list(map(int, input().split()))
ans = list()
d = dict()
def transform(a, b):
if a == b:
ans.append(a)
return True
if a > b:
return False
val1 = a * 2
val2 = a * 10 + 1
if transform(val1, b):
ans.append(a)
return True
if trans... | Title: Transformation: from A to B
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vasily has a number *a*, which he wants to turn into a number *b*. For this purpose, he can do two types of operations:
- multiply the current number by 2 (that is, replace the number *x* by 2·*x*); - app... | ```python
a, b = list(map(int, input().split()))
ans = list()
d = dict()
def transform(a, b):
if a == b:
ans.append(a)
return True
if a > b:
return False
val1 = a * 2
val2 = a * 10 + 1
if transform(val1, b):
ans.append(a)
return True
... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
123 | B | Squares | PROGRAMMING | 1,800 | [
"math"
] | null | null | You are given an infinite checkered field. You should get from a square (*x*1; *y*1) to a square (*x*2; *y*2). Using the shortest path is not necessary. You can move on the field squares in four directions. That is, when you are positioned in any square, you can move to any other side-neighboring one.
A square (*x*; ... | The only line contains integers *a*, *b*, *x*1, *y*1, *x*2 and *y*2 — the parameters of the bad squares, the coordinates of the initial and the final squares correspondingly (2<=≤<=*a*,<=*b*<=≤<=109 and |*x*1|,|*y*1|,|*x*2|,|*y*2|<=≤<=109). It is guaranteed that the initial and the final square aren't bad. | Print a single number — the minimum number of bad cells that one will have to visit in order to travel from square (*x*1; *y*1) to square (*x*2; *y*2). | [
"2 2 1 0 0 1\n",
"2 2 10 11 0 1\n",
"2 4 3 -1 3 7\n"
] | [
"1\n",
"5\n",
"2\n"
] | In the third sample one of the possible paths in (3;-1)->(3;0)->(3;1)->(3;2)->(4;2)->(4;3)->(4;4)->(4;5)->(4;6)->(4;7)->(3;7). Squares (3;1) and (4;4) are bad. | 1,000 | [
{
"input": "2 2 1 0 0 1",
"output": "1"
},
{
"input": "2 2 10 11 0 1",
"output": "5"
},
{
"input": "2 4 3 -1 3 7",
"output": "2"
},
{
"input": "2 2 9 10 -10 -11",
"output": "10"
},
{
"input": "3 2 -11 -10 10 11",
"output": "7"
},
{
"input": "3 2 11 -12... | 1,691,913,480 | 2,147,483,647 | PyPy 3-64 | COMPILATION_ERROR | TESTS | 0 | 0 | 0 | #include <bits/stdc++.h>
using namespace std;
int main(){
int a,b,x1,x2,y1,y2;
cin >> a >> b >> x1 >> y1 >> x2 >> y2;
int xs = (x1 + y1) / (2 * a);
int ys = (x1 - y1) / (2 * b);
int xf = (x2 + y2) / (2 * a);
int yf = (x2 - y2) / (2 * b);
int d = abs(xs-xf) + abs(ys-yf);
... | Title: Squares
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given an infinite checkered field. You should get from a square (*x*1; *y*1) to a square (*x*2; *y*2). Using the shortest path is not necessary. You can move on the field squares in four directions. That is, when you ar... | ```python
#include <bits/stdc++.h>
using namespace std;
int main(){
int a,b,x1,x2,y1,y2;
cin >> a >> b >> x1 >> y1 >> x2 >> y2;
int xs = (x1 + y1) / (2 * a);
int ys = (x1 - y1) / (2 * b);
int xf = (x2 + y2) / (2 * a);
int yf = (x2 - y2) / (2 * b);
int d = abs(xs-xf) + abs(ys... | -1 | MatrixStudio/Codeforces-Python-Submissions | |
765 | C | Table Tennis Game 2 | PROGRAMMING | 1,200 | [
"math"
] | null | null | Misha and Vanya have played several table tennis sets. Each set consists of several serves, each serve is won by one of the players, he receives one point and the loser receives nothing. Once one of the players scores exactly *k* points, the score is reset and a new set begins.
Across all the sets Misha scored *a* poi... | The first line contains three space-separated integers *k*, *a* and *b* (1<=≤<=*k*<=≤<=109, 0<=≤<=*a*,<=*b*<=≤<=109, *a*<=+<=*b*<=><=0). | If the situation is impossible, print a single number -1. Otherwise, print the maximum possible number of sets. | [
"11 11 5\n",
"11 2 3\n"
] | [
"1\n",
"-1\n"
] | Note that the rules of the game in this problem differ from the real table tennis game, for example, the rule of "balance" (the winning player has to be at least two points ahead to win a set) has no power within the present problem. | 1,250 | [
{
"input": "11 11 5",
"output": "1"
},
{
"input": "11 2 3",
"output": "-1"
},
{
"input": "1 5 9",
"output": "14"
},
{
"input": "2 3 3",
"output": "2"
},
{
"input": "1 1000000000 1000000000",
"output": "2000000000"
},
{
"input": "2 3 5",
"output": "... | 1,520,972,633 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 46 | 5,529,600 | k,a,b=list(map(int,input().split()))
if a+b<=k*2-1:
print("1")
else:
print("-1") | Title: Table Tennis Game 2
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Misha and Vanya have played several table tennis sets. Each set consists of several serves, each serve is won by one of the players, he receives one point and the loser receives nothing. Once one of the players scor... | ```python
k,a,b=list(map(int,input().split()))
if a+b<=k*2-1:
print("1")
else:
print("-1")
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
78 | A | Haiku | PROGRAMMING | 800 | [
"implementation",
"strings"
] | A. Haiku | 2 | 256 | Haiku is a genre of Japanese traditional poetry.
A haiku poem consists of 17 syllables split into three phrases, containing 5, 7 and 5 syllables correspondingly (the first phrase should contain exactly 5 syllables, the second phrase should contain exactly 7 syllables, and the third phrase should contain exactly 5 syll... | The input data consists of three lines. The length of each line is between 1 and 100, inclusive. The *i*-th line contains the *i*-th phrase of the poem. Each phrase consists of one or more words, which are separated by one or more spaces. A word is a non-empty sequence of lowercase Latin letters. Leading and/or trailin... | Print "YES" (without the quotes) if the poem is a haiku. Otherwise, print "NO" (also without the quotes). | [
"on codeforces \nbeta round is running\n a rustling of keys \n",
"how many gallons\nof edo s rain did you drink\n cuckoo\n"
] | [
"YES",
"NO"
] | none | 500 | [
{
"input": "on codeforces \nbeta round is running\n a rustling of keys ",
"output": "YES"
},
{
"input": "how many gallons\nof edo s rain did you drink\n cuckoo",
"output": "NO"
},
{
"input": " hatsu shigure\n saru mo komino wo\nhoshige nari",
... | 1,576,818,827 | 2,147,483,647 | Python 3 | OK | TESTS | 40 | 248 | 0 | s=str(input())
s1=str(input())
s2=str(input())
sum=0
count=0
f=0
for i in range(0,len(s),1):
if(s[i]=='a' or s[i]=='e' or s[i]=='i' or s[i]=='o' or s[i]=='u'):
count+=1
for i in range(0,len(s1),1):
if(s1[i]=='a' or s1[i]=='e' or s1[i]=='i' or s1[i]=='o' or s1[i]=='u'):
sum+=1
for i in range(0,le... | Title: Haiku
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Haiku is a genre of Japanese traditional poetry.
A haiku poem consists of 17 syllables split into three phrases, containing 5, 7 and 5 syllables correspondingly (the first phrase should contain exactly 5 syllables, the second phrase... | ```python
s=str(input())
s1=str(input())
s2=str(input())
sum=0
count=0
f=0
for i in range(0,len(s),1):
if(s[i]=='a' or s[i]=='e' or s[i]=='i' or s[i]=='o' or s[i]=='u'):
count+=1
for i in range(0,len(s1),1):
if(s1[i]=='a' or s1[i]=='e' or s1[i]=='i' or s1[i]=='o' or s1[i]=='u'):
sum+=1
for i in ... | 3.938 | MatrixStudio/Codeforces-Python-Submissions |
291 | A | Spyke Talks | PROGRAMMING | 800 | [
"*special",
"implementation",
"sortings"
] | null | null | Polycarpus is the director of a large corporation. There are *n* secretaries working for the corporation, each of them corresponds via the famous Spyke VoIP system during the day. We know that when two people call each other via Spyke, the Spyke network assigns a unique ID to this call, a positive integer session numbe... | The first line contains integer *n* (1<=≤<=*n*<=≤<=103) — the number of secretaries in Polycarpus's corporation. The next line contains *n* space-separated integers: *id*1,<=*id*2,<=...,<=*id**n* (0<=≤<=*id**i*<=≤<=109). Number *id**i* equals the number of the call session of the *i*-th secretary, if the secretary is t... | Print a single integer — the number of pairs of chatting secretaries, or -1 if Polycarpus's got a mistake in his records and the described situation could not have taken place. | [
"6\n0 1 7 1 7 10\n",
"3\n1 1 1\n",
"1\n0\n"
] | [
"2\n",
"-1\n",
"0\n"
] | In the first test sample there are two Spyke calls between secretaries: secretary 2 and secretary 4, secretary 3 and secretary 5.
In the second test sample the described situation is impossible as conferences aren't allowed. | 500 | [
{
"input": "6\n0 1 7 1 7 10",
"output": "2"
},
{
"input": "3\n1 1 1",
"output": "-1"
},
{
"input": "1\n0",
"output": "0"
},
{
"input": "5\n2 2 1 1 3",
"output": "2"
},
{
"input": "1\n1",
"output": "0"
},
{
"input": "10\n4 21 3 21 21 1 1 2 2 3",
"ou... | 1,659,244,589 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 7 | 92 | 0 | n = int(input())
vals = [int(x) for x in input().strip().split()]
count = 0
for i in vals:
counter = 0
for j in vals:
if i == j:
counter+=1
count+=1
if counter % 2 != 0 and counter != 1:
print(-1)
exit()
print((count-n)//2) | Title: Spyke Talks
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Polycarpus is the director of a large corporation. There are *n* secretaries working for the corporation, each of them corresponds via the famous Spyke VoIP system during the day. We know that when two people call each othe... | ```python
n = int(input())
vals = [int(x) for x in input().strip().split()]
count = 0
for i in vals:
counter = 0
for j in vals:
if i == j:
counter+=1
count+=1
if counter % 2 != 0 and counter != 1:
print(-1)
exit()
print((count-n)//2)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
50 | A | Domino piling | PROGRAMMING | 800 | [
"greedy",
"math"
] | A. Domino piling | 2 | 256 | You are given a rectangular board of *M*<=×<=*N* squares. Also you are given an unlimited number of standard domino pieces of 2<=×<=1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as possible on the board so as to meet the following conditions:
1. Each domino completely covers ... | In a single line you are given two integers *M* and *N* — board sizes in squares (1<=≤<=*M*<=≤<=*N*<=≤<=16). | Output one number — the maximal number of dominoes, which can be placed. | [
"2 4\n",
"3 3\n"
] | [
"4\n",
"4\n"
] | none | 500 | [
{
"input": "2 4",
"output": "4"
},
{
"input": "3 3",
"output": "4"
},
{
"input": "1 5",
"output": "2"
},
{
"input": "1 6",
"output": "3"
},
{
"input": "1 15",
"output": "7"
},
{
"input": "1 16",
"output": "8"
},
{
"input": "2 5",
"outpu... | 1,672,584,184 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 62 | 0 | m = input()
m = m.split(" ")
n = m[1]
m = m[0]
def domino(x, y):
print(((int(x)*(y))/2))
domino(m, n) | Title: Domino piling
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
You are given a rectangular board of *M*<=×<=*N* squares. Also you are given an unlimited number of standard domino pieces of 2<=×<=1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as p... | ```python
m = input()
m = m.split(" ")
n = m[1]
m = m[0]
def domino(x, y):
print(((int(x)*(y))/2))
domino(m, n)
``` | -1 | MatrixStudio/Codeforces-Python-Submissions |
768 | B | Code For 1 | PROGRAMMING | 1,600 | [
"constructive algorithms",
"dfs and similar",
"divide and conquer"
] | null | null | Jon fought bravely to rescue the wildlings who were attacked by the white-walkers at Hardhome. On his arrival, Sam tells him that he wants to go to Oldtown to train at the Citadel to become a maester, so he can return and take the deceased Aemon's place as maester of Castle Black. Jon agrees to Sam's proposal and Sam s... | The first line contains three integers *n*, *l*, *r* (0<=≤<=*n*<=<<=250, 0<=≤<=*r*<=-<=*l*<=≤<=105, *r*<=≥<=1, *l*<=≥<=1) – initial element and the range *l* to *r*.
It is guaranteed that *r* is not greater than the length of the final list. | Output the total number of 1s in the range *l* to *r* in the final sequence. | [
"7 2 5\n",
"10 3 10\n"
] | [
"4\n",
"5\n"
] | Consider first example:
<img align="middle" class="tex-formula" src="https://espresso.codeforces.com/288fbb682a6fa1934a47b763d6851f9d32a06150.png" style="max-width: 100.0%;max-height: 100.0%;"/>
Elements on positions from 2-nd to 5-th in list is [1, 1, 1, 1]. The number of ones is 4.
For the second example:
<img al... | 1,000 | [
{
"input": "7 2 5",
"output": "4"
},
{
"input": "10 3 10",
"output": "5"
},
{
"input": "56 18 40",
"output": "20"
},
{
"input": "203 40 124",
"output": "67"
},
{
"input": "903316762502 354723010040 354723105411",
"output": "78355"
},
{
"input": "335343... | 1,663,351,986 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 31 | 0 | n,i,j= input().split()
def converter(arr):
for i,n in enumerate(arr):
if(arr[-1]==1):
return arr
if(n>1):
break
if(n==0 or n==1):
continue
return converter(arr[0:i] + [n//2,n%2,n//2] + arr[i+1:len(arr)])
converter([int(n)])[i-1,j] | Title: Code For 1
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Jon fought bravely to rescue the wildlings who were attacked by the white-walkers at Hardhome. On his arrival, Sam tells him that he wants to go to Oldtown to train at the Citadel to become a maester, so he can return and ta... | ```python
n,i,j= input().split()
def converter(arr):
for i,n in enumerate(arr):
if(arr[-1]==1):
return arr
if(n>1):
break
if(n==0 or n==1):
continue
return converter(arr[0:i] + [n//2,n%2,n//2] + arr[i+1:len(arr)])
converter([int(n)])[... | -1 | MatrixStudio/Codeforces-Python-Submissions | |
102 | B | Sum of Digits | PROGRAMMING | 1,000 | [
"implementation"
] | B. Sum of Digits | 2 | 265 | Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number *n*. How many times can Gerald put a spell on it until the number becomes one-... | The first line contains the only integer *n* (0<=≤<=*n*<=≤<=10100000). It is guaranteed that *n* doesn't contain any leading zeroes. | Print the number of times a number can be replaced by the sum of its digits until it only contains one digit. | [
"0\n",
"10\n",
"991\n"
] | [
"0\n",
"1\n",
"3\n"
] | In the first sample the number already is one-digit — Herald can't cast a spell.
The second test contains number 10. After one casting of a spell it becomes 1, and here the process is completed. Thus, Gerald can only cast the spell once.
The third test contains number 991. As one casts a spell the following transform... | 1,000 | [
{
"input": "0",
"output": "0"
},
{
"input": "10",
"output": "1"
},
{
"input": "991",
"output": "3"
},
{
"input": "99",
"output": "2"
},
{
"input": "100",
"output": "1"
},
{
"input": "123456789",
"output": "2"
},
{
"input": "32",
"output... | 1,595,762,504 | 2,147,483,647 | PyPy 3 | OK | TESTS | 51 | 310 | 22,118,400 | n=input()
k=0
while (len(n)!=1):
s=0
for i in n:
s+=int(i)
n=str(s)
k+=1
print(k) | Title: Sum of Digits
Time Limit: 2 seconds
Memory Limit: 265 megabytes
Problem Description:
Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came... | ```python
n=input()
k=0
while (len(n)!=1):
s=0
for i in n:
s+=int(i)
n=str(s)
k+=1
print(k)
``` | 3.8827 | MatrixStudio/Codeforces-Python-Submissions |
58 | A | Chat room | PROGRAMMING | 1,000 | [
"greedy",
"strings"
] | A. Chat room | 1 | 256 | Vasya has recently learned to type and log on to the Internet. He immediately entered a chat room and decided to say hello to everybody. Vasya typed the word *s*. It is considered that Vasya managed to say hello if several letters can be deleted from the typed word so that it resulted in the word "hello". For example, ... | The first and only line contains the word *s*, which Vasya typed. This word consisits of small Latin letters, its length is no less that 1 and no more than 100 letters. | If Vasya managed to say hello, print "YES", otherwise print "NO". | [
"ahhellllloou\n",
"hlelo\n"
] | [
"YES\n",
"NO\n"
] | none | 500 | [
{
"input": "ahhellllloou",
"output": "YES"
},
{
"input": "hlelo",
"output": "NO"
},
{
"input": "helhcludoo",
"output": "YES"
},
{
"input": "hehwelloho",
"output": "YES"
},
{
"input": "pnnepelqomhhheollvlo",
"output": "YES"
},
{
"input": "tymbzjyqhymeda... | 1,596,645,923 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 34 | 140 | 20,172,800 | s = input()
hello = "hello"
first = 0
for char in s:
if first == 4:
break
if char == hello[first]:
first += 1
if first == 4:
print("YES")
else:
print("NO")
| Title: Chat room
Time Limit: 1 seconds
Memory Limit: 256 megabytes
Problem Description:
Vasya has recently learned to type and log on to the Internet. He immediately entered a chat room and decided to say hello to everybody. Vasya typed the word *s*. It is considered that Vasya managed to say hello if several letter... | ```python
s = input()
hello = "hello"
first = 0
for char in s:
if first == 4:
break
if char == hello[first]:
first += 1
if first == 4:
print("YES")
else:
print("NO")
``` | 0 | MatrixStudio/Codeforces-Python-Submissions |
414 | B | Mashmokh and ACM | PROGRAMMING | 1,400 | [
"combinatorics",
"dp",
"number theory"
] | null | null | Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. In order to join he was given some programming tasks and one week to solve them. Mashmokh is not a very experienced prog... | The first line of input contains two space-separated integers *n*,<=*k* (1<=≤<=*n*,<=*k*<=≤<=2000). | Output a single integer — the number of good sequences of length *k* modulo 1000000007 (109<=+<=7). | [
"3 2\n",
"6 4\n",
"2 1\n"
] | [
"5\n",
"39\n",
"2\n"
] | In the first sample the good sequences are: [1, 1], [2, 2], [3, 3], [1, 2], [1, 3]. | 1,000 | [
{
"input": "3 2",
"output": "5"
},
{
"input": "6 4",
"output": "39"
},
{
"input": "2 1",
"output": "2"
},
{
"input": "1478 194",
"output": "312087753"
},
{
"input": "1415 562",
"output": "953558593"
},
{
"input": "1266 844",
"output": "735042656"
... | 1,610,073,528 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 3 | 218 | 9,523,200 | def findDivisors(x):
divisors = []
for i in range(1,((x)**1//2)+2):
if x%i==0:
divisors.append(i)
if x/i!=i:
divisors.append(x//i)
divisors=list(set(divisors))
return divisors
anss = []
n,k = map(int,input().split())
for i in range(1,n+1):
anss.append(... | Title: Mashmokh and ACM
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. In order to join h... | ```python
def findDivisors(x):
divisors = []
for i in range(1,((x)**1//2)+2):
if x%i==0:
divisors.append(i)
if x/i!=i:
divisors.append(x//i)
divisors=list(set(divisors))
return divisors
anss = []
n,k = map(int,input().split())
for i in range(1,n+1):
an... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
681 | B | Economy Game | PROGRAMMING | 1,300 | [
"brute force"
] | null | null | Kolya is developing an economy simulator game. His most favourite part of the development process is in-game testing. Once he was entertained by the testing so much, that he found out his game-coin score become equal to 0.
Kolya remembers that at the beginning of the game his game-coin score was equal to *n* and that ... | The first line of the input contains a single integer *n* (1<=≤<=*n*<=≤<=109) — Kolya's initial game-coin score. | Print "YES" (without quotes) if it's possible that Kolya spent all of his initial *n* coins buying only houses, cars and computers. Otherwise print "NO" (without quotes). | [
"1359257\n",
"17851817\n"
] | [
"YES",
"NO"
] | In the first sample, one of the possible solutions is to buy one house, one car and one computer, spending 1 234 567 + 123 456 + 1234 = 1 359 257 game-coins in total. | 1,000 | [
{
"input": "1359257",
"output": "YES"
},
{
"input": "17851817",
"output": "NO"
},
{
"input": "1000000000",
"output": "YES"
},
{
"input": "17851818",
"output": "YES"
},
{
"input": "438734347",
"output": "YES"
},
{
"input": "43873430",
"output": "YES... | 1,584,650,313 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 1 | 1,000 | 0 | initial_score = int(input())
bug = True
paro = False
for a in range(1000):
for b in range(10000):
t = initial_score - a*1234567 - b*123456
if t>=0 and t%1234==0:
print('YES')
bug = False
paro = True
break
if paro:
break
if bug:
print ('NO')
| Title: Economy Game
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Kolya is developing an economy simulator game. His most favourite part of the development process is in-game testing. Once he was entertained by the testing so much, that he found out his game-coin score become equal to 0.... | ```python
initial_score = int(input())
bug = True
paro = False
for a in range(1000):
for b in range(10000):
t = initial_score - a*1234567 - b*123456
if t>=0 and t%1234==0:
print('YES')
bug = False
paro = True
break
if paro:
break
if bug:
print ('NO')
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
922 | D | Robot Vacuum Cleaner | PROGRAMMING | 1,800 | [
"greedy",
"sortings"
] | null | null | Pushok the dog has been chasing Imp for a few hours already.
Fortunately, Imp knows that Pushok is afraid of a robot vacuum cleaner.
While moving, the robot generates a string *t* consisting of letters 's' and 'h', that produces a lot of noise. We define noise of string *t* as the number of occurrences of string "sh... | The first line contains a single integer *n* (1<=≤<=*n*<=≤<=105) — the number of strings in robot's memory.
Next *n* lines contain the strings *t*1,<=*t*2,<=...,<=*t**n*, one per line. It is guaranteed that the strings are non-empty, contain only English letters 's' and 'h' and their total length does not exceed 105. | Print a single integer — the maxumum possible noise Imp can achieve by changing the order of the strings. | [
"4\nssh\nhs\ns\nhhhs\n",
"2\nh\ns\n"
] | [
"18\n",
"1\n"
] | The optimal concatenation in the first sample is *ssshhshhhs*. | 1,500 | [
{
"input": "4\nssh\nhs\ns\nhhhs",
"output": "18"
},
{
"input": "2\nh\ns",
"output": "1"
},
{
"input": "6\nh\ns\nhhh\nh\nssssss\ns",
"output": "40"
},
{
"input": "1\ns",
"output": "0"
},
{
"input": "10\nsshshss\nhssssssssh\nhhhhhh\nhhhs\nhshhh\nhhhhshsh\nhh\nh\nshs... | 1,693,943,407 | 2,407 | PyPy 3 | OK | TESTS | 48 | 296 | 12,697,600 | import sys
input = sys.stdin.buffer.readline
import functools
def compare(a, b):
n1, d1 = a
n2, d2= b
if n1*d2 <= n2*d1:
return 1
return -1
def process(A):
L = []
answer = 0
S = 0
H = 0
for ti in A:
total_s =0
total_h = 0
... | Title: Robot Vacuum Cleaner
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Pushok the dog has been chasing Imp for a few hours already.
Fortunately, Imp knows that Pushok is afraid of a robot vacuum cleaner.
While moving, the robot generates a string *t* consisting of letters 's' and '... | ```python
import sys
input = sys.stdin.buffer.readline
import functools
def compare(a, b):
n1, d1 = a
n2, d2= b
if n1*d2 <= n2*d1:
return 1
return -1
def process(A):
L = []
answer = 0
S = 0
H = 0
for ti in A:
total_s =0
total_... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
492 | B | Vanya and Lanterns | PROGRAMMING | 1,200 | [
"binary search",
"implementation",
"math",
"sortings"
] | null | null | Vanya walks late at night along a straight street of length *l*, lit by *n* lanterns. Consider the coordinate system with the beginning of the street corresponding to the point 0, and its end corresponding to the point *l*. Then the *i*-th lantern is at the point *a**i*. The lantern lights all points of the street that... | The first line contains two integers *n*, *l* (1<=≤<=*n*<=≤<=1000, 1<=≤<=*l*<=≤<=109) — the number of lanterns and the length of the street respectively.
The next line contains *n* integers *a**i* (0<=≤<=*a**i*<=≤<=*l*). Multiple lanterns can be located at the same point. The lanterns may be located at the ends of th... | Print the minimum light radius *d*, needed to light the whole street. The answer will be considered correct if its absolute or relative error doesn't exceed 10<=-<=9. | [
"7 15\n15 5 3 7 9 14 0\n",
"2 5\n2 5\n"
] | [
"2.5000000000\n",
"2.0000000000\n"
] | Consider the second sample. At *d* = 2 the first lantern will light the segment [0, 4] of the street, and the second lantern will light segment [3, 5]. Thus, the whole street will be lit. | 1,000 | [
{
"input": "7 15\n15 5 3 7 9 14 0",
"output": "2.5000000000"
},
{
"input": "2 5\n2 5",
"output": "2.0000000000"
},
{
"input": "46 615683844\n431749087 271781274 274974690 324606253 480870261 401650581 13285442 478090364 266585394 425024433 588791449 492057200 391293435 563090494 317950 1... | 1,696,043,451 | 2,147,483,647 | Python 3 | OK | TESTS | 32 | 46 | 0 | #author 沈天健 2300011417
n,l=map(int,input().split())
position=list(map(int,input().split()))
position.sort()
ans=0
for i in range(1,n):
ans=max(ans,(position[i]-position[i-1])/2)
print(max(ans,position[0],l-position[n-1]))
| Title: Vanya and Lanterns
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vanya walks late at night along a straight street of length *l*, lit by *n* lanterns. Consider the coordinate system with the beginning of the street corresponding to the point 0, and its end corresponding to the poi... | ```python
#author 沈天健 2300011417
n,l=map(int,input().split())
position=list(map(int,input().split()))
position.sort()
ans=0
for i in range(1,n):
ans=max(ans,(position[i]-position[i-1])/2)
print(max(ans,position[0],l-position[n-1]))
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
895 | A | Pizza Separation | PROGRAMMING | 1,200 | [
"brute force",
"implementation"
] | null | null | Students Vasya and Petya are studying at the BSU (Byteland State University). At one of the breaks they decided to order a pizza. In this problem pizza is a circle of some radius. The pizza was delivered already cut into *n* pieces. The *i*-th piece is a sector of angle equal to *a**i*. Vasya and Petya want to divide a... | The first line contains one integer *n* (1<=≤<=*n*<=≤<=360) — the number of pieces into which the delivered pizza was cut.
The second line contains *n* integers *a**i* (1<=≤<=*a**i*<=≤<=360) — the angles of the sectors into which the pizza was cut. The sum of all *a**i* is 360. | Print one integer — the minimal difference between angles of sectors that will go to Vasya and Petya. | [
"4\n90 90 90 90\n",
"3\n100 100 160\n",
"1\n360\n",
"4\n170 30 150 10\n"
] | [
"0\n",
"40\n",
"360\n",
"0\n"
] | In first sample Vasya can take 1 and 2 pieces, Petya can take 3 and 4 pieces. Then the answer is |(90 + 90) - (90 + 90)| = 0.
In third sample there is only one piece of pizza that can be taken by only one from Vasya and Petya. So the answer is |360 - 0| = 360.
In fourth sample Vasya can take 1 and 4 pieces, then Pety... | 500 | [
{
"input": "4\n90 90 90 90",
"output": "0"
},
{
"input": "3\n100 100 160",
"output": "40"
},
{
"input": "1\n360",
"output": "360"
},
{
"input": "4\n170 30 150 10",
"output": "0"
},
{
"input": "5\n10 10 10 10 320",
"output": "280"
},
{
"input": "8\n45 4... | 1,511,793,427 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 61 | 5,529,600 | minnum = int(1000)
num = input()
nums = input().split(' ', maxsplit = int(num) - 1)
def findsmalldistance (index, arr):
leftnum = 0
rightnum = 0
global minnum
for i in range(len(arr)):
for j in range(index-i, index):
if index - j < 0:
leftnum = leftnum + i... | Title: Pizza Separation
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Students Vasya and Petya are studying at the BSU (Byteland State University). At one of the breaks they decided to order a pizza. In this problem pizza is a circle of some radius. The pizza was delivered already cut in... | ```python
minnum = int(1000)
num = input()
nums = input().split(' ', maxsplit = int(num) - 1)
def findsmalldistance (index, arr):
leftnum = 0
rightnum = 0
global minnum
for i in range(len(arr)):
for j in range(index-i, index):
if index - j < 0:
leftnum = l... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
59 | A | Word | PROGRAMMING | 800 | [
"implementation",
"strings"
] | A. Word | 2 | 256 | Vasya is very upset that many people on the Net mix uppercase and lowercase letters in one word. That's why he decided to invent an extension for his favorite browser that would change the letters' register in every word so that it either only consisted of lowercase letters or, vice versa, only of uppercase ones. At th... | The first line contains a word *s* — it consists of uppercase and lowercase Latin letters and possesses the length from 1 to 100. | Print the corrected word *s*. If the given word *s* has strictly more uppercase letters, make the word written in the uppercase register, otherwise - in the lowercase one. | [
"HoUse\n",
"ViP\n",
"maTRIx\n"
] | [
"house\n",
"VIP\n",
"matrix\n"
] | none | 500 | [
{
"input": "HoUse",
"output": "house"
},
{
"input": "ViP",
"output": "VIP"
},
{
"input": "maTRIx",
"output": "matrix"
},
{
"input": "BNHWpnpawg",
"output": "bnhwpnpawg"
},
{
"input": "VTYGP",
"output": "VTYGP"
},
{
"input": "CHNenu",
"output": "chn... | 1,459,133,049 | 2,147,483,647 | Python 3 | COMPILATION_ERROR | TESTS | 0 | 0 | 0 | str=input()
lower=int(0)
upper=int(0)
for i in range(len(str)):
if str[i].islower()==True:
lower+=1
else:
upper+=1
if upper>lower:
print str.upper()
else:
print str.lower() | Title: Word
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Vasya is very upset that many people on the Net mix uppercase and lowercase letters in one word. That's why he decided to invent an extension for his favorite browser that would change the letters' register in every word so that it ei... | ```python
str=input()
lower=int(0)
upper=int(0)
for i in range(len(str)):
if str[i].islower()==True:
lower+=1
else:
upper+=1
if upper>lower:
print str.upper()
else:
print str.lower()
``` | -1 | MatrixStudio/Codeforces-Python-Submissions |
150 | B | Quantity of Strings | PROGRAMMING | 1,600 | [
"combinatorics",
"dfs and similar",
"graphs",
"math"
] | null | null | Just in case somebody missed it: this winter is totally cold in Nvodsk! It is so cold that one gets funny thoughts. For example, let's say there are strings with the length exactly *n*, based on the alphabet of size *m*. Any its substring with length equal to *k* is a palindrome. How many such strings exist? Your task ... | The first and only line contains three integers: *n*, *m* and *k* (1<=≤<=*n*,<=*m*,<=*k*<=≤<=2000). | Print a single integer — the number of strings of the described type modulo 1000000007 (109<=+<=7). | [
"1 1 1\n",
"5 2 4\n"
] | [
"1\n",
"2\n"
] | In the first sample only one string is valid: "a" (let's denote the only letter of our alphabet as "a").
In the second sample (if we denote the alphabet letters as "a" and "b") the following strings are valid: "aaaaa" and "bbbbb". | 500 | [
{
"input": "1 1 1",
"output": "1"
},
{
"input": "5 2 4",
"output": "2"
},
{
"input": "7 4 20",
"output": "16384"
},
{
"input": "8 13 9",
"output": "815730721"
},
{
"input": "10 23 9",
"output": "529"
},
{
"input": "10 25 8",
"output": "25"
},
{... | 1,660,338,812 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 4 | 46 | 0 | n,m,k=map(int,input().split())
mod=1_000_000_007
if k >= n: print(pow(m,n,mod))
elif k%2==0: print(m%mod)
else: print(pow(m,(k+1)//2,mod)) | Title: Quantity of Strings
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Just in case somebody missed it: this winter is totally cold in Nvodsk! It is so cold that one gets funny thoughts. For example, let's say there are strings with the length exactly *n*, based on the alphabet of size... | ```python
n,m,k=map(int,input().split())
mod=1_000_000_007
if k >= n: print(pow(m,n,mod))
elif k%2==0: print(m%mod)
else: print(pow(m,(k+1)//2,mod))
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
12 | A | Super Agent | PROGRAMMING | 800 | [
"implementation"
] | A. Super Agent | 2 | 256 | There is a very secret base in Potatoland where potato mash is made according to a special recipe. The neighbours from Porridgia decided to seize this recipe and to sell it to Pilauland. For this mission they have been preparing special agent Pearlo for many years. When, finally, Pearlo learned all secrets of espionage... | Input contains the matrix of three rows of three symbols each. Symbol «X» means that the corresponding button was pressed, and «.» means that is was not pressed. The matrix may contain no «X», also it may contain no «.». | Print YES if the password is symmetric with respect to the central button of the terminal and NO otherwise. | [
"XX.\n...\n.XX\n",
"X.X\nX..\n...\n"
] | [
"YES\n",
"NO\n"
] | If you are not familiar with the term «central symmetry», you may look into http://en.wikipedia.org/wiki/Central_symmetry | 0 | [
{
"input": "XX.\n...\n.XX",
"output": "YES"
},
{
"input": ".X.\n.X.\n.X.",
"output": "YES"
},
{
"input": "XXX\nXXX\nXXX",
"output": "YES"
},
{
"input": "XXX\nX.X\nXXX",
"output": "YES"
},
{
"input": "X..\n.X.\n..X",
"output": "YES"
},
{
"input": "...\n... | 1,612,637,887 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 92 | 0 | # A. Super Agent
s = ""
for _ in range(3):
s += input()
# Idea from https://codeforces.com/contest/12/submission/69686110
print("YES" if s == s[::-1] else "NO")
| Title: Super Agent
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
There is a very secret base in Potatoland where potato mash is made according to a special recipe. The neighbours from Porridgia decided to seize this recipe and to sell it to Pilauland. For this mission they have been preparin... | ```python
# A. Super Agent
s = ""
for _ in range(3):
s += input()
# Idea from https://codeforces.com/contest/12/submission/69686110
print("YES" if s == s[::-1] else "NO")
``` | 0 | MatrixStudio/Codeforces-Python-Submissions |
785 | A | Anton and Polyhedrons | PROGRAMMING | 800 | [
"implementation",
"strings"
] | null | null | Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons:
- Tetrahedron. Tetrahedron has 4 triangular faces. - Cube. Cube has 6 square faces. - Octahedron. Octahedron has 8 triangular faces. - Dodecahedron. Dodecahedron has 12 pentagonal faces. - Icosahed... | The first line of the input contains a single integer *n* (1<=≤<=*n*<=≤<=200<=000) — the number of polyhedrons in Anton's collection.
Each of the following *n* lines of the input contains a string *s**i* — the name of the *i*-th polyhedron in Anton's collection. The string can look like this:
- "Tetrahedron" (withou... | Output one number — the total number of faces in all the polyhedrons in Anton's collection. | [
"4\nIcosahedron\nCube\nTetrahedron\nDodecahedron\n",
"3\nDodecahedron\nOctahedron\nOctahedron\n"
] | [
"42\n",
"28\n"
] | In the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces. | 500 | [
{
"input": "4\nIcosahedron\nCube\nTetrahedron\nDodecahedron",
"output": "42"
},
{
"input": "3\nDodecahedron\nOctahedron\nOctahedron",
"output": "28"
},
{
"input": "25\nIcosahedron\nOctahedron\nTetrahedron\nDodecahedron\nCube\nIcosahedron\nOctahedron\nCube\nTetrahedron\nIcosahedron\nIcosa... | 1,673,354,782 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 31 | 0 | s=0
for _ in range(int(input())):
c=input()
if c=='Tetrahedron':s+=4
elif c=='Cube':s+=6
elif c=='Octahedron':s+=8
elif c=='Dodecahedron':s+=12
elif c=='Tetrahedron':s+=20
print(s) | Title: Anton and Polyhedrons
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons:
- Tetrahedron. Tetrahedron has 4 triangular faces. - Cube. Cube has 6 square faces. - Octahe... | ```python
s=0
for _ in range(int(input())):
c=input()
if c=='Tetrahedron':s+=4
elif c=='Cube':s+=6
elif c=='Octahedron':s+=8
elif c=='Dodecahedron':s+=12
elif c=='Tetrahedron':s+=20
print(s)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
676 | B | Pyramid of Glasses | PROGRAMMING | 1,500 | [
"implementation",
"math",
"math"
] | null | null | Mary has just graduated from one well-known University and is now attending celebration party. Students like to dream of a beautiful life, so they used champagne glasses to construct a small pyramid. The height of the pyramid is *n*. The top level consists of only 1 glass, that stands on 2 glasses on the second level (... | The only line of the input contains two integers *n* and *t* (1<=≤<=*n*<=≤<=10,<=0<=≤<=*t*<=≤<=10<=000) — the height of the pyramid and the number of seconds Vlad will be pouring champagne from the bottle. | Print the single integer — the number of completely full glasses after *t* seconds. | [
"3 5\n",
"4 8\n"
] | [
"4\n",
"6\n"
] | In the first sample, the glasses full after 5 seconds are: the top glass, both glasses on the second level and the middle glass at the bottom level. Left and right glasses of the bottom level will be half-empty. | 1,000 | [
{
"input": "3 5",
"output": "4"
},
{
"input": "4 8",
"output": "6"
},
{
"input": "1 1",
"output": "1"
},
{
"input": "10 10000",
"output": "55"
},
{
"input": "1 10000",
"output": "1"
},
{
"input": "10 1",
"output": "1"
},
{
"input": "1 0",
... | 1,666,941,954 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 3 | 46 | 0 | n,m = [int(i) for i in input().split()]
res = []
for i in range(n):
temp = [0 for j in range(i+1)]
res.append(temp)
def pyramid(n,m,i,j,add,t):
#print(i,j,add,t)
#print(res)
# if(j==-1):
# j=0
# if(j<0):
# return
if(j>i):
j=i-1
if(t == 0 ):... | Title: Pyramid of Glasses
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Mary has just graduated from one well-known University and is now attending celebration party. Students like to dream of a beautiful life, so they used champagne glasses to construct a small pyramid. The height of th... | ```python
n,m = [int(i) for i in input().split()]
res = []
for i in range(n):
temp = [0 for j in range(i+1)]
res.append(temp)
def pyramid(n,m,i,j,add,t):
#print(i,j,add,t)
#print(res)
# if(j==-1):
# j=0
# if(j<0):
# return
if(j>i):
j=i-1
if... | -1 | MatrixStudio/Codeforces-Python-Submissions | |
387 | B | George and Round | PROGRAMMING | 1,200 | [
"brute force",
"greedy",
"two pointers"
] | null | null | George decided to prepare a Codesecrof round, so he has prepared *m* problems for the round. Let's number the problems with integers 1 through *m*. George estimates the *i*-th problem's complexity by integer *b**i*.
To make the round good, he needs to put at least *n* problems there. Besides, he needs to have at least... | The first line contains two integers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=3000) — the minimal number of problems in a good round and the number of problems George's prepared. The second line contains space-separated integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a*1<=<<=*a*2<=<<=...<=<<=*a**n*<=≤<=106) — the requirem... | Print a single integer — the answer to the problem. | [
"3 5\n1 2 3\n1 2 2 3 3\n",
"3 5\n1 2 3\n1 1 1 1 1\n",
"3 1\n2 3 4\n1\n"
] | [
"0\n",
"2\n",
"3\n"
] | In the first sample the set of the prepared problems meets the requirements for a good round.
In the second sample, it is enough to come up with and prepare two problems with complexities 2 and 3 to get a good round.
In the third sample it is very easy to get a good round if come up with and prepare extra problems wi... | 1,000 | [
{
"input": "3 5\n1 2 3\n1 2 2 3 3",
"output": "0"
},
{
"input": "3 5\n1 2 3\n1 1 1 1 1",
"output": "2"
},
{
"input": "3 1\n2 3 4\n1",
"output": "3"
},
{
"input": "29 100\n20 32 41 67 72 155 331 382 399 412 465 470 484 511 515 529 616 637 679 715 733 763 826 843 862 903 925 97... | 1,692,540,600 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 3 | 46 | 307,200 | from collections import defaultdict
d1=defaultdict(lambda: 0)
d2=defaultdict(lambda: 0)
n,m=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
c=0
for i in y:
d2[i]+=1
for i in x:
d1[i]+=1
for i in x:
if d1[i]>d2[i]:
c+=d1[i]-d2[i]
print(... | Title: George and Round
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
George decided to prepare a Codesecrof round, so he has prepared *m* problems for the round. Let's number the problems with integers 1 through *m*. George estimates the *i*-th problem's complexity by integer *b**i*.
T... | ```python
from collections import defaultdict
d1=defaultdict(lambda: 0)
d2=defaultdict(lambda: 0)
n,m=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
c=0
for i in y:
d2[i]+=1
for i in x:
d1[i]+=1
for i in x:
if d1[i]>d2[i]:
c+=d1[i]-d2[i]... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
746 | B | Decoding | PROGRAMMING | 900 | [
"implementation",
"strings"
] | null | null | Polycarp is mad about coding, that is why he writes Sveta encoded messages. He calls the median letter in a word the letter which is in the middle of the word. If the word's length is even, the median letter is the left of the two middle letters. In the following examples, the median letter is highlighted: contest, inf... | The first line contains a positive integer *n* (1<=≤<=*n*<=≤<=2000) — the length of the encoded word.
The second line contains the string *s* of length *n* consisting of lowercase English letters — the encoding. | Print the word that Polycarp encoded. | [
"5\nlogva\n",
"2\nno\n",
"4\nabba\n"
] | [
"volga\n",
"no\n",
"baba\n"
] | In the first example Polycarp encoded the word volga. At first, he wrote down the letter l from the position 3, after that his word looked like voga. After that Polycarp wrote down the letter o from the position 2, his word became vga. Then Polycarp wrote down the letter g which was at the second position, the word bec... | 1,000 | [
{
"input": "5\nlogva",
"output": "volga"
},
{
"input": "2\nno",
"output": "no"
},
{
"input": "4\nabba",
"output": "baba"
},
{
"input": "51\nkfsmpaeviowvkdbuhdagquxxqniselafnfbrgbhmsugcbbnlrvv",
"output": "vlbcumbrfflsnxugdudvovamfkspeiwkbhaqxqieanbghsgbnrv"
},
{
"... | 1,685,902,123 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 4 | 46 | 921,600 | import sys
import re
import math
input = sys.stdin.readline
############ ---- Input Functions ---- ############
def inp():
return(int(input()))
def inlt():
return(list(map(int,input().split())))
def insr():
s = input()
return(list(s[:len(s) - 1]))
def inir(s,extrat):
if extrat:
... | Title: Decoding
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Polycarp is mad about coding, that is why he writes Sveta encoded messages. He calls the median letter in a word the letter which is in the middle of the word. If the word's length is even, the median letter is the left of the... | ```python
import sys
import re
import math
input = sys.stdin.readline
############ ---- Input Functions ---- ############
def inp():
return(int(input()))
def inlt():
return(list(map(int,input().split())))
def insr():
s = input()
return(list(s[:len(s) - 1]))
def inir(s,extrat):
i... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
994 | B | Knights of a Polygonal Table | PROGRAMMING | 1,400 | [
"greedy",
"implementation",
"sortings"
] | null | null | Unlike Knights of a Round Table, Knights of a Polygonal Table deprived of nobility and happy to kill each other. But each knight has some power and a knight can kill another knight if and only if his power is greater than the power of victim. However, even such a knight will torment his conscience, so he can kill no mo... | The first line contains two integers $n$ and $k$ $(1 \le n \le 10^5, 0 \le k \le \min(n-1,10))$ — the number of knights and the number $k$ from the statement.
The second line contains $n$ integers $p_1, p_2 ,\ldots,p_n$ $(1 \le p_i \le 10^9)$ — powers of the knights. All $p_i$ are distinct.
The third line contains $n... | Print $n$ integers — the maximum number of coins each knight can have it only he kills other knights. | [
"4 2\n4 5 9 7\n1 2 11 33\n",
"5 1\n1 2 3 4 5\n1 2 3 4 5\n",
"1 0\n2\n3\n"
] | [
"1 3 46 36 ",
"1 3 5 7 9 ",
"3 "
] | Consider the first example.
- The first knight is the weakest, so he can't kill anyone. That leaves him with the only coin he initially has. - The second knight can kill the first knight and add his coin to his own two. - The third knight is the strongest, but he can't kill more than $k = 2$ other knights. It is o... | 1,000 | [
{
"input": "4 2\n4 5 9 7\n1 2 11 33",
"output": "1 3 46 36 "
},
{
"input": "5 1\n1 2 3 4 5\n1 2 3 4 5",
"output": "1 3 5 7 9 "
},
{
"input": "1 0\n2\n3",
"output": "3 "
},
{
"input": "7 1\n2 3 4 5 7 8 9\n0 3 7 9 5 8 9",
"output": "0 3 10 16 14 17 18 "
},
{
"input"... | 1,646,648,069 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 3 | 46 | 0 | n,k=map(int,input().split())
q=list(map(int,input().split()))
p=list(map(int,input().split()))
l=[]
a=0
c=0
d={}
m=[]
for i in range(n):
l.append([q[i],p[i]])
d[i]=q[i]
# while True:
# if q[i]>q[a]:
# p[i]+=p[a]
# c+=1
# a+=1
# if a==n or c==k:... | Title: Knights of a Polygonal Table
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Unlike Knights of a Round Table, Knights of a Polygonal Table deprived of nobility and happy to kill each other. But each knight has some power and a knight can kill another knight if and only if his power ... | ```python
n,k=map(int,input().split())
q=list(map(int,input().split()))
p=list(map(int,input().split()))
l=[]
a=0
c=0
d={}
m=[]
for i in range(n):
l.append([q[i],p[i]])
d[i]=q[i]
# while True:
# if q[i]>q[a]:
# p[i]+=p[a]
# c+=1
# a+=1
# if a==... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
334 | A | Candy Bags | PROGRAMMING | 1,000 | [
"implementation"
] | null | null | Gerald has *n* younger brothers and their number happens to be even. One day he bought *n*2 candy bags. One bag has one candy, one bag has two candies, one bag has three candies and so on. In fact, for each integer *k* from 1 to *n*2 he has exactly one bag with *k* candies.
Help him give *n* bags of candies to each b... | The single line contains a single integer *n* (*n* is even, 2<=≤<=*n*<=≤<=100) — the number of Gerald's brothers. | Let's assume that Gerald indexes his brothers with numbers from 1 to *n*. You need to print *n* lines, on the *i*-th line print *n* integers — the numbers of candies in the bags for the *i*-th brother. Naturally, all these numbers should be distinct and be within limits from 1 to *n*2. You can print the numbers in the ... | [
"2\n"
] | [
"1 4\n2 3\n"
] | The sample shows Gerald's actions if he has two brothers. In this case, his bags contain 1, 2, 3 and 4 candies. He can give the bags with 1 and 4 candies to one brother and the bags with 2 and 3 to the other brother. | 500 | [
{
"input": "2",
"output": "1 4\n2 3"
},
{
"input": "4",
"output": "1 16 2 15\n3 14 4 13\n5 12 6 11\n7 10 8 9"
},
{
"input": "6",
"output": "1 36 2 35 3 34\n4 33 5 32 6 31\n7 30 8 29 9 28\n10 27 11 26 12 25\n13 24 14 23 15 22\n16 21 17 20 18 19"
},
{
"input": "8",
"output"... | 1,599,459,631 | 2,147,483,647 | Python 3 | OK | TESTS | 21 | 218 | 614,400 | n=int(input())
li=[i for i in range(1,n**2+1)]
j=[]
ans=[]
count=0
k=[]
for i in range(0,(n**2)//2):
j.append([li[i],li[-i-1]])
for i in j:
k+=i
count+=1
if count==n//2:
ans.append(k)
k=[]
count=0
for i in ans:
print(*i) | Title: Candy Bags
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Gerald has *n* younger brothers and their number happens to be even. One day he bought *n*2 candy bags. One bag has one candy, one bag has two candies, one bag has three candies and so on. In fact, for each integer *k* from ... | ```python
n=int(input())
li=[i for i in range(1,n**2+1)]
j=[]
ans=[]
count=0
k=[]
for i in range(0,(n**2)//2):
j.append([li[i],li[-i-1]])
for i in j:
k+=i
count+=1
if count==n//2:
ans.append(k)
k=[]
count=0
for i in ans:
print(*i)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
780 | A | Andryusha and Socks | PROGRAMMING | 800 | [
"implementation"
] | null | null | Andryusha is an orderly boy and likes to keep things in their place.
Today he faced a problem to put his socks in the wardrobe. He has *n* distinct pairs of socks which are initially in a bag. The pairs are numbered from 1 to *n*. Andryusha wants to put paired socks together and put them in the wardrobe. He takes the ... | The first line contains the single integer *n* (1<=≤<=*n*<=≤<=105) — the number of sock pairs.
The second line contains 2*n* integers *x*1,<=*x*2,<=...,<=*x*2*n* (1<=≤<=*x**i*<=≤<=*n*), which describe the order in which Andryusha took the socks from the bag. More precisely, *x**i* means that the *i*-th sock Andryusha ... | Print single integer — the maximum number of socks that were on the table at the same time. | [
"1\n1 1\n",
"3\n2 1 1 3 2 3\n"
] | [
"1\n",
"2\n"
] | In the first example Andryusha took a sock from the first pair and put it on the table. Then he took the next sock which is from the first pair as well, so he immediately puts both socks to the wardrobe. Thus, at most one sock was on the table at the same time.
In the second example Andryusha behaved as follows:
- ... | 500 | [
{
"input": "1\n1 1",
"output": "1"
},
{
"input": "3\n2 1 1 3 2 3",
"output": "2"
},
{
"input": "5\n5 1 3 2 4 3 1 2 4 5",
"output": "5"
},
{
"input": "10\n4 2 6 3 4 8 7 1 1 5 2 10 6 8 3 5 10 9 9 7",
"output": "6"
},
{
"input": "50\n30 47 31 38 37 50 36 43 9 23 2 2 ... | 1,563,048,210 | 2,147,483,647 | Python 3 | OK | TESTS | 56 | 280 | 11,264,000 | n = int(input())
a = [0]*n
k = 0
km = 0
for i in input().split():
i = int(i) - 1
if a[i] == 0:
a[i] = 1
k += 1
if k > km: km = k
else:
a[i] = 0
k -= 1
print(km)
| Title: Andryusha and Socks
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Andryusha is an orderly boy and likes to keep things in their place.
Today he faced a problem to put his socks in the wardrobe. He has *n* distinct pairs of socks which are initially in a bag. The pairs are numbere... | ```python
n = int(input())
a = [0]*n
k = 0
km = 0
for i in input().split():
i = int(i) - 1
if a[i] == 0:
a[i] = 1
k += 1
if k > km: km = k
else:
a[i] = 0
k -= 1
print(km)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
225 | A | Dice Tower | PROGRAMMING | 1,100 | [
"constructive algorithms",
"greedy"
] | null | null | A dice is a cube, its faces contain distinct integers from 1 to 6 as black points. The sum of numbers at the opposite dice faces always equals 7. Please note that there are only two dice (these dices are mirror of each other) that satisfy the given constraints (both of them are shown on the picture on the left).
Alice... | The first line contains a single integer *n* (1<=≤<=*n*<=≤<=100) — the number of dice in the tower.
The second line contains an integer *x* (1<=≤<=*x*<=≤<=6) — the number Bob sees at the top of the tower. Next *n* lines contain two space-separated integers each: the *i*-th line contains numbers *a**i*,<=*b**i* (1<=≤<=... | Print "YES" (without the quotes), if it is possible to to uniquely identify the numbers on the faces of all the dice in the tower. If it is impossible, print "NO" (without the quotes). | [
"3\n6\n3 2\n5 4\n2 4\n",
"3\n3\n2 6\n4 1\n5 3\n"
] | [
"YES",
"NO"
] | none | 500 | [
{
"input": "3\n6\n3 2\n5 4\n2 4",
"output": "YES"
},
{
"input": "3\n3\n2 6\n4 1\n5 3",
"output": "NO"
},
{
"input": "1\n3\n2 1",
"output": "YES"
},
{
"input": "2\n2\n3 1\n1 5",
"output": "NO"
},
{
"input": "3\n2\n1 4\n5 3\n6 4",
"output": "NO"
},
{
"in... | 1,666,584,330 | 2,147,483,647 | Python 3 | OK | TESTS | 52 | 92 | 0 | n = int(input())
top = int(input())
flag = True
for _ in range(n):
a, b = list( map(int, input().split()) )
st = set()
st.add(top)
st.add(7-top)
top = 7 - top
st.add(a)
st.add(7-a)
st.add(b)
st.add(7-b)
if len(st) != 6:
flag = False
print("YNEOS"[no... | Title: Dice Tower
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
A dice is a cube, its faces contain distinct integers from 1 to 6 as black points. The sum of numbers at the opposite dice faces always equals 7. Please note that there are only two dice (these dices are mirror of each other... | ```python
n = int(input())
top = int(input())
flag = True
for _ in range(n):
a, b = list( map(int, input().split()) )
st = set()
st.add(top)
st.add(7-top)
top = 7 - top
st.add(a)
st.add(7-a)
st.add(b)
st.add(7-b)
if len(st) != 6:
flag = False
print(... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
888 | C | K-Dominant Character | PROGRAMMING | 1,400 | [
"binary search",
"implementation",
"two pointers"
] | null | null | You are given a string *s* consisting of lowercase Latin letters. Character *c* is called *k*-dominant iff each substring of *s* with length at least *k* contains this character *c*.
You have to find minimum *k* such that there exists at least one *k*-dominant character. | The first line contains string *s* consisting of lowercase Latin letters (1<=≤<=|*s*|<=≤<=100000). | Print one number — the minimum value of *k* such that there exists at least one *k*-dominant character. | [
"abacaba\n",
"zzzzz\n",
"abcde\n"
] | [
"2\n",
"1\n",
"3\n"
] | none | 0 | [
{
"input": "abacaba",
"output": "2"
},
{
"input": "zzzzz",
"output": "1"
},
{
"input": "abcde",
"output": "3"
},
{
"input": "bcaccacaaabaacaabaaabcbbcbcaacacbcbaaaacccacbbcbaabcbacaacbabacacacaccbbccbcbacbbbbccccabcabaaab",
"output": "8"
},
{
"input": "daabcdabbab... | 1,606,544,558 | 2,147,483,647 | PyPy 3 | OK | TESTS | 51 | 140 | 6,451,200 | s=input()
c=float('Inf')
for chr in set(s):
l=0
for j in s.split(chr):
l=max(l,len(j))
c=min(l,c)
print(c+1) | Title: K-Dominant Character
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given a string *s* consisting of lowercase Latin letters. Character *c* is called *k*-dominant iff each substring of *s* with length at least *k* contains this character *c*.
You have to find minimum *k* s... | ```python
s=input()
c=float('Inf')
for chr in set(s):
l=0
for j in s.split(chr):
l=max(l,len(j))
c=min(l,c)
print(c+1)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
404 | A | Valera and X | PROGRAMMING | 1,000 | [
"implementation"
] | null | null | Valera is a little boy. Yesterday he got a huge Math hometask at school, so Valera didn't have enough time to properly learn the English alphabet for his English lesson. Unfortunately, the English teacher decided to have a test on alphabet today. At the test Valera got a square piece of squared paper. The length of the... | The first line contains integer *n* (3<=≤<=*n*<=<<=300; *n* is odd). Each of the next *n* lines contains *n* small English letters — the description of Valera's paper. | Print string "YES", if the letters on the paper form letter "X". Otherwise, print string "NO". Print the strings without quotes. | [
"5\nxooox\noxoxo\nsoxoo\noxoxo\nxooox\n",
"3\nwsw\nsws\nwsw\n",
"3\nxpx\npxp\nxpe\n"
] | [
"NO\n",
"YES\n",
"NO\n"
] | none | 500 | [
{
"input": "5\nxooox\noxoxo\nsoxoo\noxoxo\nxooox",
"output": "NO"
},
{
"input": "3\nwsw\nsws\nwsw",
"output": "YES"
},
{
"input": "3\nxpx\npxp\nxpe",
"output": "NO"
},
{
"input": "5\nliiil\nilili\niilii\nilili\nliiil",
"output": "YES"
},
{
"input": "7\nbwccccb\nck... | 1,604,222,463 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 6 | 93 | 307,200 | from sys import stdin, stdout
n = int(stdin.readline())
letters = stdin.readline()
char_in_diagonal = letters[0]
char_not_in_diagonal = letters[1]
if char_in_diagonal != letters[n - 1]:
stdout.write('NO\n')
exit()
start = 1
end = n - 2
for i in range(n - 1):
letters = stdin.readline()
remove... | Title: Valera and X
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Valera is a little boy. Yesterday he got a huge Math hometask at school, so Valera didn't have enough time to properly learn the English alphabet for his English lesson. Unfortunately, the English teacher decided to have a... | ```python
from sys import stdin, stdout
n = int(stdin.readline())
letters = stdin.readline()
char_in_diagonal = letters[0]
char_not_in_diagonal = letters[1]
if char_in_diagonal != letters[n - 1]:
stdout.write('NO\n')
exit()
start = 1
end = n - 2
for i in range(n - 1):
letters = stdin.readline(... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
195 | A | Let's Watch Football | PROGRAMMING | 1,000 | [
"binary search",
"brute force",
"math"
] | null | null | Valeric and Valerko missed the last Euro football game, so they decided to watch the game's key moments on the Net. They want to start watching as soon as possible but the connection speed is too low. If they turn on the video right now, it will "hang up" as the size of data to watch per second will be more than the si... | The first line contains three space-separated integers *a*, *b* and *c* (1<=≤<=*a*,<=*b*,<=*c*<=≤<=1000,<=*a*<=><=*b*). The first number (*a*) denotes the size of data needed to watch one second of the video. The second number (*b*) denotes the size of data Valeric and Valerko can download from the Net per second. T... | Print a single number — the minimum integer number of seconds that Valeric and Valerko must wait to watch football without pauses. | [
"4 1 1\n",
"10 3 2\n",
"13 12 1\n"
] | [
"3\n",
"5\n",
"1\n"
] | In the first sample video's length is 1 second and it is necessary 4 units of data for watching 1 second of video, so guys should download 4 · 1 = 4 units of data to watch the whole video. The most optimal way is to wait 3 seconds till 3 units of data will be downloaded and then start watching. While guys will be watch... | 500 | [
{
"input": "4 1 1",
"output": "3"
},
{
"input": "10 3 2",
"output": "5"
},
{
"input": "13 12 1",
"output": "1"
},
{
"input": "2 1 3",
"output": "3"
},
{
"input": "6 2 4",
"output": "8"
},
{
"input": "5 2 1",
"output": "2"
},
{
"input": "2 1... | 1,585,319,277 | 2,147,483,647 | Python 3 | OK | TESTS | 49 | 248 | 0 | import math
a,b,c=map(int,input().split())
print(int(math.ceil((a*c-b*c)/b))) | Title: Let's Watch Football
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Valeric and Valerko missed the last Euro football game, so they decided to watch the game's key moments on the Net. They want to start watching as soon as possible but the connection speed is too low. If they turn ... | ```python
import math
a,b,c=map(int,input().split())
print(int(math.ceil((a*c-b*c)/b)))
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
248 | A | Cupboards | PROGRAMMING | 800 | [
"implementation"
] | null | null | One foggy Stockholm morning, Karlsson decided to snack on some jam in his friend Lillebror Svantenson's house. Fortunately for Karlsson, there wasn't anybody in his friend's house. Karlsson was not going to be hungry any longer, so he decided to get some food in the house.
Karlsson's gaze immediately fell on *n* woode... | The first input line contains a single integer *n* — the number of cupboards in the kitchen (2<=≤<=*n*<=≤<=104). Then follow *n* lines, each containing two integers *l**i* and *r**i* (0<=≤<=*l**i*,<=*r**i*<=≤<=1). Number *l**i* equals one, if the left door of the *i*-th cupboard is opened, otherwise number *l**i* equal... | In the only output line print a single integer *t* — the minimum number of seconds Karlsson needs to change the doors of all cupboards to the position he needs. | [
"5\n0 1\n1 0\n0 1\n1 1\n0 1\n"
] | [
"3\n"
] | none | 500 | [
{
"input": "5\n0 1\n1 0\n0 1\n1 1\n0 1",
"output": "3"
},
{
"input": "2\n0 0\n0 0",
"output": "0"
},
{
"input": "3\n0 1\n1 1\n1 1",
"output": "1"
},
{
"input": "8\n0 1\n1 0\n0 1\n1 1\n0 1\n1 0\n0 1\n1 0",
"output": "7"
},
{
"input": "8\n1 0\n1 0\n1 0\n0 1\n0 1\n1 ... | 1,598,346,968 | 2,147,483,647 | Python 3 | OK | TESTS | 57 | 248 | 0 | n=int(input())
x=0;y=0
for _ in range(n):
l,r=map(int,input().split())
x+=l
y+=r
print(min(x,n-x)+min(y,n-y)) | Title: Cupboards
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
One foggy Stockholm morning, Karlsson decided to snack on some jam in his friend Lillebror Svantenson's house. Fortunately for Karlsson, there wasn't anybody in his friend's house. Karlsson was not going to be hungry any long... | ```python
n=int(input())
x=0;y=0
for _ in range(n):
l,r=map(int,input().split())
x+=l
y+=r
print(min(x,n-x)+min(y,n-y))
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
935 | A | Fafa and his Company | PROGRAMMING | 800 | [
"brute force",
"implementation"
] | null | null | Fafa owns a company that works on huge projects. There are *n* employees in Fafa's company. Whenever the company has a new project to start working on, Fafa has to divide the tasks of this project among all the employees.
Fafa finds doing this every time is very tiring for him. So, he decided to choose the best *l* em... | The input consists of a single line containing a positive integer *n* (2<=≤<=*n*<=≤<=105) — the number of employees in Fafa's company. | Print a single integer representing the answer to the problem. | [
"2\n",
"10\n"
] | [
"1\n",
"3\n"
] | In the second sample Fafa has 3 ways:
- choose only 1 employee as a team leader with 9 employees under his responsibility. - choose 2 employees as team leaders with 4 employees under the responsibility of each of them. - choose 5 employees as team leaders with 1 employee under the responsibility of each of them. | 500 | [
{
"input": "2",
"output": "1"
},
{
"input": "10",
"output": "3"
},
{
"input": "3",
"output": "1"
},
{
"input": "4",
"output": "2"
},
{
"input": "6",
"output": "3"
},
{
"input": "13",
"output": "1"
},
{
"input": "100000",
"output": "35"
... | 1,650,452,516 | 2,147,483,647 | Python 3 | OK | TESTS | 33 | 62 | 0 | n=int(input());l=0
for i in range(1,n):
p=n-i
if p%i==0:
l+=1
print(l)
| Title: Fafa and his Company
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Fafa owns a company that works on huge projects. There are *n* employees in Fafa's company. Whenever the company has a new project to start working on, Fafa has to divide the tasks of this project among all the emp... | ```python
n=int(input());l=0
for i in range(1,n):
p=n-i
if p%i==0:
l+=1
print(l)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
961 | B | Lecture Sleep | PROGRAMMING | 1,200 | [
"data structures",
"dp",
"implementation",
"two pointers"
] | null | null | Your friend Mishka and you attend a calculus lecture. Lecture lasts *n* minutes. Lecturer tells *a**i* theorems during the *i*-th minute.
Mishka is really interested in calculus, though it is so hard to stay awake for all the time of lecture. You are given an array *t* of Mishka's behavior. If Mishka is asleep during ... | The first line of the input contains two integer numbers *n* and *k* (1<=≤<=*k*<=≤<=*n*<=≤<=105) — the duration of the lecture in minutes and the number of minutes you can keep Mishka awake.
The second line of the input contains *n* integer numbers *a*1,<=*a*2,<=... *a**n* (1<=≤<=*a**i*<=≤<=104) — the number of theore... | Print only one integer — the maximum number of theorems Mishka will be able to write down if you use your technique only once to wake him up. | [
"6 3\n1 3 5 2 5 4\n1 1 0 1 0 0\n"
] | [
"16\n"
] | In the sample case the better way is to use the secret technique at the beginning of the third minute. Then the number of theorems Mishka will be able to write down will be equal to 16. | 0 | [
{
"input": "6 3\n1 3 5 2 5 4\n1 1 0 1 0 0",
"output": "16"
},
{
"input": "5 3\n1 9999 10000 10000 10000\n0 0 0 0 0",
"output": "30000"
},
{
"input": "3 3\n10 10 10\n1 1 0",
"output": "30"
},
{
"input": "1 1\n423\n0",
"output": "423"
},
{
"input": "6 6\n1 3 5 2 5 4... | 1,611,405,180 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 46 | 307,200 | n,k=map(int,input().split())
l=list(map(int,input().split()))
m=list(map(int,input().split()))
d,s,f=0,0,0
e=[]
for i in range(n):
if m[i]:
s+=l[i]
l[i]=0
for i in range(n):
if f<=k+1:
d+=l[i]
f+=1
else:
f=1
e.append(d)
d=0
e.append(d)... | Title: Lecture Sleep
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Your friend Mishka and you attend a calculus lecture. Lecture lasts *n* minutes. Lecturer tells *a**i* theorems during the *i*-th minute.
Mishka is really interested in calculus, though it is so hard to stay awake for al... | ```python
n,k=map(int,input().split())
l=list(map(int,input().split()))
m=list(map(int,input().split()))
d,s,f=0,0,0
e=[]
for i in range(n):
if m[i]:
s+=l[i]
l[i]=0
for i in range(n):
if f<=k+1:
d+=l[i]
f+=1
else:
f=1
e.append(d)
d=0
e... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
573 | A | Bear and Poker | PROGRAMMING | 1,300 | [
"implementation",
"math",
"number theory"
] | null | null | Limak is an old brown bear. He often plays poker with his friends. Today they went to a casino. There are *n* players (including Limak himself) and right now all of them have bids on the table. *i*-th of them has bid with size *a**i* dollars.
Each player can double his bid any number of times and triple his bid any nu... | First line of input contains an integer *n* (2<=≤<=*n*<=≤<=105), the number of players.
The second line contains *n* integer numbers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=109) — the bids of players. | Print "Yes" (without the quotes) if players can make their bids become equal, or "No" otherwise. | [
"4\n75 150 75 50\n",
"3\n100 150 250\n"
] | [
"Yes\n",
"No\n"
] | In the first sample test first and third players should double their bids twice, second player should double his bid once and fourth player should both double and triple his bid.
It can be shown that in the second sample test there is no way to make all bids equal. | 500 | [
{
"input": "4\n75 150 75 50",
"output": "Yes"
},
{
"input": "3\n100 150 250",
"output": "No"
},
{
"input": "7\n34 34 68 34 34 68 34",
"output": "Yes"
},
{
"input": "10\n72 96 12 18 81 20 6 2 54 1",
"output": "No"
},
{
"input": "20\n958692492 954966768 77387000 724... | 1,695,471,873 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 6 | 61 | 13,107,200 | import math
n=int(input())
li=list(map(int,input().split()))
l=li[0]
for i in li:
l=math.lcm(l,i)
for i in li:
ans2=math.log(l/i,2)
ans3=math.log(l/i,3)
ans6=math.log(l/i,6)
if math.ceil(ans2)!=math.floor(ans2) and math.ceil(ans3)!=math.floor(ans3) and math.ceil(ans3)!=math.floor(ans3):
... | Title: Bear and Poker
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Limak is an old brown bear. He often plays poker with his friends. Today they went to a casino. There are *n* players (including Limak himself) and right now all of them have bids on the table. *i*-th of them has bid wit... | ```python
import math
n=int(input())
li=list(map(int,input().split()))
l=li[0]
for i in li:
l=math.lcm(l,i)
for i in li:
ans2=math.log(l/i,2)
ans3=math.log(l/i,3)
ans6=math.log(l/i,6)
if math.ceil(ans2)!=math.floor(ans2) and math.ceil(ans3)!=math.floor(ans3) and math.ceil(ans3)!=math.floor... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
492 | A | Vanya and Cubes | PROGRAMMING | 800 | [
"implementation"
] | null | null | Vanya got *n* cubes. He decided to build a pyramid from them. Vanya wants to build the pyramid as follows: the top level of the pyramid must consist of 1 cube, the second level must consist of 1<=+<=2<==<=3 cubes, the third level must have 1<=+<=2<=+<=3<==<=6 cubes, and so on. Thus, the *i*-th level of the pyramid must... | The first line contains integer *n* (1<=≤<=*n*<=≤<=104) — the number of cubes given to Vanya. | Print the maximum possible height of the pyramid in the single line. | [
"1\n",
"25\n"
] | [
"1\n",
"4\n"
] | Illustration to the second sample: | 500 | [
{
"input": "1",
"output": "1"
},
{
"input": "25",
"output": "4"
},
{
"input": "2",
"output": "1"
},
{
"input": "4115",
"output": "28"
},
{
"input": "9894",
"output": "38"
},
{
"input": "7969",
"output": "35"
},
{
"input": "6560",
"outpu... | 1,699,706,973 | 2,147,483,647 | Python 3 | OK | TESTS | 25 | 31 | 0 | n = int(input())
h=0
l=0
for i in range(n):
i+=1
c = int((i+1)*(i/2))
if h+c > n:
break
h+=c
l+=1
print(l) | Title: Vanya and Cubes
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vanya got *n* cubes. He decided to build a pyramid from them. Vanya wants to build the pyramid as follows: the top level of the pyramid must consist of 1 cube, the second level must consist of 1<=+<=2<==<=3 cubes, the t... | ```python
n = int(input())
h=0
l=0
for i in range(n):
i+=1
c = int((i+1)*(i/2))
if h+c > n:
break
h+=c
l+=1
print(l)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
17 | A | Noldbach problem | PROGRAMMING | 1,000 | [
"brute force",
"math",
"number theory"
] | A. Noldbach problem | 2 | 64 | Nick is interested in prime numbers. Once he read about Goldbach problem. It states that every even integer greater than 2 can be expressed as the sum of two primes. That got Nick's attention and he decided to invent a problem of his own and call it Noldbach problem. Since Nick is interested only in prime numbers, Nold... | The first line of the input contains two integers *n* (2<=≤<=*n*<=≤<=1000) and *k* (0<=≤<=*k*<=≤<=1000). | Output YES if at least *k* prime numbers from 2 to *n* inclusively can be expressed as it was described above. Otherwise output NO. | [
"27 2\n",
"45 7\n"
] | [
"YES",
"NO"
] | In the first sample the answer is YES since at least two numbers can be expressed as it was described (for example, 13 and 19). In the second sample the answer is NO since it is impossible to express 7 prime numbers from 2 to 45 in the desired form. | 0 | [
{
"input": "27 2",
"output": "YES"
},
{
"input": "45 7",
"output": "NO"
},
{
"input": "2 0",
"output": "YES"
},
{
"input": "15 1",
"output": "YES"
},
{
"input": "17 1",
"output": "YES"
},
{
"input": "34 5",
"output": "NO"
},
{
"input": "37 ... | 1,560,465,970 | 2,147,483,647 | Python 3 | OK | TESTS | 35 | 218 | 0 | def p(n):
global primes
for i in primes:
if n%i==0:return False
if i>n**.5:break
primes.append(n)
return True
primes=[]
for i in range(2,1000):p(i)
spec=[]
for i in range(len(primes)-1):
if primes[i]+primes[i+1]+1 in primes:
spec.append(primes[i]+primes[i+1]+1)
a... | Title: Noldbach problem
Time Limit: 2 seconds
Memory Limit: 64 megabytes
Problem Description:
Nick is interested in prime numbers. Once he read about Goldbach problem. It states that every even integer greater than 2 can be expressed as the sum of two primes. That got Nick's attention and he decided to invent a prob... | ```python
def p(n):
global primes
for i in primes:
if n%i==0:return False
if i>n**.5:break
primes.append(n)
return True
primes=[]
for i in range(2,1000):p(i)
spec=[]
for i in range(len(primes)-1):
if primes[i]+primes[i+1]+1 in primes:
spec.append(primes[i]+primes[... | 3.9455 | MatrixStudio/Codeforces-Python-Submissions |
492 | B | Vanya and Lanterns | PROGRAMMING | 1,200 | [
"binary search",
"implementation",
"math",
"sortings"
] | null | null | Vanya walks late at night along a straight street of length *l*, lit by *n* lanterns. Consider the coordinate system with the beginning of the street corresponding to the point 0, and its end corresponding to the point *l*. Then the *i*-th lantern is at the point *a**i*. The lantern lights all points of the street that... | The first line contains two integers *n*, *l* (1<=≤<=*n*<=≤<=1000, 1<=≤<=*l*<=≤<=109) — the number of lanterns and the length of the street respectively.
The next line contains *n* integers *a**i* (0<=≤<=*a**i*<=≤<=*l*). Multiple lanterns can be located at the same point. The lanterns may be located at the ends of th... | Print the minimum light radius *d*, needed to light the whole street. The answer will be considered correct if its absolute or relative error doesn't exceed 10<=-<=9. | [
"7 15\n15 5 3 7 9 14 0\n",
"2 5\n2 5\n"
] | [
"2.5000000000\n",
"2.0000000000\n"
] | Consider the second sample. At *d* = 2 the first lantern will light the segment [0, 4] of the street, and the second lantern will light segment [3, 5]. Thus, the whole street will be lit. | 1,000 | [
{
"input": "7 15\n15 5 3 7 9 14 0",
"output": "2.5000000000"
},
{
"input": "2 5\n2 5",
"output": "2.0000000000"
},
{
"input": "46 615683844\n431749087 271781274 274974690 324606253 480870261 401650581 13285442 478090364 266585394 425024433 588791449 492057200 391293435 563090494 317950 1... | 1,698,587,815 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 11 | 61 | 0 | n, l = map(int, input().split())
a = [int(i) for i in input().split()]
a.sort()
if n > 1:
diff_list = [a[i+1] - a[i] for i in range(n-1)]
diff_list.sort()
maxdist = diff_list[-1]
dist_start = a[0]
dist_end = l - a[n-1]
d = max(maxdist / 2, max(dist_start, dist_end))
else:
d = 1
p... | Title: Vanya and Lanterns
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vanya walks late at night along a straight street of length *l*, lit by *n* lanterns. Consider the coordinate system with the beginning of the street corresponding to the point 0, and its end corresponding to the poi... | ```python
n, l = map(int, input().split())
a = [int(i) for i in input().split()]
a.sort()
if n > 1:
diff_list = [a[i+1] - a[i] for i in range(n-1)]
diff_list.sort()
maxdist = diff_list[-1]
dist_start = a[0]
dist_end = l - a[n-1]
d = max(maxdist / 2, max(dist_start, dist_end))
else:
... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
978 | B | File Name | PROGRAMMING | 800 | [
"greedy",
"strings"
] | null | null | You can not just take the file and send it. When Polycarp trying to send a file in the social network "Codehorses", he encountered an unexpected problem. If the name of the file contains three or more "x" (lowercase Latin letters "x") in a row, the system considers that the file content does not correspond to the socia... | The first line contains integer $n$ $(3 \le n \le 100)$ — the length of the file name.
The second line contains a string of length $n$ consisting of lowercase Latin letters only — the file name. | Print the minimum number of characters to remove from the file name so after that the name does not contain "xxx" as a substring. If initially the file name dost not contain a forbidden substring "xxx", print 0. | [
"6\nxxxiii\n",
"5\nxxoxx\n",
"10\nxxxxxxxxxx\n"
] | [
"1\n",
"0\n",
"8\n"
] | In the first example Polycarp tried to send a file with name contains number $33$, written in Roman numerals. But he can not just send the file, because it name contains three letters "x" in a row. To send the file he needs to remove any one of this letters. | 0 | [
{
"input": "6\nxxxiii",
"output": "1"
},
{
"input": "5\nxxoxx",
"output": "0"
},
{
"input": "10\nxxxxxxxxxx",
"output": "8"
},
{
"input": "100\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"output": "98"
},
{
... | 1,692,379,087 | 2,147,483,647 | Python 3 | OK | TESTS | 13 | 46 | 0 | def file_name(n, filename):
removals = 0
consecutive_x = 0
for char in filename:
if char == 'x':
consecutive_x += 1
if consecutive_x >= 3:
removals += 1
else:
consecutive_x = 0
return removals
# Read input
n = ... | Title: File Name
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You can not just take the file and send it. When Polycarp trying to send a file in the social network "Codehorses", he encountered an unexpected problem. If the name of the file contains three or more "x" (lowercase Latin let... | ```python
def file_name(n, filename):
removals = 0
consecutive_x = 0
for char in filename:
if char == 'x':
consecutive_x += 1
if consecutive_x >= 3:
removals += 1
else:
consecutive_x = 0
return removals
# Read i... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
740 | B | Alyona and flowers | PROGRAMMING | 1,200 | [
"constructive algorithms"
] | null | null | Little Alyona is celebrating Happy Birthday! Her mother has an array of *n* flowers. Each flower has some mood, the mood of *i*-th flower is *a**i*. The mood can be positive, zero or negative.
Let's define a subarray as a segment of consecutive flowers. The mother suggested some set of subarrays. Alyona wants to choos... | The first line contains two integers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=100) — the number of flowers and the number of subarrays suggested by the mother.
The second line contains the flowers moods — *n* integers *a*1,<=*a*2,<=...,<=*a**n* (<=-<=100<=≤<=*a**i*<=≤<=100).
The next *m* lines contain the description of the ... | Print single integer — the maximum possible value added to the Alyona's happiness. | [
"5 4\n1 -2 1 3 -4\n1 2\n4 5\n3 4\n1 4\n",
"4 3\n1 2 3 4\n1 3\n2 4\n1 1\n",
"2 2\n-1 -2\n1 1\n1 2\n"
] | [
"7\n",
"16\n",
"0\n"
] | The first example is the situation described in the statements.
In the second example Alyona should choose all subarrays.
The third example has answer 0 because Alyona can choose none of the subarrays. | 1,000 | [
{
"input": "5 4\n1 -2 1 3 -4\n1 2\n4 5\n3 4\n1 4",
"output": "7"
},
{
"input": "4 3\n1 2 3 4\n1 3\n2 4\n1 1",
"output": "16"
},
{
"input": "2 2\n-1 -2\n1 1\n1 2",
"output": "0"
},
{
"input": "5 6\n1 1 1 -1 0\n2 4\n1 3\n4 5\n1 5\n1 4\n4 5",
"output": "8"
},
{
"inpu... | 1,498,730,469 | 2,047 | Python 3 | OK | TESTS | 53 | 62 | 5,529,600 | n,m=map(int,input().split())
l=list(map(int,input().split()))
l1=[0 for i in range(n)]
su=[]
for i in range(m):
a,b=map(int,input().split())
su.append([a,b])
if sum(l[a-1:b])>0:
for j in range(a-1,b):
l1[j]+=1
ans=0
#print(l1)
for i in range(n):
ans+=l[i]*l1[i]
print(an... | Title: Alyona and flowers
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Little Alyona is celebrating Happy Birthday! Her mother has an array of *n* flowers. Each flower has some mood, the mood of *i*-th flower is *a**i*. The mood can be positive, zero or negative.
Let's define a subarra... | ```python
n,m=map(int,input().split())
l=list(map(int,input().split()))
l1=[0 for i in range(n)]
su=[]
for i in range(m):
a,b=map(int,input().split())
su.append([a,b])
if sum(l[a-1:b])>0:
for j in range(a-1,b):
l1[j]+=1
ans=0
#print(l1)
for i in range(n):
ans+=l[i]*l1[i]... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
331 | C1 | The Great Julya Calendar | PROGRAMMING | 1,100 | [
"dp"
] | null | null | Yet another Armageddon is coming! This time the culprit is the Julya tribe calendar.
The beavers in this tribe knew math very well. Smart Beaver, an archaeologist, got a sacred plate with a magic integer on it. The translation from Old Beaverish is as follows:
"May the Great Beaver bless you! May your chacres open ... | The single line contains the magic integer *n*, 0<=≤<=*n*.
- to get 20 points, you need to solve the problem with constraints: *n*<=≤<=106 (subproblem C1); - to get 40 points, you need to solve the problem with constraints: *n*<=≤<=1012 (subproblems C1+C2); - to get 100 points, you need to solve the problem with co... | Print a single integer — the minimum number of subtractions that turns the magic number to a zero. | [
"24\n"
] | [
"5"
] | In the first test sample the minimum number of operations can be reached by the following sequence of subtractions: | 20 | [
{
"input": "24",
"output": "5"
},
{
"input": "0",
"output": "0"
},
{
"input": "3",
"output": "1"
},
{
"input": "8",
"output": "1"
},
{
"input": "9",
"output": "1"
},
{
"input": "10",
"output": "2"
},
{
"input": "31",
"output": "6"
},
... | 1,617,293,572 | 2,147,483,647 | Python 3 | OK | TESTS1 | 24 | 340 | 0 | n=int(input())
count=0
while n>0:
n-=int(max(str(n)))
count+=1
print(count) | Title: The Great Julya Calendar
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Yet another Armageddon is coming! This time the culprit is the Julya tribe calendar.
The beavers in this tribe knew math very well. Smart Beaver, an archaeologist, got a sacred plate with a magic integer on i... | ```python
n=int(input())
count=0
while n>0:
n-=int(max(str(n)))
count+=1
print(count)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
799 | A | Carrot Cakes | PROGRAMMING | 1,100 | [
"brute force",
"implementation"
] | null | null | In some game by Playrix it takes *t* minutes for an oven to bake *k* carrot cakes, all cakes are ready at the same moment *t* minutes after they started baking. Arkady needs at least *n* cakes to complete a task, but he currently don't have any. However, he has infinitely many ingredients and one oven. Moreover, Arkady... | The only line contains four integers *n*, *t*, *k*, *d* (1<=≤<=*n*,<=*t*,<=*k*,<=*d*<=≤<=1<=000) — the number of cakes needed, the time needed for one oven to bake *k* cakes, the number of cakes baked at the same time, the time needed to build the second oven. | If it is reasonable to build the second oven, print "YES". Otherwise print "NO". | [
"8 6 4 5\n",
"8 6 4 6\n",
"10 3 11 4\n",
"4 2 1 4\n"
] | [
"YES\n",
"NO\n",
"NO\n",
"YES\n"
] | In the first example it is possible to get 8 cakes in 12 minutes using one oven. The second oven can be built in 5 minutes, so after 6 minutes the first oven bakes 4 cakes, the second oven bakes 4 more ovens after 11 minutes. Thus, it is reasonable to build the second oven.
In the second example it doesn't matter whe... | 500 | [
{
"input": "8 6 4 5",
"output": "YES"
},
{
"input": "8 6 4 6",
"output": "NO"
},
{
"input": "10 3 11 4",
"output": "NO"
},
{
"input": "4 2 1 4",
"output": "YES"
},
{
"input": "28 17 16 26",
"output": "NO"
},
{
"input": "60 69 9 438",
"output": "NO"... | 1,638,801,254 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 31 | 0 | import math
n = 0
t = 0
k = 0
d = 0
n=int(input())#10
t=int(input())#3
k=int(input())#11
d=int(input())#6
time_for_one_oven = t*math.ceil(n/k)
time_oven_1_work_only = math.ceil(d/t)
time_for_two_ovens = time_oven_1_work_only*t + min(d,t)*math.ceil((n-time_oven_1_work_only*k)/(2*k))
#print(time_for... | Title: Carrot Cakes
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
In some game by Playrix it takes *t* minutes for an oven to bake *k* carrot cakes, all cakes are ready at the same moment *t* minutes after they started baking. Arkady needs at least *n* cakes to complete a task, but he cu... | ```python
import math
n = 0
t = 0
k = 0
d = 0
n=int(input())#10
t=int(input())#3
k=int(input())#11
d=int(input())#6
time_for_one_oven = t*math.ceil(n/k)
time_oven_1_work_only = math.ceil(d/t)
time_for_two_ovens = time_oven_1_work_only*t + min(d,t)*math.ceil((n-time_oven_1_work_only*k)/(2*k))
#prin... | -1 | MatrixStudio/Codeforces-Python-Submissions | |
285 | C | Building Permutation | PROGRAMMING | 1,200 | [
"greedy",
"implementation",
"sortings"
] | null | null | Permutation *p* is an ordered set of integers *p*1,<=<=*p*2,<=<=...,<=<=*p**n*, consisting of *n* distinct positive integers, each of them doesn't exceed *n*. We'll denote the *i*-th element of permutation *p* as *p**i*. We'll call number *n* the size or the length of permutation *p*1,<=<=*p*2,<=<=...,<=<=*p**n*.
You ... | The first line contains integer *n* (1<=≤<=*n*<=≤<=3·105) — the size of the sought permutation. The second line contains *n* integers *a*1,<=*a*2,<=...,<=*a**n* (<=-<=109<=≤<=*a**i*<=≤<=109). | Print a single number — the minimum number of moves.
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. | [
"2\n3 0\n",
"3\n-1 -1 2\n"
] | [
"2\n",
"6\n"
] | In the first sample you should decrease the first number by one and then increase the second number by one. The resulting permutation is (2, 1).
In the second sample you need 6 moves to build permutation (1, 3, 2). | 1,500 | [
{
"input": "2\n3 0",
"output": "2"
},
{
"input": "3\n-1 -1 2",
"output": "6"
},
{
"input": "5\n-3 5 -3 3 3",
"output": "10"
},
{
"input": "10\n9 6 -2 4 1 1 1 9 6 2",
"output": "18"
},
{
"input": "9\n2 0 0 6 5 4 1 9 3",
"output": "15"
},
{
"input": "100... | 1,584,961,393 | 2,147,483,647 | PyPy 3 | OK | TESTS | 33 | 514 | 26,214,400 | n = int(input())
a = list(map(int, input().rstrip().split()))
j = 1
t = 0
a.sort()
for x in a:
t += abs(x - j)
j += 1
print(t) | Title: Building Permutation
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Permutation *p* is an ordered set of integers *p*1,<=<=*p*2,<=<=...,<=<=*p**n*, consisting of *n* distinct positive integers, each of them doesn't exceed *n*. We'll denote the *i*-th element of permutation *p* as *... | ```python
n = int(input())
a = list(map(int, input().rstrip().split()))
j = 1
t = 0
a.sort()
for x in a:
t += abs(x - j)
j += 1
print(t)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
0 | none | none | none | 0 | [
"none"
] | null | null | Pavel loves grid mazes. A grid maze is an *n*<=×<=*m* rectangle maze where each cell is either empty, or is a wall. You can go from one cell to another only if both cells are empty and have a common side.
Pavel drew a grid maze with all empty cells forming a connected area. That is, you can go from any empty cell to a... | The first line contains three integers *n*, *m*, *k* (1<=≤<=*n*,<=*m*<=≤<=500, 0<=≤<=*k*<=<<=*s*), where *n* and *m* are the maze's height and width, correspondingly, *k* is the number of walls Pavel wants to add and letter *s* represents the number of empty cells in the original maze.
Each of the next *n* lines co... | Print *n* lines containing *m* characters each: the new maze that fits Pavel's requirements. Mark the empty cells that you transformed into walls as "X", the other cells must be left without changes (that is, "." and "#").
It is guaranteed that a solution exists. If there are multiple solutions you can output any of t... | [
"3 4 2\n#..#\n..#.\n#...\n",
"5 4 5\n#...\n#.#.\n.#..\n...#\n.#.#\n"
] | [
"#.X#\nX.#.\n#...\n",
"#XXX\n#X#.\nX#..\n...#\n.#.#\n"
] | none | 0 | [
{
"input": "5 4 5\n#...\n#.#.\n.#..\n...#\n.#.#",
"output": "#XXX\n#X#.\nX#..\n...#\n.#.#"
},
{
"input": "3 3 2\n#.#\n...\n#.#",
"output": "#X#\nX..\n#.#"
},
{
"input": "7 7 18\n#.....#\n..#.#..\n.#...#.\n...#...\n.#...#.\n..#.#..\n#.....#",
"output": "#XXXXX#\nXX#X#X.\nX#XXX#.\nXXX#... | 1,689,065,153 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 10 | 140 | 22,118,400 | n,m,k = map(int,input().split())
matrix = []
for _ in range(n):
matrix.append(input())
ans_matrix = []
for i in range(n):
ans_matrix.append([0] * m)
sum_x = 0
for i in range(n):
for j in range(m):
if sum_x < k and matrix[i][j] == ".":
sum_x += 1
ans_matrix[i][j] =... | Title: none
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Pavel loves grid mazes. A grid maze is an *n*<=×<=*m* rectangle maze where each cell is either empty, or is a wall. You can go from one cell to another only if both cells are empty and have a common side.
Pavel drew a grid maze w... | ```python
n,m,k = map(int,input().split())
matrix = []
for _ in range(n):
matrix.append(input())
ans_matrix = []
for i in range(n):
ans_matrix.append([0] * m)
sum_x = 0
for i in range(n):
for j in range(m):
if sum_x < k and matrix[i][j] == ".":
sum_x += 1
ans_matr... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
409 | E | Dome | PROGRAMMING | 1,800 | [
"*special"
] | null | null | The input contains a single floating-point number *x* with exactly 6 decimal places (0<=<<=*x*<=<<=5). | Output two integers separated by a single space. Each integer should be between 1 and 10, inclusive. If several solutions exist, output any of them. Solution will exist for all tests. | [
"1.200000\n",
"2.572479\n",
"4.024922\n"
] | [
"3 2\n",
"10 3\n",
"9 9\n"
] | none | 0 | [
{
"input": "1.200000",
"output": "3 2"
},
{
"input": "2.572479",
"output": "10 3"
},
{
"input": "4.024922",
"output": "9 9"
},
{
"input": "0.447214",
"output": "1 1"
},
{
"input": "0.493197",
"output": "1 3"
},
{
"input": "0.496139",
"output": "1 4... | 1,649,665,555 | 2,147,483,647 | Python 3 | OK | TESTS | 44 | 46 | 0 | import math
def calcu_height(b,h):
obl=math.sqrt(b**2+h**2)
return b*h/obl;
r=float(input())
for w in range(1,11):
for h in range(1,11):
if abs(r-calcu_height(w/2,h))<=10**(-6):
print(w,end=' ')
print(h,end='\n')
exit(0)
| Title: Dome
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Input Specification:
The input contains a single floating-point number *x* with exactly 6 decimal places (0<=<<=*x*<=<<=5).
Output Specification:
Output two integers separated by a single space. Each integer should be bet... | ```python
import math
def calcu_height(b,h):
obl=math.sqrt(b**2+h**2)
return b*h/obl;
r=float(input())
for w in range(1,11):
for h in range(1,11):
if abs(r-calcu_height(w/2,h))<=10**(-6):
print(w,end=' ')
print(h,end='\n')
exit(0)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | ||
12 | A | Super Agent | PROGRAMMING | 800 | [
"implementation"
] | A. Super Agent | 2 | 256 | There is a very secret base in Potatoland where potato mash is made according to a special recipe. The neighbours from Porridgia decided to seize this recipe and to sell it to Pilauland. For this mission they have been preparing special agent Pearlo for many years. When, finally, Pearlo learned all secrets of espionage... | Input contains the matrix of three rows of three symbols each. Symbol «X» means that the corresponding button was pressed, and «.» means that is was not pressed. The matrix may contain no «X», also it may contain no «.». | Print YES if the password is symmetric with respect to the central button of the terminal and NO otherwise. | [
"XX.\n...\n.XX\n",
"X.X\nX..\n...\n"
] | [
"YES\n",
"NO\n"
] | If you are not familiar with the term «central symmetry», you may look into http://en.wikipedia.org/wiki/Central_symmetry | 0 | [
{
"input": "XX.\n...\n.XX",
"output": "YES"
},
{
"input": ".X.\n.X.\n.X.",
"output": "YES"
},
{
"input": "XXX\nXXX\nXXX",
"output": "YES"
},
{
"input": "XXX\nX.X\nXXX",
"output": "YES"
},
{
"input": "X..\n.X.\n..X",
"output": "YES"
},
{
"input": "...\n... | 1,691,827,814 | 2,147,483,647 | PyPy 3 | RUNTIME_ERROR | TESTS | 0 | 186 | 2,048,000 | enchanted_constant = 3 * 3
mystical_buttons = [False] * enchanted_constant
arcane_index = 0
while arcane_index < enchanted_constant:
ethereal_input = input()
if ethereal_input == 'X':
mystical_buttons[arcane_index] = True
arcane_index += 1
elif ethereal_input == '.':
mysti... | Title: Super Agent
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
There is a very secret base in Potatoland where potato mash is made according to a special recipe. The neighbours from Porridgia decided to seize this recipe and to sell it to Pilauland. For this mission they have been preparin... | ```python
enchanted_constant = 3 * 3
mystical_buttons = [False] * enchanted_constant
arcane_index = 0
while arcane_index < enchanted_constant:
ethereal_input = input()
if ethereal_input == 'X':
mystical_buttons[arcane_index] = True
arcane_index += 1
elif ethereal_input == '.':
... | -1 | MatrixStudio/Codeforces-Python-Submissions |
298 | A | Snow Footprints | PROGRAMMING | 1,300 | [
"greedy",
"implementation"
] | null | null | There is a straight snowy road, divided into *n* blocks. The blocks are numbered from 1 to *n* from left to right. If one moves from the *i*-th block to the (*i*<=+<=1)-th block, he will leave a right footprint on the *i*-th block. Similarly, if one moves from the *i*-th block to the (*i*<=-<=1)-th block, he will leave... | The first line of the input contains integer *n* (3<=≤<=*n*<=≤<=1000).
The second line contains the description of the road — the string that consists of *n* characters. Each character will be either "." (a block without footprint), or "L" (a block with a left footprint), "R" (a block with a right footprint).
It's gu... | Print two space-separated integers — the values of *s* and *t*. If there are several possible solutions you can print any of them. | [
"9\n..RRLL...\n",
"11\n.RRRLLLLL..\n"
] | [
"3 4\n",
"7 5\n"
] | The first test sample is the one in the picture. | 500 | [
{
"input": "11\n.RRRLLLLL..",
"output": "7 5"
},
{
"input": "4\n.RL.",
"output": "3 2"
},
{
"input": "3\n.L.",
"output": "2 1"
},
{
"input": "3\n.R.",
"output": "2 3"
}
] | 1,690,449,047 | 2,147,483,647 | Python 3 | OK | TESTS | 23 | 92 | 0 |
n=int(input())
moves=input()
began=len(moves)-len(moves.lstrip("."))+1
end=len(moves.rstrip("."))+1
for i in range(n):
if moves[i]=="L":
end=i # (i+1) -1
break
print(began,end) | Title: Snow Footprints
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
There is a straight snowy road, divided into *n* blocks. The blocks are numbered from 1 to *n* from left to right. If one moves from the *i*-th block to the (*i*<=+<=1)-th block, he will leave a right footprint on the *... | ```python
n=int(input())
moves=input()
began=len(moves)-len(moves.lstrip("."))+1
end=len(moves.rstrip("."))+1
for i in range(n):
if moves[i]=="L":
end=i # (i+1) -1
break
print(began,end)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
0 | none | none | none | 0 | [
"none"
] | null | null | Peter got a new snow blower as a New Year present. Of course, Peter decided to try it immediately. After reading the instructions he realized that it does not work like regular snow blowing machines. In order to make it work, you need to tie it to some point that it does not cover, and then switch it on. As a result it... | The first line of the input contains three integers — the number of vertices of the polygon *n* (), and coordinates of point *P*.
Each of the next *n* lines contains two integers — coordinates of the vertices of the polygon in the clockwise or counterclockwise order. It is guaranteed that no three consecutive vertices... | Print a single real value number — the area of the region that will be cleared. Your answer will be considered correct if its absolute or relative error does not exceed 10<=-<=6.
Namely: let's assume that your answer is *a*, and the answer of the jury is *b*. The checker program will consider your answer correct, if ... | [
"3 0 0\n0 1\n-1 2\n1 2\n",
"4 1 -1\n0 0\n1 2\n2 0\n1 1\n"
] | [
"12.566370614359172464\n",
"21.991148575128551812\n"
] | In the first sample snow will be removed from that area: | 0 | [
{
"input": "3 0 0\n0 1\n-1 2\n1 2",
"output": "12.566370614359172464"
},
{
"input": "4 1 -1\n0 0\n1 2\n2 0\n1 1",
"output": "21.991148575128551812"
},
{
"input": "3 0 0\n-1 1\n0 3\n1 1",
"output": "25.132741228718344928"
},
{
"input": "3 -4 2\n-3 2\n5 -5\n5 3",
"output": ... | 1,690,492,832 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 0 | 46 | 0 | print("_RANDOM_GUESS_1690492832.2705941")# 1690492832.2706125 | Title: none
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Peter got a new snow blower as a New Year present. Of course, Peter decided to try it immediately. After reading the instructions he realized that it does not work like regular snow blowing machines. In order to make it work, you ... | ```python
print("_RANDOM_GUESS_1690492832.2705941")# 1690492832.2706125
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
29 | A | Spit Problem | PROGRAMMING | 1,000 | [
"brute force"
] | A. Spit Problem | 2 | 256 | In a Berland's zoo there is an enclosure with camels. It is known that camels like to spit. Bob watched these interesting animals for the whole day and registered in his notepad where each animal spitted. Now he wants to know if in the zoo there are two camels, which spitted at each other. Help him to solve this task.
... | The first line contains integer *n* (1<=≤<=*n*<=≤<=100) — the amount of camels in the zoo. Each of the following *n* lines contains two integers *x**i* and *d**i* (<=-<=104<=≤<=*x**i*<=≤<=104,<=1<=≤<=|*d**i*|<=≤<=2·104) — records in Bob's notepad. *x**i* is a position of the *i*-th camel, and *d**i* is a distance at wh... | If there are two camels, which spitted at each other, output YES. Otherwise, output NO. | [
"2\n0 1\n1 -1\n",
"3\n0 1\n1 1\n2 -2\n",
"5\n2 -10\n3 10\n0 5\n5 -5\n10 1\n"
] | [
"YES\n",
"NO\n",
"YES\n"
] | none | 500 | [
{
"input": "2\n0 1\n1 -1",
"output": "YES"
},
{
"input": "3\n0 1\n1 1\n2 -2",
"output": "NO"
},
{
"input": "5\n2 -10\n3 10\n0 5\n5 -5\n10 1",
"output": "YES"
},
{
"input": "10\n-9897 -1144\n-4230 -6350\n2116 -3551\n-3635 4993\n3907 -9071\n-2362 4120\n-6542 984\n5807 3745\n759... | 1,645,682,611 | 2,147,483,647 | Python 3 | OK | TESTS | 30 | 92 | 0 | n = int(input())
my_dict = dict()
ans = "NO"
while n > 0:
pos, spit = [int(item) for item in input().split(' ')]
my_dict[pos] = spit
n -= 1
for key in my_dict:
secondCamel = key + my_dict[key]
if secondCamel in my_dict and secondCamel + my_dict[secondCamel] == key :
ans = "YES"
... | Title: Spit Problem
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
In a Berland's zoo there is an enclosure with camels. It is known that camels like to spit. Bob watched these interesting animals for the whole day and registered in his notepad where each animal spitted. Now he wants to know ... | ```python
n = int(input())
my_dict = dict()
ans = "NO"
while n > 0:
pos, spit = [int(item) for item in input().split(' ')]
my_dict[pos] = spit
n -= 1
for key in my_dict:
secondCamel = key + my_dict[key]
if secondCamel in my_dict and secondCamel + my_dict[secondCamel] == key :
ans =... | 3.977 | MatrixStudio/Codeforces-Python-Submissions |
25 | A | IQ test | PROGRAMMING | 1,300 | [
"brute force"
] | A. IQ test | 2 | 256 | Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given *n* numbers differs from the others. Bob observed that one number usually differs from the others in evenness. Help Bob — to check his answers, he needs a program that among the given *n* numbers finds one that i... | The first line contains integer *n* (3<=≤<=*n*<=≤<=100) — amount of numbers in the task. The second line contains *n* space-separated natural numbers, not exceeding 100. It is guaranteed, that exactly one of these numbers differs from the others in evenness. | Output index of number that differs from the others in evenness. Numbers are numbered from 1 in the input order. | [
"5\n2 4 7 8 10\n",
"4\n1 2 1 1\n"
] | [
"3\n",
"2\n"
] | none | 0 | [
{
"input": "5\n2 4 7 8 10",
"output": "3"
},
{
"input": "4\n1 2 1 1",
"output": "2"
},
{
"input": "3\n1 2 2",
"output": "1"
},
{
"input": "3\n100 99 100",
"output": "2"
},
{
"input": "3\n5 3 2",
"output": "3"
},
{
"input": "4\n43 28 1 91",
"output"... | 1,590,343,562 | 2,147,483,647 | Python 3 | OK | TESTS | 32 | 218 | 0 | a = [0] * 2
pos = [0] * 2
n = int(input())
arr = list(map(int, input().split()))
for n, i in enumerate(arr):
a[i%2] += 1
pos[i%2] = n+1
if a[0] > 1:
print(pos[1])
else:
print(pos[0]) | Title: IQ test
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given *n* numbers differs from the others. Bob observed that one number usually differs from the others in evenness. Help Bob — t... | ```python
a = [0] * 2
pos = [0] * 2
n = int(input())
arr = list(map(int, input().split()))
for n, i in enumerate(arr):
a[i%2] += 1
pos[i%2] = n+1
if a[0] > 1:
print(pos[1])
else:
print(pos[0])
``` | 3.9455 | MatrixStudio/Codeforces-Python-Submissions |
242 | B | Big Segment | PROGRAMMING | 1,100 | [
"implementation",
"sortings"
] | null | null | A coordinate line has *n* segments, the *i*-th segment starts at the position *l**i* and ends at the position *r**i*. We will denote such a segment as [*l**i*,<=*r**i*].
You have suggested that one of the defined segments covers all others. In other words, there is such segment in the given set, which contains all oth... | The first line contains integer *n* (1<=≤<=*n*<=≤<=105) — the number of segments. Next *n* lines contain the descriptions of the segments. The *i*-th line contains two space-separated integers *l**i*,<=*r**i* (1<=≤<=*l**i*<=≤<=*r**i*<=≤<=109) — the borders of the *i*-th segment.
It is guaranteed that no two segments c... | Print a single integer — the number of the segment that covers all other segments in the set. If there's no solution, print -1.
The segments are numbered starting from 1 in the order in which they appear in the input. | [
"3\n1 1\n2 2\n3 3\n",
"6\n1 5\n2 3\n1 10\n7 10\n7 7\n10 10\n"
] | [
"-1\n",
"3\n"
] | none | 1,000 | [
{
"input": "3\n1 1\n2 2\n3 3",
"output": "-1"
},
{
"input": "6\n1 5\n2 3\n1 10\n7 10\n7 7\n10 10",
"output": "3"
},
{
"input": "4\n1 5\n2 2\n2 4\n2 5",
"output": "1"
},
{
"input": "5\n3 3\n1 3\n2 2\n2 3\n1 2",
"output": "2"
},
{
"input": "7\n7 7\n8 8\n3 7\n1 6\n1 ... | 1,367,598,872 | 2,147,483,647 | Python 3 | COMPILATION_ERROR | TESTS | 0 | 0 | 0 | #python33
def program():
L=[]
R=[]
m=[]
num=-1
n=int (input ())
for i in range(n):
m.append((map(int,input().split())))
for l,r in m:
MAX=max(r)
MIN=min(l)
print "-1" if [MIN, MAX] not in m else m.index([MIN, MAX]) + 1
program()
| Title: Big Segment
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
A coordinate line has *n* segments, the *i*-th segment starts at the position *l**i* and ends at the position *r**i*. We will denote such a segment as [*l**i*,<=*r**i*].
You have suggested that one of the defined segments ... | ```python
#python33
def program():
L=[]
R=[]
m=[]
num=-1
n=int (input ())
for i in range(n):
m.append((map(int,input().split())))
for l,r in m:
MAX=max(r)
MIN=min(l)
print "-1" if [MIN, MAX] not in m else m.index([MIN, MAX]) + 1
program()
`... | -1 | MatrixStudio/Codeforces-Python-Submissions |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.