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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
588 | A | Duff and Meat | PROGRAMMING | 900 | [
"greedy"
] | null | null | Duff is addicted to meat! Malek wants to keep her happy for *n* days. In order to be happy in *i*-th day, she needs to eat exactly *a**i* kilograms of meat.
There is a big shop uptown and Malek wants to buy meat for her from there. In *i*-th day, they sell meat for *p**i* dollars per kilogram. Malek knows all numbers ... | The first line of input contains integer *n* (1<=≤<=*n*<=≤<=105), the number of days.
In the next *n* lines, *i*-th line contains two integers *a**i* and *p**i* (1<=≤<=*a**i*,<=*p**i*<=≤<=100), the amount of meat Duff needs and the cost of meat in that day. | Print the minimum money needed to keep Duff happy for *n* days, in one line. | [
"3\n1 3\n2 2\n3 1\n",
"3\n1 3\n2 1\n3 2\n"
] | [
"10\n",
"8\n"
] | In the first sample case: An optimal way would be to buy 1 kg on the first day, 2 kg on the second day and 3 kg on the third day.
In the second sample case: An optimal way would be to buy 1 kg on the first day and 5 kg (needed meat for the second and third day) on the second day. | 750 | [
{
"input": "3\n1 3\n2 2\n3 1",
"output": "10"
},
{
"input": "3\n1 3\n2 1\n3 2",
"output": "8"
},
{
"input": "1\n39 52",
"output": "2028"
},
{
"input": "2\n25 56\n94 17",
"output": "2998"
},
{
"input": "5\n39 21\n95 89\n73 90\n9 55\n85 32",
"output": "6321"
}... | 1,538,291,504 | 2,147,483,647 | Python 3 | OK | TESTS | 30 | 468 | 716,800 | n=int(input())
a=[0]*n
p=[0]*n
for i in range(n):
l=[int(x) for x in input().split(' ')]
a[i]=l[0]
p[i]=l[1]
s=p[0]*a[0]
min_p=p[0]
for i in range(1, n):
min_p=min(min_p, p[i])
s+=min_p*a[i]
print(s) | Title: Duff and Meat
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Duff is addicted to meat! Malek wants to keep her happy for *n* days. In order to be happy in *i*-th day, she needs to eat exactly *a**i* kilograms of meat.
There is a big shop uptown and Malek wants to buy meat for her ... | ```python
n=int(input())
a=[0]*n
p=[0]*n
for i in range(n):
l=[int(x) for x in input().split(' ')]
a[i]=l[0]
p[i]=l[1]
s=p[0]*a[0]
min_p=p[0]
for i in range(1, n):
min_p=min(min_p, p[i])
s+=min_p*a[i]
print(s)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
626 | B | Cards | PROGRAMMING | 1,300 | [
"constructive algorithms",
"dp",
"math"
] | null | null | Catherine has a deck of *n* cards, each of which is either red, green, or blue. As long as there are at least two cards left, she can do one of two actions:
- take any two (not necessarily adjacent) cards with different colors and exchange them for a new card of the third color; - take any two (not necessarily adja... | The first line of the input contains a single integer *n* (1<=≤<=*n*<=≤<=200) — the total number of cards.
The next line contains a string *s* of length *n* — the colors of the cards. *s* contains only the characters 'B', 'G', and 'R', representing blue, green, and red, respectively. | Print a single string of up to three characters — the possible colors of the final card (using the same symbols as the input) in alphabetical order. | [
"2\nRB\n",
"3\nGRG\n",
"5\nBBBBB\n"
] | [
"G\n",
"BR\n",
"B\n"
] | In the first sample, Catherine has one red card and one blue card, which she must exchange for a green card.
In the second sample, Catherine has two green cards and one red card. She has two options: she can exchange the two green cards for a green card, then exchange the new green card and the red card for a blue car... | 750 | [
{
"input": "2\nRB",
"output": "G"
},
{
"input": "3\nGRG",
"output": "BR"
},
{
"input": "5\nBBBBB",
"output": "B"
},
{
"input": "1\nR",
"output": "R"
},
{
"input": "200\nBBRGRRBBRGGGBGBGBGRRGRGRGRBGRGRRBBGRGBGRRGRRRGGBBRGBGBGBRBBBBBBBGGBRGGRRRGGRGBGBGGBRRRRBRRRBRBB... | 1,455,390,415 | 5,515 | Python 3 | OK | TESTS | 46 | 62 | 512,000 |
from collections import Counter
ALL_CARDS = set('RGB')
def solve():
length = int(input().strip())
cards = input().strip()
counter = Counter(cards)
card_counts = dict(counter.most_common())
available_cards = set(card_counts.keys())
missing_cards = ALL_CARDS - available_cards
more_than_1s = set([card fo... | Title: Cards
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Catherine has a deck of *n* cards, each of which is either red, green, or blue. As long as there are at least two cards left, she can do one of two actions:
- take any two (not necessarily adjacent) cards with different colors... | ```python
from collections import Counter
ALL_CARDS = set('RGB')
def solve():
length = int(input().strip())
cards = input().strip()
counter = Counter(cards)
card_counts = dict(counter.most_common())
available_cards = set(card_counts.keys())
missing_cards = ALL_CARDS - available_cards
more_than_1s = se... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
687 | B | Remainders Game | PROGRAMMING | 1,800 | [
"chinese remainder theorem",
"math",
"number theory"
] | null | null | Today Pari and Arya are playing a game called Remainders.
Pari chooses two positive integer *x* and *k*, and tells Arya *k* but not *x*. Arya have to find the value . There are *n* ancient numbers *c*1,<=*c*2,<=...,<=*c**n* and Pari has to tell Arya if Arya wants. Given *k* and the ancient values, tell us if Arya has... | The first line of the input contains two integers *n* and *k* (1<=≤<=*n*,<= *k*<=≤<=1<=000<=000) — the number of ancient integers and value *k* that is chosen by Pari.
The second line contains *n* integers *c*1,<=*c*2,<=...,<=*c**n* (1<=≤<=*c**i*<=≤<=1<=000<=000). | Print "Yes" (without quotes) if Arya has a winning strategy independent of value of *x*, or "No" (without quotes) otherwise. | [
"4 5\n2 3 5 12\n",
"2 7\n2 3\n"
] | [
"Yes\n",
"No\n"
] | In the first sample, Arya can understand <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/d170efffcde0907ee6bcf32de21051bce0677a2c.png" style="max-width: 100.0%;max-height: 100.0%;"/> because 5 is one of the ancient numbers.
In the second sample, Arya can't be sure what <img align="middle" ... | 1,000 | [
{
"input": "4 5\n2 3 5 12",
"output": "Yes"
},
{
"input": "2 7\n2 3",
"output": "No"
},
{
"input": "1 6\n8",
"output": "No"
},
{
"input": "2 3\n9 4",
"output": "Yes"
},
{
"input": "4 16\n19 16 13 9",
"output": "Yes"
},
{
"input": "5 10\n5 16 19 9 17",
... | 1,695,930,958 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 46 | 0 | n = int((input(" ")))
k = int((input(" ")))
b = list(map(int, input(" ").strip().split()))[:n]
if k in b :
print("yes")
else:
print("no")
| Title: Remainders Game
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Today Pari and Arya are playing a game called Remainders.
Pari chooses two positive integer *x* and *k*, and tells Arya *k* but not *x*. Arya have to find the value . There are *n* ancient numbers *c*1,<=*c*2,<=...,<=*... | ```python
n = int((input(" ")))
k = int((input(" ")))
b = list(map(int, input(" ").strip().split()))[:n]
if k in b :
print("yes")
else:
print("no")
``` | -1 | 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,642,474,887 | 2,147,483,647 | PyPy 3-64 | RUNTIME_ERROR | TESTS | 0 | 124 | 10,342,400 | x = int(input())
ls = []
for i in range(x):
ls.append(map(int, input().split()))
diff = []
srtd = True
for i in ls:
diff.append(abs(i[1] - i[0]))
for i in range(x - 2):
if ls[i + 1] > ls[i]:
strd = False
k = sum(diff)
if k > 0:
print('rated')
elif k == 0 and srtd == False:
... | 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
x = int(input())
ls = []
for i in range(x):
ls.append(map(int, input().split()))
diff = []
srtd = True
for i in ls:
diff.append(abs(i[1] - i[0]))
for i in range(x - 2):
if ls[i + 1] > ls[i]:
strd = False
k = sum(diff)
if k > 0:
print('rated')
elif k == 0 and srtd ... | -1 | MatrixStudio/Codeforces-Python-Submissions | |
990 | A | Commentary Boxes | PROGRAMMING | 1,000 | [
"implementation",
"math"
] | null | null | Berland Football Cup starts really soon! Commentators from all over the world come to the event.
Organizers have already built $n$ commentary boxes. $m$ regional delegations will come to the Cup. Every delegation should get the same number of the commentary boxes. If any box is left unoccupied then the delegations wil... | The only line contains four integer numbers $n$, $m$, $a$ and $b$ ($1 \le n, m \le 10^{12}$, $1 \le a, b \le 100$), where $n$ is the initial number of the commentary boxes, $m$ is the number of delegations to come, $a$ is the fee to build a box and $b$ is the fee to demolish a box. | Output the minimal amount of burles organizers should pay to satisfy all the delegations (i.e. to make the number of the boxes be divisible by $m$). It is allowed that the final number of the boxes is equal to $0$. | [
"9 7 3 8\n",
"2 7 3 7\n",
"30 6 17 19\n"
] | [
"15\n",
"14\n",
"0\n"
] | In the first example organizers can build $5$ boxes to make the total of $14$ paying $3$ burles for the each of them.
In the second example organizers can demolish $2$ boxes to make the total of $0$ paying $7$ burles for the each of them.
In the third example organizers are already able to distribute all the boxes eq... | 0 | [
{
"input": "9 7 3 8",
"output": "15"
},
{
"input": "2 7 3 7",
"output": "14"
},
{
"input": "30 6 17 19",
"output": "0"
},
{
"input": "500000000001 1000000000000 100 100",
"output": "49999999999900"
},
{
"input": "1000000000000 750000000001 10 100",
"output": "... | 1,653,488,255 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 3 | 31 | 0 | n,m,a,b = map(int,input().split(" "))
burles = 0
x = 0
if n % m != 0 and n > 4:
x = (m * 2) - n
burles = x * a
elif n % m != 0 and n <= 4:
burles = n * b
print(burles) | Title: Commentary Boxes
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Berland Football Cup starts really soon! Commentators from all over the world come to the event.
Organizers have already built $n$ commentary boxes. $m$ regional delegations will come to the Cup. Every delegation shou... | ```python
n,m,a,b = map(int,input().split(" "))
burles = 0
x = 0
if n % m != 0 and n > 4:
x = (m * 2) - n
burles = x * a
elif n % m != 0 and n <= 4:
burles = n * b
print(burles)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
500 | A | New Year Transportation | PROGRAMMING | 1,000 | [
"dfs and similar",
"graphs",
"implementation"
] | null | null | New Year is coming in Line World! In this world, there are *n* cells numbered by integers from 1 to *n*, as a 1<=×<=*n* board. People live in cells. However, it was hard to move between distinct cells, because of the difficulty of escaping the cell. People wanted to meet people who live in other cells.
So, user tncks0... | The first line contains two space-separated integers *n* (3<=≤<=*n*<=≤<=3<=×<=104) and *t* (2<=≤<=*t*<=≤<=*n*) — the number of cells, and the index of the cell which I want to go to.
The second line contains *n*<=-<=1 space-separated integers *a*1,<=*a*2,<=...,<=*a**n*<=-<=1 (1<=≤<=*a**i*<=≤<=*n*<=-<=*i*). It is guara... | If I can go to cell *t* using the transportation system, print "YES". Otherwise, print "NO". | [
"8 4\n1 2 1 2 1 2 1\n",
"8 5\n1 2 1 2 1 1 1\n"
] | [
"YES\n",
"NO\n"
] | In the first sample, the visited cells are: 1, 2, 4; so we can successfully visit the cell 4.
In the second sample, the possible cells to visit are: 1, 2, 4, 6, 7, 8; so we can't visit the cell 5, which we want to visit. | 500 | [
{
"input": "8 4\n1 2 1 2 1 2 1",
"output": "YES"
},
{
"input": "8 5\n1 2 1 2 1 1 1",
"output": "NO"
},
{
"input": "20 19\n13 16 7 6 12 1 5 7 8 6 5 7 5 5 3 3 2 2 1",
"output": "YES"
},
{
"input": "50 49\n11 7 1 41 26 36 19 16 38 14 36 35 37 27 20 27 3 6 21 2 27 11 18 17 19 16 ... | 1,687,944,086 | 2,147,483,647 | Python 3 | OK | TESTS | 34 | 46 | 3,686,400 | n, t = [int(i) for i in input().split()]
a = [0]
a.extend([int(i) for i in input().split()])
i = 1
while i < len(a):
i += a[i]
if i == t:
print('YES')
exit()
print('NO') | Title: New Year Transportation
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
New Year is coming in Line World! In this world, there are *n* cells numbered by integers from 1 to *n*, as a 1<=×<=*n* board. People live in cells. However, it was hard to move between distinct cells, because o... | ```python
n, t = [int(i) for i in input().split()]
a = [0]
a.extend([int(i) for i in input().split()])
i = 1
while i < len(a):
i += a[i]
if i == t:
print('YES')
exit()
print('NO')
``` | 3 | 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,395,763,981 | 481 | Python 3 | WRONG_ANSWER | TESTS | 7 | 122 | 0 | a,b,c=map(int,input().split())
d=c*a
ans=0
v=0
while(d>(v//a)*b):
ans+=1
v+=b
d-=b
print(ans-1)
| 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
a,b,c=map(int,input().split())
d=c*a
ans=0
v=0
while(d>(v//a)*b):
ans+=1
v+=b
d-=b
print(ans-1)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
670 | A | Holidays | PROGRAMMING | 900 | [
"brute force",
"constructive algorithms",
"greedy",
"math"
] | null | null | On the planet Mars a year lasts exactly *n* days (there are no leap years on Mars). But Martians have the same weeks as earthlings — 5 work days and then 2 days off. Your task is to determine the minimum possible and the maximum possible number of days off per year on Mars. | The first line of the input contains a positive integer *n* (1<=≤<=*n*<=≤<=1<=000<=000) — the number of days in a year on Mars. | Print two integers — the minimum possible and the maximum possible number of days off per year on Mars. | [
"14\n",
"2\n"
] | [
"4 4\n",
"0 2\n"
] | In the first sample there are 14 days in a year on Mars, and therefore independently of the day a year starts with there will be exactly 4 days off .
In the second sample there are only 2 days in a year on Mars, and they can both be either work days or days off. | 500 | [
{
"input": "14",
"output": "4 4"
},
{
"input": "2",
"output": "0 2"
},
{
"input": "1",
"output": "0 1"
},
{
"input": "3",
"output": "0 2"
},
{
"input": "4",
"output": "0 2"
},
{
"input": "5",
"output": "0 2"
},
{
"input": "6",
"output":... | 1,682,580,685 | 2,147,483,647 | Python 3 | OK | TESTS | 198 | 93 | 0 | n=int(input())
print(2*(n//7)+(1 if n%7==6 else 0),2*(n//7)+min((n%7),2)) | Title: Holidays
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
On the planet Mars a year lasts exactly *n* days (there are no leap years on Mars). But Martians have the same weeks as earthlings — 5 work days and then 2 days off. Your task is to determine the minimum possible and the maxim... | ```python
n=int(input())
print(2*(n//7)+(1 if n%7==6 else 0),2*(n//7)+min((n%7),2))
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
510 | B | Fox And Two Dots | PROGRAMMING | 1,500 | [
"dfs and similar"
] | null | null | Fox Ciel is playing a mobile puzzle game called "Two Dots". The basic levels are played on a board of size *n*<=×<=*m* cells, like this:
Each cell contains a dot that has some color. We will use different uppercase Latin characters to express different colors.
The key of this game is to find a cycle that contain dots... | The first line contains two integers *n* and *m* (2<=≤<=*n*,<=*m*<=≤<=50): the number of rows and columns of the board.
Then *n* lines follow, each line contains a string consisting of *m* characters, expressing colors of dots in each line. Each character is an uppercase Latin letter. | Output "Yes" if there exists a cycle, and "No" otherwise. | [
"3 4\nAAAA\nABCA\nAAAA\n",
"3 4\nAAAA\nABCA\nAADA\n",
"4 4\nYYYR\nBYBY\nBBBY\nBBBY\n",
"7 6\nAAAAAB\nABBBAB\nABAAAB\nABABBB\nABAAAB\nABBBAB\nAAAAAB\n",
"2 13\nABCDEFGHIJKLM\nNOPQRSTUVWXYZ\n"
] | [
"Yes\n",
"No\n",
"Yes\n",
"Yes\n",
"No\n"
] | In first sample test all 'A' form a cycle.
In second sample there is no such cycle.
The third sample is displayed on the picture above ('Y' = Yellow, 'B' = Blue, 'R' = Red). | 1,000 | [
{
"input": "3 4\nAAAA\nABCA\nAAAA",
"output": "Yes"
},
{
"input": "3 4\nAAAA\nABCA\nAADA",
"output": "No"
},
{
"input": "4 4\nYYYR\nBYBY\nBBBY\nBBBY",
"output": "Yes"
},
{
"input": "7 6\nAAAAAB\nABBBAB\nABAAAB\nABABBB\nABAAAB\nABBBAB\nAAAAAB",
"output": "Yes"
},
{
... | 1,691,233,909 | 2,147,483,647 | PyPy 3 | OK | TESTS | 24 | 998 | 57,856,000 | def has_cycle_with_same_color_adjacent(graph):
rows = len(graph)
cols = len(graph[0])
visited = set()
def dfs(row, col, parent, color, length):
nonlocal visited
if length >= 4 and (row, col) == parent:
return True
visited.add((row, col))
length ... | Title: Fox And Two Dots
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Fox Ciel is playing a mobile puzzle game called "Two Dots". The basic levels are played on a board of size *n*<=×<=*m* cells, like this:
Each cell contains a dot that has some color. We will use different uppercase La... | ```python
def has_cycle_with_same_color_adjacent(graph):
rows = len(graph)
cols = len(graph[0])
visited = set()
def dfs(row, col, parent, color, length):
nonlocal visited
if length >= 4 and (row, col) == parent:
return True
visited.add((row, col))
... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
66 | B | Petya and Countryside | PROGRAMMING | 1,100 | [
"brute force",
"implementation"
] | B. Petya and Countryside | 2 | 256 | Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1<=×<=*n* in size, when viewed from above. This rectangle is divided into *n* equal square sections. The garden is very unusual as each of the square sections possesses its own f... | The first line contains a positive integer *n* (1<=≤<=*n*<=≤<=1000). The second line contains *n* positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000. | Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section. | [
"1\n2\n",
"5\n1 2 1 2 1\n",
"8\n1 2 1 1 1 3 3 4\n"
] | [
"1\n",
"3\n",
"6\n"
] | none | 1,000 | [
{
"input": "1\n2",
"output": "1"
},
{
"input": "5\n1 2 1 2 1",
"output": "3"
},
{
"input": "8\n1 2 1 1 1 3 3 4",
"output": "6"
},
{
"input": "10\n1 2 3 4 5 6 7 8 9 10",
"output": "10"
},
{
"input": "10\n10 9 8 7 6 5 4 3 2 1",
"output": "10"
},
{
"input... | 1,646,955,444 | 2,147,483,647 | Python 3 | OK | TESTS | 80 | 996 | 0 | n = int(input())
m = map(int,input().split())
l=[]
for x in m :
l.append(x)
for x in range(len(l)):
if x == 0 :
c=l[x]
i = 0
res=0
while l[i]<=c :
res+=1
c=l[i]
i+=1
if i == len(l) :
break
eli... | Title: Petya and Countryside
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1<=×<=*n* in size, when viewed from above. This rectangle is divided into *... | ```python
n = int(input())
m = map(int,input().split())
l=[]
for x in m :
l.append(x)
for x in range(len(l)):
if x == 0 :
c=l[x]
i = 0
res=0
while l[i]<=c :
res+=1
c=l[i]
i+=1
if i == len(l) :
brea... | 3.751 | MatrixStudio/Codeforces-Python-Submissions |
898 | A | Rounding | PROGRAMMING | 800 | [
"implementation",
"math"
] | null | null | Vasya has a non-negative integer *n*. He wants to round it to nearest integer, which ends up with 0. If *n* already ends up with 0, Vasya considers it already rounded.
For example, if *n*<==<=4722 answer is 4720. If *n*<==<=5 Vasya can round it to 0 or to 10. Both ways are correct.
For given *n* find out to which int... | The first line contains single integer *n* (0<=≤<=*n*<=≤<=109) — number that Vasya has. | Print result of rounding *n*. Pay attention that in some cases answer isn't unique. In that case print any correct answer. | [
"5\n",
"113\n",
"1000000000\n",
"5432359\n"
] | [
"0\n",
"110\n",
"1000000000\n",
"5432360\n"
] | In the first example *n* = 5. Nearest integers, that ends up with zero are 0 and 10. Any of these answers is correct, so you can print 0 or 10. | 500 | [
{
"input": "5",
"output": "0"
},
{
"input": "113",
"output": "110"
},
{
"input": "1000000000",
"output": "1000000000"
},
{
"input": "5432359",
"output": "5432360"
},
{
"input": "999999994",
"output": "999999990"
},
{
"input": "10",
"output": "10"
... | 1,700,508,561 | 2,147,483,647 | Python 3 | OK | TESTS | 64 | 46 | 0 | n=int(input())
n=n/10
n=round(n)
n=n*10
print(n) | Title: Rounding
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vasya has a non-negative integer *n*. He wants to round it to nearest integer, which ends up with 0. If *n* already ends up with 0, Vasya considers it already rounded.
For example, if *n*<==<=4722 answer is 4720. If *n*<==<=5... | ```python
n=int(input())
n=n/10
n=round(n)
n=n*10
print(n)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
709 | A | Juicer | PROGRAMMING | 900 | [
"implementation"
] | null | null | Kolya is going to make fresh orange juice. He has *n* oranges of sizes *a*1,<=*a*2,<=...,<=*a**n*. Kolya will put them in the juicer in the fixed order, starting with orange of size *a*1, then orange of size *a*2 and so on. To be put in the juicer the orange must have size not exceeding *b*, so if Kolya sees an orange ... | The first line of the input contains three integers *n*, *b* and *d* (1<=≤<=*n*<=≤<=100<=000, 1<=≤<=*b*<=≤<=*d*<=≤<=1<=000<=000) — the number of oranges, the maximum size of the orange that fits in the juicer and the value *d*, which determines the condition when the waste section should be emptied.
The second line co... | Print one integer — the number of times Kolya will have to empty the waste section. | [
"2 7 10\n5 6\n",
"1 5 10\n7\n",
"3 10 10\n5 7 7\n",
"1 1 1\n1\n"
] | [
"1\n",
"0\n",
"1\n",
"0\n"
] | In the first sample, Kolya will squeeze the juice from two oranges and empty the waste section afterwards.
In the second sample, the orange won't fit in the juicer so Kolya will have no juice at all. | 500 | [
{
"input": "2 7 10\n5 6",
"output": "1"
},
{
"input": "1 5 10\n7",
"output": "0"
},
{
"input": "3 10 10\n5 7 7",
"output": "1"
},
{
"input": "1 1 1\n1",
"output": "0"
},
{
"input": "2 951637 951638\n44069 951637",
"output": "1"
},
{
"input": "50 100 12... | 1,692,914,169 | 2,147,483,647 | Python 3 | OK | TESTS | 58 | 78 | 13,619,200 | n,b,d=map(int,input().split())
the_list=list(map(int,input().split()))
sum=empty=0
for i in the_list:
if i>b:
continue
sum+=i
if sum>d:
empty+=1
sum=0
print(empty) | Title: Juicer
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Kolya is going to make fresh orange juice. He has *n* oranges of sizes *a*1,<=*a*2,<=...,<=*a**n*. Kolya will put them in the juicer in the fixed order, starting with orange of size *a*1, then orange of size *a*2 and so on. To b... | ```python
n,b,d=map(int,input().split())
the_list=list(map(int,input().split()))
sum=empty=0
for i in the_list:
if i>b:
continue
sum+=i
if sum>d:
empty+=1
sum=0
print(empty)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
382 | A | Ksenia and Pan Scales | PROGRAMMING | 1,100 | [
"greedy",
"implementation"
] | null | null | Ksenia has ordinary pan scales and several weights of an equal mass. Ksenia has already put some weights on the scales, while other weights are untouched. Ksenia is now wondering whether it is possible to put all the remaining weights on the scales so that the scales were in equilibrium.
The scales is in equilibrium ... | The first line has a non-empty sequence of characters describing the scales. In this sequence, an uppercase English letter indicates a weight, and the symbol "|" indicates the delimiter (the character occurs in the sequence exactly once). All weights that are recorded in the sequence before the delimiter are initially ... | If you cannot put all the weights on the scales so that the scales were in equilibrium, print string "Impossible". Otherwise, print the description of the resulting scales, copy the format of the input.
If there are multiple answers, print any of them. | [
"AC|T\nL\n",
"|ABC\nXYZ\n",
"W|T\nF\n",
"ABC|\nD\n"
] | [
"AC|TL\n",
"XYZ|ABC\n",
"Impossible\n",
"Impossible\n"
] | none | 500 | [
{
"input": "AC|T\nL",
"output": "AC|TL"
},
{
"input": "|ABC\nXYZ",
"output": "XYZ|ABC"
},
{
"input": "W|T\nF",
"output": "Impossible"
},
{
"input": "ABC|\nD",
"output": "Impossible"
},
{
"input": "A|BC\nDEF",
"output": "ADF|BCE"
},
{
"input": "|\nABC",... | 1,473,180,485 | 2,147,483,647 | Python 3 | OK | TESTS | 39 | 77 | 0 | n,m=input().split('|')
l=list(input())
for x in l:
if len(n)<len(m): n+=x
else: m+=x
if len(n)==len(m): print('|'.join([n,m]))
else: print('Impossible') | Title: Ksenia and Pan Scales
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Ksenia has ordinary pan scales and several weights of an equal mass. Ksenia has already put some weights on the scales, while other weights are untouched. Ksenia is now wondering whether it is possible to put all ... | ```python
n,m=input().split('|')
l=list(input())
for x in l:
if len(n)<len(m): n+=x
else: m+=x
if len(n)==len(m): print('|'.join([n,m]))
else: print('Impossible')
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
154 | B | Colliders | PROGRAMMING | 1,600 | [
"math",
"number theory"
] | null | null | By 2312 there were *n* Large Hadron Colliders in the inhabited part of the universe. Each of them corresponded to a single natural number from 1 to *n*. However, scientists did not know what activating several colliders simultaneously could cause, so the colliders were deactivated.
In 2312 there was a startling discov... | The first line contains two space-separated integers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=105) — the number of colliders and the number of requests, correspondingly.
Next *m* lines contain numbers of requests, one per line, in the form of either "+ i" (without the quotes) — activate the *i*-th collider, or "- i" (without ... | Print *m* lines — the results of executing requests in the above given format. The requests should be processed in the order, in which they are given in the input. Don't forget that the responses to the requests should be printed without quotes. | [
"10 10\n+ 6\n+ 10\n+ 5\n- 10\n- 5\n- 6\n+ 10\n+ 3\n+ 6\n+ 3\n"
] | [
"Success\nConflict with 6\nSuccess\nAlready off\nSuccess\nSuccess\nSuccess\nSuccess\nConflict with 10\nAlready on\n"
] | Note that in the sample the colliders don't turn on after the second and ninth requests. The ninth request could also receive response "Conflict with 3". | 1,000 | [
{
"input": "10 10\n+ 6\n+ 10\n+ 5\n- 10\n- 5\n- 6\n+ 10\n+ 3\n+ 6\n+ 3",
"output": "Success\nConflict with 6\nSuccess\nAlready off\nSuccess\nSuccess\nSuccess\nSuccess\nConflict with 10\nAlready on"
},
{
"input": "7 5\n+ 7\n+ 6\n+ 4\n+ 3\n- 7",
"output": "Success\nSuccess\nConflict with 6\nConfli... | 1,621,157,469 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 26 | 2,000 | 1,433,600 | #User function Template for python3
class Solution:
def __init__(self):
self.sieve=[]
self.spf=[]
self.active=[]
self.actlist=set()
def buildsieve(self,n):
self.active=[-1]*n
self.spf=[-1]*(n-2)
a=[-1]*(n-2)
for i in range(0,... | Title: Colliders
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
By 2312 there were *n* Large Hadron Colliders in the inhabited part of the universe. Each of them corresponded to a single natural number from 1 to *n*. However, scientists did not know what activating several colliders simul... | ```python
#User function Template for python3
class Solution:
def __init__(self):
self.sieve=[]
self.spf=[]
self.active=[]
self.actlist=set()
def buildsieve(self,n):
self.active=[-1]*n
self.spf=[-1]*(n-2)
a=[-1]*(n-2)
for i i... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
14 | A | Letter | PROGRAMMING | 800 | [
"implementation"
] | A. Letter | 1 | 64 | A boy Bob likes to draw. Not long ago he bought a rectangular graph (checked) sheet with *n* rows and *m* columns. Bob shaded some of the squares on the sheet. Having seen his masterpiece, he decided to share it with his elder brother, who lives in Flatland. Now Bob has to send his picture by post, but because of the w... | The first line of the input data contains numbers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=50), *n* — amount of lines, and *m* — amount of columns on Bob's sheet. The following *n* lines contain *m* characters each. Character «.» stands for a non-shaded square on the sheet, and «*» — for a shaded square. It is guaranteed that ... | Output the required rectangle of the minimum cost. Study the output data in the sample tests to understand the output format better. | [
"6 7\n.......\n..***..\n..*....\n..***..\n..*....\n..***..\n",
"3 3\n***\n*.*\n***\n"
] | [
"***\n*..\n***\n*..\n***\n",
"***\n*.*\n***\n"
] | none | 0 | [
{
"input": "6 7\n.......\n..***..\n..*....\n..***..\n..*....\n..***..",
"output": "***\n*..\n***\n*..\n***"
},
{
"input": "3 3\n***\n*.*\n***",
"output": "***\n*.*\n***"
},
{
"input": "1 1\n*",
"output": "*"
},
{
"input": "2 1\n*\n*",
"output": "*\n*"
},
{
"input"... | 1,529,313,498 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 124 | 0 | n,m = map(int,input().split())
a = []
latest = 0
earliest = m
last = 0
first = m
for i in range(n):
temp = input()
a.append(temp)
if '*' in temp and temp.rindex('*')>latest:
latest = temp.rindex('*')+1
if '*' in temp and temp.index('*')<=earliest:
earliest = temp.index('*')... | Title: Letter
Time Limit: 1 seconds
Memory Limit: 64 megabytes
Problem Description:
A boy Bob likes to draw. Not long ago he bought a rectangular graph (checked) sheet with *n* rows and *m* columns. Bob shaded some of the squares on the sheet. Having seen his masterpiece, he decided to share it with his elder brothe... | ```python
n,m = map(int,input().split())
a = []
latest = 0
earliest = m
last = 0
first = m
for i in range(n):
temp = input()
a.append(temp)
if '*' in temp and temp.rindex('*')>latest:
latest = temp.rindex('*')+1
if '*' in temp and temp.index('*')<=earliest:
earliest = temp.... | 0 | MatrixStudio/Codeforces-Python-Submissions |
2 | A | Winner | PROGRAMMING | 1,500 | [
"hashing",
"implementation"
] | A. Winner | 1 | 64 | The winner of the card game popular in Berland "Berlogging" is determined according to the following rules. If at the end of the game there is only one player with the maximum number of points, he is the winner. The situation becomes more difficult if the number of such players is more than one. During each round a pla... | The first line contains an integer number *n* (1<=<=≤<=<=*n*<=<=≤<=<=1000), *n* is the number of rounds played. Then follow *n* lines, containing the information about the rounds in "name score" format in chronological order, where name is a string of lower-case Latin letters with the length from 1 to 32, and score is ... | Print the name of the winner. | [
"3\nmike 3\nandrew 5\nmike 2\n",
"3\nandrew 3\nandrew 2\nmike 5\n"
] | [
"andrew\n",
"andrew\n"
] | none | 0 | [
{
"input": "3\nmike 3\nandrew 5\nmike 2",
"output": "andrew"
},
{
"input": "3\nandrew 3\nandrew 2\nmike 5",
"output": "andrew"
},
{
"input": "5\nkaxqybeultn -352\nmgochgrmeyieyskhuourfg -910\nkaxqybeultn 691\nmgochgrmeyieyskhuourfg -76\nkaxqybeultn -303",
"output": "kaxqybeultn"
},... | 1,489,809,724 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 92 | 4,608,000 | n = int(input())
l = []
m = {}
for _ in range(n):
k = input().split(' ')
if k[0] not in l:
l.append(k[0])
else:
l.remove(k[0])
if k[0] not in m:
m[k[0]] = int(k[1])
else:
m[k[0]] += int(k[1])
best_person = None
best_score = 0
for key in m:
if m[key] > best_score:
best_score = m[key]
best_person = k... | Title: Winner
Time Limit: 1 seconds
Memory Limit: 64 megabytes
Problem Description:
The winner of the card game popular in Berland "Berlogging" is determined according to the following rules. If at the end of the game there is only one player with the maximum number of points, he is the winner. The situation becomes... | ```python
n = int(input())
l = []
m = {}
for _ in range(n):
k = input().split(' ')
if k[0] not in l:
l.append(k[0])
else:
l.remove(k[0])
if k[0] not in m:
m[k[0]] = int(k[1])
else:
m[k[0]] += int(k[1])
best_person = None
best_score = 0
for key in m:
if m[key] > best_score:
best_score = m[key]
best_... | 0 | MatrixStudio/Codeforces-Python-Submissions |
4 | C | Registration System | PROGRAMMING | 1,300 | [
"data structures",
"hashing",
"implementation"
] | C. Registration system | 5 | 64 | A new e-mail service "Berlandesk" is going to be opened in Berland in the near future. The site administration wants to launch their project as soon as possible, that's why they ask you to help. You're suggested to implement the prototype of site registration system. The system should work on the following principle.
... | The first line contains number *n* (1<=≤<=*n*<=≤<=105). The following *n* lines contain the requests to the system. Each request is a non-empty line, and consists of not more than 32 characters, which are all lowercase Latin letters. | Print *n* lines, which are system responses to the requests: OK in case of successful registration, or a prompt with a new name, if the requested name is already taken. | [
"4\nabacaba\nacaba\nabacaba\nacab\n",
"6\nfirst\nfirst\nsecond\nsecond\nthird\nthird\n"
] | [
"OK\nOK\nabacaba1\nOK\n",
"OK\nfirst1\nOK\nsecond1\nOK\nthird1\n"
] | none | 0 | [
{
"input": "4\nabacaba\nacaba\nabacaba\nacab",
"output": "OK\nOK\nabacaba1\nOK"
},
{
"input": "6\nfirst\nfirst\nsecond\nsecond\nthird\nthird",
"output": "OK\nfirst1\nOK\nsecond1\nOK\nthird1"
},
{
"input": "1\nn",
"output": "OK"
},
{
"input": "2\nu\nu",
"output": "OK\nu1"
... | 1,689,338,530 | 2,147,483,647 | PyPy 3 | OK | TESTS | 25 | 3,120 | 9,728,000 | n = int(input())
database = {}
for i in range(n):
s = input()
if s not in database:
print("OK")
database[s] = 1
else:
print(s + str(database[s]))
database[s] += 1
| Title: Registration System
Time Limit: 5 seconds
Memory Limit: 64 megabytes
Problem Description:
A new e-mail service "Berlandesk" is going to be opened in Berland in the near future. The site administration wants to launch their project as soon as possible, that's why they ask you to help. You're suggested to imple... | ```python
n = int(input())
database = {}
for i in range(n):
s = input()
if s not in database:
print("OK")
database[s] = 1
else:
print(s + str(database[s]))
database[s] += 1
``` | 3.615521 | MatrixStudio/Codeforces-Python-Submissions |
832 | A | Sasha and Sticks | PROGRAMMING | 800 | [
"games",
"math"
] | null | null | It's one more school day now. Sasha doesn't like classes and is always bored at them. So, each day he invents some game and plays in it alone or with friends.
Today he invented one simple game to play with Lena, with whom he shares a desk. The rules are simple. Sasha draws *n* sticks in a row. After that the players t... | The first line contains two integers *n* and *k* (1<=≤<=*n*,<=*k*<=≤<=1018, *k*<=≤<=*n*) — the number of sticks drawn by Sasha and the number *k* — the number of sticks to be crossed out on each turn. | If Sasha wins, print "YES" (without quotes), otherwise print "NO" (without quotes).
You can print each letter in arbitrary case (upper of lower). | [
"1 1\n",
"10 4\n"
] | [
"YES\n",
"NO\n"
] | In the first example Sasha crosses out 1 stick, and then there are no sticks. So Lena can't make a move, and Sasha wins.
In the second example Sasha crosses out 4 sticks, then Lena crosses out 4 sticks, and after that there are only 2 sticks left. Sasha can't make a move. The players make equal number of moves, so Sas... | 500 | [
{
"input": "1 1",
"output": "YES"
},
{
"input": "10 4",
"output": "NO"
},
{
"input": "251656215122324104 164397544865601257",
"output": "YES"
},
{
"input": "963577813436662285 206326039287271924",
"output": "NO"
},
{
"input": "1000000000000000000 1",
"output":... | 1,579,625,777 | 2,147,483,647 | Python 3 | OK | TESTS | 62 | 124 | 0 | a=input().split()
b=int(a[0])
c=int(a[1])
if b//c%2==1:
print('YES')
else:
print('NO')
| Title: Sasha and Sticks
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
It's one more school day now. Sasha doesn't like classes and is always bored at them. So, each day he invents some game and plays in it alone or with friends.
Today he invented one simple game to play with Lena, with ... | ```python
a=input().split()
b=int(a[0])
c=int(a[1])
if b//c%2==1:
print('YES')
else:
print('NO')
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
459 | D | Pashmak and Parmida's problem | PROGRAMMING | 1,800 | [
"data structures",
"divide and conquer",
"sortings"
] | null | null | Parmida is a clever girl and she wants to participate in Olympiads this year. Of course she wants her partner to be clever too (although he's not)! Parmida has prepared the following test problem for Pashmak.
There is a sequence *a* that consists of *n* integers *a*1,<=*a*2,<=...,<=*a**n*. Let's denote *f*(*l*,<=*r*,<... | The first line of the input contains an integer *n* (1<=≤<=*n*<=≤<=106). The second line contains *n* space-separated integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=109). | Print a single integer — the answer to the problem. | [
"7\n1 2 1 1 2 2 1\n",
"3\n1 1 1\n",
"5\n1 2 3 4 5\n"
] | [
"8\n",
"1\n",
"0\n"
] | none | 2,000 | [
{
"input": "7\n1 2 1 1 2 2 1",
"output": "8"
},
{
"input": "3\n1 1 1",
"output": "1"
},
{
"input": "5\n1 2 3 4 5",
"output": "0"
},
{
"input": "24\n1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4",
"output": "114"
},
{
"input": "1\n1",
"output": "0"
},
{
... | 1,679,046,892 | 2,147,483,647 | PyPy 3 | OK | TESTS | 33 | 1,777 | 97,894,400 | import sys
input=sys.stdin.readline
BIT = [0]*(10**6)
def update(idx):
while(idx<len(BIT)):
BIT[idx] += 1
idx += idx & -idx
def query(idx):
s = 0
while(idx > 0):
s += BIT[idx]
idx -= idx & -idx
return s
n=int(input())
a=list(map(int,input().split()))
ans=0
cnt={}
l=[0]*n
r=[0]*... | Title: Pashmak and Parmida's problem
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Parmida is a clever girl and she wants to participate in Olympiads this year. Of course she wants her partner to be clever too (although he's not)! Parmida has prepared the following test problem for Pashm... | ```python
import sys
input=sys.stdin.readline
BIT = [0]*(10**6)
def update(idx):
while(idx<len(BIT)):
BIT[idx] += 1
idx += idx & -idx
def query(idx):
s = 0
while(idx > 0):
s += BIT[idx]
idx -= idx & -idx
return s
n=int(input())
a=list(map(int,input().split()))
ans=0
cnt={}
l=[0]... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
698 | A | Vacations | PROGRAMMING | 1,400 | [
"dp"
] | null | null | Vasya has *n* days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this *n* days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the *i*-th day there are four options:
1. on this day the gym is close... | The first line contains a positive integer *n* (1<=≤<=*n*<=≤<=100) — the number of days of Vasya's vacations.
The second line contains the sequence of integers *a*1,<=*a*2,<=...,<=*a**n* (0<=≤<=*a**i*<=≤<=3) separated by space, where:
- *a**i* equals 0, if on the *i*-th day of vacations the gym is closed and the co... | Print the minimum possible number of days on which Vasya will have a rest. Remember that Vasya refuses:
- to do sport on any two consecutive days, - to write the contest on any two consecutive days. | [
"4\n1 3 2 0\n",
"7\n1 3 3 2 1 2 3\n",
"2\n2 2\n"
] | [
"2\n",
"0\n",
"1\n"
] | In the first test Vasya can write the contest on the day number 1 and do sport on the day number 3. Thus, he will have a rest for only 2 days.
In the second test Vasya should write contests on days number 1, 3, 5 and 7, in other days do sport. Thus, he will not have a rest for a single day.
In the third test Vasya ca... | 500 | [
{
"input": "4\n1 3 2 0",
"output": "2"
},
{
"input": "7\n1 3 3 2 1 2 3",
"output": "0"
},
{
"input": "2\n2 2",
"output": "1"
},
{
"input": "1\n0",
"output": "1"
},
{
"input": "10\n0 0 1 1 0 0 0 0 1 0",
"output": "8"
},
{
"input": "100\n3 2 3 3 3 2 3 1 ... | 1,637,939,878 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 88 | 93 | 5,734,400 | n = int(input())
a = [set()for i in range(n)]
b = list(map(int,input().split()))
if b[0] == 0:
a[0] |= {(1, 0)}
if b[0] == 1:
a[0] |= {(0, 1)}
a[0] |= {(1, 0)}
if b[0] == 2:
a[0] |= {(0, 2)}
a[0] |= {(1, 0)}
if b[0] == 3:
a[0] |= {(0, 1)}
a[0] |= {(0, 2)}
a[0] |= {(1, 0)}
... | Title: Vacations
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vasya has *n* days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this *n* days: whether that gym opened and whether a contest was carried out in the Int... | ```python
n = int(input())
a = [set()for i in range(n)]
b = list(map(int,input().split()))
if b[0] == 0:
a[0] |= {(1, 0)}
if b[0] == 1:
a[0] |= {(0, 1)}
a[0] |= {(1, 0)}
if b[0] == 2:
a[0] |= {(0, 2)}
a[0] |= {(1, 0)}
if b[0] == 3:
a[0] |= {(0, 1)}
a[0] |= {(0, 2)}
a[0] |= ... | 3 | 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,609,699,087 | 2,147,483,647 | Python 3 | OK | TESTS | 35 | 218 | 0 | m,n = map(int, input().split())
p = m*n
print(p//2) | 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,n = map(int, input().split())
p = m*n
print(p//2)
``` | 3.9455 | MatrixStudio/Codeforces-Python-Submissions |
844 | B | Rectangles | PROGRAMMING | 1,300 | [
"combinatorics",
"math"
] | null | null | You are given *n*<=×<=*m* table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such that:
1. All cells in a set have the same color. 1. Every two cells in a set share row or column. | The first line of input contains integers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=50) — the number of rows and the number of columns correspondingly.
The next *n* lines of input contain descriptions of rows. There are *m* integers, separated by spaces, in each line. The number equals 0 if the corresponding cell is colored wh... | Output single integer — the number of non-empty sets from the problem description. | [
"1 1\n0\n",
"2 3\n1 0 1\n0 1 0\n"
] | [
"1\n",
"8\n"
] | In the second example, there are six one-element sets. Additionally, there are two two-element sets, the first one consists of the first and the third cells of the first row, the second one consists of the first and the third cells of the second row. To sum up, there are 8 sets. | 1,000 | [
{
"input": "1 1\n0",
"output": "1"
},
{
"input": "2 3\n1 0 1\n0 1 0",
"output": "8"
},
{
"input": "2 2\n1 1\n1 1",
"output": "8"
},
{
"input": "1 10\n0 0 0 0 0 0 0 0 0 0",
"output": "1023"
},
{
"input": "11 1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1",
"output": "2047"... | 1,570,915,306 | 2,147,483,647 | PyPy 3 | OK | TESTS | 55 | 155 | 1,536,000 | n, m = map(int, input().split())
a = []
for i in range(n):
a.append(list(map(int, input().split())))
d = 0
for i in range(n):
b, w = 0, 0
for j in range(m):
if a[i][j] == 1:
b += 1
else:
w += 1
if b > 0:
d += 2 ** b - 1
if w > 0:
... | Title: Rectangles
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given *n*<=×<=*m* table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such that:
1. All cells in a set have the same color. 1. Every two cells in a set share row or ... | ```python
n, m = map(int, input().split())
a = []
for i in range(n):
a.append(list(map(int, input().split())))
d = 0
for i in range(n):
b, w = 0, 0
for j in range(m):
if a[i][j] == 1:
b += 1
else:
w += 1
if b > 0:
d += 2 ** b - 1
if w > 0... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
479 | A | Expression | PROGRAMMING | 1,000 | [
"brute force",
"math"
] | null | null | Petya studies in a school and he adores Maths. His class has been studying arithmetic expressions. On the last class the teacher wrote three positive integers *a*, *b*, *c* on the blackboard. The task was to insert signs of operations '+' and '*', and probably brackets between the numbers so that the value of the resul... | The input contains three integers *a*, *b* and *c*, each on a single line (1<=≤<=*a*,<=*b*,<=*c*<=≤<=10). | Print the maximum value of the expression that you can obtain. | [
"1\n2\n3\n",
"2\n10\n3\n"
] | [
"9\n",
"60\n"
] | none | 500 | [
{
"input": "1\n2\n3",
"output": "9"
},
{
"input": "2\n10\n3",
"output": "60"
},
{
"input": "1\n1\n1",
"output": "3"
},
{
"input": "1\n2\n1",
"output": "4"
},
{
"input": "10\n10\n10",
"output": "1000"
},
{
"input": "5\n1\n3",
"output": "20"
},
{... | 1,688,074,526 | 2,147,483,647 | Python 3 | OK | TESTS | 29 | 46 | 0 | x = int(input())
y = int(input())
z = int(input())
case1 = x + y + z
case2 = x * y * z
case3 = x * (y + z)
case4 = (x + y) * z
print(max(case1,case2,case3,case4)) | Title: Expression
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Petya studies in a school and he adores Maths. His class has been studying arithmetic expressions. On the last class the teacher wrote three positive integers *a*, *b*, *c* on the blackboard. The task was to insert signs of ... | ```python
x = int(input())
y = int(input())
z = int(input())
case1 = x + y + z
case2 = x * y * z
case3 = x * (y + z)
case4 = (x + y) * z
print(max(case1,case2,case3,case4))
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
490 | C | Hacking Cypher | PROGRAMMING | 1,700 | [
"brute force",
"math",
"number theory",
"strings"
] | null | null | Polycarpus participates in a competition for hacking into a new secure messenger. He's almost won.
Having carefully studied the interaction protocol, Polycarpus came to the conclusion that the secret key can be obtained if he properly cuts the public key of the application into two parts. The public key is a long inte... | The first line of the input contains the public key of the messenger — an integer without leading zeroes, its length is in range from 1 to 106 digits. The second line contains a pair of space-separated positive integers *a*, *b* (1<=≤<=*a*,<=*b*<=≤<=108). | In the first line print "YES" (without the quotes), if the method satisfying conditions above exists. In this case, next print two lines — the left and right parts after the cut. These two parts, being concatenated, must be exactly identical to the public key. The left part must be divisible by *a*, and the right part ... | [
"116401024\n97 1024\n",
"284254589153928171911281811000\n1009 1000\n",
"120\n12 1\n"
] | [
"YES\n11640\n1024\n",
"YES\n2842545891539\n28171911281811000\n",
"NO\n"
] | none | 1,500 | [
{
"input": "116401024\n97 1024",
"output": "YES\n11640\n1024"
},
{
"input": "284254589153928171911281811000\n1009 1000",
"output": "YES\n2842545891539\n28171911281811000"
},
{
"input": "120\n12 1",
"output": "NO"
},
{
"input": "604\n6 4",
"output": "YES\n60\n4"
},
{
... | 1,670,448,194 | 2,147,483,647 | PyPy 3-64 | TIME_LIMIT_EXCEEDED | TESTS | 33 | 1,000 | 9,216,000 | s = input()
a, b = input().split()
a, b = int(a), int(b)
s1 = ""
dA = []
dB = []
for x in s:
s1 += x
dA.append(int(s[:len(s1)]) % a)
dB.append(int(s[len(s1)-1:]) % b)
for i in range(len(dA)-1):
if dA[i] == 0 and dB[i] == 0 and s[:i+1][0] != "0" and s[i+1:][0] != "0":
print("YES")
... | Title: Hacking Cypher
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Polycarpus participates in a competition for hacking into a new secure messenger. He's almost won.
Having carefully studied the interaction protocol, Polycarpus came to the conclusion that the secret key can be obtained... | ```python
s = input()
a, b = input().split()
a, b = int(a), int(b)
s1 = ""
dA = []
dB = []
for x in s:
s1 += x
dA.append(int(s[:len(s1)]) % a)
dB.append(int(s[len(s1)-1:]) % b)
for i in range(len(dA)-1):
if dA[i] == 0 and dB[i] == 0 and s[:i+1][0] != "0" and s[i+1:][0] != "0":
print(... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
742 | A | Arpa’s hard exam and Mehrdad’s naive cheat | PROGRAMMING | 1,000 | [
"implementation",
"math",
"number theory"
] | null | null | There exists an island called Arpa’s land, some beautiful girls live there, as ugly ones do.
Mehrdad wants to become minister of Arpa’s land. Arpa has prepared an exam. Exam has only one question, given *n*, print the last digit of 1378*n*.
Mehrdad has become quite confused and wants you to help him. Please help, al... | The single line of input contains one integer *n* (0<=<=≤<=<=*n*<=<=≤<=<=109). | Print single integer — the last digit of 1378*n*. | [
"1\n",
"2\n"
] | [
"8",
"4"
] | In the first example, last digit of 1378<sup class="upper-index">1</sup> = 1378 is 8.
In the second example, last digit of 1378<sup class="upper-index">2</sup> = 1378·1378 = 1898884 is 4. | 500 | [
{
"input": "1",
"output": "8"
},
{
"input": "2",
"output": "4"
},
{
"input": "1000",
"output": "6"
},
{
"input": "3",
"output": "2"
},
{
"input": "4",
"output": "6"
},
{
"input": "1000000000",
"output": "6"
},
{
"input": "5",
"output": ... | 1,655,453,160 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 5 | 1,000 | 2,560,000 | ### Hello! World ... ###
n = int(input())
n = 1378 ** n
print(n%10) | Title: Arpa’s hard exam and Mehrdad’s naive cheat
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
There exists an island called Arpa’s land, some beautiful girls live there, as ugly ones do.
Mehrdad wants to become minister of Arpa’s land. Arpa has prepared an exam. Exam has only one ques... | ```python
### Hello! World ... ###
n = int(input())
n = 1378 ** n
print(n%10)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
245 | A | System Administrator | PROGRAMMING | 800 | [
"implementation"
] | null | null | Polycarpus is a system administrator. There are two servers under his strict guidance — *a* and *b*. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a progra... | The first line contains a single integer *n* (2<=≤<=*n*<=≤<=1000) — the number of commands Polycarpus has fulfilled. Each of the following *n* lines contains three integers — the description of the commands. The *i*-th of these lines contains three space-separated integers *t**i*, *x**i*, *y**i* (1<=≤<=*t**i*<=≤<=2; *x... | In the first line print string "LIVE" (without the quotes) if server *a* is "alive", otherwise print "DEAD" (without the quotes).
In the second line print the state of server *b* in the similar format. | [
"2\n1 5 5\n2 6 4\n",
"3\n1 0 10\n2 0 10\n1 10 0\n"
] | [
"LIVE\nLIVE\n",
"LIVE\nDEAD\n"
] | Consider the first test case. There 10 packets were sent to server *a*, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server *b*, 6 of them reached it. Therefore, at least half of all packets sent to t... | 0 | [
{
"input": "2\n1 5 5\n2 6 4",
"output": "LIVE\nLIVE"
},
{
"input": "3\n1 0 10\n2 0 10\n1 10 0",
"output": "LIVE\nDEAD"
},
{
"input": "10\n1 3 7\n2 4 6\n1 2 8\n2 5 5\n2 10 0\n2 10 0\n1 8 2\n2 2 8\n2 10 0\n1 1 9",
"output": "DEAD\nLIVE"
},
{
"input": "11\n1 8 2\n1 6 4\n1 9 1\n1... | 1,640,361,531 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 60 | 0 | a = 0; b = 0; at = 0; bt = 0
for _ in int(input()):
t, x, y = [int(i) for i in input().split()]
if t == 1:
a += x
at += 1
else:
b += x
bt += 1
print("LIVE" if a >= (at*10)//2 else "DEAD")
print("LIVE" if b >= (bt*10)//2 else "DEAD")
| Title: System Administrator
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Polycarpus is a system administrator. There are two servers under his strict guidance — *a* and *b*. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping co... | ```python
a = 0; b = 0; at = 0; bt = 0
for _ in int(input()):
t, x, y = [int(i) for i in input().split()]
if t == 1:
a += x
at += 1
else:
b += x
bt += 1
print("LIVE" if a >= (at*10)//2 else "DEAD")
print("LIVE" if b >= (bt*10)//2 else "DEAD")
... | -1 | MatrixStudio/Codeforces-Python-Submissions | |
520 | A | Pangram | PROGRAMMING | 800 | [
"implementation",
"strings"
] | null | null | A word or a sentence in some language is called a pangram if all the characters of the alphabet of this language appear in it at least once. Pangrams are often used to demonstrate fonts in printing or test the output devices.
You are given a string consisting of lowercase and uppercase Latin letters. Check whether thi... | The first line contains a single integer *n* (1<=≤<=*n*<=≤<=100) — the number of characters in the string.
The second line contains the string. The string consists only of uppercase and lowercase Latin letters. | Output "YES", if the string is a pangram and "NO" otherwise. | [
"12\ntoosmallword\n",
"35\nTheQuickBrownFoxJumpsOverTheLazyDog\n"
] | [
"NO\n",
"YES\n"
] | none | 500 | [
{
"input": "12\ntoosmallword",
"output": "NO"
},
{
"input": "35\nTheQuickBrownFoxJumpsOverTheLazyDog",
"output": "YES"
},
{
"input": "1\na",
"output": "NO"
},
{
"input": "26\nqwertyuiopasdfghjklzxcvbnm",
"output": "YES"
},
{
"input": "26\nABCDEFGHIJKLMNOPQRSTUVWXY... | 1,693,660,021 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 31 | 0 | text = input().lower()
text_set = set(text)
if len(text_set) == 26:
print('YES')
else:
print('NO') | Title: Pangram
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
A word or a sentence in some language is called a pangram if all the characters of the alphabet of this language appear in it at least once. Pangrams are often used to demonstrate fonts in printing or test the output devices.
... | ```python
text = input().lower()
text_set = set(text)
if len(text_set) == 26:
print('YES')
else:
print('NO')
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
372 | A | Counting Kangaroos is Fun | PROGRAMMING | 1,600 | [
"binary search",
"greedy",
"sortings",
"two pointers"
] | null | null | There are *n* kangaroos with pockets. Each kangaroo has a size (integer number). A kangaroo can go into another kangaroo's pocket if and only if the size of kangaroo who hold the kangaroo is at least twice as large as the size of kangaroo who is held.
Each kangaroo can hold at most one kangaroo, and the kangaroo who i... | The first line contains a single integer — *n* (1<=≤<=*n*<=≤<=5·105). Each of the next *n* lines contains an integer *s**i* — the size of the *i*-th kangaroo (1<=≤<=*s**i*<=≤<=105). | Output a single integer — the optimal number of visible kangaroos. | [
"8\n2\n5\n7\n6\n9\n8\n4\n2\n",
"8\n9\n1\n6\n2\n6\n5\n8\n3\n"
] | [
"5\n",
"5\n"
] | none | 500 | [
{
"input": "8\n2\n5\n7\n6\n9\n8\n4\n2",
"output": "5"
},
{
"input": "8\n9\n1\n6\n2\n6\n5\n8\n3",
"output": "5"
},
{
"input": "12\n3\n99\n24\n46\n75\n63\n57\n55\n10\n62\n34\n52",
"output": "7"
},
{
"input": "12\n55\n75\n1\n98\n63\n64\n9\n39\n82\n18\n47\n9",
"output": "6"
... | 1,636,819,008 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 5 | 77 | 18,944,000 |
n = int(input())
a = []
for i in range(n):
a.append(int(input()))
used = [0 for i in range(n)]
a.sort()
res = 0
it_second = n-1
for first in range(n-2, -1, -1):
if used[first]==1:
continue
for second in range(it_second, first, -1):
if used[second] == 1:
con... | Title: Counting Kangaroos is Fun
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
There are *n* kangaroos with pockets. Each kangaroo has a size (integer number). A kangaroo can go into another kangaroo's pocket if and only if the size of kangaroo who hold the kangaroo is at least twice as ... | ```python
n = int(input())
a = []
for i in range(n):
a.append(int(input()))
used = [0 for i in range(n)]
a.sort()
res = 0
it_second = n-1
for first in range(n-2, -1, -1):
if used[first]==1:
continue
for second in range(it_second, first, -1):
if used[second] == 1:
... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
4 | A | Watermelon | PROGRAMMING | 800 | [
"brute force",
"math"
] | A. Watermelon | 1 | 64 | One hot summer day Pete and his friend Billy decided to buy a watermelon. They chose the biggest and the ripest one, in their opinion. After that the watermelon was weighed, and the scales showed *w* kilos. They rushed home, dying of thirst, and decided to divide the berry, however they faced a hard problem.
Pete and ... | The first (and the only) input line contains integer number *w* (1<=≤<=*w*<=≤<=100) — the weight of the watermelon bought by the boys. | Print YES, if the boys can divide the watermelon into two parts, each of them weighing even number of kilos; and NO in the opposite case. | [
"8\n"
] | [
"YES\n"
] | For example, the boys can divide the watermelon into two parts of 2 and 6 kilos respectively (another variant — two parts of 4 and 4 kilos). | 0 | [
{
"input": "8",
"output": "YES"
},
{
"input": "5",
"output": "NO"
},
{
"input": "4",
"output": "YES"
},
{
"input": "3",
"output": "NO"
},
{
"input": "2",
"output": "NO"
},
{
"input": "1",
"output": "NO"
},
{
"input": "7",
"output": "NO"... | 1,689,599,095 | 2,147,483,647 | Python 3 | OK | TESTS | 20 | 62 | 0 | n=int(input())
if (n%2==0 and n>2) :
print("YES")
else :
print("NO")
| Title: Watermelon
Time Limit: 1 seconds
Memory Limit: 64 megabytes
Problem Description:
One hot summer day Pete and his friend Billy decided to buy a watermelon. They chose the biggest and the ripest one, in their opinion. After that the watermelon was weighed, and the scales showed *w* kilos. They rushed home, dyin... | ```python
n=int(input())
if (n%2==0 and n>2) :
print("YES")
else :
print("NO")
``` | 3.969 | MatrixStudio/Codeforces-Python-Submissions |
741 | C | Arpa’s overnight party and Mehrdad’s silent entering | PROGRAMMING | 2,600 | [
"constructive algorithms",
"dfs and similar",
"graphs"
] | null | null | Note that girls in Arpa’s land are really attractive.
Arpa loves overnight parties. In the middle of one of these parties Mehrdad suddenly appeared. He saw *n* pairs of friends sitting around a table. *i*-th pair consisted of a boy, sitting on the *a**i*-th chair, and his girlfriend, sitting on the *b**i*-th chair. Th... | The first line contains an integer *n* (1<=<=≤<=<=*n*<=<=≤<=<=105) — the number of pairs of guests.
The *i*-th of the next *n* lines contains a pair of integers *a**i* and *b**i* (1<=<=≤<=*a**i*,<=*b**i*<=≤<=<=2*n*) — the number of chair on which the boy in the *i*-th pair was sitting and the number of chair on which ... | If there is no solution, print -1.
Otherwise print *n* lines, the *i*-th of them should contain two integers which represent the type of food for the *i*-th pair. The first integer in the line is the type of food the boy had, and the second integer is the type of food the girl had. If someone had Kooft, print 1, other... | [
"3\n1 4\n2 5\n3 6\n"
] | [
"1 2\n2 1\n1 2\n"
] | none | 1,250 | [
{
"input": "3\n1 4\n2 5\n3 6",
"output": "1 2\n2 1\n1 2"
},
{
"input": "6\n3 2\n5 11\n7 12\n6 9\n8 4\n1 10",
"output": "1 2\n1 2\n2 1\n2 1\n1 2\n1 2"
},
{
"input": "19\n30 27\n6 38\n10 28\n20 5\n14 18\n32 2\n36 29\n12 1\n31 24\n15 4\n35 11\n3 7\n21 17\n25 19\n16 8\n23 22\n37 33\n13 9\n34... | 1,481,121,024 | 2,147,483,647 | PyPy 3 | TIME_LIMIT_EXCEEDED | TESTS | 12 | 1,000 | 26,726,400 | def dfs(v, c):
if clr[v]: return
clr[v] = c
for u in g[v]:
dfs(u, 3 - c)
read = lambda: map(int, input().split())
n = int(input())
p = [tuple(read()) for i in range(n)]
m = 2 * n + 1
g = [list() for i in range(m)]
for i in range(n):
a, b = p[i]
g[a].append(b)
g[b].append(a... | Title: Arpa’s overnight party and Mehrdad’s silent entering
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Note that girls in Arpa’s land are really attractive.
Arpa loves overnight parties. In the middle of one of these parties Mehrdad suddenly appeared. He saw *n* pairs of friends sitt... | ```python
def dfs(v, c):
if clr[v]: return
clr[v] = c
for u in g[v]:
dfs(u, 3 - c)
read = lambda: map(int, input().split())
n = int(input())
p = [tuple(read()) for i in range(n)]
m = 2 * n + 1
g = [list() for i in range(m)]
for i in range(n):
a, b = p[i]
g[a].append(b)
g[b... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
599 | A | Patrick and Shopping | PROGRAMMING | 800 | [
"implementation"
] | null | null | Today Patrick waits for a visit from his friend Spongebob. To prepare for the visit, Patrick needs to buy some goodies in two stores located near his house. There is a *d*1 meter long road between his house and the first shop and a *d*2 meter long road between his house and the second shop. Also, there is a road of len... | The first line of the input contains three integers *d*1, *d*2, *d*3 (1<=≤<=*d*1,<=*d*2,<=*d*3<=≤<=108) — the lengths of the paths.
- *d*1 is the length of the path connecting Patrick's house and the first shop; - *d*2 is the length of the path connecting Patrick's house and the second shop; - *d*3 is the length o... | Print the minimum distance that Patrick will have to walk in order to visit both shops and return to his house. | [
"10 20 30\n",
"1 1 5\n"
] | [
"60\n",
"4\n"
] | The first sample is shown on the picture in the problem statement. One of the optimal routes is: house <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/70a0795f45d32287dba0eb83fc4a3f470c6e5537.png" style="max-width: 100.0%;max-height: 100.0%;"/> first shop <img align="middle" class="tex-form... | 500 | [
{
"input": "10 20 30",
"output": "60"
},
{
"input": "1 1 5",
"output": "4"
},
{
"input": "100 33 34",
"output": "134"
},
{
"input": "777 777 777",
"output": "2331"
},
{
"input": "2 2 8",
"output": "8"
},
{
"input": "12 34 56",
"output": "92"
},
... | 1,668,412,091 | 2,147,483,647 | Python 3 | OK | TESTS | 21 | 46 | 0 | a,b,c = map(int,input().split())
s1 = a+b+c
s2 = (2*a)+(2*b)
s3= (2*a)+(2*c)
s4 = (2*b)+(2*c)
print(min(s1,s2,s3,s4)) | Title: Patrick and Shopping
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Today Patrick waits for a visit from his friend Spongebob. To prepare for the visit, Patrick needs to buy some goodies in two stores located near his house. There is a *d*1 meter long road between his house and the... | ```python
a,b,c = map(int,input().split())
s1 = a+b+c
s2 = (2*a)+(2*b)
s3= (2*a)+(2*c)
s4 = (2*b)+(2*c)
print(min(s1,s2,s3,s4))
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
16 | A | Flag | PROGRAMMING | 800 | [
"implementation"
] | A. Flag | 2 | 64 | According to a new ISO standard, a flag of every country should have a chequered field *n*<=×<=*m*, each square should be of one of 10 colours, and the flag should be «striped»: each horizontal row of the flag should contain squares of the same colour, and the colours of adjacent horizontal rows should be different. Be... | The first line of the input contains numbers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=100), *n* — the amount of rows, *m* — the amount of columns on the flag of Berland. Then there follows the description of the flag: each of the following *n* lines contain *m* characters. Each character is a digit between 0 and 9, and stands ... | Output YES, if the flag meets the new ISO standard, and NO otherwise. | [
"3 3\n000\n111\n222\n",
"3 3\n000\n000\n111\n",
"3 3\n000\n111\n002\n"
] | [
"YES\n",
"NO\n",
"NO\n"
] | none | 0 | [
{
"input": "3 3\n000\n111\n222",
"output": "YES"
},
{
"input": "3 3\n000\n000\n111",
"output": "NO"
},
{
"input": "3 3\n000\n111\n002",
"output": "NO"
},
{
"input": "10 10\n2222222222\n5555555555\n0000000000\n4444444444\n1111111111\n3333333393\n3333333333\n5555555555\n0000000... | 1,643,724,781 | 2,147,483,647 | Python 3 | OK | TESTS | 35 | 92 | 0 | def solve():
n, m = map(int,input().split())
arr = [set(input()) for x in range(n)]
curr = '#'
for x in arr:
if len(x) != 1 or x == curr:
return 'NO'
curr = x
return 'YES'
print(solve())
| Title: Flag
Time Limit: 2 seconds
Memory Limit: 64 megabytes
Problem Description:
According to a new ISO standard, a flag of every country should have a chequered field *n*<=×<=*m*, each square should be of one of 10 colours, and the flag should be «striped»: each horizontal row of the flag should contain squares of... | ```python
def solve():
n, m = map(int,input().split())
arr = [set(input()) for x in range(n)]
curr = '#'
for x in arr:
if len(x) != 1 or x == curr:
return 'NO'
curr = x
return 'YES'
print(solve())
``` | 3.977 | MatrixStudio/Codeforces-Python-Submissions |
84 | C | Biathlon | PROGRAMMING | 1,700 | [
"binary search",
"implementation"
] | C. Biathlon | 1 | 256 | Perhaps many have heard that the World Biathlon Championship has finished. Although our hero Valera was not present at this spectacular event himself and only watched it on TV, it excited him so much that he decided to enroll in a biathlon section.
Of course, biathlon as any sport, proved very difficult in practice. I... | The first line of the input file contains the integer *n* (1<=≤<=*n*<=≤<=104), which is the number of targets. The next *n* lines contain descriptions of the targets. Each target is a circle whose center is located on the *Ox* axis. Each circle is given by its coordinate of the center *x* (<=-<=2·104<=≤<=*x*<=≤<=2·104)... | Print on the first line a single number, the number of targets hit by Valera. Print on the second line for each of the targets the number of its first hit or "-1" (without quotes) if this number does not exist. Separate numbers with spaces. | [
"3\n2 1\n5 2\n10 1\n5\n0 1\n1 3\n3 0\n4 0\n4 0\n",
"3\n3 2\n7 1\n11 2\n4\n2 1\n6 0\n6 4\n11 2\n"
] | [
"2\n3 3 -1 \n",
"3\n1 2 4 \n"
] | none | 1,500 | [
{
"input": "3\n2 1\n5 2\n10 1\n5\n0 1\n1 3\n3 0\n4 0\n4 0",
"output": "2\n3 3 -1 "
},
{
"input": "3\n3 2\n7 1\n11 2\n4\n2 1\n6 0\n6 4\n11 2",
"output": "3\n1 2 4 "
},
{
"input": "2\n0 5\n10 5\n2\n7 2\n6 1",
"output": "1\n-1 1 "
},
{
"input": "3\n-3 3\n-10 2\n10 2\n4\n10 2\n2 ... | 1,552,985,071 | 2,147,483,647 | PyPy 3 | TIME_LIMIT_EXCEEDED | TESTS | 24 | 1,000 | 8,294,400 | import bisect
O = -1
n = int(input())
xr = []
for i in range(n):
xi, ri = map(int, input().split())
xr.append((xi, ri ** 2, i))
xr.sort()
cur = 1
res1 = 0
res2 = [O] * n
for _2 in range(int(input())):
x2, y = map(int, input().split())
bs = bisect.bisect(xr, (x2,))
for i in bs, bs - 1:
... | Title: Biathlon
Time Limit: 1 seconds
Memory Limit: 256 megabytes
Problem Description:
Perhaps many have heard that the World Biathlon Championship has finished. Although our hero Valera was not present at this spectacular event himself and only watched it on TV, it excited him so much that he decided to enroll in a... | ```python
import bisect
O = -1
n = int(input())
xr = []
for i in range(n):
xi, ri = map(int, input().split())
xr.append((xi, ri ** 2, i))
xr.sort()
cur = 1
res1 = 0
res2 = [O] * n
for _2 in range(int(input())):
x2, y = map(int, input().split())
bs = bisect.bisect(xr, (x2,))
for i in bs... | 0 | MatrixStudio/Codeforces-Python-Submissions |
877 | B | Nikita and string | PROGRAMMING | 1,500 | [
"brute force",
"dp"
] | null | null | One day Nikita found the string containing letters "a" and "b" only.
Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st and the 3-rd one contain only letters "a" and the 2-nd contains only letters "b".
Nikita wants to make... | The first line contains a non-empty string of length not greater than 5<=000 containing only lowercase English letters "a" and "b". | Print a single integer — the maximum possible size of beautiful string Nikita can get. | [
"abba\n",
"bab\n"
] | [
"4",
"2"
] | It the first sample the string is already beautiful.
In the second sample he needs to delete one of "b" to make it beautiful. | 1,000 | [
{
"input": "abba",
"output": "4"
},
{
"input": "bab",
"output": "2"
},
{
"input": "bbabbbaabbbb",
"output": "9"
},
{
"input": "bbabbbbbaaba",
"output": "10"
},
{
"input": "bbabbbababaa",
"output": "9"
},
{
"input": "aabbaababbab",
"output": "8"
}... | 1,681,148,699 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 2 | 46 | 0 | import sys
input = lambda: sys.stdin.readline().rstrip()
S = input()
N = len(S)
ac,bc = [0,],[0]
ta = 0
for i in range(N):
if S[i]=='a':
ac.append(ac[-1]+1)
bc.append(bc[-1])
ta+=1
else:
ac.append(ac[-1])
bc.append(bc[-1]+1)
# print(ta)
# print(ac)
#... | Title: Nikita and string
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
One day Nikita found the string containing letters "a" and "b" only.
Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st ... | ```python
import sys
input = lambda: sys.stdin.readline().rstrip()
S = input()
N = len(S)
ac,bc = [0,],[0]
ta = 0
for i in range(N):
if S[i]=='a':
ac.append(ac[-1]+1)
bc.append(bc[-1])
ta+=1
else:
ac.append(ac[-1])
bc.append(bc[-1]+1)
# print(ta)
# pr... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
819 | A | Mister B and Boring Game | PROGRAMMING | 2,200 | [
"games",
"greedy"
] | null | null | Sometimes Mister B has free evenings when he doesn't know what to do. Fortunately, Mister B found a new game, where the player can play against aliens.
All characters in this game are lowercase English letters. There are two players: Mister B and his competitor.
Initially the players have a string *s* consisting of t... | First and only line contains four space-separated integers: *a*, *b*, *l* and *r* (1<=≤<=*a*,<=*b*<=≤<=12, 1<=≤<=*l*<=≤<=*r*<=≤<=109) — the numbers of letters each player appends and the bounds of the segment. | Print one integer — the minimum possible number of different letters in the segment from position *l* to position *r*, inclusive, in string *s*. | [
"1 1 1 8\n",
"4 2 2 6\n",
"3 7 4 6\n"
] | [
"2",
"3",
"1"
] | In the first sample test one of optimal strategies generate string *s* = "abababab...", that's why answer is 2.
In the second sample test string *s* = "abcdbcaefg..." can be obtained, chosen segment will look like "bcdbc", that's why answer is 3.
In the third sample test string *s* = "abczzzacad..." can be obtained, ... | 500 | [
{
"input": "1 1 1 8",
"output": "2"
},
{
"input": "4 2 2 6",
"output": "3"
},
{
"input": "3 7 4 6",
"output": "1"
},
{
"input": "4 5 1 1",
"output": "1"
},
{
"input": "12 12 1 1000",
"output": "13"
},
{
"input": "12 1 1000 1000",
"output": "1"
},... | 1,498,631,515 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 12 | 46 | 4,915,200 | a,b,l,r=map(int, input().split())
length=int(l/(a+b))
l-=length*(a+b)
r-=length*(a+b)
if b>a:
if l>=a:
cnt=1
else:
cnt=min(a,r)-l+1
else:
_A=[]
for i in range(a):
_A.append(i+1)
for i in range(b):
_A.append(a)
for i in range(a):
if(i+1<b):
_A.a... | Title: Mister B and Boring Game
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Sometimes Mister B has free evenings when he doesn't know what to do. Fortunately, Mister B found a new game, where the player can play against aliens.
All characters in this game are lowercase English letters... | ```python
a,b,l,r=map(int, input().split())
length=int(l/(a+b))
l-=length*(a+b)
r-=length*(a+b)
if b>a:
if l>=a:
cnt=1
else:
cnt=min(a,r)-l+1
else:
_A=[]
for i in range(a):
_A.append(i+1)
for i in range(b):
_A.append(a)
for i in range(a):
if(i+1<b):
... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
143 | B | Help Kingdom of Far Far Away 2 | PROGRAMMING | 1,200 | [
"implementation",
"strings"
] | null | null | For some time the program of rounding numbers that had been developed by the Codeforces participants during one of the previous rounds, helped the citizens of Far Far Away to convert numbers into a more easily readable format. However, as time went by, the economy of the Far Far Away developed and the scale of operatio... | The input contains a number that needs to be converted into financial format. The number's notation length does not exceed 100 characters, including (possible) signs "-" (minus) and "." (decimal point). The number's notation is correct, that is:
- The number's notation only contains characters from the set {"0" – "9... | Print the number given in the input in the financial format by the rules described in the problem statement. | [
"2012\n",
"0.000\n",
"-0.00987654321\n",
"-12345678.9\n"
] | [
"$2,012.00",
"$0.00",
"($0.00)",
"($12,345,678.90)"
] | Pay attention to the second and third sample tests. They show that the sign of a number in the financial format (and consequently, the presence or absence of brackets) is determined solely by the sign of the initial number. It does not depend on the sign of the number you got after translating the number to the financi... | 1,000 | [
{
"input": "2012",
"output": "$2,012.00"
},
{
"input": "0.000",
"output": "$0.00"
},
{
"input": "-0.00987654321",
"output": "($0.00)"
},
{
"input": "-12345678.9",
"output": "($12,345,678.90)"
},
{
"input": "0.99999999999999999999",
"output": "$0.99"
},
{
... | 1,653,512,710 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 4 | 30 | 0 | # / *
#
# / \ | | / \ | | | |
# / __\ | | / __\ |--| | |
# / \ |__ | __ / \ | | \__ /
#
# __ __
# / \ | / | ) / \ | )
# / __\ |< |-< / __\ |-<
# / \ | \ |__) / \ | \
#
# * /
from itertools import combinations
d... | Title: Help Kingdom of Far Far Away 2
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
For some time the program of rounding numbers that had been developed by the Codeforces participants during one of the previous rounds, helped the citizens of Far Far Away to convert numbers into a more e... | ```python
# / *
#
# / \ | | / \ | | | |
# / __\ | | / __\ |--| | |
# / \ |__ | __ / \ | | \__ /
#
# __ __
# / \ | / | ) / \ | )
# / __\ |< |-< / __\ |-<
# / \ | \ |__) / \ | \
#
# * /
from itertools import combina... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
463 | B | Caisa and Pylons | PROGRAMMING | 1,100 | [
"brute force",
"implementation",
"math"
] | null | null | Caisa solved the problem with the sugar and now he is on the way back to home.
Caisa is playing a mobile game during his path. There are (*n*<=+<=1) pylons numbered from 0 to *n* in this game. The pylon with number 0 has zero height, the pylon with number *i* (*i*<=><=0) has height *h**i*. The goal of the game is ... | The first line contains integer *n* (1<=≤<=*n*<=≤<=105). The next line contains *n* integers *h*1, *h*2,<=..., *h**n* (1<=<=≤<=<=*h**i*<=<=≤<=<=105) representing the heights of the pylons. | Print a single number representing the minimum number of dollars paid by Caisa. | [
"5\n3 4 3 2 4\n",
"3\n4 4 4\n"
] | [
"4\n",
"4\n"
] | In the first sample he can pay 4 dollars and increase the height of pylon with number 0 by 4 units. Then he can safely pass to the last pylon. | 1,000 | [
{
"input": "5\n3 4 3 2 4",
"output": "4"
},
{
"input": "3\n4 4 4",
"output": "4"
},
{
"input": "99\n1401 2019 1748 3785 3236 3177 3443 3772 2138 1049 353 908 310 2388 1322 88 2160 2783 435 2248 1471 706 2468 2319 3156 3506 2794 1999 1983 2519 2597 3735 537 344 3519 3772 3872 2961 3895 20... | 1,681,073,741 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 5 | 61 | 204,800 | n = int(input())
h = list(map(int, input().split()))
# Calculate the minimum energy needed at each pylon
e = [0] * n
e[-1] = 0
for i in range(n-2, -1, -1):
e[i] = max(0, e[i+1] + h[i+1] - h[i])
# Find the minimum height we need to increase
min_height = max(h)
energy = 0
for i in range(n):
energy ... | Title: Caisa and Pylons
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Caisa solved the problem with the sugar and now he is on the way back to home.
Caisa is playing a mobile game during his path. There are (*n*<=+<=1) pylons numbered from 0 to *n* in this game. The pylon with number 0... | ```python
n = int(input())
h = list(map(int, input().split()))
# Calculate the minimum energy needed at each pylon
e = [0] * n
e[-1] = 0
for i in range(n-2, -1, -1):
e[i] = max(0, e[i+1] + h[i+1] - h[i])
# Find the minimum height we need to increase
min_height = max(h)
energy = 0
for i in range(n):
... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
911 | A | Nearest Minimums | PROGRAMMING | 1,100 | [
"implementation"
] | null | null | You are given an array of *n* integer numbers *a*0,<=*a*1,<=...,<=*a**n*<=-<=1. Find the distance between two closest (nearest) minimums in it. It is guaranteed that in the array a minimum occurs at least two times. | The first line contains positive integer *n* (2<=≤<=*n*<=≤<=105) — size of the given array. The second line contains *n* integers *a*0,<=*a*1,<=...,<=*a**n*<=-<=1 (1<=≤<=*a**i*<=≤<=109) — elements of the array. It is guaranteed that in the array a minimum occurs at least two times. | Print the only number — distance between two nearest minimums in the array. | [
"2\n3 3\n",
"3\n5 6 5\n",
"9\n2 1 3 5 4 1 2 3 1\n"
] | [
"1\n",
"2\n",
"3\n"
] | none | 0 | [
{
"input": "2\n3 3",
"output": "1"
},
{
"input": "3\n5 6 5",
"output": "2"
},
{
"input": "9\n2 1 3 5 4 1 2 3 1",
"output": "3"
},
{
"input": "6\n4 6 7 8 6 4",
"output": "5"
},
{
"input": "2\n1000000000 1000000000",
"output": "1"
},
{
"input": "42\n1 1 ... | 1,563,025,168 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 3 | 124 | 1,126,400 | n=int(input())
brr=list(map(int,input().strip().split()))[:n]
arr=sorted(brr)
count=1
a=arr[0]
for i in range(1,n):
if(a==arr[i]):
count=count+1
else:
break
if(i==1):
print(1)
else:
print(count)
| Title: Nearest Minimums
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given an array of *n* integer numbers *a*0,<=*a*1,<=...,<=*a**n*<=-<=1. Find the distance between two closest (nearest) minimums in it. It is guaranteed that in the array a minimum occurs at least two times.
I... | ```python
n=int(input())
brr=list(map(int,input().strip().split()))[:n]
arr=sorted(brr)
count=1
a=arr[0]
for i in range(1,n):
if(a==arr[i]):
count=count+1
else:
break
if(i==1):
print(1)
else:
print(count)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
936 | B | Sleepy Game | PROGRAMMING | 2,100 | [
"dfs and similar",
"dp",
"games",
"graphs"
] | null | null | Petya and Vasya arranged a game. The game runs by the following rules. Players have a directed graph consisting of *n* vertices and *m* edges. One of the vertices contains a chip. Initially the chip is located at vertex *s*. Players take turns moving the chip along some edge of the graph. Petya goes first. Player who c... | The first line of input contain two integers *n* and *m* — the number of vertices and the number of edges in the graph (2<=≤<=*n*<=≤<=105, 0<=≤<=*m*<=≤<=2·105).
The next *n* lines contain the information about edges of the graph. *i*-th line (1<=≤<=*i*<=≤<=*n*) contains nonnegative integer *c**i* — number of vertices ... | If Petya can win print «Win» in the first line. In the next line print numbers *v*1,<=*v*2,<=...,<=*v**k* (1<=≤<=*k*<=≤<=106) — the sequence of vertices Petya should visit for the winning. Vertex *v*1 should coincide with *s*. For *i*<==<=1... *k*<=-<=1 there should be an edge from *v**i* to *v**i*<=+<=1 in the graph. ... | [
"5 6\n2 2 3\n2 4 5\n1 4\n1 5\n0\n1\n",
"3 2\n1 3\n1 1\n0\n2\n",
"2 2\n1 2\n1 1\n1\n"
] | [
"Win\n1 2 4 5 \n",
"Lose\n",
"Draw\n"
] | In the first example the graph is the following:
Initially the chip is located at vertex 1. In the first move Petya moves the chip to vertex 2, after that he moves it to vertex 4 for Vasya. After that he moves to vertex 5. Now it is Vasya's turn and there is no possible move, so Petya wins.
In the second example the ... | 1,000 | [
{
"input": "5 6\n2 2 3\n2 4 5\n1 4\n1 5\n0\n1",
"output": "Win\n1 2 4 5 "
},
{
"input": "3 2\n1 3\n1 1\n0\n2",
"output": "Lose"
},
{
"input": "2 2\n1 2\n1 1\n1",
"output": "Draw"
},
{
"input": "92 69\n1 76\n1 14\n1 9\n0\n1 46\n1 80\n0\n0\n1 77\n0\n1 53\n1 81\n1 61\n1 40\n0\n1... | 1,522,172,145 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 4 | 701 | 28,979,200 | def dfs(a,p1,mode):
visited[a][0]=True
if(mode==1):
visited[a][1]=p1
if(mode==2):
visited[a][2]=p1
if(len(edges[a])==0):
return [1,-1]
toreturn=[-1,-1]
x=[-1,-1]
for i in edges[a]:
if(visited[i][0]):
if(mode==3):
if(vis... | Title: Sleepy Game
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Petya and Vasya arranged a game. The game runs by the following rules. Players have a directed graph consisting of *n* vertices and *m* edges. One of the vertices contains a chip. Initially the chip is located at vertex *s*... | ```python
def dfs(a,p1,mode):
visited[a][0]=True
if(mode==1):
visited[a][1]=p1
if(mode==2):
visited[a][2]=p1
if(len(edges[a])==0):
return [1,-1]
toreturn=[-1,-1]
x=[-1,-1]
for i in edges[a]:
if(visited[i][0]):
if(mode==3):
... | -1 | MatrixStudio/Codeforces-Python-Submissions | |
439 | A | Devu, the Singer and Churu, the Joker | PROGRAMMING | 900 | [
"greedy",
"implementation"
] | null | null | Devu is a renowned classical singer. He is invited to many big functions/festivals. Recently he was invited to "All World Classical Singing Festival". Other than Devu, comedian Churu was also invited.
Devu has provided organizers a list of the songs and required time for singing them. He will sing *n* songs, *i**th* s... | The first line contains two space separated integers *n*, *d* (1<=≤<=*n*<=≤<=100; 1<=≤<=*d*<=≤<=10000). The second line contains *n* space-separated integers: *t*1,<=*t*2,<=...,<=*t**n* (1<=≤<=*t**i*<=≤<=100). | If there is no way to conduct all the songs of Devu, output -1. Otherwise output the maximum number of jokes that Churu can crack in the grand event. | [
"3 30\n2 2 1\n",
"3 20\n2 1 1\n"
] | [
"5\n",
"-1\n"
] | Consider the first example. The duration of the event is 30 minutes. There could be maximum 5 jokes in the following way:
- First Churu cracks a joke in 5 minutes. - Then Devu performs the first song for 2 minutes. - Then Churu cracks 2 jokes in 10 minutes. - Now Devu performs second song for 2 minutes. - Then Ch... | 500 | [
{
"input": "3 30\n2 2 1",
"output": "5"
},
{
"input": "3 20\n2 1 1",
"output": "-1"
},
{
"input": "50 10000\n5 4 10 9 9 6 7 7 7 3 3 7 7 4 7 4 10 10 1 7 10 3 1 4 5 7 2 10 10 10 2 3 4 7 6 1 8 4 7 3 8 8 4 10 1 1 9 2 6 1",
"output": "1943"
},
{
"input": "50 10000\n4 7 15 9 11 12 ... | 1,665,912,570 | 2,147,483,647 | Python 3 | OK | TESTS | 26 | 46 | 0 | def solve(l,d):
singduration = sum(l)
singduration += (len(l)-1)*10
if singduration > d:
return -1
return (d-singduration)//5 + (len(l)-1)*2
n,d=map(int, input().split(" "))
l = list(map(int, input().split(" ")))
print (solve(l,d)) | Title: Devu, the Singer and Churu, the Joker
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Devu is a renowned classical singer. He is invited to many big functions/festivals. Recently he was invited to "All World Classical Singing Festival". Other than Devu, comedian Churu was also invit... | ```python
def solve(l,d):
singduration = sum(l)
singduration += (len(l)-1)*10
if singduration > d:
return -1
return (d-singduration)//5 + (len(l)-1)*2
n,d=map(int, input().split(" "))
l = list(map(int, input().split(" ")))
print (solve(l,d))
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
680 | B | Bear and Finding Criminals | PROGRAMMING | 1,000 | [
"constructive algorithms",
"implementation"
] | null | null | There are *n* cities in Bearland, numbered 1 through *n*. Cities are arranged in one long row. The distance between cities *i* and *j* is equal to |*i*<=-<=*j*|.
Limak is a police officer. He lives in a city *a*. His job is to catch criminals. It's hard because he doesn't know in which cities criminals are. Though, he... | The first line of the input contains two integers *n* and *a* (1<=≤<=*a*<=≤<=*n*<=≤<=100) — the number of cities and the index of city where Limak lives.
The second line contains *n* integers *t*1,<=*t*2,<=...,<=*t**n* (0<=≤<=*t**i*<=≤<=1). There are *t**i* criminals in the *i*-th city. | Print the number of criminals Limak will catch. | [
"6 3\n1 1 1 0 1 0\n",
"5 2\n0 0 0 1 0\n"
] | [
"3\n",
"1\n"
] | In the first sample, there are six cities and Limak lives in the third one (blue arrow below). Criminals are in cities marked red.
Using the BCD gives Limak the following information:
- There is one criminal at distance 0 from the third city — Limak is sure that this criminal is exactly in the third city. - There i... | 1,000 | [
{
"input": "6 3\n1 1 1 0 1 0",
"output": "3"
},
{
"input": "5 2\n0 0 0 1 0",
"output": "1"
},
{
"input": "1 1\n1",
"output": "1"
},
{
"input": "1 1\n0",
"output": "0"
},
{
"input": "9 3\n1 1 1 1 1 1 1 1 0",
"output": "8"
},
{
"input": "9 5\n1 0 1 0 1 0... | 1,599,613,806 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 77 | 307,200 | n,a = map(int, input().split())
cities = list(map(int, input().split()))
max_distance = max(n-a, a)
total = 0
new_cities = cities
if n-a != a-1:
diff = max(n-a, a-1) - min(n-a, a-1)
to_add = [2 for i in range(diff)]
if n-a < a-1:
new_cities =cities
new_cities.extend(to_add)
else:
new_cities= to_ad... | Title: Bear and Finding Criminals
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
There are *n* cities in Bearland, numbered 1 through *n*. Cities are arranged in one long row. The distance between cities *i* and *j* is equal to |*i*<=-<=*j*|.
Limak is a police officer. He lives in a city... | ```python
n,a = map(int, input().split())
cities = list(map(int, input().split()))
max_distance = max(n-a, a)
total = 0
new_cities = cities
if n-a != a-1:
diff = max(n-a, a-1) - min(n-a, a-1)
to_add = [2 for i in range(diff)]
if n-a < a-1:
new_cities =cities
new_cities.extend(to_add)
else:
new_cit... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
500 | A | New Year Transportation | PROGRAMMING | 1,000 | [
"dfs and similar",
"graphs",
"implementation"
] | null | null | New Year is coming in Line World! In this world, there are *n* cells numbered by integers from 1 to *n*, as a 1<=×<=*n* board. People live in cells. However, it was hard to move between distinct cells, because of the difficulty of escaping the cell. People wanted to meet people who live in other cells.
So, user tncks0... | The first line contains two space-separated integers *n* (3<=≤<=*n*<=≤<=3<=×<=104) and *t* (2<=≤<=*t*<=≤<=*n*) — the number of cells, and the index of the cell which I want to go to.
The second line contains *n*<=-<=1 space-separated integers *a*1,<=*a*2,<=...,<=*a**n*<=-<=1 (1<=≤<=*a**i*<=≤<=*n*<=-<=*i*). It is guara... | If I can go to cell *t* using the transportation system, print "YES". Otherwise, print "NO". | [
"8 4\n1 2 1 2 1 2 1\n",
"8 5\n1 2 1 2 1 1 1\n"
] | [
"YES\n",
"NO\n"
] | In the first sample, the visited cells are: 1, 2, 4; so we can successfully visit the cell 4.
In the second sample, the possible cells to visit are: 1, 2, 4, 6, 7, 8; so we can't visit the cell 5, which we want to visit. | 500 | [
{
"input": "8 4\n1 2 1 2 1 2 1",
"output": "YES"
},
{
"input": "8 5\n1 2 1 2 1 1 1",
"output": "NO"
},
{
"input": "20 19\n13 16 7 6 12 1 5 7 8 6 5 7 5 5 3 3 2 2 1",
"output": "YES"
},
{
"input": "50 49\n11 7 1 41 26 36 19 16 38 14 36 35 37 27 20 27 3 6 21 2 27 11 18 17 19 16 ... | 1,687,243,876 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 12 | 140 | 12,697,600 | import math, heapq
from sys import stdin
from collections import Counter, defaultdict, deque, namedtuple
from bisect import bisect_right, bisect_left
from typing import List, DefaultDict
from itertools import permutations
from copy import deepcopy
def sieve_of_eratosthenes(n):
is_prime = [True] * (n+1... | Title: New Year Transportation
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
New Year is coming in Line World! In this world, there are *n* cells numbered by integers from 1 to *n*, as a 1<=×<=*n* board. People live in cells. However, it was hard to move between distinct cells, because o... | ```python
import math, heapq
from sys import stdin
from collections import Counter, defaultdict, deque, namedtuple
from bisect import bisect_right, bisect_left
from typing import List, DefaultDict
from itertools import permutations
from copy import deepcopy
def sieve_of_eratosthenes(n):
is_prime = [Tr... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
9 | A | Die Roll | PROGRAMMING | 800 | [
"math",
"probabilities"
] | A. Die Roll | 1 | 64 | Yakko, Wakko and Dot, world-famous animaniacs, decided to rest from acting in cartoons, and take a leave to travel a bit. Yakko dreamt to go to Pennsylvania, his Motherland and the Motherland of his ancestors. Wakko thought about Tasmania, its beaches, sun and sea. Dot chose Transylvania as the most mysterious and unpr... | The only line of the input file contains two natural numbers Y and W — the results of Yakko's and Wakko's die rolls. | Output the required probability in the form of irreducible fraction in format «A/B», where A — the numerator, and B — the denominator. If the required probability equals to zero, output «0/1». If the required probability equals to 1, output «1/1». | [
"4 2\n"
] | [
"1/2\n"
] | Dot will go to Transylvania, if she is lucky to roll 4, 5 or 6 points. | 0 | [
{
"input": "4 2",
"output": "1/2"
},
{
"input": "1 1",
"output": "1/1"
},
{
"input": "1 2",
"output": "5/6"
},
{
"input": "1 3",
"output": "2/3"
},
{
"input": "1 4",
"output": "1/2"
},
{
"input": "1 5",
"output": "1/3"
},
{
"input": "1 6",
... | 1,644,249,388 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 92 | 512,000 | import fractions as fr
a = input()
b = a.split(' ')
y = int(b[0])
w = int(b[1])
c = 7
asa = 0
if y > w:
for i in range(y,7):
asa += 1
else:
for aga in range(w,7):
asa +=1
probabi = fr.Fraction(asa / 6)
print (probabi)
| Title: Die Roll
Time Limit: 1 seconds
Memory Limit: 64 megabytes
Problem Description:
Yakko, Wakko and Dot, world-famous animaniacs, decided to rest from acting in cartoons, and take a leave to travel a bit. Yakko dreamt to go to Pennsylvania, his Motherland and the Motherland of his ancestors. Wakko thought about T... | ```python
import fractions as fr
a = input()
b = a.split(' ')
y = int(b[0])
w = int(b[1])
c = 7
asa = 0
if y > w:
for i in range(y,7):
asa += 1
else:
for aga in range(w,7):
asa +=1
probabi = fr.Fraction(asa / 6)
print (probabi)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions |
88 | A | Chord | PROGRAMMING | 1,200 | [
"brute force",
"implementation"
] | A. Chord | 2 | 256 | Vasya studies music.
He has learned lots of interesting stuff. For example, he knows that there are 12 notes: C, C#, D, D#, E, F, F#, G, G#, A, B, H. He also knows that the notes are repeated cyclically: after H goes C again, and before C stands H. We will consider the C note in the row's beginning and the C note aft... | The only line contains 3 space-separated notes in the above-given notation. | Print "major" if the chord is major, "minor" if it is minor, and "strange" if the teacher gave Vasya some weird chord which is neither major nor minor. Vasya promises you that the answer will always be unambiguous. That is, there are no chords that are both major and minor simultaneously. | [
"C E G\n",
"C# B F\n",
"A B H\n"
] | [
"major\n",
"minor\n",
"strange\n"
] | none | 500 | [
{
"input": "C E G",
"output": "major"
},
{
"input": "C# B F",
"output": "minor"
},
{
"input": "A B H",
"output": "strange"
},
{
"input": "G H E",
"output": "minor"
},
{
"input": "D# B G",
"output": "major"
},
{
"input": "D# B F#",
"output": "minor"... | 1,597,041,232 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 3 | 186 | 6,963,200 | # Author: SaykaT
# Problem: 88A
# Time Created: August 10(Monday) 2020 || 11:37:58
#>-------------------------<#
import sys
input = sys.stdin.readline
#>-------------------------<#
from itertools import permutations
# Helper Functions. -> Don't cluster your code.
def check_chord(tup):
notes = ['C'... | Title: Chord
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Vasya studies music.
He has learned lots of interesting stuff. For example, he knows that there are 12 notes: C, C#, D, D#, E, F, F#, G, G#, A, B, H. He also knows that the notes are repeated cyclically: after H goes C again, and b... | ```python
# Author: SaykaT
# Problem: 88A
# Time Created: August 10(Monday) 2020 || 11:37:58
#>-------------------------<#
import sys
input = sys.stdin.readline
#>-------------------------<#
from itertools import permutations
# Helper Functions. -> Don't cluster your code.
def check_chord(tup):
no... | 0 | MatrixStudio/Codeforces-Python-Submissions |
722 | B | Verse Pattern | PROGRAMMING | 1,200 | [
"implementation",
"strings"
] | null | null | You are given a text consisting of *n* lines. Each line contains some space-separated words, consisting of lowercase English letters.
We define a syllable as a string that contains exactly one vowel and any arbitrary number (possibly none) of consonants. In English alphabet following letters are considered to be vowel... | The first line of the input contains a single integer *n* (1<=≤<=*n*<=≤<=100) — the number of lines in the text.
The second line contains integers *p*1,<=...,<=*p**n* (0<=≤<=*p**i*<=≤<=100) — the verse pattern.
Next *n* lines contain the text itself. Text consists of lowercase English letters and spaces. It's guarant... | If the given text matches the given verse pattern, then print "YES" (without quotes) in the only line of the output. Otherwise, print "NO" (without quotes). | [
"3\n2 2 3\nintel\ncode\nch allenge\n",
"4\n1 2 3 1\na\nbcdefghi\njklmnopqrstu\nvwxyz\n",
"4\n13 11 15 15\nto be or not to be that is the question\nwhether tis nobler in the mind to suffer\nthe slings and arrows of outrageous fortune\nor to take arms against a sea of troubles\n"
] | [
"YES\n",
"NO\n",
"YES\n"
] | In the first sample, one can split words into syllables in the following way:
Since the word "ch" in the third line doesn't contain vowels, we can ignore it. As the result we get 2 syllabels in first two lines and 3 syllables in the third one. | 500 | [
{
"input": "3\n2 2 3\nintel\ncode\nch allenge",
"output": "YES"
},
{
"input": "4\n1 2 3 1\na\nbcdefghi\njklmnopqrstu\nvwxyz",
"output": "NO"
},
{
"input": "4\n13 11 15 15\nto be or not to be that is the question\nwhether tis nobler in the mind to suffer\nthe slings and arrows of outrageo... | 1,480,970,217 | 2,147,483,647 | Python 3 | OK | TESTS | 54 | 77 | 0 | n, p = int(input()), list(map(int, input().split()))
for i in range(n):
l = input()
if sum(l.count(v) for v in 'aeiouy') != p[i]:
print('NO')
exit()
print('YES') | Title: Verse Pattern
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given a text consisting of *n* lines. Each line contains some space-separated words, consisting of lowercase English letters.
We define a syllable as a string that contains exactly one vowel and any arbitrary num... | ```python
n, p = int(input()), list(map(int, input().split()))
for i in range(n):
l = input()
if sum(l.count(v) for v in 'aeiouy') != p[i]:
print('NO')
exit()
print('YES')
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
719 | B | Anatoly and Cockroaches | PROGRAMMING | 1,400 | [
"greedy"
] | null | null | Anatoly lives in the university dorm as many other students do. As you know, cockroaches are also living there together with students. Cockroaches might be of two colors: black and red. There are *n* cockroaches living in Anatoly's room.
Anatoly just made all his cockroaches to form a single line. As he is a perfectio... | The first line of the input contains a single integer *n* (1<=≤<=*n*<=≤<=100<=000) — the number of cockroaches.
The second line contains a string of length *n*, consisting of characters 'b' and 'r' that denote black cockroach and red cockroach respectively. | Print one integer — the minimum number of moves Anatoly has to perform in order to make the colors of cockroaches in the line to alternate. | [
"5\nrbbrr\n",
"5\nbbbbb\n",
"3\nrbr\n"
] | [
"1\n",
"2\n",
"0\n"
] | In the first sample, Anatoly has to swap third and fourth cockroaches. He needs 1 turn to do this.
In the second sample, the optimum answer is to paint the second and the fourth cockroaches red. This requires 2 turns.
In the third sample, the colors of cockroaches in the line are alternating already, thus the answer ... | 1,000 | [
{
"input": "5\nrbbrr",
"output": "1"
},
{
"input": "5\nbbbbb",
"output": "2"
},
{
"input": "3\nrbr",
"output": "0"
},
{
"input": "13\nrbbbrbrrbrrbb",
"output": "3"
},
{
"input": "18\nrrrrrrrrrrrrrrrrrb",
"output": "8"
},
{
"input": "100\nbrbbbrrrbbrbrb... | 1,571,118,075 | 6,075 | Python 3 | WRONG_ANSWER | TESTS | 0 | 93 | 0 | n = 0
n = int(input())
if (n>=1 and n<=1000000):
tarakan = []
sum = 0
for i in range(0,n):
color = str(input())
if color != 'r' and color != 'b':
break
if i > 1 and i < n-1:
if (tarakan[i-2] != tarakan[i-1]):
tarakan.append(color)
elif (tarakan[i-2] == tarakan[i-1... | Title: Anatoly and Cockroaches
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Anatoly lives in the university dorm as many other students do. As you know, cockroaches are also living there together with students. Cockroaches might be of two colors: black and red. There are *n* cockroaches... | ```python
n = 0
n = int(input())
if (n>=1 and n<=1000000):
tarakan = []
sum = 0
for i in range(0,n):
color = str(input())
if color != 'r' and color != 'b':
break
if i > 1 and i < n-1:
if (tarakan[i-2] != tarakan[i-1]):
tarakan.append(color)
elif (tarakan[i-2] == t... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
189 | A | Cut Ribbon | PROGRAMMING | 1,300 | [
"brute force",
"dp"
] | null | null | Polycarpus has a ribbon, its length is *n*. He wants to cut the ribbon in a way that fulfils the following two conditions:
- After the cutting each ribbon piece should have length *a*, *b* or *c*. - After the cutting the number of ribbon pieces should be maximum.
Help Polycarpus and find the number of ribbon piece... | The first line contains four space-separated integers *n*, *a*, *b* and *c* (1<=≤<=*n*,<=*a*,<=*b*,<=*c*<=≤<=4000) — the length of the original ribbon and the acceptable lengths of the ribbon pieces after the cutting, correspondingly. The numbers *a*, *b* and *c* can coincide. | Print a single number — the maximum possible number of ribbon pieces. It is guaranteed that at least one correct ribbon cutting exists. | [
"5 5 3 2\n",
"7 5 5 2\n"
] | [
"2\n",
"2\n"
] | In the first example Polycarpus can cut the ribbon in such way: the first piece has length 2, the second piece has length 3.
In the second example Polycarpus can cut the ribbon in such way: the first piece has length 5, the second piece has length 2. | 500 | [
{
"input": "5 5 3 2",
"output": "2"
},
{
"input": "7 5 5 2",
"output": "2"
},
{
"input": "4 4 4 4",
"output": "1"
},
{
"input": "1 1 1 1",
"output": "1"
},
{
"input": "4000 1 2 3",
"output": "4000"
},
{
"input": "4000 3 4 5",
"output": "1333"
},
... | 1,684,369,538 | 2,147,483,647 | PyPy 3 | OK | TESTS | 58 | 93 | 1,638,400 | import sys
input = sys.stdin.readline
n,a,b,c = map(int, input().split())
vals = [a,b,c]
dp = [-1]*(n+1)
dp[0] = 0
for i in range(1, n+1):
for val in vals:
if i >= val:
dp[i] = max(dp[i], dp[i-val])
if dp[i] >= 0:
dp[i] += 1
print(dp[n]) | Title: Cut Ribbon
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Polycarpus has a ribbon, its length is *n*. He wants to cut the ribbon in a way that fulfils the following two conditions:
- After the cutting each ribbon piece should have length *a*, *b* or *c*. - After the cutting the... | ```python
import sys
input = sys.stdin.readline
n,a,b,c = map(int, input().split())
vals = [a,b,c]
dp = [-1]*(n+1)
dp[0] = 0
for i in range(1, n+1):
for val in vals:
if i >= val:
dp[i] = max(dp[i], dp[i-val])
if dp[i] >= 0:
dp[i] += 1
print(dp[n])
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
832 | A | Sasha and Sticks | PROGRAMMING | 800 | [
"games",
"math"
] | null | null | It's one more school day now. Sasha doesn't like classes and is always bored at them. So, each day he invents some game and plays in it alone or with friends.
Today he invented one simple game to play with Lena, with whom he shares a desk. The rules are simple. Sasha draws *n* sticks in a row. After that the players t... | The first line contains two integers *n* and *k* (1<=≤<=*n*,<=*k*<=≤<=1018, *k*<=≤<=*n*) — the number of sticks drawn by Sasha and the number *k* — the number of sticks to be crossed out on each turn. | If Sasha wins, print "YES" (without quotes), otherwise print "NO" (without quotes).
You can print each letter in arbitrary case (upper of lower). | [
"1 1\n",
"10 4\n"
] | [
"YES\n",
"NO\n"
] | In the first example Sasha crosses out 1 stick, and then there are no sticks. So Lena can't make a move, and Sasha wins.
In the second example Sasha crosses out 4 sticks, then Lena crosses out 4 sticks, and after that there are only 2 sticks left. Sasha can't make a move. The players make equal number of moves, so Sas... | 500 | [
{
"input": "1 1",
"output": "YES"
},
{
"input": "10 4",
"output": "NO"
},
{
"input": "251656215122324104 164397544865601257",
"output": "YES"
},
{
"input": "963577813436662285 206326039287271924",
"output": "NO"
},
{
"input": "1000000000000000000 1",
"output":... | 1,693,652,672 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 2 | 31 | 0 | n, k = map(int, input().split())
print('YES' if n % k == 0 else 'NO')
| Title: Sasha and Sticks
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
It's one more school day now. Sasha doesn't like classes and is always bored at them. So, each day he invents some game and plays in it alone or with friends.
Today he invented one simple game to play with Lena, with ... | ```python
n, k = map(int, input().split())
print('YES' if n % k == 0 else 'NO')
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
851 | A | Arpa and a research in Mexican wave | PROGRAMMING | 800 | [
"implementation",
"math"
] | null | null | Arpa is researching the Mexican wave.
There are *n* spectators in the stadium, labeled from 1 to *n*. They start the Mexican wave at time 0.
- At time 1, the first spectator stands. - At time 2, the second spectator stands. - ... - At time *k*, the *k*-th spectator stands. - At time *k*<=+<=1, the (*k*<=+<=1)-t... | The first line contains three integers *n*, *k*, *t* (1<=≤<=*n*<=≤<=109, 1<=≤<=*k*<=≤<=*n*, 1<=≤<=*t*<=<<=*n*<=+<=*k*). | Print single integer: how many spectators are standing at time *t*. | [
"10 5 3\n",
"10 5 7\n",
"10 5 12\n"
] | [
"3\n",
"5\n",
"3\n"
] | In the following a sitting spectator is represented as -, a standing spectator is represented as ^.
- At *t* = 0 ---------- <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/4d97e684117250a9afe9be022ab8a63653dd15aa.png" style="max-width: 100.0%;max-height: 100.0%;"/> number of standing spe... | 500 | [
{
"input": "10 5 3",
"output": "3"
},
{
"input": "10 5 7",
"output": "5"
},
{
"input": "10 5 12",
"output": "3"
},
{
"input": "840585600 770678331 788528791",
"output": "770678331"
},
{
"input": "25462281 23343504 8024619",
"output": "8024619"
},
{
"in... | 1,621,930,003 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 46 | 0 | n,k,t=map(int,input().split())
if t<k:
print(3)
elif t>n:
print(t-n-k)
elif t<n and t>=k:
print(k)
| Title: Arpa and a research in Mexican wave
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Arpa is researching the Mexican wave.
There are *n* spectators in the stadium, labeled from 1 to *n*. They start the Mexican wave at time 0.
- At time 1, the first spectator stands. - At time 2,... | ```python
n,k,t=map(int,input().split())
if t<k:
print(3)
elif t>n:
print(t-n-k)
elif t<n and t>=k:
print(k)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
566 | D | Restructuring Company | PROGRAMMING | 1,900 | [
"data structures",
"dsu"
] | null | null | Even the most successful company can go through a crisis period when you have to make a hard decision — to restructure, discard and merge departments, fire employees and do other unpleasant stuff. Let's consider the following model of a company.
There are *n* people working for the Large Software Company. Each person ... | The first line of the input contains two integers *n* and *q* (1<=≤<=*n*<=≤<=200<=000, 1<=≤<=*q*<=≤<=500<=000) — the number of the employees of the company and the number of queries the crisis manager has.
Next *q* lines contain the queries of the crisis manager. Each query looks like *type* *x* *y*, where . If *type*... | For each question of type 3 print "YES" or "NO" (without the quotes), depending on whether the corresponding people work in the same department. | [
"8 6\n3 2 5\n1 2 5\n3 2 5\n2 4 7\n2 1 2\n3 1 7\n"
] | [
"NO\nYES\nYES\n"
] | none | 1,000 | [
{
"input": "8 6\n3 2 5\n1 2 5\n3 2 5\n2 4 7\n2 1 2\n3 1 7",
"output": "NO\nYES\nYES"
},
{
"input": "1 1\n3 1 1",
"output": "YES"
},
{
"input": "1 3\n1 1 1\n2 1 1\n3 1 1",
"output": "YES"
}
] | 1,576,074,298 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 2 | 2,000 | 0 | n,q = map(int, input().split(' '))
uf = dict()
def find2(l):
if l in uf:
return find2(uf[l])
else:
return l
def find(l):
mem=l
r=find2(l)
if r != l:
uf[l]=r
return r
def union(l,r):
if find(l) != find(r):
uf[find(l)] = r
def union_list(l,r):
for i in ... | Title: Restructuring Company
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Even the most successful company can go through a crisis period when you have to make a hard decision — to restructure, discard and merge departments, fire employees and do other unpleasant stuff. Let's consider t... | ```python
n,q = map(int, input().split(' '))
uf = dict()
def find2(l):
if l in uf:
return find2(uf[l])
else:
return l
def find(l):
mem=l
r=find2(l)
if r != l:
uf[l]=r
return r
def union(l,r):
if find(l) != find(r):
uf[find(l)] = r
def union_list(l,r):
... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
279 | B | Books | PROGRAMMING | 1,400 | [
"binary search",
"brute force",
"implementation",
"two pointers"
] | null | null | When Valera has got some free time, he goes to the library to read some books. Today he's got *t* free minutes to read. That's why Valera took *n* books in the library and for each book he estimated the time he is going to need to read it. Let's number the books by integers from 1 to *n*. Valera needs *a**i* minutes to... | The first line contains two integers *n* and *t* (1<=≤<=*n*<=≤<=105; 1<=≤<=*t*<=≤<=109) — the number of books and the number of free minutes Valera's got. The second line contains a sequence of *n* integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=104), where number *a**i* shows the number of minutes that the boy n... | Print a single integer — the maximum number of books Valera can read. | [
"4 5\n3 1 2 1\n",
"3 3\n2 2 3\n"
] | [
"3\n",
"1\n"
] | none | 1,000 | [
{
"input": "4 5\n3 1 2 1",
"output": "3"
},
{
"input": "3 3\n2 2 3",
"output": "1"
},
{
"input": "1 3\n5",
"output": "0"
},
{
"input": "1 10\n4",
"output": "1"
},
{
"input": "2 10\n6 4",
"output": "2"
},
{
"input": "6 10\n2 3 4 2 1 1",
"output": "4... | 1,670,991,608 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 3 | 156 | 0 | n,t=map(int,input().split())
a=list(map(int,input().split()))
ans=0
count=0
b=sorted(a)
if b[0]>t:
print(0)
else:
for i in b:
if i<=t:
ans+=i
if ans<=t:
count+=1
else:
print(count)
break
| Title: Books
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
When Valera has got some free time, he goes to the library to read some books. Today he's got *t* free minutes to read. That's why Valera took *n* books in the library and for each book he estimated the time he is going to need t... | ```python
n,t=map(int,input().split())
a=list(map(int,input().split()))
ans=0
count=0
b=sorted(a)
if b[0]>t:
print(0)
else:
for i in b:
if i<=t:
ans+=i
if ans<=t:
count+=1
else:
print(count)
break
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
169 | B | Replacing Digits | PROGRAMMING | 1,100 | [
"greedy"
] | null | null | You are given an integer *a* that consists of *n* digits. You are also given a sequence of digits *s* of length *m*. The digit in position *j* (1<=≤<=*j*<=≤<=*m*) of sequence *s* means that you can choose an arbitrary position *i* (1<=≤<=*i*<=≤<=*n*) in *a* and replace the digit in the chosen position *i* with *s**j*. ... | The first line contains positive integer *a*. Its length *n* is positive and doesn't exceed 105. The second line contains sequence of digits *s*. Its length *m* is positive and doesn't exceed 105. The digits in the sequence *s* are written consecutively without any separators.
The given number *a* doesn't contain lead... | Print the maximum value that can be obtained from *a* after a series of replacements. You are allowed to use not all elements from *s*. The printed number shouldn't contain any leading zeroes. | [
"1024\n010\n",
"987\n1234567\n"
] | [
"1124\n",
"987\n"
] | none | 1,000 | [
{
"input": "1024\n010",
"output": "1124"
},
{
"input": "987\n1234567",
"output": "987"
},
{
"input": "10\n1",
"output": "11"
},
{
"input": "11\n1",
"output": "11"
},
{
"input": "12\n2",
"output": "22"
},
{
"input": "1\n0",
"output": "1"
},
{
... | 1,618,300,639 | 2,147,483,647 | Python 3 | OK | TESTS | 75 | 312 | 1,126,400 | # link: https://codeforces.com/problemset/problem/169/B
if __name__ == "__main__":
a = list(input())
s = list(input())
n = len(a)
m = len(s)
dict_ = {}
for j in range(9,0,-1):
if s.count(str(j)) != 0:
dict_[str(j)] = s.count(str(j))
for i in range(n):
f... | Title: Replacing Digits
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given an integer *a* that consists of *n* digits. You are also given a sequence of digits *s* of length *m*. The digit in position *j* (1<=≤<=*j*<=≤<=*m*) of sequence *s* means that you can choose an arbitrary ... | ```python
# link: https://codeforces.com/problemset/problem/169/B
if __name__ == "__main__":
a = list(input())
s = list(input())
n = len(a)
m = len(s)
dict_ = {}
for j in range(9,0,-1):
if s.count(str(j)) != 0:
dict_[str(j)] = s.count(str(j))
for i in range(n):
... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
369 | A | Valera and Plates | PROGRAMMING | 900 | [
"greedy",
"implementation"
] | null | null | Valera is a lazy student. He has *m* clean bowls and *k* clean plates.
Valera has made an eating plan for the next *n* days. As Valera is lazy, he will eat exactly one dish per day. At that, in order to eat a dish, he needs exactly one clean plate or bowl. We know that Valera can cook only two types of dishes. He can... | The first line of the input contains three integers *n*, *m*, *k* (1<=≤<=*n*,<=*m*,<=*k*<=≤<=1000) — the number of the planned days, the number of clean bowls and the number of clean plates.
The second line contains *n* integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=2). If *a**i* equals one, then on day *i* Val... | Print a single integer — the minimum number of times Valera will need to wash a plate/bowl. | [
"3 1 1\n1 2 1\n",
"4 3 1\n1 1 1 1\n",
"3 1 2\n2 2 2\n",
"8 2 2\n1 2 1 2 1 2 1 2\n"
] | [
"1\n",
"1\n",
"0\n",
"4\n"
] | In the first sample Valera will wash a bowl only on the third day, so the answer is one.
In the second sample, Valera will have the first type of the dish during all four days, and since there are only three bowls, he will wash a bowl exactly once.
In the third sample, Valera will have the second type of dish for all... | 500 | [
{
"input": "3 1 1\n1 2 1",
"output": "1"
},
{
"input": "4 3 1\n1 1 1 1",
"output": "1"
},
{
"input": "3 1 2\n2 2 2",
"output": "0"
},
{
"input": "8 2 2\n1 2 1 2 1 2 1 2",
"output": "4"
},
{
"input": "2 100 100\n2 2",
"output": "0"
},
{
"input": "1 1 1\... | 1,649,356,140 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 10 | 46 | 0 | n, m, k=map(int, input().split())
a=list(map(int, input().split()))
v1=a.count(1)
v2=a.count(2)
h=v2-k
if(h<0):
h=0
l=v1+h-m
print(l) | Title: Valera and Plates
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Valera is a lazy student. He has *m* clean bowls and *k* clean plates.
Valera has made an eating plan for the next *n* days. As Valera is lazy, he will eat exactly one dish per day. At that, in order to eat a dish, ... | ```python
n, m, k=map(int, input().split())
a=list(map(int, input().split()))
v1=a.count(1)
v2=a.count(2)
h=v2-k
if(h<0):
h=0
l=v1+h-m
print(l)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
279 | B | Books | PROGRAMMING | 1,400 | [
"binary search",
"brute force",
"implementation",
"two pointers"
] | null | null | When Valera has got some free time, he goes to the library to read some books. Today he's got *t* free minutes to read. That's why Valera took *n* books in the library and for each book he estimated the time he is going to need to read it. Let's number the books by integers from 1 to *n*. Valera needs *a**i* minutes to... | The first line contains two integers *n* and *t* (1<=≤<=*n*<=≤<=105; 1<=≤<=*t*<=≤<=109) — the number of books and the number of free minutes Valera's got. The second line contains a sequence of *n* integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=104), where number *a**i* shows the number of minutes that the boy n... | Print a single integer — the maximum number of books Valera can read. | [
"4 5\n3 1 2 1\n",
"3 3\n2 2 3\n"
] | [
"3\n",
"1\n"
] | none | 1,000 | [
{
"input": "4 5\n3 1 2 1",
"output": "3"
},
{
"input": "3 3\n2 2 3",
"output": "1"
},
{
"input": "1 3\n5",
"output": "0"
},
{
"input": "1 10\n4",
"output": "1"
},
{
"input": "2 10\n6 4",
"output": "2"
},
{
"input": "6 10\n2 3 4 2 1 1",
"output": "4... | 1,678,388,804 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 30 | 0 | ww=[int(i) for i in input().split()]
n,tar=ww[0],ww[1]
ar=[int(i) for i in input().split()]
l=1
h=max(ar)
def pred(book,ar,tar):
cur_time=0
count=0
for i in range(book,len(ar)):
cur_time+=(ar[i])
if cur_time>tar:
return count
count+=1
return count
an... | Title: Books
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
When Valera has got some free time, he goes to the library to read some books. Today he's got *t* free minutes to read. That's why Valera took *n* books in the library and for each book he estimated the time he is going to need t... | ```python
ww=[int(i) for i in input().split()]
n,tar=ww[0],ww[1]
ar=[int(i) for i in input().split()]
l=1
h=max(ar)
def pred(book,ar,tar):
cur_time=0
count=0
for i in range(book,len(ar)):
cur_time+=(ar[i])
if cur_time>tar:
return count
count+=1
return cou... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
769 | C | Cycle In Maze | PROGRAMMING | 1,700 | [
"*special",
"dfs and similar",
"graphs",
"greedy",
"shortest paths"
] | null | null | The Robot is in a rectangular maze of size *n*<=×<=*m*. Each cell of the maze is either empty or occupied by an obstacle. The Robot can move between neighboring cells on the side left (the symbol "L"), right (the symbol "R"), up (the symbol "U") or down (the symbol "D"). The Robot can move to the cell only if it is emp... | The first line contains three integers *n*, *m* and *k* (1<=≤<=*n*,<=*m*<=≤<=1000, 1<=≤<=*k*<=≤<=106) — the size of the maze and the length of the cycle.
Each of the following *n* lines contains *m* symbols — the description of the maze. If the symbol equals to "." the current cell is empty. If the symbol equals to "... | Print the lexicographically minimum Robot's way with the length exactly *k*, which starts and ends in the cell where initially Robot is. If there is no such way, print "IMPOSSIBLE"(without quotes). | [
"2 3 2\n.**\nX..\n",
"5 6 14\n..***.\n*...X.\n..*...\n..*.**\n....*.\n",
"3 3 4\n***\n*X*\n***\n"
] | [
"RL\n",
"DLDDLLLRRRUURU\n",
"IMPOSSIBLE\n"
] | In the first sample two cyclic ways for the Robot with the length 2 exist — "UD" and "RL". The second cycle is lexicographically less.
In the second sample the Robot should move in the following way: down, left, down, down, left, left, left, right, right, right, up, up, right, up.
In the third sample the Robot can'... | 1,500 | [
{
"input": "2 3 2\n.**\nX..",
"output": "RL"
},
{
"input": "5 6 14\n..***.\n*...X.\n..*...\n..*.**\n....*.",
"output": "DLDDLLLRRRUURU"
},
{
"input": "3 3 4\n***\n*X*\n***",
"output": "IMPOSSIBLE"
},
{
"input": "1 1 1\nX",
"output": "IMPOSSIBLE"
},
{
"input": "1 2... | 1,488,710,406 | 81,606 | Python 3 | WRONG_ANSWER | PRETESTS | 5 | 46 | 4,915,200 | n,m, k = map(int, input().split())
a=[]
pos=[]
line=""
for i in range(n):
b=input()
if(b.find("X")!=-1):
pos=[i, b.find("X")]
b=list(b)
a.append(b)
if(k%2!=0):
print("IMPOSSIBLE")
else:
breakable=False
x=pos[0]
y=pos[1]
a[x][y]=='.'
i=0
while(i<k... | Title: Cycle In Maze
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The Robot is in a rectangular maze of size *n*<=×<=*m*. Each cell of the maze is either empty or occupied by an obstacle. The Robot can move between neighboring cells on the side left (the symbol "L"), right (the symbol "... | ```python
n,m, k = map(int, input().split())
a=[]
pos=[]
line=""
for i in range(n):
b=input()
if(b.find("X")!=-1):
pos=[i, b.find("X")]
b=list(b)
a.append(b)
if(k%2!=0):
print("IMPOSSIBLE")
else:
breakable=False
x=pos[0]
y=pos[1]
a[x][y]=='.'
i=0
... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
789 | A | Anastasia and pebbles | PROGRAMMING | 1,100 | [
"implementation",
"math"
] | null | null | Anastasia loves going for a walk in Central Uzhlyandian Park. But she became uninterested in simple walking, so she began to collect Uzhlyandian pebbles. At first, she decided to collect all the pebbles she could find in the park.
She has only two pockets. She can put at most *k* pebbles in each pocket at the same tim... | The first line contains two integers *n* and *k* (1<=≤<=*n*<=≤<=105, 1<=≤<=*k*<=≤<=109) — the number of different pebble types and number of pebbles Anastasia can place in one pocket.
The second line contains *n* integers *w*1,<=*w*2,<=...,<=*w**n* (1<=≤<=*w**i*<=≤<=104) — number of pebbles of each type. | The only line of output contains one integer — the minimum number of days Anastasia needs to collect all the pebbles. | [
"3 2\n2 3 4\n",
"5 4\n3 1 8 9 7\n"
] | [
"3\n",
"5\n"
] | In the first sample case, Anastasia can collect all pebbles of the first type on the first day, of second type — on the second day, and of third type — on the third day.
Optimal sequence of actions in the second sample case:
- In the first day Anastasia collects 8 pebbles of the third type. - In the second day she... | 500 | [
{
"input": "3 2\n2 3 4",
"output": "3"
},
{
"input": "5 4\n3 1 8 9 7",
"output": "5"
},
{
"input": "1 22\n1",
"output": "1"
},
{
"input": "3 57\n78 165 54",
"output": "3"
},
{
"input": "5 72\n74 10 146 189 184",
"output": "6"
},
{
"input": "9 13\n132 8... | 1,601,050,758 | 2,147,483,647 | Python 3 | OK | TESTS | 31 | 202 | 7,372,800 | parameters = [int(i) for i in input().split()]
pebbles = [int(i) for i in input().split()]
n = parameters[0]
k = parameters[-1]
counter = 0
for pebble in pebbles:
x = pebble/k
if x > int(x):
counter += int(x) + 1
else:
counter += int(x)
days = counter/2
if days > int(days):
print(int(day... | Title: Anastasia and pebbles
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Anastasia loves going for a walk in Central Uzhlyandian Park. But she became uninterested in simple walking, so she began to collect Uzhlyandian pebbles. At first, she decided to collect all the pebbles she could ... | ```python
parameters = [int(i) for i in input().split()]
pebbles = [int(i) for i in input().split()]
n = parameters[0]
k = parameters[-1]
counter = 0
for pebble in pebbles:
x = pebble/k
if x > int(x):
counter += int(x) + 1
else:
counter += int(x)
days = counter/2
if days > int(days):
pri... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
755 | A | PolandBall and Hypothesis | PROGRAMMING | 800 | [
"brute force",
"graphs",
"math",
"number theory"
] | null | null | PolandBall is a young, clever Ball. He is interested in prime numbers. He has stated a following hypothesis: "There exists such a positive integer *n* that for each positive integer *m* number *n*·*m*<=+<=1 is a prime number".
Unfortunately, PolandBall is not experienced yet and doesn't know that his hypothesis is inc... | The only number in the input is *n* (1<=≤<=*n*<=≤<=1000) — number from the PolandBall's hypothesis. | Output such *m* that *n*·*m*<=+<=1 is not a prime number. Your answer will be considered correct if you output any suitable *m* such that 1<=≤<=*m*<=≤<=103. It is guaranteed the the answer exists. | [
"3\n",
"4\n"
] | [
"1",
"2"
] | A prime number (or a prime) is a natural number greater than 1 that has no positive divisors other than 1 and itself.
For the first sample testcase, 3·1 + 1 = 4. We can output 1.
In the second sample testcase, 4·1 + 1 = 5. We cannot output 1 because 5 is prime. However, *m* = 2 is okay since 4·2 + 1 = 9, which is not... | 500 | [
{
"input": "3",
"output": "1"
},
{
"input": "4",
"output": "2"
},
{
"input": "10",
"output": "2"
},
{
"input": "153",
"output": "1"
},
{
"input": "1000",
"output": "1"
},
{
"input": "1",
"output": "3"
},
{
"input": "2",
"output": "4"
... | 1,696,571,977 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 4 | 46 | 0 | def _input(): return list(map(int, input().split()))
def main():
return 3 * int(input()) + 2
if __name__ == '__main__':
print(main())
| Title: PolandBall and Hypothesis
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
PolandBall is a young, clever Ball. He is interested in prime numbers. He has stated a following hypothesis: "There exists such a positive integer *n* that for each positive integer *m* number *n*·*m*<=+<=1 is... | ```python
def _input(): return list(map(int, input().split()))
def main():
return 3 * int(input()) + 2
if __name__ == '__main__':
print(main())
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
677 | B | Vanya and Food Processor | PROGRAMMING | 1,400 | [
"implementation",
"math"
] | null | null | Vanya smashes potato in a vertical food processor. At each moment of time the height of the potato in the processor doesn't exceed *h* and the processor smashes *k* centimeters of potato each second. If there are less than *k* centimeters remaining, than during this second processor smashes all the remaining potato.
V... | The first line of the input contains integers *n*, *h* and *k* (1<=≤<=*n*<=≤<=100<=000,<=1<=≤<=*k*<=≤<=*h*<=≤<=109) — the number of pieces of potato, the height of the food processor and the amount of potato being smashed each second, respectively.
The second line contains *n* integers *a**i* (1<=≤<=*a**i*<=≤<=*h*) — ... | Print a single integer — the number of seconds required to smash all the potatoes following the process described in the problem statement. | [
"5 6 3\n5 4 3 2 1\n",
"5 6 3\n5 5 5 5 5\n",
"5 6 3\n1 2 1 1 1\n"
] | [
"5\n",
"10\n",
"2\n"
] | Consider the first sample.
1. First Vanya puts the piece of potato of height 5 into processor. At the end of the second there is only amount of height 2 remaining inside. 1. Now Vanya puts the piece of potato of height 4. At the end of the second there is amount of height 3 remaining. 1. Vanya puts the piece of he... | 1,000 | [
{
"input": "5 6 3\n5 4 3 2 1",
"output": "5"
},
{
"input": "5 6 3\n5 5 5 5 5",
"output": "10"
},
{
"input": "5 6 3\n1 2 1 1 1",
"output": "2"
},
{
"input": "10 100 80\n76 75 73 71 76 74 73 70 78 75",
"output": "10"
},
{
"input": "10 100 88\n11 23 69 6 71 15 25 1 4... | 1,697,455,006 | 2,147,483,647 | PyPy 3-64 | TIME_LIMIT_EXCEEDED | TESTS | 7 | 1,000 | 1,740,800 | l = input().split()
n, h, k = list(map(int, l))
l = input().split()
pieces = list(map(int, l))
res = 0
capacity = 0
i = 0
while capacity > 0 or i < len(pieces):
# keep placing pieces in the processor as long as h isn't exceeded
if i < len(pieces) and capacity + pieces[i] <= h:
capacity += pieces[i]
... | Title: Vanya and Food Processor
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vanya smashes potato in a vertical food processor. At each moment of time the height of the potato in the processor doesn't exceed *h* and the processor smashes *k* centimeters of potato each second. If there a... | ```python
l = input().split()
n, h, k = list(map(int, l))
l = input().split()
pieces = list(map(int, l))
res = 0
capacity = 0
i = 0
while capacity > 0 or i < len(pieces):
# keep placing pieces in the processor as long as h isn't exceeded
if i < len(pieces) and capacity + pieces[i] <= h:
capacity += p... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
424 | B | Megacity | PROGRAMMING | 1,200 | [
"binary search",
"greedy",
"implementation",
"sortings"
] | null | null | The administration of the Tomsk Region firmly believes that it's time to become a megacity (that is, get population of one million). Instead of improving the demographic situation, they decided to achieve its goal by expanding the boundaries of the city.
The city of Tomsk can be represented as point on the plane with ... | The first line of the input contains two integers *n* and *s* (1<=≤<=*n*<=≤<=103; 1<=≤<=*s*<=<<=106) — the number of locatons around Tomsk city and the population of the city. Then *n* lines follow. The *i*-th line contains three integers — the *x**i* and *y**i* coordinate values of the *i*-th location and the numbe... | In the output, print "-1" (without the quotes), if Tomsk won't be able to become a megacity. Otherwise, in the first line print a single real number — the minimum radius of the circle that the city needs to expand to in order to become a megacity.
The answer is considered correct if the absolute or relative error don'... | [
"4 999998\n1 1 1\n2 2 1\n3 3 1\n2 -2 1\n",
"4 999998\n1 1 2\n2 2 1\n3 3 1\n2 -2 1\n",
"2 1\n1 1 999997\n2 2 1\n"
] | [
"2.8284271\n",
"1.4142136\n",
"-1"
] | none | 1,000 | [
{
"input": "4 999998\n1 1 1\n2 2 1\n3 3 1\n2 -2 1",
"output": "2.8284271"
},
{
"input": "4 999998\n1 1 2\n2 2 1\n3 3 1\n2 -2 1",
"output": "1.4142136"
},
{
"input": "2 1\n1 1 999997\n2 2 1",
"output": "-1"
},
{
"input": "4 999998\n3 3 10\n-3 3 10\n3 -3 10\n-3 -3 10",
"out... | 1,398,417,662 | 2,147,483,647 | Python 3 | OK | TESTS | 54 | 1,263 | 0 | from math import*
n, s = map(int, input().split())
k = [0] * 1001
x = [0] * 1001
y = [0] * 1001
r0 = 0
r = 0
count = 0
Minr = 1000000
otv = -1
for i in range(n):
x[i], y[i], k[i] = map(int, input().split())
for i in range(n):
count = s
r0 = sqrt((x[i]) ** 2 + y[i] ** 2)
for j in range(n):... | Title: Megacity
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The administration of the Tomsk Region firmly believes that it's time to become a megacity (that is, get population of one million). Instead of improving the demographic situation, they decided to achieve its goal by expanding... | ```python
from math import*
n, s = map(int, input().split())
k = [0] * 1001
x = [0] * 1001
y = [0] * 1001
r0 = 0
r = 0
count = 0
Minr = 1000000
otv = -1
for i in range(n):
x[i], y[i], k[i] = map(int, input().split())
for i in range(n):
count = s
r0 = sqrt((x[i]) ** 2 + y[i] ** 2)
for j in... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
189 | A | Cut Ribbon | PROGRAMMING | 1,300 | [
"brute force",
"dp"
] | null | null | Polycarpus has a ribbon, its length is *n*. He wants to cut the ribbon in a way that fulfils the following two conditions:
- After the cutting each ribbon piece should have length *a*, *b* or *c*. - After the cutting the number of ribbon pieces should be maximum.
Help Polycarpus and find the number of ribbon piece... | The first line contains four space-separated integers *n*, *a*, *b* and *c* (1<=≤<=*n*,<=*a*,<=*b*,<=*c*<=≤<=4000) — the length of the original ribbon and the acceptable lengths of the ribbon pieces after the cutting, correspondingly. The numbers *a*, *b* and *c* can coincide. | Print a single number — the maximum possible number of ribbon pieces. It is guaranteed that at least one correct ribbon cutting exists. | [
"5 5 3 2\n",
"7 5 5 2\n"
] | [
"2\n",
"2\n"
] | In the first example Polycarpus can cut the ribbon in such way: the first piece has length 2, the second piece has length 3.
In the second example Polycarpus can cut the ribbon in such way: the first piece has length 5, the second piece has length 2. | 500 | [
{
"input": "5 5 3 2",
"output": "2"
},
{
"input": "7 5 5 2",
"output": "2"
},
{
"input": "4 4 4 4",
"output": "1"
},
{
"input": "1 1 1 1",
"output": "1"
},
{
"input": "4000 1 2 3",
"output": "4000"
},
{
"input": "4000 3 4 5",
"output": "1333"
},
... | 1,698,139,441 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 4 | 31 | 1,024,000 | array = list(map(int, input().split()))
def search(left, list):
result = 0
updated = 0
for x in list:
if (x > left):
continue
else:
next = search(left - x, list)
if (next == -1):
continue
else:
resu... | Title: Cut Ribbon
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Polycarpus has a ribbon, its length is *n*. He wants to cut the ribbon in a way that fulfils the following two conditions:
- After the cutting each ribbon piece should have length *a*, *b* or *c*. - After the cutting the... | ```python
array = list(map(int, input().split()))
def search(left, list):
result = 0
updated = 0
for x in list:
if (x > left):
continue
else:
next = search(left - x, list)
if (next == -1):
continue
else:
... | -1 | MatrixStudio/Codeforces-Python-Submissions | |
709 | A | Juicer | PROGRAMMING | 900 | [
"implementation"
] | null | null | Kolya is going to make fresh orange juice. He has *n* oranges of sizes *a*1,<=*a*2,<=...,<=*a**n*. Kolya will put them in the juicer in the fixed order, starting with orange of size *a*1, then orange of size *a*2 and so on. To be put in the juicer the orange must have size not exceeding *b*, so if Kolya sees an orange ... | The first line of the input contains three integers *n*, *b* and *d* (1<=≤<=*n*<=≤<=100<=000, 1<=≤<=*b*<=≤<=*d*<=≤<=1<=000<=000) — the number of oranges, the maximum size of the orange that fits in the juicer and the value *d*, which determines the condition when the waste section should be emptied.
The second line co... | Print one integer — the number of times Kolya will have to empty the waste section. | [
"2 7 10\n5 6\n",
"1 5 10\n7\n",
"3 10 10\n5 7 7\n",
"1 1 1\n1\n"
] | [
"1\n",
"0\n",
"1\n",
"0\n"
] | In the first sample, Kolya will squeeze the juice from two oranges and empty the waste section afterwards.
In the second sample, the orange won't fit in the juicer so Kolya will have no juice at all. | 500 | [
{
"input": "2 7 10\n5 6",
"output": "1"
},
{
"input": "1 5 10\n7",
"output": "0"
},
{
"input": "3 10 10\n5 7 7",
"output": "1"
},
{
"input": "1 1 1\n1",
"output": "0"
},
{
"input": "2 951637 951638\n44069 951637",
"output": "1"
},
{
"input": "50 100 12... | 1,615,979,660 | 2,147,483,647 | Python 3 | COMPILATION_ERROR | TESTS | 0 | 0 | 0 | n, b, d = map(int, input().split())
a = map(int, input().split())
ans = sum(a[map(lambda x: x <= b, a)]))
print(ans//d if ans%d != 0 else ans//d -1) | Title: Juicer
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Kolya is going to make fresh orange juice. He has *n* oranges of sizes *a*1,<=*a*2,<=...,<=*a**n*. Kolya will put them in the juicer in the fixed order, starting with orange of size *a*1, then orange of size *a*2 and so on. To b... | ```python
n, b, d = map(int, input().split())
a = map(int, input().split())
ans = sum(a[map(lambda x: x <= b, a)]))
print(ans//d if ans%d != 0 else ans//d -1)
``` | -1 | MatrixStudio/Codeforces-Python-Submissions | |
116 | A | Tram | PROGRAMMING | 800 | [
"implementation"
] | null | null | Linear Kingdom has exactly one tram line. It has *n* stops, numbered from 1 to *n* in the order of tram's movement. At the *i*-th stop *a**i* passengers exit the tram, while *b**i* passengers enter it. The tram is empty before it arrives at the first stop. Also, when the tram arrives at the last stop, all passengers ex... | The first line contains a single number *n* (2<=≤<=*n*<=≤<=1000) — the number of the tram's stops.
Then *n* lines follow, each contains two integers *a**i* and *b**i* (0<=≤<=*a**i*,<=*b**i*<=≤<=1000) — the number of passengers that exits the tram at the *i*-th stop, and the number of passengers that enter the tram at... | Print a single integer denoting the minimum possible capacity of the tram (0 is allowed). | [
"4\n0 3\n2 5\n4 2\n4 0\n"
] | [
"6\n"
] | For the first example, a capacity of 6 is sufficient:
- At the first stop, the number of passengers inside the tram before arriving is 0. Then, 3 passengers enter the tram, and the number of passengers inside the tram becomes 3. - At the second stop, 2 passengers exit the tram (1 passenger remains inside). Then, 5 ... | 500 | [
{
"input": "4\n0 3\n2 5\n4 2\n4 0",
"output": "6"
},
{
"input": "5\n0 4\n4 6\n6 5\n5 4\n4 0",
"output": "6"
},
{
"input": "10\n0 5\n1 7\n10 8\n5 3\n0 5\n3 3\n8 8\n0 6\n10 1\n9 0",
"output": "18"
},
{
"input": "3\n0 1\n1 1\n1 0",
"output": "1"
},
{
"input": "4\n0 1... | 1,688,294,856 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 60 | 0 | n=int(input())
mc=0
cc=0
for _ in range(n):
e1,e2=map(int, input().dplit())
cc-=e1
cc+=e2
mc=max(mc,cc)
print(mc) | Title: Tram
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Linear Kingdom has exactly one tram line. It has *n* stops, numbered from 1 to *n* in the order of tram's movement. At the *i*-th stop *a**i* passengers exit the tram, while *b**i* passengers enter it. The tram is empty before it ... | ```python
n=int(input())
mc=0
cc=0
for _ in range(n):
e1,e2=map(int, input().dplit())
cc-=e1
cc+=e2
mc=max(mc,cc)
print(mc)
``` | -1 | MatrixStudio/Codeforces-Python-Submissions | |
417 | C | Football | PROGRAMMING | 1,400 | [
"constructive algorithms",
"graphs",
"implementation"
] | null | null | One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided into *n* teams and played several matches, two teams could not play against each other more than once.
The appointed Judge was the most experienced member — Pavel. But since he was the ... | The first line contains two integers — *n* and *k* (1<=≤<=*n*,<=*k*<=≤<=1000). | In the first line print an integer *m* — number of the played games. The following *m* lines should contain the information about all the matches, one match per line. The *i*-th line should contain two integers *a**i* and *b**i* (1<=≤<=*a**i*,<=*b**i*<=≤<=*n*; *a**i*<=≠<=*b**i*). The numbers *a**i* and *b**i* mean, tha... | [
"3 1\n"
] | [
"3\n1 2\n2 3\n3 1\n"
] | none | 1,500 | [
{
"input": "3 1",
"output": "3\n1 2\n2 3\n3 1"
},
{
"input": "7 3",
"output": "21\n1 2\n1 3\n1 4\n2 3\n2 4\n2 5\n3 4\n3 5\n3 6\n4 5\n4 6\n4 7\n5 6\n5 7\n5 1\n6 7\n6 1\n6 2\n7 1\n7 2\n7 3"
},
{
"input": "4 1",
"output": "4\n1 2\n2 3\n3 4\n4 1"
},
{
"input": "5 2",
"output"... | 1,680,602,463 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 5 | 46 | 0 | n, k = map(int, input().split())
nods = [[] for _ in range(n)]
for i in range(k):
m = 2
for j in range(n):
d = 0
if (i + m) > n:
d = i + m - n
else:
d = i + m
nods[j].append(d)
m += 1
print(n * k)
for i in range(n):
for j in range(k):
print(i + 1, nods[i][j]) | Title: Football
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided into *n* teams and played several matches, two teams could not play against each other more ... | ```python
n, k = map(int, input().split())
nods = [[] for _ in range(n)]
for i in range(k):
m = 2
for j in range(n):
d = 0
if (i + m) > n:
d = i + m - n
else:
d = i + m
nods[j].append(d)
m += 1
print(n * k)
for i in range(n):
for j in range(k):
print(i + 1, nods[... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
608 | A | Saitama Destroys Hotel | PROGRAMMING | 1,000 | [
"implementation",
"math"
] | null | null | Saitama accidentally destroyed a hotel again. To repay the hotel company, Genos has volunteered to operate an elevator in one of its other hotels. The elevator is special — it starts on the top floor, can only move down, and has infinite capacity. Floors are numbered from 0 to *s* and elevator initially starts on floor... | The first line of input contains two integers *n* and *s* (1<=≤<=*n*<=≤<=100, 1<=≤<=*s*<=≤<=1000) — the number of passengers and the number of the top floor respectively.
The next *n* lines each contain two space-separated integers *f**i* and *t**i* (1<=≤<=*f**i*<=≤<=*s*, 1<=≤<=*t**i*<=≤<=1000) — the floor and the tim... | Print a single integer — the minimum amount of time in seconds needed to bring all the passengers to floor 0. | [
"3 7\n2 1\n3 8\n5 2\n",
"5 10\n2 77\n3 33\n8 21\n9 12\n10 64\n"
] | [
"11\n",
"79\n"
] | In the first sample, it takes at least 11 seconds to bring all passengers to floor 0. Here is how this could be done:
1. Move to floor 5: takes 2 seconds.
2. Pick up passenger 3.
3. Move to floor 3: takes 2 seconds.
4. Wait for passenger 2 to arrive: takes 4 seconds.
5. Pick up passenger 2.
6. Go to floor 2: take... | 500 | [
{
"input": "3 7\n2 1\n3 8\n5 2",
"output": "11"
},
{
"input": "5 10\n2 77\n3 33\n8 21\n9 12\n10 64",
"output": "79"
},
{
"input": "1 1000\n1000 1000",
"output": "2000"
},
{
"input": "1 1\n1 1",
"output": "2"
},
{
"input": "1 1000\n1 1",
"output": "1000"
},
... | 1,522,402,225 | 2,147,483,647 | Python 3 | OK | TESTS | 39 | 78 | 7,065,600 | n,k=map(int,input().split())
for i in range(n):
f,t=map(int,input().split())
if k-f<t:
k=f+t
print(k) | Title: Saitama Destroys Hotel
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Saitama accidentally destroyed a hotel again. To repay the hotel company, Genos has volunteered to operate an elevator in one of its other hotels. The elevator is special — it starts on the top floor, can only mo... | ```python
n,k=map(int,input().split())
for i in range(n):
f,t=map(int,input().split())
if k-f<t:
k=f+t
print(k)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
835 | A | Key races | PROGRAMMING | 800 | [
"math"
] | null | null | Two boys decided to compete in text typing on the site "Key races". During the competition, they have to type a text consisting of *s* characters. The first participant types one character in *v*1 milliseconds and has ping *t*1 milliseconds. The second participant types one character in *v*2 milliseconds and has ping *... | The first line contains five integers *s*, *v*1, *v*2, *t*1, *t*2 (1<=≤<=*s*,<=*v*1,<=*v*2,<=*t*1,<=*t*2<=≤<=1000) — the number of characters in the text, the time of typing one character for the first participant, the time of typing one character for the the second participant, the ping of the first participant and th... | If the first participant wins, print "First". If the second participant wins, print "Second". In case of a draw print "Friendship". | [
"5 1 2 1 2\n",
"3 3 1 1 1\n",
"4 5 3 1 5\n"
] | [
"First\n",
"Second\n",
"Friendship\n"
] | In the first example, information on the success of the first participant comes in 7 milliseconds, of the second participant — in 14 milliseconds. So, the first wins.
In the second example, information on the success of the first participant comes in 11 milliseconds, of the second participant — in 5 milliseconds. So, ... | 500 | [
{
"input": "5 1 2 1 2",
"output": "First"
},
{
"input": "3 3 1 1 1",
"output": "Second"
},
{
"input": "4 5 3 1 5",
"output": "Friendship"
},
{
"input": "1000 1000 1000 1000 1000",
"output": "Friendship"
},
{
"input": "1 1 1 1 1",
"output": "Friendship"
},
... | 1,588,401,803 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 93 | 0 | I=[int(i) for i in input().split()]
a,b=(I[1]*I[0])+(2*I[3]),(I[0]*I[2])+(2*I[4])
if a<b:
print("First")
elif b<a:
print("Second")
else:
print("Frienship")
| Title: Key races
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Two boys decided to compete in text typing on the site "Key races". During the competition, they have to type a text consisting of *s* characters. The first participant types one character in *v*1 milliseconds and has ping *t... | ```python
I=[int(i) for i in input().split()]
a,b=(I[1]*I[0])+(2*I[3]),(I[0]*I[2])+(2*I[4])
if a<b:
print("First")
elif b<a:
print("Second")
else:
print("Frienship")
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
996 | A | Hit the Lottery | PROGRAMMING | 800 | [
"dp",
"greedy"
] | null | null | Allen has a LOT of money. He has $n$ dollars in the bank. For security reasons, he wants to withdraw it in cash (we will not disclose the reasons here). The denominations for dollar bills are $1$, $5$, $10$, $20$, $100$. What is the minimum number of bills Allen could receive after withdrawing his entire balance? | The first and only line of input contains a single integer $n$ ($1 \le n \le 10^9$). | Output the minimum number of bills that Allen could receive. | [
"125\n",
"43\n",
"1000000000\n"
] | [
"3\n",
"5\n",
"10000000\n"
] | In the first sample case, Allen can withdraw this with a $100$ dollar bill, a $20$ dollar bill, and a $5$ dollar bill. There is no way for Allen to receive $125$ dollars in one or two bills.
In the second sample case, Allen can withdraw two $20$ dollar bills and three $1$ dollar bills.
In the third sample case, Allen... | 500 | [
{
"input": "125",
"output": "3"
},
{
"input": "43",
"output": "5"
},
{
"input": "1000000000",
"output": "10000000"
},
{
"input": "4",
"output": "4"
},
{
"input": "5",
"output": "1"
},
{
"input": "1",
"output": "1"
},
{
"input": "74",
"o... | 1,694,796,583 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 49 | 62 | 0 | def main():
from sys import stdin, stdout
n = stdin.readline().rstrip()
n = int(n)
temp = n
count = 0
while True:
if temp == 0:
break
if temp >= 100:
count += int(temp/100)
temp = temp % 100
continue
if temp >... | Title: Hit the Lottery
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Allen has a LOT of money. He has $n$ dollars in the bank. For security reasons, he wants to withdraw it in cash (we will not disclose the reasons here). The denominations for dollar bills are $1$, $5$, $10$, $20$, $100$... | ```python
def main():
from sys import stdin, stdout
n = stdin.readline().rstrip()
n = int(n)
temp = n
count = 0
while True:
if temp == 0:
break
if temp >= 100:
count += int(temp/100)
temp = temp % 100
continue
... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
449 | B | Jzzhu and Cities | PROGRAMMING | 2,000 | [
"graphs",
"greedy",
"shortest paths"
] | null | null | Jzzhu is the president of country A. There are *n* cities numbered from 1 to *n* in his country. City 1 is the capital of A. Also there are *m* roads connecting the cities. One can go from city *u**i* to *v**i* (and vise versa) using the *i*-th road, the length of this road is *x**i*. Finally, there are *k* train route... | The first line contains three integers *n*,<=*m*,<=*k* (2<=≤<=*n*<=≤<=105; 1<=≤<=*m*<=≤<=3·105; 1<=≤<=*k*<=≤<=105).
Each of the next *m* lines contains three integers *u**i*,<=*v**i*,<=*x**i* (1<=≤<=*u**i*,<=*v**i*<=≤<=*n*; *u**i*<=≠<=*v**i*; 1<=≤<=*x**i*<=≤<=109).
Each of the next *k* lines contains two integers *s*... | Output a single integer representing the maximum number of the train routes which can be closed. | [
"5 5 3\n1 2 1\n2 3 2\n1 3 3\n3 4 4\n1 5 5\n3 5\n4 5\n5 5\n",
"2 2 3\n1 2 2\n2 1 3\n2 1\n2 2\n2 3\n"
] | [
"2\n",
"2\n"
] | none | 1,000 | [
{
"input": "5 5 3\n1 2 1\n2 3 2\n1 3 3\n3 4 4\n1 5 5\n3 5\n4 5\n5 5",
"output": "2"
},
{
"input": "2 2 3\n1 2 2\n2 1 3\n2 1\n2 2\n2 3",
"output": "2"
},
{
"input": "5 4 3\n1 2 999999999\n2 3 1000000000\n3 4 529529529\n5 1 524524524\n5 524444444\n5 529999999\n2 1000000000",
"output": ... | 1,696,494,269 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 3 | 30 | 0 | # LUOGU_RID: 127785026
#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
print(2) | Title: Jzzhu and Cities
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Jzzhu is the president of country A. There are *n* cities numbered from 1 to *n* in his country. City 1 is the capital of A. Also there are *m* roads connecting the cities. One can go from city *u**i* to *v**i* (and vi... | ```python
# LUOGU_RID: 127785026
#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
print(2)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
230 | B | T-primes | PROGRAMMING | 1,300 | [
"binary search",
"implementation",
"math",
"number theory"
] | null | null | We know that prime numbers are positive integers that have exactly two distinct positive divisors. Similarly, we'll call a positive integer *t* Т-prime, if *t* has exactly three distinct positive divisors.
You are given an array of *n* positive integers. For each of them determine whether it is Т-prime or not. | The first line contains a single positive integer, *n* (1<=≤<=*n*<=≤<=105), showing how many numbers are in the array. The next line contains *n* space-separated integers *x**i* (1<=≤<=*x**i*<=≤<=1012).
Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is advised to use the cin, cout st... | Print *n* lines: the *i*-th line should contain "YES" (without the quotes), if number *x**i* is Т-prime, and "NO" (without the quotes), if it isn't. | [
"3\n4 5 6\n"
] | [
"YES\nNO\nNO\n"
] | The given test has three numbers. The first number 4 has exactly three divisors — 1, 2 and 4, thus the answer for this number is "YES". The second number 5 has two divisors (1 and 5), and the third number 6 has four divisors (1, 2, 3, 6), hence the answer for them is "NO". | 500 | [
{
"input": "3\n4 5 6",
"output": "YES\nNO\nNO"
},
{
"input": "2\n48 49",
"output": "NO\nYES"
},
{
"input": "10\n10 9 8 7 6 5 4 3 2 1",
"output": "NO\nYES\nNO\nNO\nNO\nNO\nYES\nNO\nNO\nNO"
},
{
"input": "1\n36",
"output": "NO"
},
{
"input": "1\n999966000289",
"... | 1,697,025,696 | 2,147,483,647 | Python 3 | OK | TESTS | 68 | 904 | 18,841,600 | def primesquare(n2):
n=int(n2**0.5)
sieve = [True] * (n + 1)
sieve[0] = sieve[1] = False
for i in range(2, int(n**0.5) + 1):
if sieve[i]:
for j in range(i*i, n+1, i):
sieve[j] = False
primesquare = set()
for i in range(2, n+1):
if sieve[i... | Title: T-primes
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
We know that prime numbers are positive integers that have exactly two distinct positive divisors. Similarly, we'll call a positive integer *t* Т-prime, if *t* has exactly three distinct positive divisors.
You are given an ar... | ```python
def primesquare(n2):
n=int(n2**0.5)
sieve = [True] * (n + 1)
sieve[0] = sieve[1] = False
for i in range(2, int(n**0.5) + 1):
if sieve[i]:
for j in range(i*i, n+1, i):
sieve[j] = False
primesquare = set()
for i in range(2, n+1):
... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
841 | B | Godsend | PROGRAMMING | 1,100 | [
"games",
"math"
] | null | null | Leha somehow found an array consisting of *n* integers. Looking at it, he came up with a task. Two players play the game on the array. Players move one by one. The first player can choose for his move a subsegment of non-zero length with an odd sum of numbers and remove it from the array, after that the remaining parts... | First line of input data contains single integer *n* (1<=≤<=*n*<=≤<=106) — length of the array.
Next line contains *n* integers *a*1,<=*a*2,<=...,<=*a**n* (0<=≤<=*a**i*<=≤<=109). | Output answer in single line. "First", if first player wins, and "Second" otherwise (without quotes). | [
"4\n1 3 2 3\n",
"2\n2 2\n"
] | [
"First\n",
"Second\n"
] | In first sample first player remove whole array in one move and win.
In second sample first player can't make a move and lose. | 1,000 | [
{
"input": "4\n1 3 2 3",
"output": "First"
},
{
"input": "2\n2 2",
"output": "Second"
},
{
"input": "4\n2 4 6 8",
"output": "Second"
},
{
"input": "5\n1 1 1 1 1",
"output": "First"
},
{
"input": "4\n720074544 345031254 849487632 80870826",
"output": "Second"
... | 1,669,881,014 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 31 | 0 | n = int(input())
ele = list(map(int,input().split()))
flag=sum(ele)
for i in range(2):
if i%2==0 and flag%2==1:
print("First")
elif flag%2==0:
print("Second") | Title: Godsend
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Leha somehow found an array consisting of *n* integers. Looking at it, he came up with a task. Two players play the game on the array. Players move one by one. The first player can choose for his move a subsegment of non-zero l... | ```python
n = int(input())
ele = list(map(int,input().split()))
flag=sum(ele)
for i in range(2):
if i%2==0 and flag%2==1:
print("First")
elif flag%2==0:
print("Second")
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
577 | A | Multiplication Table | PROGRAMMING | 1,000 | [
"implementation",
"number theory"
] | null | null | Let's consider a table consisting of *n* rows and *n* columns. The cell located at the intersection of *i*-th row and *j*-th column contains number *i*<=×<=*j*. The rows and columns are numbered starting from 1.
You are given a positive integer *x*. Your task is to count the number of cells in a table that contain num... | The single line contains numbers *n* and *x* (1<=≤<=*n*<=≤<=105, 1<=≤<=*x*<=≤<=109) — the size of the table and the number that we are looking for in the table. | Print a single number: the number of times *x* occurs in the table. | [
"10 5\n",
"6 12\n",
"5 13\n"
] | [
"2\n",
"4\n",
"0\n"
] | A table for the second sample test is given below. The occurrences of number 12 are marked bold. | 500 | [
{
"input": "10 5",
"output": "2"
},
{
"input": "6 12",
"output": "4"
},
{
"input": "5 13",
"output": "0"
},
{
"input": "1 1",
"output": "1"
},
{
"input": "2 1",
"output": "1"
},
{
"input": "100000 1",
"output": "1"
},
{
"input": "1 10000000... | 1,653,994,015 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 3 | 31 | 0 | n,x=[int(x) for x in input().split()]
temp=[]
res=0
for k in range(1,n+1):
if k*k<=x<=k*n:
temp.append(k)
for k in temp:
for p in range(k,n+1):
if p*k==x:
res+=1
print(2*res) | Title: Multiplication Table
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Let's consider a table consisting of *n* rows and *n* columns. The cell located at the intersection of *i*-th row and *j*-th column contains number *i*<=×<=*j*. The rows and columns are numbered starting from 1.
Y... | ```python
n,x=[int(x) for x in input().split()]
temp=[]
res=0
for k in range(1,n+1):
if k*k<=x<=k*n:
temp.append(k)
for k in temp:
for p in range(k,n+1):
if p*k==x:
res+=1
print(2*res)
``` | 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,618,808,505 | 2,147,483,647 | Python 3 | OK | TESTS | 40 | 124 | 0 | i=input()
o=input()
r=i[::-1]
if o==r:
print("YES")
else:
print("NO") | 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
i=input()
o=input()
r=i[::-1]
if o==r:
print("YES")
else:
print("NO")
``` | 3.969 | MatrixStudio/Codeforces-Python-Submissions |
471 | A | MUH and Sticks | PROGRAMMING | 1,100 | [
"implementation"
] | null | null | Two polar bears Menshykov and Uslada from the St.Petersburg zoo and elephant Horace from the Kiev zoo got six sticks to play with and assess the animals' creativity. Menshykov, Uslada and Horace decided to make either an elephant or a bear from those sticks. They can make an animal from sticks in the following way:
-... | The single line contains six space-separated integers *l**i* (1<=≤<=*l**i*<=≤<=9) — the lengths of the six sticks. It is guaranteed that the input is such that you cannot make both animals from the sticks. | If you can make a bear from the given set, print string "Bear" (without the quotes). If you can make an elephant, print string "Elephant" (wıthout the quotes). If you can make neither a bear nor an elephant, print string "Alien" (without the quotes). | [
"4 2 5 4 4 4\n",
"4 4 5 4 4 5\n",
"1 2 3 4 5 6\n"
] | [
"Bear",
"Elephant",
"Alien"
] | If you're out of creative ideas, see instructions below which show how to make a bear and an elephant in the first two samples. The stick of length 2 is in red, the sticks of length 4 are in green, the sticks of length 5 are in blue. | 500 | [
{
"input": "4 2 5 4 4 4",
"output": "Bear"
},
{
"input": "4 4 5 4 4 5",
"output": "Elephant"
},
{
"input": "1 2 3 4 5 6",
"output": "Alien"
},
{
"input": "5 5 5 5 5 5",
"output": "Elephant"
},
{
"input": "1 1 1 2 3 5",
"output": "Alien"
},
{
"input": "... | 1,412,442,418 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 14 | 46 | 0 | import sys
l = [int(x) for x in (sys.stdin.readline()).split()]
l.sort()
k = l[3]
temp = []
for i in l:
if(k != i):
temp.append(i)
sz = len(temp)
if(sz == 0):
print("Elephant")
elif(sz == 1):
if(temp[0] > k):
print("Alien")
else:
print("Bear")... | Title: MUH and Sticks
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Two polar bears Menshykov and Uslada from the St.Petersburg zoo and elephant Horace from the Kiev zoo got six sticks to play with and assess the animals' creativity. Menshykov, Uslada and Horace decided to make either an... | ```python
import sys
l = [int(x) for x in (sys.stdin.readline()).split()]
l.sort()
k = l[3]
temp = []
for i in l:
if(k != i):
temp.append(i)
sz = len(temp)
if(sz == 0):
print("Elephant")
elif(sz == 1):
if(temp[0] > k):
print("Alien")
else:
pri... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
535 | B | Tavas and SaDDas | PROGRAMMING | 1,100 | [
"bitmasks",
"brute force",
"combinatorics",
"implementation"
] | null | null | Once again Tavas started eating coffee mix without water! Keione told him that it smells awful, but he didn't stop doing that. That's why Keione told his smart friend, SaDDas to punish him! SaDDas took Tavas' headphones and told him: "If you solve the following problem, I'll return it to you."
The problem is:
You ar... | The first and only line of input contains a lucky number *n* (1<=≤<=*n*<=≤<=109). | Print the index of *n* among all lucky numbers. | [
"4\n",
"7\n",
"77\n"
] | [
"1\n",
"2\n",
"6\n"
] | none | 1,000 | [
{
"input": "4",
"output": "1"
},
{
"input": "7",
"output": "2"
},
{
"input": "77",
"output": "6"
},
{
"input": "4",
"output": "1"
},
{
"input": "474744",
"output": "83"
},
{
"input": "777774",
"output": "125"
},
{
"input": "447",
"outpu... | 1,668,208,976 | 2,147,483,647 | Python 3 | OK | TESTS | 33 | 46 | 0 | # lucky numbers
number = input()
lenNumber = len(number)
count = 0
for i in range(lenNumber):
if number[i] == '7':
count += 2**(lenNumber-i)
else:
count += 2**(lenNumber-i-1)
print(count)
| Title: Tavas and SaDDas
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Once again Tavas started eating coffee mix without water! Keione told him that it smells awful, but he didn't stop doing that. That's why Keione told his smart friend, SaDDas to punish him! SaDDas took Tavas' headphone... | ```python
# lucky numbers
number = input()
lenNumber = len(number)
count = 0
for i in range(lenNumber):
if number[i] == '7':
count += 2**(lenNumber-i)
else:
count += 2**(lenNumber-i-1)
print(count)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
289 | B | Polo the Penguin and Matrix | PROGRAMMING | 1,400 | [
"brute force",
"dp",
"implementation",
"sortings",
"ternary search"
] | null | null | Little penguin Polo has an *n*<=×<=*m* matrix, consisting of integers. Let's index the matrix rows from 1 to *n* from top to bottom and let's index the columns from 1 to *m* from left to right. Let's represent the matrix element on the intersection of row *i* and column *j* as *a**ij*.
In one move the penguin can add ... | The first line contains three integers *n*, *m* and *d* (1<=≤<=*n*,<=*m*<=≤<=100,<=1<=≤<=*d*<=≤<=104) — the matrix sizes and the *d* parameter. Next *n* lines contain the matrix: the *j*-th integer in the *i*-th row is the matrix element *a**ij* (1<=≤<=*a**ij*<=≤<=104). | In a single line print a single integer — the minimum number of moves the penguin needs to make all matrix elements equal. If that is impossible, print "-1" (without the quotes). | [
"2 2 2\n2 4\n6 8\n",
"1 2 7\n6 7\n"
] | [
"4\n",
"-1\n"
] | none | 1,000 | [
{
"input": "2 2 2\n2 4\n6 8",
"output": "4"
},
{
"input": "1 2 7\n6 7",
"output": "-1"
},
{
"input": "3 2 1\n5 7\n1 2\n5 100",
"output": "104"
},
{
"input": "3 3 3\n5 8 5\n11 11 17\n14 5 2",
"output": "12"
},
{
"input": "3 3 3\n5 8 5\n11 11 17\n14 5 3",
"outpu... | 1,574,379,852 | 2,147,483,647 | PyPy 3 | OK | TESTS | 31 | 310 | 2,252,800 | def Gcd(a,b):
while a*b!=0:
if a>b:
a=int(a)%int(b)
else:
b=b%a
return a+b
n,m,d=map(int,input().split())
a=[]
for i in range(n):
a+=list(map(int,input().split()))
a=sorted(a)
cnt=0
mid=a[n*m//2]
for element in a:
if mid-element>=0:
if (mid... | Title: Polo the Penguin and Matrix
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Little penguin Polo has an *n*<=×<=*m* matrix, consisting of integers. Let's index the matrix rows from 1 to *n* from top to bottom and let's index the columns from 1 to *m* from left to right. Let's represe... | ```python
def Gcd(a,b):
while a*b!=0:
if a>b:
a=int(a)%int(b)
else:
b=b%a
return a+b
n,m,d=map(int,input().split())
a=[]
for i in range(n):
a+=list(map(int,input().split()))
a=sorted(a)
cnt=0
mid=a[n*m//2]
for element in a:
if mid-element>=0:
... | 3 | 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,671,236,545 | 2,147,483,647 | Python 3 | OK | TESTS | 30 | 92 | 0 | s = input()
isu = 0
for c in s:
if c.isupper():
isu+=1
if isu > len(s)-isu:
print(s.upper())
else:
print(s.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
s = input()
isu = 0
for c in s:
if c.isupper():
isu+=1
if isu > len(s)-isu:
print(s.upper())
else:
print(s.lower())
``` | 3.977 | MatrixStudio/Codeforces-Python-Submissions |
405 | A | Gravity Flip | PROGRAMMING | 900 | [
"greedy",
"implementation",
"sortings"
] | null | null | Little Chris is bored during his physics lessons (too easy), so he has built a toy box to keep himself occupied. The box is special, since it has the ability to change gravity.
There are *n* columns of toy cubes in the box arranged in a line. The *i*-th column contains *a**i* cubes. At first, the gravity in the box is... | The first line of input contains an integer *n* (1<=≤<=*n*<=≤<=100), the number of the columns in the box. The next line contains *n* space-separated integer numbers. The *i*-th number *a**i* (1<=≤<=*a**i*<=≤<=100) denotes the number of cubes in the *i*-th column. | Output *n* integer numbers separated by spaces, where the *i*-th number is the amount of cubes in the *i*-th column after the gravity switch. | [
"4\n3 2 1 2\n",
"3\n2 3 8\n"
] | [
"1 2 2 3 \n",
"2 3 8 \n"
] | The first example case is shown on the figure. The top cube of the first column falls to the top of the last column; the top cube of the second column falls to the top of the third column; the middle cube of the first column falls to the top of the second column.
In the second example case the gravity switch does not ... | 500 | [
{
"input": "4\n3 2 1 2",
"output": "1 2 2 3 "
},
{
"input": "3\n2 3 8",
"output": "2 3 8 "
},
{
"input": "5\n2 1 2 1 2",
"output": "1 1 2 2 2 "
},
{
"input": "1\n1",
"output": "1 "
},
{
"input": "2\n4 3",
"output": "3 4 "
},
{
"input": "6\n100 40 60 20... | 1,691,526,791 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 15 | 0 | l = []
n = int(input("Enter the number of elements: "))
for i in range(n):
f = int(input())
l.append(f)
l_n = sorted(l)
p = " " # Remove the extra space after the equals sign
result = p.join(map(str, l_n))
print(result)
| Title: Gravity Flip
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Little Chris is bored during his physics lessons (too easy), so he has built a toy box to keep himself occupied. The box is special, since it has the ability to change gravity.
There are *n* columns of toy cubes in the bo... | ```python
l = []
n = int(input("Enter the number of elements: "))
for i in range(n):
f = int(input())
l.append(f)
l_n = sorted(l)
p = " " # Remove the extra space after the equals sign
result = p.join(map(str, l_n))
print(result)
``` | -1 | MatrixStudio/Codeforces-Python-Submissions | |
844 | A | Diversity | PROGRAMMING | 1,000 | [
"greedy",
"implementation",
"strings"
] | null | null | Calculate the minimum number of characters you need to change in the string *s*, so that it contains at least *k* different letters, or print that it is impossible.
String *s* consists only of lowercase Latin letters, and it is allowed to change characters only to lowercase Latin letters too. | First line of input contains string *s*, consisting only of lowercase Latin letters (1<=≤<=|*s*|<=≤<=1000, |*s*| denotes the length of *s*).
Second line of input contains integer *k* (1<=≤<=*k*<=≤<=26). | Print single line with a minimum number of necessary changes, or the word «impossible» (without quotes) if it is impossible. | [
"yandex\n6\n",
"yahoo\n5\n",
"google\n7\n"
] | [
"0\n",
"1\n",
"impossible\n"
] | In the first test case string contains 6 different letters, so we don't need to change anything.
In the second test case string contains 4 different letters: {'*a*', '*h*', '*o*', '*y*'}. To get 5 different letters it is necessary to change one occurrence of '*o*' to some letter, which doesn't occur in the string, for... | 500 | [
{
"input": "yandex\n6",
"output": "0"
},
{
"input": "yahoo\n5",
"output": "1"
},
{
"input": "google\n7",
"output": "impossible"
},
{
"input": "a\n1",
"output": "0"
},
{
"input": "z\n2",
"output": "impossible"
},
{
"input": "fwgfrwgkuwghfiruhewgirueguhe... | 1,600,946,717 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 11 | 140 | 0 | s=input()
k=int(input())
l,j=len(set(s)),len(s)
if k==l:print(0)
elif k>j:print('impossible')
else:print(k-l) | Title: Diversity
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Calculate the minimum number of characters you need to change in the string *s*, so that it contains at least *k* different letters, or print that it is impossible.
String *s* consists only of lowercase Latin letters, and it... | ```python
s=input()
k=int(input())
l,j=len(set(s)),len(s)
if k==l:print(0)
elif k>j:print('impossible')
else:print(k-l)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
9 | A | Die Roll | PROGRAMMING | 800 | [
"math",
"probabilities"
] | A. Die Roll | 1 | 64 | Yakko, Wakko and Dot, world-famous animaniacs, decided to rest from acting in cartoons, and take a leave to travel a bit. Yakko dreamt to go to Pennsylvania, his Motherland and the Motherland of his ancestors. Wakko thought about Tasmania, its beaches, sun and sea. Dot chose Transylvania as the most mysterious and unpr... | The only line of the input file contains two natural numbers Y and W — the results of Yakko's and Wakko's die rolls. | Output the required probability in the form of irreducible fraction in format «A/B», where A — the numerator, and B — the denominator. If the required probability equals to zero, output «0/1». If the required probability equals to 1, output «1/1». | [
"4 2\n"
] | [
"1/2\n"
] | Dot will go to Transylvania, if she is lucky to roll 4, 5 or 6 points. | 0 | [
{
"input": "4 2",
"output": "1/2"
},
{
"input": "1 1",
"output": "1/1"
},
{
"input": "1 2",
"output": "5/6"
},
{
"input": "1 3",
"output": "2/3"
},
{
"input": "1 4",
"output": "1/2"
},
{
"input": "1 5",
"output": "1/3"
},
{
"input": "1 6",
... | 1,628,629,940 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 186 | 7,782,400 | #9A (37No. Problem A)
from fractions import Fraction
yw = list(map(int,input().split()))
sec = max(yw)
flag = 0
for i in range(sec,6+1):
flag+=1
# prop = (flag/6) * 100
print(Fraction(flag,6))
| Title: Die Roll
Time Limit: 1 seconds
Memory Limit: 64 megabytes
Problem Description:
Yakko, Wakko and Dot, world-famous animaniacs, decided to rest from acting in cartoons, and take a leave to travel a bit. Yakko dreamt to go to Pennsylvania, his Motherland and the Motherland of his ancestors. Wakko thought about T... | ```python
#9A (37No. Problem A)
from fractions import Fraction
yw = list(map(int,input().split()))
sec = max(yw)
flag = 0
for i in range(sec,6+1):
flag+=1
# prop = (flag/6) * 100
print(Fraction(flag,6))
``` | 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,633,298,154 | 2,147,483,647 | Python 3 | COMPILATION_ERROR | TESTS | 0 | 0 | 0 | m = int (input())
n = int (input())
z=[]
z[0]=m
z[1]=n
x = 0
if m % 2!=0 && n % 2!=0:
x= (m*n /2)
else:
x = str(m*n/2)
print(x)
| 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 = int (input())
n = int (input())
z=[]
z[0]=m
z[1]=n
x = 0
if m % 2!=0 && n % 2!=0:
x= (m*n /2)
else:
x = str(m*n/2)
print(x)
``` | -1 | MatrixStudio/Codeforces-Python-Submissions |
847 | G | University Classes | PROGRAMMING | 900 | [
"implementation"
] | null | null | There are *n* student groups at the university. During the study day, each group can take no more than 7 classes. Seven time slots numbered from 1 to 7 are allocated for the classes.
The schedule on Monday is known for each group, i. e. time slots when group will have classes are known.
Your task is to determine the ... | The first line contains a single integer *n* (1<=≤<=*n*<=≤<=1000) — the number of groups.
Each of the following *n* lines contains a sequence consisting of 7 zeroes and ones — the schedule of classes on Monday for a group. If the symbol in a position equals to 1 then the group has class in the corresponding time slot... | Print minimum number of rooms needed to hold all groups classes on Monday. | [
"2\n0101010\n1010101\n",
"3\n0101011\n0011001\n0110111\n"
] | [
"1\n",
"3\n"
] | In the first example one room is enough. It will be occupied in each of the seven time slot by the first group or by the second group.
In the second example three rooms is enough, because in the seventh time slot all three groups have classes. | 0 | [
{
"input": "2\n0101010\n1010101",
"output": "1"
},
{
"input": "3\n0101011\n0011001\n0110111",
"output": "3"
},
{
"input": "1\n0111000",
"output": "1"
},
{
"input": "1\n0000000",
"output": "0"
},
{
"input": "1\n1111111",
"output": "1"
},
{
"input": "2\n... | 1,584,027,902 | 2,147,483,647 | Python 3 | OK | TESTS | 21 | 109 | 0 | l,c=[],0
for x in range(int(input())):l.append(input())
for y in range(7):
s=0
for x in range(len(l)):
if l[x][y]=="1":s+=1
c=max(c,s)
print(c) | Title: University Classes
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
There are *n* student groups at the university. During the study day, each group can take no more than 7 classes. Seven time slots numbered from 1 to 7 are allocated for the classes.
The schedule on Monday is known ... | ```python
l,c=[],0
for x in range(int(input())):l.append(input())
for y in range(7):
s=0
for x in range(len(l)):
if l[x][y]=="1":s+=1
c=max(c,s)
print(c)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
241 | A | Old Peykan | PROGRAMMING | 1,300 | [
"greedy"
] | null | null | There are *n* cities in the country where the Old Peykan lives. These cities are located on a straight line, we'll denote them from left to right as *c*1,<=*c*2,<=...,<=*c**n*. The Old Peykan wants to travel from city *c*1 to *c**n* using roads. There are (*n*<=-<=1) one way roads, the *i*-th road goes from city *c**i*... | The first line of the input contains two space-separated integers *m* and *k* (1<=≤<=*m*,<=*k*<=≤<=1000). The value *m* specifies the number of roads between cities which is equal to *n*<=-<=1.
The next line contains *m* space-separated integers *d*1,<=*d*2,<=...,<=*d**m* (1<=≤<=*d**i*<=≤<=1000) and the following line... | In the only line of the output print a single integer — the minimum time required for The Old Peykan to reach city *c**n* from city *c*1. | [
"4 6\n1 2 5 2\n2 3 3 4\n",
"2 3\n5 6\n5 5\n"
] | [
"10\n",
"14\n"
] | In the second sample above, the Old Peykan stays in *c*<sub class="lower-index">1</sub> for 3 hours. | 0 | [
{
"input": "4 6\n1 2 5 2\n2 3 3 4",
"output": "10"
},
{
"input": "2 3\n5 6\n5 5",
"output": "14"
},
{
"input": "24 3\n11 8 8 12 17 4 4 25 39 37 31 32 38 34 29 29 34 39 39 39 17 9 24 6\n3 5 4 3 3 3 4 3 4 3 3 3 3 4 3 3 4 3 4 3 3 3 3 3",
"output": "862"
},
{
"input": "43 5\n6 7 ... | 1,463,032,190 | 2,147,483,647 | Python 3 | OK | TESTS | 52 | 124 | 5,120,000 | # -*- coding: utf-8 -*-
def main():
m, k = [int(x) for x in input().split()]
d = [int(x) for x in input().split()]
s = [int(x) for x in input().split()]
ans = 0 # total time spent
fuel = 0 # amount of fuel in the tank
mx = 0 # largest depo seen so far
for i in range(m... | Title: Old Peykan
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
There are *n* cities in the country where the Old Peykan lives. These cities are located on a straight line, we'll denote them from left to right as *c*1,<=*c*2,<=...,<=*c**n*. The Old Peykan wants to travel from city *c*1 t... | ```python
# -*- coding: utf-8 -*-
def main():
m, k = [int(x) for x in input().split()]
d = [int(x) for x in input().split()]
s = [int(x) for x in input().split()]
ans = 0 # total time spent
fuel = 0 # amount of fuel in the tank
mx = 0 # largest depo seen so far
for i ... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
37 | A | Towers | PROGRAMMING | 1,000 | [
"sortings"
] | A. Towers | 2 | 256 | Little Vasya has received a young builder’s kit. The kit consists of several wooden bars, the lengths of all of them are known. The bars can be put one on the top of the other if their lengths are the same.
Vasya wants to construct the minimal number of towers from the bars. Help Vasya to use the bars in the best way ... | The first line contains an integer *N* (1<=≤<=*N*<=≤<=1000) — the number of bars at Vasya’s disposal. The second line contains *N* space-separated integers *l**i* — the lengths of the bars. All the lengths are natural numbers not exceeding 1000. | In one line output two numbers — the height of the largest tower and their total number. Remember that Vasya should use all the bars. | [
"3\n1 2 3\n",
"4\n6 5 6 7\n"
] | [
"1 3\n",
"2 3\n"
] | none | 500 | [
{
"input": "3\n1 2 3",
"output": "1 3"
},
{
"input": "4\n6 5 6 7",
"output": "2 3"
},
{
"input": "4\n3 2 1 1",
"output": "2 3"
},
{
"input": "4\n1 2 3 3",
"output": "2 3"
},
{
"input": "3\n20 22 36",
"output": "1 3"
},
{
"input": "25\n47 30 94 41 45 20... | 1,552,291,199 | 2,147,483,647 | Python 3 | OK | TESTS | 61 | 248 | 0 | n = int(input())
arr = list(map(int, input().split()))
m = max(arr) + 1
counts = [0]*m
for i in arr:
counts[i] += 1
sub_list = []
for i in range(m):
if i in arr:
sub_list.append(counts[i])
sub_list.sort()
print (sub_list[-1], len(sub_list)) | Title: Towers
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Little Vasya has received a young builder’s kit. The kit consists of several wooden bars, the lengths of all of them are known. The bars can be put one on the top of the other if their lengths are the same.
Vasya wants to construct... | ```python
n = int(input())
arr = list(map(int, input().split()))
m = max(arr) + 1
counts = [0]*m
for i in arr:
counts[i] += 1
sub_list = []
for i in range(m):
if i in arr:
sub_list.append(counts[i])
sub_list.sort()
print (sub_list[-1], len(sub_list))
``` | 3.938 | 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,616,675,485 | 2,147,483,647 | Python 3 | OK | TESTS | 34 | 77 | 0 | input(); a = input()
if (a[0]== "S" and a[-1] == "F") and (a[0]!=a[-1]):
print("\nYES")
else:
print("\nNO") | 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
input(); a = input()
if (a[0]== "S" and a[-1] == "F") and (a[0]!=a[-1]):
print("\nYES")
else:
print("\nNO")
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
625 | C | K-special Tables | PROGRAMMING | 1,300 | [
"constructive algorithms",
"implementation"
] | null | null | People do many crazy things to stand out in a crowd. Some of them dance, some learn by heart rules of Russian language, some try to become an outstanding competitive programmers, while others collect funny math objects.
Alis is among these collectors. Right now she wants to get one of *k*-special tables. In case you f... | The first line of the input contains two integers *n* and *k* (1<=≤<=*n*<=≤<=500,<=1<=≤<=*k*<=≤<=*n*) — the size of the table Alice is looking for and the column that should have maximum possible sum. | First print the sum of the integers in the *k*-th column of the required table.
Next *n* lines should contain the description of the table itself: first line should contains *n* elements of the first row, second line should contain *n* elements of the second row and so on.
If there are multiple suitable table, you ar... | [
"4 1\n",
"5 3\n"
] | [
"28\n1 2 3 4\n5 6 7 8\n9 10 11 12\n13 14 15 16\n",
"85\n5 6 17 18 19\n9 10 23 24 25\n7 8 20 21 22\n3 4 14 15 16\n1 2 11 12 13\n\n"
] | none | 1,000 | [
{
"input": "4 1",
"output": "28\n1 2 3 4\n5 6 7 8\n9 10 11 12\n13 14 15 16"
},
{
"input": "5 3",
"output": "85\n1 2 11 12 13\n3 4 14 15 16\n5 6 17 18 19\n7 8 20 21 22\n9 10 23 24 25"
},
{
"input": "1 1",
"output": "1\n1"
},
{
"input": "2 1",
"output": "4\n1 2\n3 4"
},
... | 1,584,337,476 | 2,147,483,647 | PyPy 3 | OK | TESTS | 52 | 405 | 10,035,200 | #625C
n, k = map(int, input().split())
matrix = [[0]*n for _ in range(n)]
value = 1
for i in range(n):
for j in range(k-1):
matrix[i][j] = value
value += 1
for i in range(n):
for j in range(k-1,n):
matrix[i][j] = value
value += 1
ans = 0
for i in range(n):
ans +... | Title: K-special Tables
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
People do many crazy things to stand out in a crowd. Some of them dance, some learn by heart rules of Russian language, some try to become an outstanding competitive programmers, while others collect funny math objects... | ```python
#625C
n, k = map(int, input().split())
matrix = [[0]*n for _ in range(n)]
value = 1
for i in range(n):
for j in range(k-1):
matrix[i][j] = value
value += 1
for i in range(n):
for j in range(k-1,n):
matrix[i][j] = value
value += 1
ans = 0
for i in range(n):
... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
255 | A | Greg's Workout | PROGRAMMING | 800 | [
"implementation"
] | null | null | Greg is a beginner bodybuilder. Today the gym coach gave him the training plan. All it had was *n* integers *a*1,<=*a*2,<=...,<=*a**n*. These numbers mean that Greg needs to do exactly *n* exercises today. Besides, Greg should repeat the *i*-th in order exercise *a**i* times.
Greg now only does three types of exercise... | The first line contains integer *n* (1<=≤<=*n*<=≤<=20). The second line contains *n* integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=25) — the number of times Greg repeats the exercises. | Print word "chest" (without the quotes), if the chest gets the most exercise, "biceps" (without the quotes), if the biceps gets the most exercise and print "back" (without the quotes) if the back gets the most exercise.
It is guaranteed that the input is such that the answer to the problem is unambiguous. | [
"2\n2 8\n",
"3\n5 1 10\n",
"7\n3 3 2 7 9 6 8\n"
] | [
"biceps\n",
"back\n",
"chest\n"
] | In the first sample Greg does 2 chest, 8 biceps and zero back exercises, so the biceps gets the most exercises.
In the second sample Greg does 5 chest, 1 biceps and 10 back exercises, so the back gets the most exercises.
In the third sample Greg does 18 chest, 12 biceps and 8 back exercises, so the chest gets the mos... | 500 | [
{
"input": "2\n2 8",
"output": "biceps"
},
{
"input": "3\n5 1 10",
"output": "back"
},
{
"input": "7\n3 3 2 7 9 6 8",
"output": "chest"
},
{
"input": "4\n5 6 6 2",
"output": "chest"
},
{
"input": "5\n8 2 2 6 3",
"output": "chest"
},
{
"input": "6\n8 7 ... | 1,611,833,600 | 2,147,483,647 | Python 3 | OK | TESTS | 61 | 154 | 0 | N=int(input())
exercise=list(map(int,input().split()))
times=[0]*3
for ind in range(N):
times[ind%3]+=exercise[ind]
maxExercise=times.index(max(times))
types=['chest','biceps','back']
print(types[maxExercise])
| Title: Greg's Workout
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Greg is a beginner bodybuilder. Today the gym coach gave him the training plan. All it had was *n* integers *a*1,<=*a*2,<=...,<=*a**n*. These numbers mean that Greg needs to do exactly *n* exercises today. Besides, Greg ... | ```python
N=int(input())
exercise=list(map(int,input().split()))
times=[0]*3
for ind in range(N):
times[ind%3]+=exercise[ind]
maxExercise=times.index(max(times))
types=['chest','biceps','back']
print(types[maxExercise])
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
801 | B | Valued Keys | PROGRAMMING | 900 | [
"constructive algorithms",
"greedy",
"strings"
] | null | null | You found a mysterious function *f*. The function takes two strings *s*1 and *s*2. These strings must consist only of lowercase English letters, and must be the same length.
The output of the function *f* is another string of the same length. The *i*-th character of the output is equal to the minimum of the *i*-th cha... | The first line of input contains the string *x*.
The second line of input contains the string *y*.
Both *x* and *y* consist only of lowercase English letters, *x* and *y* have same length and this length is between 1 and 100. | If there is no string *z* such that *f*(*x*,<=*z*)<==<=*y*, print -1.
Otherwise, print a string *z* such that *f*(*x*,<=*z*)<==<=*y*. If there are multiple possible answers, print any of them. The string *z* should be the same length as *x* and *y* and consist only of lowercase English letters. | [
"ab\naa\n",
"nzwzl\nniwel\n",
"ab\nba\n"
] | [
"ba\n",
"xiyez\n",
"-1\n"
] | The first case is from the statement.
Another solution for the second case is "zizez"
There is no solution for the third case. That is, there is no *z* such that *f*("ab", *z*) = "ba". | 1,000 | [
{
"input": "ab\naa",
"output": "ba"
},
{
"input": "nzwzl\nniwel",
"output": "xiyez"
},
{
"input": "ab\nba",
"output": "-1"
},
{
"input": "r\nl",
"output": "l"
},
{
"input": "d\ny",
"output": "-1"
},
{
"input": "yvowz\ncajav",
"output": "cajav"
},... | 1,685,473,691 | 2,147,483,647 | Python 3 | OK | TESTS | 35 | 46 | 0 | x = input()
y = input()
ans = ''
k = True
for i in range(len(x)):
if x[i]<y[i]:
print(-1)
k = False
break
elif x[i]==y[i]:
ans+=x[i]
else:
ans+=y[i]
if k:
print(ans)
| Title: Valued Keys
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You found a mysterious function *f*. The function takes two strings *s*1 and *s*2. These strings must consist only of lowercase English letters, and must be the same length.
The output of the function *f* is another string... | ```python
x = input()
y = input()
ans = ''
k = True
for i in range(len(x)):
if x[i]<y[i]:
print(-1)
k = False
break
elif x[i]==y[i]:
ans+=x[i]
else:
ans+=y[i]
if k:
print(ans)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
7 | C | Line | PROGRAMMING | 1,800 | [
"math",
"number theory"
] | C. Line | 1 | 256 | A line on the plane is described by an equation *Ax*<=+<=*By*<=+<=*C*<==<=0. You are to find any point on this line, whose coordinates are integer numbers from <=-<=5·1018 to 5·1018 inclusive, or to find out that such points do not exist. | The first line contains three integers *A*, *B* and *C* (<=-<=2·109<=≤<=*A*,<=*B*,<=*C*<=≤<=2·109) — corresponding coefficients of the line equation. It is guaranteed that *A*2<=+<=*B*2<=><=0. | If the required point exists, output its coordinates, otherwise output -1. | [
"2 5 3\n"
] | [
"6 -3\n"
] | none | 0 | [
{
"input": "2 5 3",
"output": "6 -3"
},
{
"input": "0 2 3",
"output": "-1"
},
{
"input": "931480234 -1767614767 -320146190",
"output": "-98880374013340920 -52107006370101410"
},
{
"input": "-1548994394 -1586527767 -1203252104",
"output": "-878123061596147680 8573488141506... | 1,628,414,543 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 2 | 154 | 20,172,800 | import math
def ext_euclid(a, b):
if b == 0:
return 1, 0
else:
x, y = ext_euclid(b, a % b)
x, y = y, x - (a // b) * y
return x, y
A, B, C = map(int, input().split())
if C % math.gcd(A, B) != 0:
print(-1)
else:
x0, y0 = ext_euclid(A, B)
... | Title: Line
Time Limit: 1 seconds
Memory Limit: 256 megabytes
Problem Description:
A line on the plane is described by an equation *Ax*<=+<=*By*<=+<=*C*<==<=0. You are to find any point on this line, whose coordinates are integer numbers from <=-<=5·1018 to 5·1018 inclusive, or to find out that such points do not ex... | ```python
import math
def ext_euclid(a, b):
if b == 0:
return 1, 0
else:
x, y = ext_euclid(b, a % b)
x, y = y, x - (a // b) * y
return x, y
A, B, C = map(int, input().split())
if C % math.gcd(A, B) != 0:
print(-1)
else:
x0, y0 = ext_euclid(A... | 0 | MatrixStudio/Codeforces-Python-Submissions |
23 | A | You're Given a String... | PROGRAMMING | 1,200 | [
"brute force",
"greedy"
] | A. You're Given a String... | 2 | 256 | You're given a string of lower-case Latin letters. Your task is to find the length of its longest substring that can be met in the string at least twice. These occurrences can overlap (see sample test 2). | The first input line contains the string. It's guaranteed, that the string is non-empty, consists of lower-case Latin letters, and its length doesn't exceed 100. | Output one number — length of the longest substring that can be met in the string at least twice. | [
"abcd\n",
"ababa\n",
"zzz\n"
] | [
"0",
"3",
"2"
] | none | 0 | [
{
"input": "abcd",
"output": "0"
},
{
"input": "ababa",
"output": "3"
},
{
"input": "zzz",
"output": "2"
},
{
"input": "kmmm",
"output": "2"
},
{
"input": "wzznz",
"output": "1"
},
{
"input": "qlzazaaqll",
"output": "2"
},
{
"input": "lzggg... | 1,680,955,097 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 62 | 0 | s = input()
n = len(s)
ans = 0
for i in range(n):
for j in range(i+1, n):
substr = s[i:j+1]
if s.count(substr) >= 2:
ans = max(ans, len(substr))
print(ans)
| Title: You're Given a String...
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
You're given a string of lower-case Latin letters. Your task is to find the length of its longest substring that can be met in the string at least twice. These occurrences can overlap (see sample test 2).
Input Sp... | ```python
s = input()
n = len(s)
ans = 0
for i in range(n):
for j in range(i+1, n):
substr = s[i:j+1]
if s.count(substr) >= 2:
ans = max(ans, len(substr))
print(ans)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions |
939 | B | Hamster Farm | PROGRAMMING | 1,000 | [
"implementation"
] | null | null | Dima has a hamsters farm. Soon *N* hamsters will grow up on it and Dima will sell them in a city nearby.
Hamsters should be transported in boxes. If some box is not completely full, the hamsters in it are bored, that's why each box should be completely full with hamsters.
Dima can buy boxes at a factory. The factory ... | The first line contains two integers *N* and *K* (0<=≤<=*N*<=≤<=1018, 1<=≤<=*K*<=≤<=105) — the number of hamsters that will grow up on Dima's farm and the number of types of boxes that the factory produces.
The second line contains *K* integers *a*1, *a*2, ..., *a**K* (1<=≤<=*a**i*<=≤<=1018 for all *i*) — the capaciti... | Output two integers: the type of boxes that Dima should buy and the number of boxes of that type Dima should buy. Types of boxes are numbered from 1 to *K* in the order they are given in input.
If there are many correct answers, output any of them. | [
"19 3\n5 4 10\n",
"28 3\n5 6 30\n"
] | [
"2 4\n",
"1 5\n"
] | none | 1,000 | [
{
"input": "19 3\n5 4 10",
"output": "2 4"
},
{
"input": "28 3\n5 6 30",
"output": "1 5"
},
{
"input": "1 1\n1",
"output": "1 1"
},
{
"input": "0 2\n2 3",
"output": "1 0"
},
{
"input": "30 4\n4 5 5 4",
"output": "2 6"
},
{
"input": "120 7\n109 92 38 38... | 1,627,404,789 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 46 | 6,656,000 | n,k = map(int,input().split())
H = list(map(int,input().split()))
mod_H = [n%x for x in H]
print(mod_H)
idx = mod_H.index(min(mod_H))
boxes = n // H[idx]
print(idx+1,boxes)
| Title: Hamster Farm
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Dima has a hamsters farm. Soon *N* hamsters will grow up on it and Dima will sell them in a city nearby.
Hamsters should be transported in boxes. If some box is not completely full, the hamsters in it are bored, that's wh... | ```python
n,k = map(int,input().split())
H = list(map(int,input().split()))
mod_H = [n%x for x in H]
print(mod_H)
idx = mod_H.index(min(mod_H))
boxes = n // H[idx]
print(idx+1,boxes)
``` | 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,677,098,235 | 2,147,483,647 | Python 3 | OK | TESTS | 40 | 92 | 0 | s = input()
s2 = input()
s3 = input()
s = s.replace(" ","")
s2 = s2.replace(" ","")
s3 = s3.replace(" ","")
l1 = 0
l2 = 0
l3 = 0
for i in s:
if i== "a" or i== "e" or i== "o" or i== "i" or i== "u":
l1 += 1
for i in s2:
if i== "a" or i== "e" or i== "o" or i== "i" or i== "u":
l2 += 1
f... | 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 = input()
s2 = input()
s3 = input()
s = s.replace(" ","")
s2 = s2.replace(" ","")
s3 = s3.replace(" ","")
l1 = 0
l2 = 0
l3 = 0
for i in s:
if i== "a" or i== "e" or i== "o" or i== "i" or i== "u":
l1 += 1
for i in s2:
if i== "a" or i== "e" or i== "o" or i== "i" or i== "u":
l2... | 3.977 | MatrixStudio/Codeforces-Python-Submissions |
66 | B | Petya and Countryside | PROGRAMMING | 1,100 | [
"brute force",
"implementation"
] | B. Petya and Countryside | 2 | 256 | Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1<=×<=*n* in size, when viewed from above. This rectangle is divided into *n* equal square sections. The garden is very unusual as each of the square sections possesses its own f... | The first line contains a positive integer *n* (1<=≤<=*n*<=≤<=1000). The second line contains *n* positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000. | Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section. | [
"1\n2\n",
"5\n1 2 1 2 1\n",
"8\n1 2 1 1 1 3 3 4\n"
] | [
"1\n",
"3\n",
"6\n"
] | none | 1,000 | [
{
"input": "1\n2",
"output": "1"
},
{
"input": "5\n1 2 1 2 1",
"output": "3"
},
{
"input": "8\n1 2 1 1 1 3 3 4",
"output": "6"
},
{
"input": "10\n1 2 3 4 5 6 7 8 9 10",
"output": "10"
},
{
"input": "10\n10 9 8 7 6 5 4 3 2 1",
"output": "10"
},
{
"input... | 1,611,435,779 | 2,147,483,647 | Python 3 | OK | TESTS | 80 | 1,090 | 307,200 | n = int(input())
arr = [int(i) for i in input().split()]
l = []
for i in range(n):
c = 0
j = i
while (j>= 1 and arr[j-1] <= arr[j]):
c = c + 1
j = j - 1
j = i
while (j <= n - 2and arr[j+1] <= arr[j]):
c = c + 1
j = j + 1
l.append(c + 1)
print(max(l)) | Title: Petya and Countryside
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1<=×<=*n* in size, when viewed from above. This rectangle is divided into *... | ```python
n = int(input())
arr = [int(i) for i in input().split()]
l = []
for i in range(n):
c = 0
j = i
while (j>= 1 and arr[j-1] <= arr[j]):
c = c + 1
j = j - 1
j = i
while (j <= n - 2and arr[j+1] <= arr[j]):
c = c + 1
j = j + 1
l.append(c + 1)
pri... | 3.726928 | 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,375,486 | 2,147,483,647 | Python 3 | OK | TESTS | 21 | 62 | 0 | L=[]
n=int(input())
for i in range(0,n):
a=input().split()
c=0
if a.count('1')>=2:
c+=1
L.append(c)
print(len(L)) | 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
L=[]
n=int(input())
for i in range(0,n):
a=input().split()
c=0
if a.count('1')>=2:
c+=1
L.append(c)
print(len(L))
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
926 | H | Endless Roses Most Beautiful | PROGRAMMING | 2,200 | [] | null | null | Arkady decided to buy roses for his girlfriend.
A flower shop has white, orange and red roses, and the total amount of them is *n*. Arkady thinks that red roses are not good together with white roses, so he won't buy a bouquet containing both red and white roses. Also, Arkady won't buy a bouquet where all roses have t... | The first line contains two integers *n* and *k* (1<=≤<=*k*<=≤<=*n*<=≤<=200<=000) — the number of roses in the show and the number of roses Arkady wants to buy.
The second line contains a sequence of integers *b*1,<=*b*2,<=...,<=*b**n* (1<=≤<=*b**i*<=≤<=10<=000), where *b**i* equals the beauty of the *i*-th rose.
The... | Print the maximum possible total beauty of a bouquet of *k* roses that satisfies the constraints above. If it is not possible to make a single such bouquet, print -1. | [
"5 3\n4 3 4 1 6\nRROWW\n",
"5 2\n10 20 14 20 11\nRRRRR\n",
"11 5\n5 6 3 2 3 4 7 5 4 5 6\nRWOORWORROW\n"
] | [
"11\n",
"-1\n",
"28\n"
] | In the first example Arkady wants to buy 3 roses. He can, for example, buy both red roses (their indices are 1 and 2, and their total beauty is 7) and the only orange rose (its index is 3, its beauty is 4). This way the total beauty of the bouquet is 11.
In the second example Arkady can not buy a bouquet because all ... | 0 | [
{
"input": "5 3\n4 3 4 1 6\nRROWW",
"output": "11"
},
{
"input": "5 2\n10 20 14 20 11\nRRRRR",
"output": "-1"
},
{
"input": "11 5\n5 6 3 2 3 4 7 5 4 5 6\nRWOORWORROW",
"output": "28"
},
{
"input": "15 10\n8560 6244 9607 5137 7187 3217 5527 9919 282 8748 3529 6110 5767 521 339... | 1,540,051,153 | 2,147,483,647 | Python 3 | MEMORY_LIMIT_EXCEEDED | TESTS | 8 | 1,076 | 268,390,400 | import unittest
from itertools import combinations
def problem_h(n, k, b, c):
# map roses to their weight
# shop = zip(b, c)
# roses stack by color
if len(set(c)) == 1:
return -1
whites, reds, oranges = list(), list(), list()
for beauty, color in zip(b, c):
if col... | Title: Endless Roses Most Beautiful
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Arkady decided to buy roses for his girlfriend.
A flower shop has white, orange and red roses, and the total amount of them is *n*. Arkady thinks that red roses are not good together with white roses, so h... | ```python
import unittest
from itertools import combinations
def problem_h(n, k, b, c):
# map roses to their weight
# shop = zip(b, c)
# roses stack by color
if len(set(c)) == 1:
return -1
whites, reds, oranges = list(), list(), list()
for beauty, color in zip(b, c):
... | 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,591,465,189 | 2,147,483,647 | Python 3 | OK | TESTS | 30 | 218 | 0 | word = input()
count1=0
count2=0
for char in word:
if char.isupper():
count1+=1
elif char.islower():
count2+=1
if(count1<=count2):
print(word.lower())
else:
print(word.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
word = input()
count1=0
count2=0
for char in word:
if char.isupper():
count1+=1
elif char.islower():
count2+=1
if(count1<=count2):
print(word.lower())
else:
print(word.upper())
``` | 3.9455 | MatrixStudio/Codeforces-Python-Submissions |
815 | B | Karen and Test | PROGRAMMING | 2,200 | [
"brute force",
"combinatorics",
"constructive algorithms",
"math"
] | null | null | Karen has just arrived at school, and she has a math test today!
The test is about basic addition and subtraction. Unfortunately, the teachers were too busy writing tasks for Codeforces rounds, and had no time to make an actual test. So, they just put one question in the test that is worth all the points.
There are *... | The first line of input contains a single integer *n* (1<=≤<=*n*<=≤<=200000), the number of numbers written on the first row.
The next line contains *n* integers. Specifically, the *i*-th one among these is *a**i* (1<=≤<=*a**i*<=≤<=109), the *i*-th number on the first row. | Output a single integer on a line by itself, the number on the final row after performing the process above.
Since this number can be quite large, print only the non-negative remainder after dividing it by 109<=+<=7. | [
"5\n3 6 9 12 15\n",
"4\n3 7 5 2\n"
] | [
"36\n",
"1000000006\n"
] | In the first test case, the numbers written on the first row are 3, 6, 9, 12 and 15.
Karen performs the operations as follows:
The non-negative remainder after dividing the final number by 10<sup class="upper-index">9</sup> + 7 is still 36, so this is the correct output.
In the second test case, the numbers written ... | 1,250 | [
{
"input": "5\n3 6 9 12 15",
"output": "36"
},
{
"input": "4\n3 7 5 2",
"output": "1000000006"
},
{
"input": "1\n1",
"output": "1"
},
{
"input": "16\n985629174 189232688 48695377 692426437 952164554 243460498 173956955 210310239 237322183 96515847 678847559 682240199 49879255... | 1,525,291,222 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 77 | 7,065,600 | n = int(input())
l = list(map(int,input().split()))
le = len(l)
m = 1000000007
if(le%2==0):
x = 0
y = 0
for i in range(le):
if(i%2):
y+=l[i]
else:
x+=l[i]
print((x-y)%m)
else:
print((l[0]+l[n-1]+2*l[(n-1)//2])%m) | Title: Karen and Test
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Karen has just arrived at school, and she has a math test today!
The test is about basic addition and subtraction. Unfortunately, the teachers were too busy writing tasks for Codeforces rounds, and had no time to make a... | ```python
n = int(input())
l = list(map(int,input().split()))
le = len(l)
m = 1000000007
if(le%2==0):
x = 0
y = 0
for i in range(le):
if(i%2):
y+=l[i]
else:
x+=l[i]
print((x-y)%m)
else:
print((l[0]+l[n-1]+2*l[(n-1)//2])%m)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
510 | A | Fox And Snake | PROGRAMMING | 800 | [
"implementation"
] | null | null | Fox Ciel starts to learn programming. The first task is drawing a fox! However, that turns out to be too hard for a beginner, so she decides to draw a snake instead.
A snake is a pattern on a *n* by *m* table. Denote *c*-th cell of *r*-th row as (*r*,<=*c*). The tail of the snake is located at (1,<=1), then it's body ... | The only line contains two integers: *n* and *m* (3<=≤<=*n*,<=*m*<=≤<=50).
*n* is an odd number. | Output *n* lines. Each line should contain a string consisting of *m* characters. Do not output spaces. | [
"3 3\n",
"3 4\n",
"5 3\n",
"9 9\n"
] | [
"###\n..#\n###\n",
"####\n...#\n####\n",
"###\n..#\n###\n#..\n###\n",
"#########\n........#\n#########\n#........\n#########\n........#\n#########\n#........\n#########\n"
] | none | 500 | [
{
"input": "3 3",
"output": "###\n..#\n###"
},
{
"input": "3 4",
"output": "####\n...#\n####"
},
{
"input": "5 3",
"output": "###\n..#\n###\n#..\n###"
},
{
"input": "9 9",
"output": "#########\n........#\n#########\n#........\n#########\n........#\n#########\n#........\n#... | 1,677,146,537 | 2,147,483,647 | Python 3 | OK | TESTS | 28 | 46 | 0 | x,y = map(int,input().split())
c = True
for i in range(x):
if i % 2 == 0:
for j in range(y):
print('#',end = "")
else:
if c == False:
print('#',end = "")
for j in range(y-1):
print('.',end = "")
if c == True:
... | Title: Fox And Snake
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Fox Ciel starts to learn programming. The first task is drawing a fox! However, that turns out to be too hard for a beginner, so she decides to draw a snake instead.
A snake is a pattern on a *n* by *m* table. Denote *c*... | ```python
x,y = map(int,input().split())
c = True
for i in range(x):
if i % 2 == 0:
for j in range(y):
print('#',end = "")
else:
if c == False:
print('#',end = "")
for j in range(y-1):
print('.',end = "")
if c == T... | 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,675,495,270 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 3 | 46 | 28,262,400 | a , b=map(int, input().split())
с=a//b
c= с+с//b
print(c+a) | 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
a , b=map(int, input().split())
с=a//b
c= с+с//b
print(c+a)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
522 | A | Reposts | PROGRAMMING | 1,200 | [
"*special",
"dfs and similar",
"dp",
"graphs",
"trees"
] | null | null | One day Polycarp published a funny picture in a social network making a poll about the color of his handle. Many of his friends started reposting Polycarp's joke to their news feed. Some of them reposted the reposts and so on.
These events are given as a sequence of strings "name1 reposted name2", where name1 is the n... | The first line of the input contains integer *n* (1<=≤<=*n*<=≤<=200) — the number of reposts. Next follow the reposts in the order they were made. Each of them is written on a single line and looks as "name1 reposted name2". All the names in the input consist of lowercase or uppercase English letters and/or digits and ... | Print a single integer — the maximum length of a repost chain. | [
"5\ntourist reposted Polycarp\nPetr reposted Tourist\nWJMZBMR reposted Petr\nsdya reposted wjmzbmr\nvepifanov reposted sdya\n",
"6\nMike reposted Polycarp\nMax reposted Polycarp\nEveryOne reposted Polycarp\n111 reposted Polycarp\nVkCup reposted Polycarp\nCodeforces reposted Polycarp\n",
"1\nSoMeStRaNgEgUe repos... | [
"6\n",
"2\n",
"2\n"
] | none | 500 | [
{
"input": "5\ntourist reposted Polycarp\nPetr reposted Tourist\nWJMZBMR reposted Petr\nsdya reposted wjmzbmr\nvepifanov reposted sdya",
"output": "6"
},
{
"input": "6\nMike reposted Polycarp\nMax reposted Polycarp\nEveryOne reposted Polycarp\n111 reposted Polycarp\nVkCup reposted Polycarp\nCodeforc... | 1,495,265,598 | 2,147,483,647 | Python 3 | OK | TESTS | 36 | 62 | 716,800 | n = int(input())
d = {}
for i in range(n):
l = [a.lower() for a in input().split()]
if l[2] in d:
d[l[2]].append(l[0])
else:
d[l[2]] = [l[0]]
dist = {}
vis = {}
def dfs(b):
vis[b] = True
if b in d:
for i in d[b]:
val = vis.get(i,False)
if not val:
dist[i] = dist[b]+1
dfs(i)
dist["polycarp"] = 1... | Title: Reposts
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
One day Polycarp published a funny picture in a social network making a poll about the color of his handle. Many of his friends started reposting Polycarp's joke to their news feed. Some of them reposted the reposts and so on.
... | ```python
n = int(input())
d = {}
for i in range(n):
l = [a.lower() for a in input().split()]
if l[2] in d:
d[l[2]].append(l[0])
else:
d[l[2]] = [l[0]]
dist = {}
vis = {}
def dfs(b):
vis[b] = True
if b in d:
for i in d[b]:
val = vis.get(i,False)
if not val:
dist[i] = dist[b]+1
dfs(i)
dist["poly... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
489 | B | BerSU Ball | PROGRAMMING | 1,200 | [
"dfs and similar",
"dp",
"graph matchings",
"greedy",
"sortings",
"two pointers"
] | null | null | The Berland State University is hosting a ballroom dance in celebration of its 100500-th anniversary! *n* boys and *m* girls are already busy rehearsing waltz, minuet, polonaise and quadrille moves.
We know that several boy&girl pairs are going to be invited to the ball. However, the partners' dancing skill in eac... | The first line contains an integer *n* (1<=≤<=*n*<=≤<=100) — the number of boys. The second line contains sequence *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=100), where *a**i* is the *i*-th boy's dancing skill.
Similarly, the third line contains an integer *m* (1<=≤<=*m*<=≤<=100) — the number of girls. The fourth l... | Print a single number — the required maximum possible number of pairs. | [
"4\n1 4 6 2\n5\n5 1 5 7 9\n",
"4\n1 2 3 4\n4\n10 11 12 13\n",
"5\n1 1 1 1 1\n3\n1 2 3\n"
] | [
"3\n",
"0\n",
"2\n"
] | none | 1,000 | [
{
"input": "4\n1 4 6 2\n5\n5 1 5 7 9",
"output": "3"
},
{
"input": "4\n1 2 3 4\n4\n10 11 12 13",
"output": "0"
},
{
"input": "5\n1 1 1 1 1\n3\n1 2 3",
"output": "2"
},
{
"input": "1\n1\n1\n1",
"output": "1"
},
{
"input": "2\n1 10\n1\n9",
"output": "1"
},
{... | 1,682,280,192 | 2,147,483,647 | Python 3 | OK | TESTS | 81 | 62 | 0 | n=int(input())
list1=list(map(int,input().split()))
m=int(input())
list2=list(map(int,input().split()))
count=0
k=0
l=0
list1.sort()
list2.sort()
while k<n and l<m:
if abs(list1[k] - list2[l]) <= 1:
count += 1
k += 1
l += 1
elif list1[k] < list2[l]:
... | Title: BerSU Ball
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The Berland State University is hosting a ballroom dance in celebration of its 100500-th anniversary! *n* boys and *m* girls are already busy rehearsing waltz, minuet, polonaise and quadrille moves.
We know that several boy... | ```python
n=int(input())
list1=list(map(int,input().split()))
m=int(input())
list2=list(map(int,input().split()))
count=0
k=0
l=0
list1.sort()
list2.sort()
while k<n and l<m:
if abs(list1[k] - list2[l]) <= 1:
count += 1
k += 1
l += 1
elif list1[k] < list... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
886 | A | ACM ICPC | PROGRAMMING | 1,000 | [
"brute force"
] | null | null | In a small but very proud high school it was decided to win ACM ICPC. This goal requires to compose as many teams of three as possible, but since there were only 6 students who wished to participate, the decision was to build exactly two teams.
After practice competition, participant number *i* got a score of *a**i*. ... | The single line contains six integers *a*1,<=...,<=*a*6 (0<=≤<=*a**i*<=≤<=1000) — scores of the participants | Print "YES" (quotes for clarity), if it is possible to build teams with equal score, and "NO" otherwise.
You can print each character either upper- or lowercase ("YeS" and "yes" are valid when the answer is "YES"). | [
"1 3 2 1 2 1\n",
"1 1 1 1 1 99\n"
] | [
"YES\n",
"NO\n"
] | In the first sample, first team can be composed of 1st, 2nd and 6th participant, second — of 3rd, 4th and 5th: team scores are 1 + 3 + 1 = 2 + 1 + 2 = 5.
In the second sample, score of participant number 6 is too high: his team score will be definitely greater. | 500 | [
{
"input": "1 3 2 1 2 1",
"output": "YES"
},
{
"input": "1 1 1 1 1 99",
"output": "NO"
},
{
"input": "1000 1000 1000 1000 1000 1000",
"output": "YES"
},
{
"input": "0 0 0 0 0 0",
"output": "YES"
},
{
"input": "633 609 369 704 573 416",
"output": "NO"
},
{
... | 1,523,108,580 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 78 | 7,065,600 | import itertools
# arr = map(int, input().splite())
arr = [1, 1, 1, 1, 1, 99]
rn = range(6)
def othersIters(arr):
_arr = set(rn)
return list(_arr.symmetric_difference(arr))
t = False
for i in list(itertools.combinations(rn, 3)):
summ1 = sum((arr[j] for j in i))
summ2 = sum((arr[j] for j in othersIters(i)))
if su... | Title: ACM ICPC
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
In a small but very proud high school it was decided to win ACM ICPC. This goal requires to compose as many teams of three as possible, but since there were only 6 students who wished to participate, the decision was to build ... | ```python
import itertools
# arr = map(int, input().splite())
arr = [1, 1, 1, 1, 1, 99]
rn = range(6)
def othersIters(arr):
_arr = set(rn)
return list(_arr.symmetric_difference(arr))
t = False
for i in list(itertools.combinations(rn, 3)):
summ1 = sum((arr[j] for j in i))
summ2 = sum((arr[j] for j in othersIters(i... | 0 | MatrixStudio/Codeforces-Python-Submissions |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.