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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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,673,714,944 | 2,147,483,647 | Python 3 | OK | TESTS | 30 | 92 | 0 | word = input()
word_strip = word.strip()
uppercase_count, lower_case_count = 0,0
for x in word_strip:
if x.isupper() == True:
uppercase_count = uppercase_count + 1
elif x.islower() == True:
lower_case_count = lower_case_count + 1
if uppercase_count > lower_case_count:
word = w... | 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()
word_strip = word.strip()
uppercase_count, lower_case_count = 0,0
for x in word_strip:
if x.isupper() == True:
uppercase_count = uppercase_count + 1
elif x.islower() == True:
lower_case_count = lower_case_count + 1
if uppercase_count > lower_case_count:
... | 3.977 | MatrixStudio/Codeforces-Python-Submissions |
534 | A | Exam | PROGRAMMING | 1,100 | [
"constructive algorithms",
"implementation",
"math"
] | null | null | An exam for *n* students will take place in a long and narrow room, so the students will sit in a line in some order. The teacher suspects that students with adjacent numbers (*i* and *i*<=+<=1) always studied side by side and became friends and if they take an exam sitting next to each other, they will help each other... | A single line contains integer *n* (1<=≤<=*n*<=≤<=5000) — the number of students at an exam. | In the first line print integer *k* — the maximum number of students who can be seated so that no two students with adjacent numbers sit next to each other.
In the second line print *k* distinct integers *a*1,<=*a*2,<=...,<=*a**k* (1<=≤<=*a**i*<=≤<=*n*), where *a**i* is the number of the student on the *i*-th position... | [
"6",
"3\n"
] | [
"6\n1 5 3 6 2 4",
"2\n1 3"
] | none | 500 | [
{
"input": "6",
"output": "6\n5 3 1 6 4 2 "
},
{
"input": "3",
"output": "2\n1 3"
},
{
"input": "1",
"output": "1\n1 "
},
{
"input": "2",
"output": "1\n1"
},
{
"input": "4",
"output": "4\n3 1 4 2 "
},
{
"input": "5",
"output": "5\n5 3 1 4 2 "
},
... | 1,428,855,520 | 1,120 | Python 3 | WRONG_ANSWER | PRETESTS | 4 | 46 | 0 | n = int(input())
if n > 3:
print(n)
a = []
for i in range(0, n, 2):
a.append(i+1)
for i in range(1, n, 2):
a.append(i+1)
for i in range(n-1):
print(a[i], end = ' ')
print(a[n-1])
else:
if n < 3:
print(1, 1, sep = '\n')
else:
print(2,... | Title: Exam
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
An exam for *n* students will take place in a long and narrow room, so the students will sit in a line in some order. The teacher suspects that students with adjacent numbers (*i* and *i*<=+<=1) always studied side by side and bec... | ```python
n = int(input())
if n > 3:
print(n)
a = []
for i in range(0, n, 2):
a.append(i+1)
for i in range(1, n, 2):
a.append(i+1)
for i in range(n-1):
print(a[i], end = ' ')
print(a[n-1])
else:
if n < 3:
print(1, 1, sep = '\n')
else:
... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
275 | A | Lights Out | PROGRAMMING | 900 | [
"implementation"
] | null | null | Lenny is playing a game on a 3<=×<=3 grid of lights. In the beginning of the game all lights are switched on. Pressing any of the lights will toggle it and all side-adjacent lights. The goal of the game is to switch all the lights off. We consider the toggling as follows: if the light was switched on then it will be sw... | The input consists of three rows. Each row contains three integers each between 0 to 100 inclusive. The *j*-th number in the *i*-th row is the number of times the *j*-th light of the *i*-th row of the grid is pressed. | Print three lines, each containing three characters. The *j*-th character of the *i*-th line is "1" if and only if the corresponding light is switched on, otherwise it's "0". | [
"1 0 0\n0 0 0\n0 0 1\n",
"1 0 1\n8 8 8\n2 0 3\n"
] | [
"001\n010\n100\n",
"010\n011\n100\n"
] | none | 500 | [
{
"input": "1 0 0\n0 0 0\n0 0 1",
"output": "001\n010\n100"
},
{
"input": "1 0 1\n8 8 8\n2 0 3",
"output": "010\n011\n100"
},
{
"input": "13 85 77\n25 50 45\n65 79 9",
"output": "000\n010\n000"
},
{
"input": "96 95 5\n8 84 74\n67 31 61",
"output": "011\n011\n101"
},
{... | 1,628,916,994 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 62 | 6,963,200 | matrix = [[0, 0, 0, 0, 0]]
for _ in range(0, 3):
line = input().split(' ')
line = [int(x) for x in line]
line.append(0)
line.insert(0,0)
matrix.append(line)
matrix.append([0, 0, 0, 0, 0])
row = []
output = []
for i in range(1, 4):
for j in range(1, 4):
toggle = matrix[i][j]... | Title: Lights Out
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Lenny is playing a game on a 3<=×<=3 grid of lights. In the beginning of the game all lights are switched on. Pressing any of the lights will toggle it and all side-adjacent lights. The goal of the game is to switch all the ... | ```python
matrix = [[0, 0, 0, 0, 0]]
for _ in range(0, 3):
line = input().split(' ')
line = [int(x) for x in line]
line.append(0)
line.insert(0,0)
matrix.append(line)
matrix.append([0, 0, 0, 0, 0])
row = []
output = []
for i in range(1, 4):
for j in range(1, 4):
toggle = ma... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
0 | none | none | none | 0 | [
"none"
] | null | null | A classroom in a school has six rows with 3 desks in each row. Two people can use the same desk: one sitting on the left and one sitting on the right.
Some places are already occupied, and some places are vacant. Petya has just entered the class and wants to occupy the most convenient place. The conveniences of the p... | The input consists of 6 lines. Each line describes one row of desks, starting from the closest to the blackboard. Each line is given in the following format: two characters, each is '*' or '.' — the description of the left desk in the current row; a character '-' — the aisle; two characters, each is '*' or '.' — the de... | Print the plan of the classroom after Petya takes one of the most convenient for him places. Mark this place with the letter 'P'. There should be exactly one letter 'P' in the plan. Petya can only take a vacant place. In all other places the output should coincide with the input.
If there are multiple answers, print a... | [
"..-**-..\n..-**-..\n..-..-..\n..-..-..\n..-..-..\n..-..-..\n",
"**-**-**\n**-**-**\n..-**-.*\n**-**-**\n..-..-..\n..-**-..\n",
"**-**-*.\n*.-*.-**\n**-**-**\n**-**-**\n..-..-..\n..-**-..\n"
] | [
"..-**-..\n..-**-..\n..-..-..\n..-P.-..\n..-..-..\n..-..-..\n",
"**-**-**\n**-**-**\n..-**-.*\n**-**-**\n..-P.-..\n..-**-..\n",
"**-**-*.\n*.-*P-**\n**-**-**\n**-**-**\n..-..-..\n..-**-..\n"
] | In the first example the maximum convenience is 3.
In the second example the maximum convenience is 2.
In the third example the maximum convenience is 4. | 0 | [
{
"input": "..-**-..\n..-**-..\n..-..-..\n..-..-..\n..-..-..\n..-..-..",
"output": "..-**-..\n..-**-..\n..-..-..\n..-P.-..\n..-..-..\n..-..-.."
},
{
"input": "**-**-**\n**-**-**\n..-**-.*\n**-**-**\n..-..-..\n..-**-..",
"output": "**-**-**\n**-**-**\n..-**-.*\n**-**-**\n..-P.-..\n..-**-.."
},
... | 1,521,305,072 | 4,172 | Python 3 | COMPILATION_ERROR | TESTS | 0 | 0 | 0 | # -*- coding: UTF-8 -*-
flag=0
for i in range(6)
name=raw_input()
for j in range(3,4,1)
if flag=0
if name[i]="."
name[i]="P"
flag=1
break#
for j in range(0,1,1)
if flag=0
if name[i]="."
name[i]="P"
flag=1
break#
for j in range(6,7,1)
if flag=0
if name[i]="."
... | Title: none
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
A classroom in a school has six rows with 3 desks in each row. Two people can use the same desk: one sitting on the left and one sitting on the right.
Some places are already occupied, and some places are vacant. Petya has just ... | ```python
# -*- coding: UTF-8 -*-
flag=0
for i in range(6)
name=raw_input()
for j in range(3,4,1)
if flag=0
if name[i]="."
name[i]="P"
flag=1
break#
for j in range(0,1,1)
if flag=0
if name[i]="."
name[i]="P"
flag=1
break#
for j in range(6,7,1)
if flag=0
if na... | -1 | MatrixStudio/Codeforces-Python-Submissions | |
194 | A | Exams | PROGRAMMING | 900 | [
"implementation",
"math"
] | null | null | One day the Codeforces round author sat exams. He had *n* exams and he needed to get an integer from 2 to 5 for each exam. He will have to re-sit each failed exam, i.e. the exam that gets mark 2.
The author would need to spend too much time and effort to make the sum of his marks strictly more than *k*. That could ha... | The single input line contains space-separated integers *n* and *k* (1<=≤<=*n*<=≤<=50, 1<=≤<=*k*<=≤<=250) — the number of exams and the required sum of marks.
It is guaranteed that there exists a way to pass *n* exams in the way that makes the sum of marks equal exactly *k*. | Print the single number — the minimum number of exams that the author will get a 2 for, considering that the sum of marks for all exams must equal *k*. | [
"4 8\n",
"4 10\n",
"1 3\n"
] | [
"4\n",
"2\n",
"0\n"
] | In the first sample the author has to get a 2 for all his exams.
In the second sample he should get a 3 for two exams and a 2 for two more.
In the third sample he should get a 3 for one exam. | 500 | [
{
"input": "4 8",
"output": "4"
},
{
"input": "4 10",
"output": "2"
},
{
"input": "1 3",
"output": "0"
},
{
"input": "1 2",
"output": "1"
},
{
"input": "4 9",
"output": "3"
},
{
"input": "50 234",
"output": "0"
},
{
"input": "50 100",
"... | 1,632,451,886 | 2,147,483,647 | PyPy 3 | OK | TESTS | 38 | 218 | 20,172,800 | n, k = map(int, input().split())
if k < 3 * n:
ans = 3 * n - k
if 3 * n <= k:
ans = 0
print(ans) | Title: Exams
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
One day the Codeforces round author sat exams. He had *n* exams and he needed to get an integer from 2 to 5 for each exam. He will have to re-sit each failed exam, i.e. the exam that gets mark 2.
The author would need to spend ... | ```python
n, k = map(int, input().split())
if k < 3 * n:
ans = 3 * n - k
if 3 * n <= k:
ans = 0
print(ans)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
987 | A | Infinity Gauntlet | PROGRAMMING | 800 | [
"implementation"
] | null | null | You took a peek on Thanos wearing Infinity Gauntlet. In the Gauntlet there is a place for six Infinity Gems:
- the Power Gem of purple color, - the Time Gem of green color, - the Space Gem of blue color, - the Soul Gem of orange color, - the Reality Gem of red color, - the Mind Gem of yellow color.
Using colors... | In the first line of input there is one integer $n$ ($0 \le n \le 6$) — the number of Gems in Infinity Gauntlet.
In next $n$ lines there are colors of Gems you saw. Words used for colors are: purple, green, blue, orange, red, yellow. It is guaranteed that all the colors are distinct. All colors are given in lowercase ... | In the first line output one integer $m$ ($0 \le m \le 6$) — the number of absent Gems.
Then in $m$ lines print the names of absent Gems, each on its own line. Words used for names are: Power, Time, Space, Soul, Reality, Mind. Names can be printed in any order. Keep the first letter uppercase, others lowercase. | [
"4\nred\npurple\nyellow\norange\n",
"0\n"
] | [
"2\nSpace\nTime\n",
"6\nTime\nMind\nSoul\nPower\nReality\nSpace\n"
] | In the first sample Thanos already has Reality, Power, Mind and Soul Gems, so he needs two more: Time and Space.
In the second sample Thanos doesn't have any Gems, so he needs all six. | 500 | [
{
"input": "4\nred\npurple\nyellow\norange",
"output": "2\nSpace\nTime"
},
{
"input": "0",
"output": "6\nMind\nSpace\nPower\nTime\nReality\nSoul"
},
{
"input": "6\npurple\nblue\nyellow\nred\ngreen\norange",
"output": "0"
},
{
"input": "1\npurple",
"output": "5\nTime\nReal... | 1,654,897,075 | 2,147,483,647 | Python 3 | OK | TESTS | 64 | 46 | 0 | n = int(input())
l1 = ["Time","Mind","Soul","Power","Reality","Space"]
l2 = ["green","yellow","orange","purple","red","blue"]
lst = []
for i in range(n):
b = str(input()).lower()
lst.append(b)
print(6-n)
for j in l2:
if j not in lst:
print(l1[l2.index(j)])
... | Title: Infinity Gauntlet
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You took a peek on Thanos wearing Infinity Gauntlet. In the Gauntlet there is a place for six Infinity Gems:
- the Power Gem of purple color, - the Time Gem of green color, - the Space Gem of blue color, - the So... | ```python
n = int(input())
l1 = ["Time","Mind","Soul","Power","Reality","Space"]
l2 = ["green","yellow","orange","purple","red","blue"]
lst = []
for i in range(n):
b = str(input()).lower()
lst.append(b)
print(6-n)
for j in l2:
if j not in lst:
print(l1[l2.index(j)])
... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
580 | A | Kefa and First Steps | PROGRAMMING | 900 | [
"brute force",
"dp",
"implementation"
] | null | null | Kefa decided to make some money doing business on the Internet for exactly *n* days. He knows that on the *i*-th day (1<=≤<=*i*<=≤<=*n*) he makes *a**i* money. Kefa loves progress, that's why he wants to know the length of the maximum non-decreasing subsegment in sequence *a**i*. Let us remind you that the subsegment o... | The first line contains integer *n* (1<=≤<=*n*<=≤<=105).
The second line contains *n* integers *a*1,<=<=*a*2,<=<=...,<=<=*a**n* (1<=≤<=*a**i*<=≤<=109). | Print a single integer — the length of the maximum non-decreasing subsegment of sequence *a*. | [
"6\n2 2 1 3 4 1\n",
"3\n2 2 9\n"
] | [
"3",
"3"
] | In the first test the maximum non-decreasing subsegment is the numbers from the third to the fifth one.
In the second test the maximum non-decreasing subsegment is the numbers from the first to the third one. | 750 | [
{
"input": "6\n2 2 1 3 4 1",
"output": "3"
},
{
"input": "3\n2 2 9",
"output": "3"
},
{
"input": "5\n10 100 111 1 2",
"output": "3"
},
{
"input": "10\n1 2 3 4 1 2 3 4 5 6",
"output": "6"
},
{
"input": "50\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... | 1,692,191,134 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 8 | 46 | 1,024,000 | n = int(input())
seq = list(map(int,input().split()))
counter=1
prev=seq[0]
seq_counter=[]
for i in range(1,n):
if seq[i]>=prev:
counter+=1
if i==(n-1):
seq_counter.append(counter)
else:
seq_counter.append(counter)
counter=1
prev=seq[i]
print(max(seq_counter)) | Title: Kefa and First Steps
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Kefa decided to make some money doing business on the Internet for exactly *n* days. He knows that on the *i*-th day (1<=≤<=*i*<=≤<=*n*) he makes *a**i* money. Kefa loves progress, that's why he wants to know the l... | ```python
n = int(input())
seq = list(map(int,input().split()))
counter=1
prev=seq[0]
seq_counter=[]
for i in range(1,n):
if seq[i]>=prev:
counter+=1
if i==(n-1):
seq_counter.append(counter)
else:
seq_counter.append(counter)
counter=1
prev=seq[i]
print(max(seq_cou... | -1 | 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,640,705,110 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 92 | 0 | for i in range(len(s)):
if 65 <= ord(s[i]) < 90:
b += 1
if 97 <= ord(s[i]) < 122:
d += 1
if b > d:
print(s.upper())
elif b == d:
print(s.lower())
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
for i in range(len(s)):
if 65 <= ord(s[i]) < 90:
b += 1
if 97 <= ord(s[i]) < 122:
d += 1
if b > d:
print(s.upper())
elif b == d:
print(s.lower())
else:
print(s.lower())
``` | -1 | MatrixStudio/Codeforces-Python-Submissions |
637 | C | Promocodes with Mistakes | PROGRAMMING | 1,400 | [
"*special",
"brute force",
"constructive algorithms",
"implementation"
] | null | null | During a New Year special offer the "Sudislavl Bars" offered *n* promo codes. Each promo code consists of exactly six digits and gives right to one free cocktail at the bar "Mosquito Shelter". Of course, all the promocodes differ.
As the "Mosquito Shelter" opens only at 9, and partying in Sudislavl usually begins at a... | The first line of the output contains number *n* (1<=≤<=*n*<=≤<=1000) — the number of promocodes.
Each of the next *n* lines contains a single promocode, consisting of exactly 6 digits. It is guaranteed that all the promocodes are distinct. Promocodes can start from digit "0". | Print the maximum *k* (naturally, not exceeding the length of the promocode), such that any promocode can be uniquely identified if it is typed with at most *k* mistakes. | [
"2\n000000\n999999\n",
"6\n211111\n212111\n222111\n111111\n112111\n121111\n"
] | [
"2\n",
"0\n"
] | In the first sample *k* < 3, so if a bar customer types in value "090909", then it will be impossible to define which promocode exactly corresponds to it. | 1,500 | [
{
"input": "2\n000000\n999999",
"output": "2"
},
{
"input": "6\n211111\n212111\n222111\n111111\n112111\n121111",
"output": "0"
},
{
"input": "1\n123456",
"output": "6"
},
{
"input": "2\n000000\n099999",
"output": "2"
},
{
"input": "2\n000000\n009999",
"output"... | 1,457,904,007 | 33,607 | Python 3 | TIME_LIMIT_EXCEEDED | PRETESTS | 12 | 1,000 | 0 | n = int(input())
s = [''] * (n)
for i in range(n):
s[i] = input()
if (n == 1):
print(6)
else:
diff = 6
for u in s:
for v in s:
kol = 0
for i in range(6):
if u[i] != v[i]:
kol += 1
if kol > 0:
... | Title: Promocodes with Mistakes
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
During a New Year special offer the "Sudislavl Bars" offered *n* promo codes. Each promo code consists of exactly six digits and gives right to one free cocktail at the bar "Mosquito Shelter". Of course, all th... | ```python
n = int(input())
s = [''] * (n)
for i in range(n):
s[i] = input()
if (n == 1):
print(6)
else:
diff = 6
for u in s:
for v in s:
kol = 0
for i in range(6):
if u[i] != v[i]:
kol += 1
if kol... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
682 | A | Alyona and Numbers | PROGRAMMING | 1,100 | [
"constructive algorithms",
"math",
"number theory"
] | null | null | After finishing eating her bun, Alyona came up with two integers *n* and *m*. She decided to write down two columns of integers — the first column containing integers from 1 to *n* and the second containing integers from 1 to *m*. Now the girl wants to count how many pairs of integers she can choose, one from the first... | The only line of the input contains two integers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=1<=000<=000). | Print the only integer — the number of pairs of integers (*x*,<=*y*) such that 1<=≤<=*x*<=≤<=*n*, 1<=≤<=*y*<=≤<=*m* and (*x*<=+<=*y*) is divisible by 5. | [
"6 12\n",
"11 14\n",
"1 5\n",
"3 8\n",
"5 7\n",
"21 21\n"
] | [
"14\n",
"31\n",
"1\n",
"5\n",
"7\n",
"88\n"
] | Following pairs are suitable in the first sample case:
- for *x* = 1 fits *y* equal to 4 or 9; - for *x* = 2 fits *y* equal to 3 or 8; - for *x* = 3 fits *y* equal to 2, 7 or 12; - for *x* = 4 fits *y* equal to 1, 6 or 11; - for *x* = 5 fits *y* equal to 5 or 10; - for *x* = 6 fits *y* equal to 4 or 9.
Only th... | 500 | [
{
"input": "6 12",
"output": "14"
},
{
"input": "11 14",
"output": "31"
},
{
"input": "1 5",
"output": "1"
},
{
"input": "3 8",
"output": "5"
},
{
"input": "5 7",
"output": "7"
},
{
"input": "21 21",
"output": "88"
},
{
"input": "10 15",
... | 1,671,391,288 | 2,147,483,647 | PyPy 3 | COMPILATION_ERROR | TESTS | 0 | 0 | 0 | #include <iostream>
using namespace std;
int main()
{
int n,m,cnt=0;
cin>>n>>m;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
if((i+j) % 5==0)
{
cnt++;
}
}
}
cout<<cnt<<endl;
}
| Title: Alyona and Numbers
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
After finishing eating her bun, Alyona came up with two integers *n* and *m*. She decided to write down two columns of integers — the first column containing integers from 1 to *n* and the second containing integers ... | ```python
#include <iostream>
using namespace std;
int main()
{
int n,m,cnt=0;
cin>>n>>m;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
if((i+j) % 5==0)
{
cnt++;
}
}
}
cout<<cnt<<endl;
}
``` | -1 | MatrixStudio/Codeforces-Python-Submissions | |
659 | D | Bicycle Race | PROGRAMMING | 1,500 | [
"geometry",
"implementation",
"math"
] | null | null | Maria participates in a bicycle race.
The speedway takes place on the shores of Lake Lucerne, just repeating its contour. As you know, the lake shore consists only of straight sections, directed to the north, south, east or west.
Let's introduce a system of coordinates, directing the *Ox* axis from west to east, and ... | The first line of the input contains an integer *n* (4<=≤<=*n*<=≤<=1000) — the number of straight sections of the track.
The following (*n*<=+<=1)-th line contains pairs of integers (*x**i*,<=*y**i*) (<=-<=10<=000<=≤<=*x**i*,<=*y**i*<=≤<=10<=000). The first of these points is the starting position. The *i*-th straight... | Print a single integer — the number of dangerous turns on the track. | [
"6\n0 0\n0 1\n1 1\n1 2\n2 2\n2 0\n0 0\n",
"16\n1 1\n1 5\n3 5\n3 7\n2 7\n2 9\n6 9\n6 7\n5 7\n5 3\n4 3\n4 4\n3 4\n3 2\n5 2\n5 1\n1 1\n"
] | [
"1\n",
"6\n"
] | The first sample corresponds to the picture:
The picture shows that you can get in the water under unfortunate circumstances only at turn at the point (1, 1). Thus, the answer is 1. | 1,250 | [
{
"input": "6\n0 0\n0 1\n1 1\n1 2\n2 2\n2 0\n0 0",
"output": "1"
},
{
"input": "16\n1 1\n1 5\n3 5\n3 7\n2 7\n2 9\n6 9\n6 7\n5 7\n5 3\n4 3\n4 4\n3 4\n3 2\n5 2\n5 1\n1 1",
"output": "6"
},
{
"input": "4\n-10000 -10000\n-10000 10000\n10000 10000\n10000 -10000\n-10000 -10000",
"output": ... | 1,613,737,027 | 2,147,483,647 | Python 3 | OK | TESTS | 22 | 61 | 307,200 | def dangerous_turns(number_of_straight_sections):
return (number_of_straight_sections - 4) // 2
def main():
number_of_straight_sections = int(input())
points = []
for i in range(number_of_straight_sections + 1):
point = list(map(lambda x: float(x), input().split(" ")))
points.append(point)
print(dangerous_t... | Title: Bicycle Race
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Maria participates in a bicycle race.
The speedway takes place on the shores of Lake Lucerne, just repeating its contour. As you know, the lake shore consists only of straight sections, directed to the north, south, east ... | ```python
def dangerous_turns(number_of_straight_sections):
return (number_of_straight_sections - 4) // 2
def main():
number_of_straight_sections = int(input())
points = []
for i in range(number_of_straight_sections + 1):
point = list(map(lambda x: float(x), input().split(" ")))
points.append(point)
print(d... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
551 | A | GukiZ and Contest | PROGRAMMING | 800 | [
"brute force",
"implementation",
"sortings"
] | null | null | Professor GukiZ likes programming contests. He especially likes to rate his students on the contests he prepares. Now, he has decided to prepare a new contest.
In total, *n* students will attend, and before the start, every one of them has some positive integer rating. Students are indexed from 1 to *n*. Let's denote... | The first line contains integer *n* (1<=≤<=*n*<=≤<=2000), number of GukiZ's students.
The second line contains *n* numbers *a*1,<=*a*2,<=... *a**n* (1<=≤<=*a**i*<=≤<=2000) where *a**i* is the rating of *i*-th student (1<=≤<=*i*<=≤<=*n*). | In a single line, print the position after the end of the contest for each of *n* students in the same order as they appear in the input. | [
"3\n1 3 3\n",
"1\n1\n",
"5\n3 5 3 4 5\n"
] | [
"3 1 1\n",
"1\n",
"4 1 4 3 1\n"
] | In the first sample, students 2 and 3 are positioned first (there is no other student with higher rating), and student 1 is positioned third since there are two students with higher rating.
In the second sample, first student is the only one on the contest.
In the third sample, students 2 and 5 share the first positi... | 500 | [
{
"input": "3\n1 3 3",
"output": "3 1 1"
},
{
"input": "1\n1",
"output": "1"
},
{
"input": "5\n3 5 3 4 5",
"output": "4 1 4 3 1"
},
{
"input": "7\n1 3 5 4 2 2 1",
"output": "6 3 1 2 4 4 6"
},
{
"input": "11\n5 6 4 2 9 7 6 6 6 6 7",
"output": "9 4 10 11 1 2 4 4... | 1,589,814,841 | 2,147,483,647 | PyPy 3 | OK | TESTS | 36 | 171 | 23,347,200 |
n=int(input())
a=list(map(int,input().split()))
s=list(set(a))
s.sort(reverse=True)
#print(s)
ans=[0]*n
k=1
for y in s:
count=0
for j in range(0,n):
if a[j]==y:
ans[j]=k
count+=1
else:
continue
k+=count
for x in ans:
print(x,end=' ')
#unknown_2433 | Title: GukiZ and Contest
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Professor GukiZ likes programming contests. He especially likes to rate his students on the contests he prepares. Now, he has decided to prepare a new contest.
In total, *n* students will attend, and before the star... | ```python
n=int(input())
a=list(map(int,input().split()))
s=list(set(a))
s.sort(reverse=True)
#print(s)
ans=[0]*n
k=1
for y in s:
count=0
for j in range(0,n):
if a[j]==y:
ans[j]=k
count+=1
else:
continue
k+=count
for x in ans:
print(x,end=' ')
#unknown_2433
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
620 | B | Grandfather Dovlet’s calculator | PROGRAMMING | 1,000 | [
"implementation"
] | null | null | Once Max found an electronic calculator from his grandfather Dovlet's chest. He noticed that the numbers were written with seven-segment indicators ([https://en.wikipedia.org/wiki/Seven-segment_display](https://en.wikipedia.org/wiki/Seven-segment_display)).
Max starts to type all the values from *a* to *b*. After typi... | The only line contains two integers *a*,<=*b* (1<=≤<=*a*<=≤<=*b*<=≤<=106) — the first and the last number typed by Max. | Print the only integer *a* — the total number of printed segments. | [
"1 3\n",
"10 15\n"
] | [
"12\n",
"39\n"
] | none | 0 | [
{
"input": "1 3",
"output": "12"
},
{
"input": "10 15",
"output": "39"
},
{
"input": "1 100",
"output": "928"
},
{
"input": "100 10000",
"output": "188446"
},
{
"input": "213 221442",
"output": "5645356"
},
{
"input": "1 1000000",
"output": "287333... | 1,461,158,649 | 849 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 5 | 1,000 | 4,608,000 | a, b = map(int, input().split())
res = 0
for i in range(a, b + 1):
s = str(i)
for j in s:
if j == '0':
res += 6
if j == '1':
res += 2
if j == '2':
res += 5
if j == '3':
res += 5
if j == '4':
res ... | Title: Grandfather Dovlet’s calculator
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Once Max found an electronic calculator from his grandfather Dovlet's chest. He noticed that the numbers were written with seven-segment indicators ([https://en.wikipedia.org/wiki/Seven-segment_display](... | ```python
a, b = map(int, input().split())
res = 0
for i in range(a, b + 1):
s = str(i)
for j in s:
if j == '0':
res += 6
if j == '1':
res += 2
if j == '2':
res += 5
if j == '3':
res += 5
if j == '4':
... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
879 | A | Borya's Diagnosis | PROGRAMMING | 900 | [
"implementation"
] | null | null | It seems that Borya is seriously sick. He is going visit *n* doctors to find out the exact diagnosis. Each of the doctors needs the information about all previous visits, so Borya has to visit them in the prescribed order (i.e. Borya should first visit doctor 1, then doctor 2, then doctor 3 and so on). Borya will get t... | First line contains an integer *n* — number of doctors (1<=≤<=*n*<=≤<=1000).
Next *n* lines contain two numbers *s**i* and *d**i* (1<=≤<=*s**i*,<=*d**i*<=≤<=1000). | Output a single integer — the minimum day at which Borya can visit the last doctor. | [
"3\n2 2\n1 2\n2 2\n",
"2\n10 1\n6 5\n"
] | [
"4\n",
"11\n"
] | In the first sample case, Borya can visit all doctors on days 2, 3 and 4.
In the second sample case, Borya can visit all doctors on days 10 and 11. | 500 | [
{
"input": "3\n2 2\n1 2\n2 2",
"output": "4"
},
{
"input": "2\n10 1\n6 5",
"output": "11"
},
{
"input": "3\n6 10\n3 3\n8 2",
"output": "10"
},
{
"input": "4\n4 8\n10 10\n4 2\n8 2",
"output": "14"
},
{
"input": "5\n7 1\n5 1\n6 1\n1 6\n6 8",
"output": "14"
},
... | 1,559,623,524 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 12 | 108 | 307,200 | ##a = list(map(int, input().split()))
##print(' '.join(map(str, res)))
n = int(input())
dat = list()
for i in range(n):
dat.append(list(map(int, input().split())))
day = dat[0][0]
for i in range(1, n):
s = dat[i][0]
d = dat[i][1]
k = (day-s+d)//d
day = s+k*d
print(day) | Title: Borya's Diagnosis
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
It seems that Borya is seriously sick. He is going visit *n* doctors to find out the exact diagnosis. Each of the doctors needs the information about all previous visits, so Borya has to visit them in the prescribed o... | ```python
##a = list(map(int, input().split()))
##print(' '.join(map(str, res)))
n = int(input())
dat = list()
for i in range(n):
dat.append(list(map(int, input().split())))
day = dat[0][0]
for i in range(1, n):
s = dat[i][0]
d = dat[i][1]
k = (day-s+d)//d
day = s+k*d
print(day)
``` | 0 | 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,583,405,245 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 1 | 109 | 0 | k=0
test=[]
for i in range(int(input())):
rating= input().split()
if int(rating[0])!=int(rating[1]):
k=1
test.append(int(rating[0]))
check =test
test.sort(reverse=True)
if k==1:
print("rated")
elif check==test:
print("maybe")
else:
print("rated") | 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
k=0
test=[]
for i in range(int(input())):
rating= input().split()
if int(rating[0])!=int(rating[1]):
k=1
test.append(int(rating[0]))
check =test
test.sort(reverse=True)
if k==1:
print("rated")
elif check==test:
print("maybe")
else:
print("rated")
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
714 | A | Meeting of Old Friends | PROGRAMMING | 1,100 | [
"implementation",
"math"
] | null | null | Today an outstanding event is going to happen in the forest — hedgehog Filya will come to his old fried Sonya!
Sonya is an owl and she sleeps during the day and stay awake from minute *l*1 to minute *r*1 inclusive. Also, during the minute *k* she prinks and is unavailable for Filya.
Filya works a lot and he plans to ... | The only line of the input contains integers *l*1, *r*1, *l*2, *r*2 and *k* (1<=≤<=*l*1,<=*r*1,<=*l*2,<=*r*2,<=*k*<=≤<=1018, *l*1<=≤<=*r*1, *l*2<=≤<=*r*2), providing the segments of time for Sonya and Filya and the moment of time when Sonya prinks. | Print one integer — the number of minutes Sonya and Filya will be able to spend together. | [
"1 10 9 20 1\n",
"1 100 50 200 75\n"
] | [
"2\n",
"50\n"
] | In the first sample, they will be together during minutes 9 and 10.
In the second sample, they will be together from minute 50 to minute 74 and from minute 76 to minute 100. | 500 | [
{
"input": "1 10 9 20 1",
"output": "2"
},
{
"input": "1 100 50 200 75",
"output": "50"
},
{
"input": "6 6 5 8 9",
"output": "1"
},
{
"input": "1 1000000000 1 1000000000 1",
"output": "999999999"
},
{
"input": "5 100 8 8 8",
"output": "0"
},
{
"input":... | 1,597,100,262 | 2,147,483,647 | Python 3 | OK | TESTS | 96 | 109 | 6,656,000 | l1 , r1 , l2 , r2 , k = map(int,input().split())
x = max(l1 , l2)
y = min(r1 , r2)
res = y - x + 1
if y < x :
print(0)
exit()
else:
if k == x or k == y or k > x and k < y :
print(res - 1)
else:
print(res)
| Title: Meeting of Old Friends
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Today an outstanding event is going to happen in the forest — hedgehog Filya will come to his old fried Sonya!
Sonya is an owl and she sleeps during the day and stay awake from minute *l*1 to minute *r*1 inclusi... | ```python
l1 , r1 , l2 , r2 , k = map(int,input().split())
x = max(l1 , l2)
y = min(r1 , r2)
res = y - x + 1
if y < x :
print(0)
exit()
else:
if k == x or k == y or k > x and k < y :
print(res - 1)
else:
print(res)
``` | 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,668,868,527 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 60 | 0 | M, N = list(map(int,input().split()))
if(M%2!=0 and M>1):
M=M-1
if(N%2!=0 and N>1):
N=N-1
print((M*N)/4)
| 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 = list(map(int,input().split()))
if(M%2!=0 and M>1):
M=M-1
if(N%2!=0 and N>1):
N=N-1
print((M*N)/4)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions |
714 | B | Filya and Homework | PROGRAMMING | 1,200 | [
"implementation",
"sortings"
] | null | null | Today, hedgehog Filya went to school for the very first time! Teacher gave him a homework which Filya was unable to complete without your help.
Filya is given an array of non-negative integers *a*1,<=*a*2,<=...,<=*a**n*. First, he pick an integer *x* and then he adds *x* to some elements of the array (no more than onc... | The first line of the input contains an integer *n* (1<=≤<=*n*<=≤<=100<=000) — the number of integers in the Filya's array. The second line contains *n* integers *a*1,<=*a*2,<=...,<=*a**n* (0<=≤<=*a**i*<=≤<=109) — elements of the array. | If it's impossible to make all elements of the array equal using the process given in the problem statement, then print "NO" (without quotes) in the only line of the output. Otherwise print "YES" (without quotes). | [
"5\n1 3 3 2 1\n",
"5\n1 2 3 4 5\n"
] | [
"YES\n",
"NO\n"
] | In the first sample Filya should select *x* = 1, then add it to the first and the last elements of the array and subtract from the second and the third elements. | 1,000 | [
{
"input": "5\n1 3 3 2 1",
"output": "YES"
},
{
"input": "5\n1 2 3 4 5",
"output": "NO"
},
{
"input": "2\n1 2",
"output": "YES"
},
{
"input": "3\n1 2 3",
"output": "YES"
},
{
"input": "3\n1 1 1",
"output": "YES"
},
{
"input": "2\n1 1000000000",
"ou... | 1,474,118,023 | 523 | Python 3 | OK | TESTS | 79 | 93 | 9,318,400 | n = int(input())
nums = list(map(int, input().split()))
numsU = list(set(nums))
numsU.sort()
if len(numsU) <= 2 or (len(numsU) == 3 and numsU[1] - numsU[0] == numsU[2] - numsU[1]):
print("YES")
else:
print("NO") | Title: Filya and Homework
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Today, hedgehog Filya went to school for the very first time! Teacher gave him a homework which Filya was unable to complete without your help.
Filya is given an array of non-negative integers *a*1,<=*a*2,<=...,<=*a... | ```python
n = int(input())
nums = list(map(int, input().split()))
numsU = list(set(nums))
numsU.sort()
if len(numsU) <= 2 or (len(numsU) == 3 and numsU[1] - numsU[0] == numsU[2] - numsU[1]):
print("YES")
else:
print("NO")
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
20 | B | Equation | PROGRAMMING | 2,000 | [
"math"
] | B. Equation | 1 | 256 | You are given an equation:
Your task is to find the number of distinct roots of the equation and print all of them in ascending order. | The first line contains three integer numbers *A*,<=*B* and *C* (<=-<=105<=≤<=*A*,<=*B*,<=*C*<=≤<=105). Any coefficient may be equal to 0. | In case of infinite root count print the only integer -1. In case of no roots print the only integer 0. In other cases print the number of root on the first line and the roots on the following lines in the ascending order. Print roots with at least 5 digits after the decimal point. | [
"1 -5 6\n"
] | [
"2\n2.0000000000\n3.0000000000"
] | none | 1,000 | [
{
"input": "1 -5 6",
"output": "2\n2.0000000000\n3.0000000000"
},
{
"input": "1 1 1",
"output": "0"
},
{
"input": "1 2 1",
"output": "1\n-1.0000000000"
},
{
"input": "0 0 0",
"output": "-1"
},
{
"input": "0 -2 1",
"output": "1\n0.5000000000"
},
{
"inpu... | 1,674,159,243 | 2,147,483,647 | PyPy 3-64 | RUNTIME_ERROR | TESTS | 0 | 77 | 2,867,200 | import math
a = float(input())
b = float(input())
c = float(input())
special = b**2 - 4*a*c
if special < 0:
print(0)
elif special == 0:
x = (-b)/(2*a)
print(1)
print(x)
elif special > 9999999999:
print(-1)
else:
x1 = float( (-b-math.sqrt(special))/(2*a) )
x2 = fl... | Title: Equation
Time Limit: 1 seconds
Memory Limit: 256 megabytes
Problem Description:
You are given an equation:
Your task is to find the number of distinct roots of the equation and print all of them in ascending order.
Input Specification:
The first line contains three integer numbers *A*,<=*B* and *C* (<=-<=1... | ```python
import math
a = float(input())
b = float(input())
c = float(input())
special = b**2 - 4*a*c
if special < 0:
print(0)
elif special == 0:
x = (-b)/(2*a)
print(1)
print(x)
elif special > 9999999999:
print(-1)
else:
x1 = float( (-b-math.sqrt(special))/(2*a) )
... | -1 | MatrixStudio/Codeforces-Python-Submissions |
276 | D | Little Girl and Maximum XOR | PROGRAMMING | 1,700 | [
"bitmasks",
"dp",
"greedy",
"implementation",
"math"
] | null | null | A little girl loves problems on bitwise operations very much. Here's one of them.
You are given two integers *l* and *r*. Let's consider the values of for all pairs of integers *a* and *b* (*l*<=≤<=*a*<=≤<=*b*<=≤<=*r*). Your task is to find the maximum value among all considered ones.
Expression means applying bitw... | The single line contains space-separated integers *l* and *r* (1<=≤<=*l*<=≤<=*r*<=≤<=1018).
Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier. | In a single line print a single integer — the maximum value of for all pairs of integers *a*, *b* (*l*<=≤<=*a*<=≤<=*b*<=≤<=*r*). | [
"1 2\n",
"8 16\n",
"1 1\n"
] | [
"3\n",
"31\n",
"0\n"
] | none | 2,000 | [
{
"input": "1 2",
"output": "3"
},
{
"input": "8 16",
"output": "31"
},
{
"input": "1 1",
"output": "0"
},
{
"input": "506 677",
"output": "1023"
},
{
"input": "33 910",
"output": "1023"
},
{
"input": "36 94",
"output": "127"
},
{
"input": ... | 1,667,474,387 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 3 | 31 | 0 | import sys
input = sys.stdin.readline
left, right = list(map(int, input().split()))
_max = right
bigPowerOfTwo = 1
msb = 0
while bigPowerOfTwo * 2 <= _max:
bigPowerOfTwo *= 2
msb += 1
shift = bigPowerOfTwo
ans = left
for i in range(msb, -1, -1):
get = (right >> i) & 1
if get and ans & ~... | Title: Little Girl and Maximum XOR
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
A little girl loves problems on bitwise operations very much. Here's one of them.
You are given two integers *l* and *r*. Let's consider the values of for all pairs of integers *a* and *b* (*l*<=≤<=*a*<=≤<... | ```python
import sys
input = sys.stdin.readline
left, right = list(map(int, input().split()))
_max = right
bigPowerOfTwo = 1
msb = 0
while bigPowerOfTwo * 2 <= _max:
bigPowerOfTwo *= 2
msb += 1
shift = bigPowerOfTwo
ans = left
for i in range(msb, -1, -1):
get = (right >> i) & 1
if get a... | 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,692,987,551 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 0 | 92 | 0 | a=input()
n=len(a)
c=0
for i in a:
if i>='a' and i<='z':
c+=1
if c>=(n/2):
print(a.lower)
else:
print(a.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
a=input()
n=len(a)
c=0
for i in a:
if i>='a' and i<='z':
c+=1
if c>=(n/2):
print(a.lower)
else:
print(a.upper)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions |
450 | B | Jzzhu and Sequences | PROGRAMMING | 1,300 | [
"implementation",
"math"
] | null | null | Jzzhu has invented a kind of sequences, they meet the following property:
You are given *x* and *y*, please calculate *f**n* modulo 1000000007 (109<=+<=7). | The first line contains two integers *x* and *y* (|*x*|,<=|*y*|<=≤<=109). The second line contains a single integer *n* (1<=≤<=*n*<=≤<=2·109). | Output a single integer representing *f**n* modulo 1000000007 (109<=+<=7). | [
"2 3\n3\n",
"0 -1\n2\n"
] | [
"1\n",
"1000000006\n"
] | In the first sample, *f*<sub class="lower-index">2</sub> = *f*<sub class="lower-index">1</sub> + *f*<sub class="lower-index">3</sub>, 3 = 2 + *f*<sub class="lower-index">3</sub>, *f*<sub class="lower-index">3</sub> = 1.
In the second sample, *f*<sub class="lower-index">2</sub> = - 1; - 1 modulo (10<sup class="upper-... | 1,000 | [
{
"input": "2 3\n3",
"output": "1"
},
{
"input": "0 -1\n2",
"output": "1000000006"
},
{
"input": "-9 -11\n12345",
"output": "1000000005"
},
{
"input": "0 0\n1000000000",
"output": "0"
},
{
"input": "-1000000000 1000000000\n2000000000",
"output": "1000000000"
... | 1,663,961,731 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 74 | 62 | 0 | f1,f2=map(int,input().split( ))
f3=f2-f1
n=int(input())
if n%3==0:
if n%2==0:
print((-f3)%(10**9+7))
else:
print(f3%(10**9+7))
elif n%3==1:
if n%2==0:
print((-f1)%(10**9+7))
else:
print(f1%(10**9+7))
else:
if n%2==0:
print(f2%(10**9+7))
els... | Title: Jzzhu and Sequences
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Jzzhu has invented a kind of sequences, they meet the following property:
You are given *x* and *y*, please calculate *f**n* modulo 1000000007 (109<=+<=7).
Input Specification:
The first line contains two integers... | ```python
f1,f2=map(int,input().split( ))
f3=f2-f1
n=int(input())
if n%3==0:
if n%2==0:
print((-f3)%(10**9+7))
else:
print(f3%(10**9+7))
elif n%3==1:
if n%2==0:
print((-f1)%(10**9+7))
else:
print(f1%(10**9+7))
else:
if n%2==0:
print(f2%(10**9+7)... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
44 | A | Indian Summer | PROGRAMMING | 900 | [
"implementation"
] | A. Indian Summer | 2 | 256 | Indian summer is such a beautiful time of the year! A girl named Alyona is walking in the forest and picking a bouquet from fallen leaves. Alyona is very choosy — she doesn't take a leaf if it matches the color and the species of the tree of one of the leaves she already has. Find out how many leaves Alyona has picked. | The first line contains an integer *n* (1<=≤<=*n*<=≤<=100) — the number of leaves Alyona has found. The next *n* lines contain the leaves' descriptions. Each leaf is characterized by the species of the tree it has fallen from and by the color. The species of the trees and colors are given in names, consisting of no mor... | Output the single number — the number of Alyona's leaves. | [
"5\nbirch yellow\nmaple red\nbirch yellow\nmaple yellow\nmaple green\n",
"3\noak yellow\noak yellow\noak yellow\n"
] | [
"4\n",
"1\n"
] | none | 0 | [
{
"input": "5\nbirch yellow\nmaple red\nbirch yellow\nmaple yellow\nmaple green",
"output": "4"
},
{
"input": "3\noak yellow\noak yellow\noak yellow",
"output": "1"
},
{
"input": "5\nxbnbkzn hp\nkaqkl vrgzbvqstu\nj aqidx\nhos gyul\nwefxmh tygpluae",
"output": "5"
},
{
"input"... | 1,672,123,663 | 2,147,483,647 | Python 3 | OK | TESTS | 29 | 92 | 0 | l = []
for _ in range(int(input())):
a = input()
l.append(a)
c = set(l)
print(len(c))
| Title: Indian Summer
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Indian summer is such a beautiful time of the year! A girl named Alyona is walking in the forest and picking a bouquet from fallen leaves. Alyona is very choosy — she doesn't take a leaf if it matches the color and the specie... | ```python
l = []
for _ in range(int(input())):
a = input()
l.append(a)
c = set(l)
print(len(c))
``` | 3.977 | MatrixStudio/Codeforces-Python-Submissions |
909 | B | Segments | PROGRAMMING | 1,300 | [
"constructive algorithms",
"math"
] | null | null | You are given an integer *N*. Consider all possible segments on the coordinate axis with endpoints at integer points with coordinates between 0 and *N*, inclusive; there will be of them.
You want to draw these segments in several layers so that in each layer the segments don't overlap (they might touch at the endpoin... | The only input line contains a single integer *N* (1<=≤<=*N*<=≤<=100). | Output a single integer - the minimal number of layers required to draw the segments for the given *N*. | [
"2\n",
"3\n",
"4\n"
] | [
"2\n",
"4\n",
"6\n"
] | As an example, here are the segments and their optimal arrangement into layers for *N* = 4. | 1,000 | [
{
"input": "2",
"output": "2"
},
{
"input": "3",
"output": "4"
},
{
"input": "4",
"output": "6"
},
{
"input": "21",
"output": "121"
},
{
"input": "100",
"output": "2550"
},
{
"input": "1",
"output": "1"
},
{
"input": "5",
"output": "9"
... | 1,583,660,771 | 2,147,483,647 | PyPy 3 | OK | TESTS | 102 | 155 | 0 | n = int(input())
if n & 1:
print(n * (n + 1) // 2 - (n - 1) * (n + 1) // 4)
else:
print(n * n // 2 - (n - 2) * n // 4) | Title: Segments
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given an integer *N*. Consider all possible segments on the coordinate axis with endpoints at integer points with coordinates between 0 and *N*, inclusive; there will be of them.
You want to draw these segments in se... | ```python
n = int(input())
if n & 1:
print(n * (n + 1) // 2 - (n - 1) * (n + 1) // 4)
else:
print(n * n // 2 - (n - 2) * n // 4)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
650 | A | Watchmen | PROGRAMMING | 1,400 | [
"data structures",
"geometry",
"math"
] | null | null | Watchmen are in a danger and Doctor Manhattan together with his friend Daniel Dreiberg should warn them as soon as possible. There are *n* watchmen on a plane, the *i*-th watchman is located at point (*x**i*,<=*y**i*).
They need to arrange a plan, but there are some difficulties on their way. As you know, Doctor Manha... | The first line of the input contains the single integer *n* (1<=≤<=*n*<=≤<=200<=000) — the number of watchmen.
Each of the following *n* lines contains two integers *x**i* and *y**i* (|*x**i*|,<=|*y**i*|<=≤<=109).
Some positions may coincide. | Print the number of pairs of watchmen such that the distance between them calculated by Doctor Manhattan is equal to the distance calculated by Daniel. | [
"3\n1 1\n7 5\n1 5\n",
"6\n0 0\n0 1\n0 2\n-1 1\n0 1\n1 1\n"
] | [
"2\n",
"11\n"
] | In the first sample, the distance between watchman 1 and watchman 2 is equal to |1 - 7| + |1 - 5| = 10 for Doctor Manhattan and <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/bcb5b7064b5f02088da0fdcf677e6fda495dd0df.png" style="max-width: 100.0%;max-height: 100.0%;"/> for Daniel. For pairs... | 500 | [
{
"input": "3\n1 1\n7 5\n1 5",
"output": "2"
},
{
"input": "6\n0 0\n0 1\n0 2\n-1 1\n0 1\n1 1",
"output": "11"
},
{
"input": "10\n46 -55\n46 45\n46 45\n83 -55\n46 45\n83 -55\n46 45\n83 45\n83 45\n46 -55",
"output": "33"
},
{
"input": "1\n-5 -90",
"output": "0"
},
{
... | 1,518,216,835 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 9 | 3,000 | 26,009,600 | import math
n = int(input())
coordinates = []
for i in range(n):
point = input()
point = point.split(" ")
point = list(map(int, point))
coordinates.append(point)
count = 0
for i in range(len(coordinates)):
watchman = coordinates[i]
for j in range(i+1, len(coordinates)):
man = math.fabs... | Title: Watchmen
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Watchmen are in a danger and Doctor Manhattan together with his friend Daniel Dreiberg should warn them as soon as possible. There are *n* watchmen on a plane, the *i*-th watchman is located at point (*x**i*,<=*y**i*).
They n... | ```python
import math
n = int(input())
coordinates = []
for i in range(n):
point = input()
point = point.split(" ")
point = list(map(int, point))
coordinates.append(point)
count = 0
for i in range(len(coordinates)):
watchman = coordinates[i]
for j in range(i+1, len(coordinates)):
man =... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
887 | A | Div. 64 | PROGRAMMING | 1,000 | [
"implementation"
] | null | null | Top-model Izabella participates in the competition. She wants to impress judges and show her mathematical skills.
Her problem is following: for given string, consisting of only 0 and 1, tell if it's possible to remove some digits in such a way, that remaining number is a representation of some positive integer, divisi... | In the only line given a non-empty binary string *s* with length up to 100. | Print «yes» (without quotes) if it's possible to remove digits required way and «no» otherwise. | [
"100010001\n",
"100\n"
] | [
"yes",
"no"
] | In the first test case, you can get string 1 000 000 after removing two ones which is a representation of number 64 in the binary numerical system.
You can read more about binary numeral system representation here: [https://en.wikipedia.org/wiki/Binary_system](https://en.wikipedia.org/wiki/Binary_system) | 500 | [
{
"input": "100010001",
"output": "yes"
},
{
"input": "100",
"output": "no"
},
{
"input": "0000001000000",
"output": "yes"
},
{
"input": "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111",
"output": "no"
},
{
"in... | 1,517,737,706 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 3 | 62 | 5,632,000 | #887A
#10**6
a=list(map(int,list(input())))
a=a[::-1]
if 1 in a:
if a.index(1)<6:
a.remove(1)
if 1 in a:
print('yes')
else:
print('no') | Title: Div. 64
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Top-model Izabella participates in the competition. She wants to impress judges and show her mathematical skills.
Her problem is following: for given string, consisting of only 0 and 1, tell if it's possible to remove some dig... | ```python
#887A
#10**6
a=list(map(int,list(input())))
a=a[::-1]
if 1 in a:
if a.index(1)<6:
a.remove(1)
if 1 in a:
print('yes')
else:
print('no')
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
251 | A | Points on Line | PROGRAMMING | 1,300 | [
"binary search",
"combinatorics",
"two pointers"
] | null | null | Little Petya likes points a lot. Recently his mom has presented him *n* points lying on the line *OX*. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed *d*.
Note that the order of the points inside the group of three chosen... | The first line contains two integers: *n* and *d* (1<=≤<=*n*<=≤<=105; 1<=≤<=*d*<=≤<=109). The next line contains *n* integers *x*1,<=*x*2,<=...,<=*x**n*, their absolute value doesn't exceed 109 — the *x*-coordinates of the points that Petya has got.
It is guaranteed that the coordinates of the points in the input stri... | Print a single integer — the number of groups of three points, where the distance between two farthest points doesn't exceed *d*.
Please do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. | [
"4 3\n1 2 3 4\n",
"4 2\n-3 -2 -1 0\n",
"5 19\n1 10 20 30 50\n"
] | [
"4\n",
"2\n",
"1\n"
] | In the first sample any group of three points meets our conditions.
In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.
In the third sample only one group does: {1, 10, 20}. | 500 | [
{
"input": "4 3\n1 2 3 4",
"output": "4"
},
{
"input": "4 2\n-3 -2 -1 0",
"output": "2"
},
{
"input": "5 19\n1 10 20 30 50",
"output": "1"
},
{
"input": "10 5\n31 36 43 47 48 50 56 69 71 86",
"output": "2"
},
{
"input": "10 50\n1 4 20 27 65 79 82 83 99 100",
"... | 1,459,349,584 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 9 | 2,000 | 716,800 | import os;
[n,d]=[int(i) for i in input().split()];
x=[int(i) for i in input().split()];
s=0;
#print(n);
if(n>2):
for i in range(0,n-2):
for j in range(i+2,n):
if(x[j]-x[i]<=d):
s=s+j-i-1;
print(s);
else:
print(0);
| Title: Points on Line
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Little Petya likes points a lot. Recently his mom has presented him *n* points lying on the line *OX*. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two fart... | ```python
import os;
[n,d]=[int(i) for i in input().split()];
x=[int(i) for i in input().split()];
s=0;
#print(n);
if(n>2):
for i in range(0,n-2):
for j in range(i+2,n):
if(x[j]-x[i]<=d):
s=s+j-i-1;
print(s);
else:
print(0);
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
629 | D | Babaei and Birthday Cake | PROGRAMMING | 2,000 | [
"data structures",
"dp"
] | null | null | As you know, every birthday party has a cake! This time, Babaei is going to prepare the very special birthday party's cake.
Simple cake is a cylinder of some radius and height. The volume of the simple cake is equal to the volume of corresponding cylinder. Babaei has *n* simple cakes and he is going to make a special ... | The first line of the input contains a single integer *n* (1<=≤<=*n*<=≤<=100<=000) — the number of simple cakes Babaei has.
Each of the following *n* lines contains two integers *r**i* and *h**i* (1<=≤<=*r**i*,<=*h**i*<=≤<=10<=000), giving the radius and height of the *i*-th cake. | Print the maximum volume of the cake that Babaei can make. Your answer will be considered correct if its absolute or relative error does not exceed 10<=-<=6.
Namely: let's assume that your answer is *a*, and the answer of the jury is *b*. The checker program will consider your answer correct, if . | [
"2\n100 30\n40 10\n",
"4\n1 1\n9 7\n1 4\n10 7\n"
] | [
"942477.796077000\n",
"3983.539484752\n"
] | In first sample, the optimal way is to choose the cake number 1.
In second sample, the way to get the maximum volume is to use cakes with indices 1, 2 and 4. | 2,000 | [
{
"input": "2\n100 30\n40 10",
"output": "942477.796077000"
},
{
"input": "4\n1 1\n9 7\n1 4\n10 7",
"output": "3983.539484752"
},
{
"input": "3\n2 2\n1 1\n3 3",
"output": "109.955742876"
},
{
"input": "3\n2 2\n3 3\n1 1",
"output": "109.955742876"
},
{
"input": "3\... | 1,455,990,133 | 4,033 | Python 3 | WRONG_ANSWER | PRETESTS | 1 | 46 | 0 | n=int(input())
from math import pi
d=[]
d1=[]
d2=[]
V=[]
res=[]
def vol(r,h):
return(h*pi*r**2)
for i in range(n):
ch=input()
d=ch.split()
d1.append(int(d[0]))
d2.append(int(d[1]))
for i in range (n):
V.append(vol(d1[i],d2[i]))
for i in range(len(V)-1):
S=V[i]
for j in ... | Title: Babaei and Birthday Cake
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
As you know, every birthday party has a cake! This time, Babaei is going to prepare the very special birthday party's cake.
Simple cake is a cylinder of some radius and height. The volume of the simple cake is... | ```python
n=int(input())
from math import pi
d=[]
d1=[]
d2=[]
V=[]
res=[]
def vol(r,h):
return(h*pi*r**2)
for i in range(n):
ch=input()
d=ch.split()
d1.append(int(d[0]))
d2.append(int(d[1]))
for i in range (n):
V.append(vol(d1[i],d2[i]))
for i in range(len(V)-1):
S=V[i]
... | 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,695,429,050 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 30 | 0 | s=str(input())
for i in s:
if i.islower()>i.isupper():
print(s.lower())
break
else:
print(s.upper())
break | 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=str(input())
for i in s:
if i.islower()>i.isupper():
print(s.lower())
break
else:
print(s.upper())
break
``` | 0 | MatrixStudio/Codeforces-Python-Submissions |
215 | B | Olympic Medal | PROGRAMMING | 1,300 | [
"greedy",
"math"
] | null | null | The World Programming Olympics Medal is a metal disk, consisting of two parts: the first part is a ring with outer radius of *r*1 cm, inner radius of *r*2 cm, (0<=<<=*r*2<=<<=*r*1) made of metal with density *p*1 g/cm3. The second part is an inner disk with radius *r*2 cm, it is made of metal with density *p*2 g/... | The first input line contains an integer *n* and a sequence of integers *x*1,<=*x*2,<=...,<=*x**n*. The second input line contains an integer *m* and a sequence of integers *y*1,<=*y*2,<=...,<=*y**m*. The third input line contains an integer *k* and a sequence of integers *z*1,<=*z*2,<=...,<=*z**k*. The last line conta... | Print a single real number — the sought value *r*2 with absolute or relative error of at most 10<=-<=6. It is guaranteed that the solution that meets the problem requirements exists. | [
"3 1 2 3\n1 2\n3 3 2 1\n1 2\n",
"4 2 3 6 4\n2 1 2\n3 10 6 8\n2 1\n"
] | [
"2.683281573000\n",
"2.267786838055\n"
] | In the first sample the jury should choose the following values: *r*<sub class="lower-index">1</sub> = 3, *p*<sub class="lower-index">1</sub> = 2, *p*<sub class="lower-index">2</sub> = 1. | 500 | [
{
"input": "3 1 2 3\n1 2\n3 3 2 1\n1 2",
"output": "2.683281573000"
},
{
"input": "4 2 3 6 4\n2 1 2\n3 10 6 8\n2 1",
"output": "2.267786838055"
},
{
"input": "1 5\n1 3\n1 7\n515 892",
"output": "3.263613058533"
},
{
"input": "2 3 2\n3 2 3 1\n2 2 1\n733 883",
"output": "2.... | 1,611,582,071 | 2,147,483,647 | Python 3 | OK | TESTS | 31 | 124 | 921,600 | r1 = list(map(int , input().split()))
n = r1.pop(0)
r1.sort()
r = r1[-1]
p1 = list(map(int , input().split()))
m = p1.pop(0)
p1.sort()
a = p1[-1]
p2 = list(map(int , input().split()))
k = p2.pop(0)
p2.sort()
b = p2[0]
A , B = map(int , input().split())
B *= (a/b)
import math
print(r*(math... | Title: Olympic Medal
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The World Programming Olympics Medal is a metal disk, consisting of two parts: the first part is a ring with outer radius of *r*1 cm, inner radius of *r*2 cm, (0<=<<=*r*2<=<<=*r*1) made of metal with density *p*1 g/... | ```python
r1 = list(map(int , input().split()))
n = r1.pop(0)
r1.sort()
r = r1[-1]
p1 = list(map(int , input().split()))
m = p1.pop(0)
p1.sort()
a = p1[-1]
p2 = list(map(int , input().split()))
k = p2.pop(0)
p2.sort()
b = p2[0]
A , B = map(int , input().split())
B *= (a/b)
import math
pri... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
937 | A | Olympiad | PROGRAMMING | 800 | [
"implementation",
"sortings"
] | null | null | The recent All-Berland Olympiad in Informatics featured *n* participants with each scoring a certain amount of points.
As the head of the programming committee, you are to determine the set of participants to be awarded with diplomas with respect to the following criteria:
- At least one participant should get a di... | The first line contains a single integer *n* (1<=≤<=*n*<=≤<=100) — the number of participants.
The next line contains a sequence of *n* integers *a*1,<=*a*2,<=...,<=*a**n* (0<=≤<=*a**i*<=≤<=600) — participants' scores.
It's guaranteed that at least one participant has non-zero score. | Print a single integer — the desired number of ways. | [
"4\n1 3 3 2\n",
"3\n1 1 1\n",
"4\n42 0 0 42\n"
] | [
"3\n",
"1\n",
"1\n"
] | There are three ways to choose a subset in sample case one.
1. Only participants with 3 points will get diplomas. 1. Participants with 2 or 3 points will get diplomas. 1. Everyone will get a diploma!
The only option in sample case two is to award everyone.
Note that in sample case three participants with zero sco... | 500 | [
{
"input": "4\n1 3 3 2",
"output": "3"
},
{
"input": "3\n1 1 1",
"output": "1"
},
{
"input": "4\n42 0 0 42",
"output": "1"
},
{
"input": "10\n1 0 1 0 1 0 0 0 0 1",
"output": "1"
},
{
"input": "10\n572 471 540 163 50 30 561 510 43 200",
"output": "10"
},
{
... | 1,521,833,738 | 2,147,483,647 | Python 3 | OK | TESTS | 21 | 93 | 7,065,600 | n=int(input())
l=list(map(int,input().split()))
s=set(l)
s.discard(0)
print(len(s))
| Title: Olympiad
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The recent All-Berland Olympiad in Informatics featured *n* participants with each scoring a certain amount of points.
As the head of the programming committee, you are to determine the set of participants to be awarded with ... | ```python
n=int(input())
l=list(map(int,input().split()))
s=set(l)
s.discard(0)
print(len(s))
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
496 | A | Minimum Difficulty | PROGRAMMING | 900 | [
"brute force",
"implementation",
"math"
] | null | null | Mike is trying rock climbing but he is awful at it.
There are *n* holds on the wall, *i*-th hold is at height *a**i* off the ground. Besides, let the sequence *a**i* increase, that is, *a**i*<=<<=*a**i*<=+<=1 for all *i* from 1 to *n*<=-<=1; we will call such sequence a track. Mike thinks that the track *a*1, ...,... | The first line contains a single integer *n* (3<=≤<=*n*<=≤<=100) — the number of holds.
The next line contains *n* space-separated integers *a**i* (1<=≤<=*a**i*<=≤<=1000), where *a**i* is the height where the hold number *i* hangs. The sequence *a**i* is increasing (i.e. each element except for the first one is strict... | Print a single number — the minimum difficulty of the track after removing a single hold. | [
"3\n1 4 6\n",
"5\n1 2 3 4 5\n",
"5\n1 2 3 7 8\n"
] | [
"5\n",
"2\n",
"4\n"
] | In the first sample you can remove only the second hold, then the sequence looks like (1, 6), the maximum difference of the neighboring elements equals 5.
In the second test after removing every hold the difficulty equals 2.
In the third test you can obtain sequences (1, 3, 7, 8), (1, 2, 7, 8), (1, 2, 3, 8), for whic... | 500 | [
{
"input": "3\n1 4 6",
"output": "5"
},
{
"input": "5\n1 2 3 4 5",
"output": "2"
},
{
"input": "5\n1 2 3 7 8",
"output": "4"
},
{
"input": "3\n1 500 1000",
"output": "999"
},
{
"input": "10\n1 2 3 4 5 6 7 8 9 10",
"output": "2"
},
{
"input": "10\n1 4 9... | 1,651,567,736 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 16 | 61 | 512,000 | n = int(input())
a = list(map(int, input().split(' ')))
low = (1e9, -1)
for i in range(1, n - 1):
d0 = a[i + 1] - a[i]
d1 = a[i + 1] - a[i - 1]
low = min((d1 - d0, i), low)
l, r, d = 0, 1, 0
while l < n and r < n:
if r == low[-1]:
r += 1
if l == low[-1]:
l += 1
if l ... | Title: Minimum Difficulty
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Mike is trying rock climbing but he is awful at it.
There are *n* holds on the wall, *i*-th hold is at height *a**i* off the ground. Besides, let the sequence *a**i* increase, that is, *a**i*<=<<=*a**i*<=+<=1 fo... | ```python
n = int(input())
a = list(map(int, input().split(' ')))
low = (1e9, -1)
for i in range(1, n - 1):
d0 = a[i + 1] - a[i]
d1 = a[i + 1] - a[i - 1]
low = min((d1 - d0, i), low)
l, r, d = 0, 1, 0
while l < n and r < n:
if r == low[-1]:
r += 1
if l == low[-1]:
l += 1
... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
0 | none | none | none | 0 | [
"none"
] | null | null | Santa Claus likes palindromes very much. There was his birthday recently. *k* of his friends came to him to congratulate him, and each of them presented to him a string *s**i* having the same length *n*. We denote the beauty of the *i*-th string by *a**i*. It can happen that *a**i* is negative — that means that Santa d... | The first line contains two positive integers *k* and *n* divided by space and denoting the number of Santa friends and the length of every string they've presented, respectively (1<=≤<=*k*,<=*n*<=≤<=100<=000; *n*·*k* <=≤<=100<=000).
*k* lines follow. The *i*-th of them contains the string *s**i* and its beauty *a**i*... | In the only line print the required maximum possible beauty. | [
"7 3\nabb 2\naaa -3\nbba -1\nzyz -4\nabb 5\naaa 7\nxyx 4\n",
"3 1\na 1\na 2\na 3\n",
"2 5\nabcde 10000\nabcde 10000\n"
] | [
"12\n",
"6\n",
"0\n"
] | In the first example Santa can obtain abbaaaxyxaaabba by concatenating strings 5, 2, 7, 6 and 3 (in this order). | 0 | [
{
"input": "7 3\nabb 2\naaa -3\nbba -1\nzyz -4\nabb 5\naaa 7\nxyx 4",
"output": "12"
},
{
"input": "3 1\na 1\na 2\na 3",
"output": "6"
},
{
"input": "2 5\nabcde 10000\nabcde 10000",
"output": "0"
},
{
"input": "10 10\nnjxbzflaka -1\nfelbvvtkja 6\ngxiuztqkcw 5\naomvscmtti 6\nj... | 1,502,906,992 | 2,147,483,647 | Python 3 | OK | TESTS | 62 | 390 | 3,072,000 | # teamwork with rainboy
k, n = map(int, input().split())
ht = {}
for _ in range(k):
s, a = input().split()
ht.setdefault(s, []).append(int(a))
a0, a1 = [], []
for s in ht:
ht[s].sort()
for s in ht:
ls = ht[s]
t = s[::-1]
if s == t:
l = len(ls)
tot = 0
for i in range(l - 1... | Title: none
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Santa Claus likes palindromes very much. There was his birthday recently. *k* of his friends came to him to congratulate him, and each of them presented to him a string *s**i* having the same length *n*. We denote the beauty of th... | ```python
# teamwork with rainboy
k, n = map(int, input().split())
ht = {}
for _ in range(k):
s, a = input().split()
ht.setdefault(s, []).append(int(a))
a0, a1 = [], []
for s in ht:
ht[s].sort()
for s in ht:
ls = ht[s]
t = s[::-1]
if s == t:
l = len(ls)
tot = 0
for i in r... | 3 | 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,689,647,792 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 31 | 0 | input()
n = list(map(int , input().split()))
n.sort()
print("".join(n)) | 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
input()
n = list(map(int , input().split()))
n.sort()
print("".join(n))
``` | -1 | 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,566,713,171 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 186 | 0 | a=input()
b=0
c=0
d=''
e=''
for i in range(0,len(a)):
if(ord(a[i])<=ord('Z')):
#print("lower",i)
d=d+chr(ord(a[i])+32)
e=e+a[i]
b=b+1
else:
#print("upper",i)
c=c+1
e=e+chr(ord(a[i])-32)
d=d+a[i]
#print(e,d)
if(b==c):
print(d)
... | 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
a=input()
b=0
c=0
d=''
e=''
for i in range(0,len(a)):
if(ord(a[i])<=ord('Z')):
#print("lower",i)
d=d+chr(ord(a[i])+32)
e=e+a[i]
b=b+1
else:
#print("upper",i)
c=c+1
e=e+chr(ord(a[i])-32)
d=d+a[i]
#print(e,d)
if(b==c):
... | 0 | MatrixStudio/Codeforces-Python-Submissions |
482 | A | Diverse Permutation | PROGRAMMING | 1,200 | [
"constructive algorithms",
"greedy"
] | null | null | Permutation *p* is an ordered set of integers *p*1,<=<=<=*p*2,<=<=<=...,<=<=<=*p**n*, consisting of *n* distinct positive integers not larger than *n*. We'll denote as *n* the length of permutation *p*1,<=<=<=*p*2,<=<=<=...,<=<=<=*p**n*.
Your task is to find such permutation *p* of length *n*, that the group of number... | The single line of the input contains two space-separated positive integers *n*, *k* (1<=≤<=*k*<=<<=*n*<=≤<=105). | Print *n* integers forming the permutation. If there are multiple answers, print any of them. | [
"3 2\n",
"3 1\n",
"5 2\n"
] | [
"1 3 2\n",
"1 2 3\n",
"1 3 2 4 5\n"
] | By |*x*| we denote the absolute value of number *x*. | 500 | [
{
"input": "3 2",
"output": "1 3 2"
},
{
"input": "3 1",
"output": "1 2 3"
},
{
"input": "5 2",
"output": "1 3 2 4 5"
},
{
"input": "5 4",
"output": "1 5 2 4 3"
},
{
"input": "10 4",
"output": "1 10 2 9 8 7 6 5 4 3"
},
{
"input": "10 3",
"output": ... | 1,687,153,835 | 2,147,483,647 | Python 3 | OK | TESTS | 37 | 93 | 9,011,200 | integer_quantity, distance_quantity = \
map(int, input().split())
permutation = ['1']
right_pointer = distance_quantity + 1
append_after_distance_quantity = right_pointer
left_pointer = 2
append_right = True
for i in range(2, integer_quantity+1):
if distance_quantity > 0:
distance_quantity -=... | Title: Diverse Permutation
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Permutation *p* is an ordered set of integers *p*1,<=<=<=*p*2,<=<=<=...,<=<=<=*p**n*, consisting of *n* distinct positive integers not larger than *n*. We'll denote as *n* the length of permutation *p*1,<=<=<=*p*2,<... | ```python
integer_quantity, distance_quantity = \
map(int, input().split())
permutation = ['1']
right_pointer = distance_quantity + 1
append_after_distance_quantity = right_pointer
left_pointer = 2
append_right = True
for i in range(2, integer_quantity+1):
if distance_quantity > 0:
distance_q... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
765 | C | Table Tennis Game 2 | PROGRAMMING | 1,200 | [
"math"
] | null | null | Misha and Vanya have played several table tennis sets. Each set consists of several serves, each serve is won by one of the players, he receives one point and the loser receives nothing. Once one of the players scores exactly *k* points, the score is reset and a new set begins.
Across all the sets Misha scored *a* poi... | The first line contains three space-separated integers *k*, *a* and *b* (1<=≤<=*k*<=≤<=109, 0<=≤<=*a*,<=*b*<=≤<=109, *a*<=+<=*b*<=><=0). | If the situation is impossible, print a single number -1. Otherwise, print the maximum possible number of sets. | [
"11 11 5\n",
"11 2 3\n"
] | [
"1\n",
"-1\n"
] | Note that the rules of the game in this problem differ from the real table tennis game, for example, the rule of "balance" (the winning player has to be at least two points ahead to win a set) has no power within the present problem. | 1,250 | [
{
"input": "11 11 5",
"output": "1"
},
{
"input": "11 2 3",
"output": "-1"
},
{
"input": "1 5 9",
"output": "14"
},
{
"input": "2 3 3",
"output": "2"
},
{
"input": "1 1000000000 1000000000",
"output": "2000000000"
},
{
"input": "2 3 5",
"output": "... | 1,653,781,877 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 14 | 61 | 0 | a, b, c = map(int, input().split())
out = b//a + c//a
if out == 0:
print(-1)
else:
print(out)
| Title: Table Tennis Game 2
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Misha and Vanya have played several table tennis sets. Each set consists of several serves, each serve is won by one of the players, he receives one point and the loser receives nothing. Once one of the players scor... | ```python
a, b, c = map(int, input().split())
out = b//a + c//a
if out == 0:
print(-1)
else:
print(out)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
731 | A | Night at the Museum | PROGRAMMING | 800 | [
"implementation",
"strings"
] | null | null | Grigoriy, like the hero of one famous comedy film, found a job as a night security guard at the museum. At first night he received embosser and was to take stock of the whole exposition.
Embosser is a special devise that allows to "print" the text of a plastic tape. Text is printed sequentially, character by character... | The only line of input contains the name of some exhibit — the non-empty string consisting of no more than 100 characters. It's guaranteed that the string consists of only lowercase English letters. | Print one integer — the minimum number of rotations of the wheel, required to print the name given in the input. | [
"zeus\n",
"map\n",
"ares\n"
] | [
"18\n",
"35\n",
"34\n"
] | To print the string from the first sample it would be optimal to perform the following sequence of rotations:
1. from 'a' to 'z' (1 rotation counterclockwise), 1. from 'z' to 'e' (5 clockwise rotations), 1. from 'e' to 'u' (10 rotations counterclockwise), 1. from 'u' to 's' (2 counterclockwise rotations). | 500 | [
{
"input": "zeus",
"output": "18"
},
{
"input": "map",
"output": "35"
},
{
"input": "ares",
"output": "34"
},
{
"input": "l",
"output": "11"
},
{
"input": "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuv",
"... | 1,679,208,443 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 44 | 62 | 1,536,000 | st = input()
li = [0] * 26
k = 0
k1 = 0
mn = 0
pos = 0
pos1 = 0
for i in range(26):
li[i] = chr(ord('a') + i)
for i in range(len(st)):
while li[pos] != st[i]:
pos += 1
k += 1
if pos == 26:
pos = 0
while li[pos1] != st[i]:
pos1 -= 1
... | Title: Night at the Museum
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Grigoriy, like the hero of one famous comedy film, found a job as a night security guard at the museum. At first night he received embosser and was to take stock of the whole exposition.
Embosser is a special devis... | ```python
st = input()
li = [0] * 26
k = 0
k1 = 0
mn = 0
pos = 0
pos1 = 0
for i in range(26):
li[i] = chr(ord('a') + i)
for i in range(len(st)):
while li[pos] != st[i]:
pos += 1
k += 1
if pos == 26:
pos = 0
while li[pos1] != st[i]:
pos1 -= ... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
818 | F | Level Generation | PROGRAMMING | 2,100 | [
"binary search",
"math",
"ternary search"
] | null | null | Ivan is developing his own computer game. Now he tries to create some levels for his game. But firstly for each level he needs to draw a graph representing the structure of the level.
Ivan decided that there should be exactly *n**i* vertices in the graph representing level *i*, and the edges have to be bidirectional. ... | The first line of input file contains a positive integer *q* (1<=≤<=*q*<=≤<=100<=000) — the number of graphs Ivan needs to construct.
Then *q* lines follow, *i*-th line contains one positive integer *n**i* (1<=≤<=*n**i*<=≤<=2·109) — the number of vertices in *i*-th graph.
Note that in hacks you have to use *q*<==<=1. | Output *q* numbers, *i*-th of them must be equal to the maximum number of edges in *i*-th graph. | [
"3\n3\n4\n6\n"
] | [
"2\n3\n6\n"
] | In the first example it is possible to construct these graphs:
1. 1 - 2, 1 - 3; 1. 1 - 2, 1 - 3, 2 - 4; 1. 1 - 2, 1 - 3, 2 - 3, 1 - 4, 2 - 5, 3 - 6. | 0 | [
{
"input": "3\n3\n4\n6",
"output": "2\n3\n6"
},
{
"input": "10\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10",
"output": "0\n1\n2\n3\n4\n6\n7\n8\n10\n12"
},
{
"input": "1\n212055293",
"output": "424069398"
},
{
"input": "1\n508427854",
"output": "1016791932"
},
{
"input": "1\n39... | 1,609,729,173 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 109 | 307,200 | """
https://codeforces.com/problemset/problem/818/F
3
3
4
6 should output 2, 3, and 6, each on a new line
"""
from math import ceil
def bridging_possible(vertices: int, edges: int) -> bool:
bridge_num = ceil(edges / 2)
vertices -= bridge_num
edges -= bridge_num
return vertices >= 0 and v... | Title: Level Generation
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Ivan is developing his own computer game. Now he tries to create some levels for his game. But firstly for each level he needs to draw a graph representing the structure of the level.
Ivan decided that there should be... | ```python
"""
https://codeforces.com/problemset/problem/818/F
3
3
4
6 should output 2, 3, and 6, each on a new line
"""
from math import ceil
def bridging_possible(vertices: int, edges: int) -> bool:
bridge_num = ceil(edges / 2)
vertices -= bridge_num
edges -= bridge_num
return vertices ... | 0 | 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,659,369,564 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 3 | 77 | 0 | a,b=input("").split()
a=int(a)
b=int(b)
c=a//b
if c<b:
print(a+c)
elif c==b:
print(a+c+1) | 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=input("").split()
a=int(a)
b=int(b)
c=a//b
if c<b:
print(a+c)
elif c==b:
print(a+c+1)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
356 | B | Xenia and Hamming | PROGRAMMING | 1,900 | [
"implementation",
"math"
] | null | null | Xenia is an amateur programmer. Today on the IT lesson she learned about the Hamming distance.
The Hamming distance between two strings *s*<==<=*s*1*s*2... *s**n* and *t*<==<=*t*1*t*2... *t**n* of equal length *n* is value . Record [*s**i*<=≠<=*t**i*] is the Iverson notation and represents the following: if *s**i*<=≠<... | The first line contains two integers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=1012). The second line contains a non-empty string *x*. The third line contains a non-empty string *y*. Both strings consist of at most 106 lowercase English letters.
It is guaranteed that strings *a* and *b* that you obtain from the input have the ... | Print a single integer — the required Hamming distance.
Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. | [
"100 10\na\naaaaaaaaaa\n",
"1 1\nabacaba\nabzczzz\n",
"2 3\nrzr\naz\n"
] | [
"0\n",
"4\n",
"5\n"
] | In the first test case string *a* is the same as string *b* and equals 100 letters a. As both strings are equal, the Hamming distance between them is zero.
In the second test case strings *a* and *b* differ in their 3-rd, 5-th, 6-th and 7-th characters. Thus, the Hamming distance equals 4.
In the third test case stri... | 1,000 | [] | 1,573,993,228 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 7 | 1,000 | 34,816,000 | x=[]
s=input()
x=s.split()
n=int(x[0])
m=int(x[1])
x=str(input())
y=str(input())
a=[]
b=[]
c=[]
d=[]
count=0
for i in range(n):
a.append(x)
for j in range(m):
b.append(y)
a="".join(a)
b="".join(b)
m=max(len(a),len(b))
f=min(len(a),len(b))
l=m-f
for i in a:
c.append(i)
for j in b:
d.append(j)
if(len(a)<l... | Title: Xenia and Hamming
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Xenia is an amateur programmer. Today on the IT lesson she learned about the Hamming distance.
The Hamming distance between two strings *s*<==<=*s*1*s*2... *s**n* and *t*<==<=*t*1*t*2... *t**n* of equal length *n* is... | ```python
x=[]
s=input()
x=s.split()
n=int(x[0])
m=int(x[1])
x=str(input())
y=str(input())
a=[]
b=[]
c=[]
d=[]
count=0
for i in range(n):
a.append(x)
for j in range(m):
b.append(y)
a="".join(a)
b="".join(b)
m=max(len(a),len(b))
f=min(len(a),len(b))
l=m-f
for i in a:
c.append(i)
for j in b:
d.append(j)
i... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
705 | A | Hulk | PROGRAMMING | 800 | [
"implementation"
] | null | null | Dr. Bruce Banner hates his enemies (like others don't). As we all know, he can barely talk when he turns into the incredible Hulk. That's why he asked you to help him to express his feelings.
Hulk likes the Inception so much, and like that his feelings are complicated. They have *n* layers. The first layer is hate, se... | The only line of the input contains a single integer *n* (1<=≤<=*n*<=≤<=100) — the number of layers of love and hate. | Print Dr.Banner's feeling in one line. | [
"1\n",
"2\n",
"3\n"
] | [
"I hate it\n",
"I hate that I love it\n",
"I hate that I love that I hate it\n"
] | none | 500 | [
{
"input": "1",
"output": "I hate it"
},
{
"input": "2",
"output": "I hate that I love it"
},
{
"input": "3",
"output": "I hate that I love that I hate it"
},
{
"input": "4",
"output": "I hate that I love that I hate that I love it"
},
{
"input": "5",
"output"... | 1,696,389,849 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 3 | 30 | 0 | hulk=int(input())
ans=[]
if hulk%2==1:
hulk=hulk-1
hulk=hulk/2
hulk=int(hulk)
for x in range(hulk):
ans=list(ans)
ans.append('I hate that ')
ans.append('I love that ')
ans.append('I hate it')
elif hulk%2==0:
hulk=hulk/2
hulk=int(hulk)
for y in range(hulk):
ans.append('I ... | Title: Hulk
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Dr. Bruce Banner hates his enemies (like others don't). As we all know, he can barely talk when he turns into the incredible Hulk. That's why he asked you to help him to express his feelings.
Hulk likes the Inception so much, and... | ```python
hulk=int(input())
ans=[]
if hulk%2==1:
hulk=hulk-1
hulk=hulk/2
hulk=int(hulk)
for x in range(hulk):
ans=list(ans)
ans.append('I hate that ')
ans.append('I love that ')
ans.append('I hate it')
elif hulk%2==0:
hulk=hulk/2
hulk=int(hulk)
for y in range(hulk):
ans.... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
717 | C | Potions Homework | PROGRAMMING | 1,200 | [
"implementation",
"sortings"
] | null | null | Harry Water, Ronaldo, Her-my-oh-knee and their friends have started a new school year at their MDCS School of Speechcraft and Misery. At the time, they are very happy to have seen each other after a long time. The sun is shining, birds are singing, flowers are blooming, and their Potions class teacher, professor Snipe ... | The first line of input contains integer *n* (1<=≤<=*n*<=≤<=100<=000) — the number of tasks. The next *n* lines contain exactly one integer number *a**i* (1<=≤<=*a**i*<=≤<=100<=000) — both the difficulty of the initial task and the laziness of the *i*-th students. | Print the minimum total time to finish all tasks modulo 10<=007. | [
"2\n1\n3\n"
] | [
"6\n"
] | In the first sample, if the students switch their tasks, they will be able to finish them in 3 + 3 = 6 time units. | 0 | [
{
"input": "2\n1\n3",
"output": "6"
}
] | 1,678,176,824 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 1 | 155 | 4,710,400 | n = int(input())
nums = []
for _ in range(n):
nums.append(int(input()))
nums.sort()
left, right = 0, n-1
ans = 0
while left <= right:
if left != right:
ans += 2*nums[left]*nums[right]
ans %= 1007
else:
ans += nums[left]*nums[right]
ans %= 1007
le... | Title: Potions Homework
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Harry Water, Ronaldo, Her-my-oh-knee and their friends have started a new school year at their MDCS School of Speechcraft and Misery. At the time, they are very happy to have seen each other after a long time. The sun ... | ```python
n = int(input())
nums = []
for _ in range(n):
nums.append(int(input()))
nums.sort()
left, right = 0, n-1
ans = 0
while left <= right:
if left != right:
ans += 2*nums[left]*nums[right]
ans %= 1007
else:
ans += nums[left]*nums[right]
ans %= 1007... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
785 | A | Anton and Polyhedrons | PROGRAMMING | 800 | [
"implementation",
"strings"
] | null | null | Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons:
- Tetrahedron. Tetrahedron has 4 triangular faces. - Cube. Cube has 6 square faces. - Octahedron. Octahedron has 8 triangular faces. - Dodecahedron. Dodecahedron has 12 pentagonal faces. - Icosahed... | The first line of the input contains a single integer *n* (1<=≤<=*n*<=≤<=200<=000) — the number of polyhedrons in Anton's collection.
Each of the following *n* lines of the input contains a string *s**i* — the name of the *i*-th polyhedron in Anton's collection. The string can look like this:
- "Tetrahedron" (withou... | Output one number — the total number of faces in all the polyhedrons in Anton's collection. | [
"4\nIcosahedron\nCube\nTetrahedron\nDodecahedron\n",
"3\nDodecahedron\nOctahedron\nOctahedron\n"
] | [
"42\n",
"28\n"
] | In the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces. | 500 | [
{
"input": "4\nIcosahedron\nCube\nTetrahedron\nDodecahedron",
"output": "42"
},
{
"input": "3\nDodecahedron\nOctahedron\nOctahedron",
"output": "28"
},
{
"input": "25\nIcosahedron\nOctahedron\nTetrahedron\nDodecahedron\nCube\nIcosahedron\nOctahedron\nCube\nTetrahedron\nIcosahedron\nIcosa... | 1,694,959,754 | 2,147,483,647 | Python 3 | OK | TESTS | 30 | 248 | 16,076,800 | b=[]
for i in range(int(input())):b.append(input())
print(b.count('Tetrahedron')*4+b.count('Cube')*6+b.count('Octahedron')*8+b.count('Dodecahedron')*12+b.count('Icosahedron')*20) | Title: Anton and Polyhedrons
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons:
- Tetrahedron. Tetrahedron has 4 triangular faces. - Cube. Cube has 6 square faces. - Octahe... | ```python
b=[]
for i in range(int(input())):b.append(input())
print(b.count('Tetrahedron')*4+b.count('Cube')*6+b.count('Octahedron')*8+b.count('Dodecahedron')*12+b.count('Icosahedron')*20)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
331 | C1 | The Great Julya Calendar | PROGRAMMING | 1,100 | [
"dp"
] | null | null | Yet another Armageddon is coming! This time the culprit is the Julya tribe calendar.
The beavers in this tribe knew math very well. Smart Beaver, an archaeologist, got a sacred plate with a magic integer on it. The translation from Old Beaverish is as follows:
"May the Great Beaver bless you! May your chacres open ... | The single line contains the magic integer *n*, 0<=≤<=*n*.
- to get 20 points, you need to solve the problem with constraints: *n*<=≤<=106 (subproblem C1); - to get 40 points, you need to solve the problem with constraints: *n*<=≤<=1012 (subproblems C1+C2); - to get 100 points, you need to solve the problem with co... | Print a single integer — the minimum number of subtractions that turns the magic number to a zero. | [
"24\n"
] | [
"5"
] | In the first test sample the minimum number of operations can be reached by the following sequence of subtractions: | 20 | [
{
"input": "24",
"output": "5"
},
{
"input": "0",
"output": "0"
},
{
"input": "3",
"output": "1"
},
{
"input": "8",
"output": "1"
},
{
"input": "9",
"output": "1"
},
{
"input": "10",
"output": "2"
},
{
"input": "31",
"output": "6"
},
... | 1,674,736,856 | 2,147,483,647 | Python 3 | OK | TESTS1 | 24 | 280 | 3,891,200 | ls = [0]*int(1e6)
for i in range(9):
ls[i] = 1
def get_max(num):
tmp = '0'
num_str = str(num)
for char in num_str:
if char > tmp:
tmp = char
return int(tmp)
tmp = []
def solve(n,max_num):
count = 0
while n > 0:
n = n - max_num
max_num = ... | Title: The Great Julya Calendar
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Yet another Armageddon is coming! This time the culprit is the Julya tribe calendar.
The beavers in this tribe knew math very well. Smart Beaver, an archaeologist, got a sacred plate with a magic integer on i... | ```python
ls = [0]*int(1e6)
for i in range(9):
ls[i] = 1
def get_max(num):
tmp = '0'
num_str = str(num)
for char in num_str:
if char > tmp:
tmp = char
return int(tmp)
tmp = []
def solve(n,max_num):
count = 0
while n > 0:
n = n - max_num
... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
472 | A | Design Tutorial: Learn from Math | PROGRAMMING | 800 | [
"math",
"number theory"
] | null | null | One way to create a task is to learn from math. You can generate some random math statement or modify some theorems to get something new and build a new task from that.
For example, there is a statement called the "Goldbach's conjecture". It says: "each even number no less than four can be expressed as the sum of two ... | The only line contains an integer *n* (12<=≤<=*n*<=≤<=106). | Output two composite integers *x* and *y* (1<=<<=*x*,<=*y*<=<<=*n*) such that *x*<=+<=*y*<==<=*n*. If there are multiple solutions, you can output any of them. | [
"12\n",
"15\n",
"23\n",
"1000000\n"
] | [
"4 8\n",
"6 9\n",
"8 15\n",
"500000 500000\n"
] | In the first example, 12 = 4 + 8 and both 4, 8 are composite numbers. You can output "6 6" or "8 4" as well.
In the second example, 15 = 6 + 9. Note that you can't output "1 14" because 1 is not a composite number. | 500 | [
{
"input": "12",
"output": "4 8"
},
{
"input": "15",
"output": "6 9"
},
{
"input": "23",
"output": "8 15"
},
{
"input": "1000000",
"output": "500000 500000"
},
{
"input": "63874",
"output": "4 63870"
},
{
"input": "14568",
"output": "4 14564"
},
... | 1,672,502,302 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 46 | 0 | def cp(num):
for i in range(2,(num//2)+1):
if(num%i)==0:
return True
else:
return False
if __name__=="__main__":
n=int(input())
for i in range(4,n):
o=n-1
if cp(i) and cp(o):
print(f"{i} {o}")
break | Title: Design Tutorial: Learn from Math
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
One way to create a task is to learn from math. You can generate some random math statement or modify some theorems to get something new and build a new task from that.
For example, there is a statemen... | ```python
def cp(num):
for i in range(2,(num//2)+1):
if(num%i)==0:
return True
else:
return False
if __name__=="__main__":
n=int(input())
for i in range(4,n):
o=n-1
if cp(i) and cp(o):
print(f"{i} {o}")
break
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
898 | B | Proper Nutrition | PROGRAMMING | 1,100 | [
"brute force",
"implementation",
"number theory"
] | null | null | Vasya has *n* burles. One bottle of Ber-Cola costs *a* burles and one Bars bar costs *b* burles. He can buy any non-negative integer number of bottles of Ber-Cola and any non-negative integer number of Bars bars.
Find out if it's possible to buy some amount of bottles of Ber-Cola and Bars bars and spend exactly *n* bu... | First line contains single integer *n* (1<=≤<=*n*<=≤<=10<=000<=000) — amount of money, that Vasya has.
Second line contains single integer *a* (1<=≤<=*a*<=≤<=10<=000<=000) — cost of one bottle of Ber-Cola.
Third line contains single integer *b* (1<=≤<=*b*<=≤<=10<=000<=000) — cost of one Bars bar. | If Vasya can't buy Bars and Ber-Cola in such a way to spend exactly *n* burles print «NO» (without quotes).
Otherwise in first line print «YES» (without quotes). In second line print two non-negative integers *x* and *y* — number of bottles of Ber-Cola and number of Bars bars Vasya should buy in order to spend exactly... | [
"7\n2\n3\n",
"100\n25\n10\n",
"15\n4\n8\n",
"9960594\n2551\n2557\n"
] | [
"YES\n2 1\n",
"YES\n0 10\n",
"NO\n",
"YES\n1951 1949\n"
] | In first example Vasya can buy two bottles of Ber-Cola and one Bars bar. He will spend exactly 2·2 + 1·3 = 7 burles.
In second example Vasya can spend exactly *n* burles multiple ways:
- buy two bottles of Ber-Cola and five Bars bars; - buy four bottles of Ber-Cola and don't buy Bars bars; - don't buy Ber-Cola an... | 750 | [
{
"input": "7\n2\n3",
"output": "YES\n2 1"
},
{
"input": "100\n25\n10",
"output": "YES\n0 10"
},
{
"input": "15\n4\n8",
"output": "NO"
},
{
"input": "9960594\n2551\n2557",
"output": "YES\n1951 1949"
},
{
"input": "10000000\n1\n1",
"output": "YES\n0 10000000"
... | 1,607,883,475 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 39 | 826 | 1,331,200 | n=int(input())
a=int(input())
b=int(input())
for i in range(0,n):
if (n-i*b)%a==0:
print("YES")
print((n-i*b)//a,i)
exit()
print("NO") | Title: Proper Nutrition
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vasya has *n* burles. One bottle of Ber-Cola costs *a* burles and one Bars bar costs *b* burles. He can buy any non-negative integer number of bottles of Ber-Cola and any non-negative integer number of Bars bars.
Find... | ```python
n=int(input())
a=int(input())
b=int(input())
for i in range(0,n):
if (n-i*b)%a==0:
print("YES")
print((n-i*b)//a,i)
exit()
print("NO")
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
12 | A | Super Agent | PROGRAMMING | 800 | [
"implementation"
] | A. Super Agent | 2 | 256 | There is a very secret base in Potatoland where potato mash is made according to a special recipe. The neighbours from Porridgia decided to seize this recipe and to sell it to Pilauland. For this mission they have been preparing special agent Pearlo for many years. When, finally, Pearlo learned all secrets of espionage... | Input contains the matrix of three rows of three symbols each. Symbol «X» means that the corresponding button was pressed, and «.» means that is was not pressed. The matrix may contain no «X», also it may contain no «.». | Print YES if the password is symmetric with respect to the central button of the terminal and NO otherwise. | [
"XX.\n...\n.XX\n",
"X.X\nX..\n...\n"
] | [
"YES\n",
"NO\n"
] | If you are not familiar with the term «central symmetry», you may look into http://en.wikipedia.org/wiki/Central_symmetry | 0 | [
{
"input": "XX.\n...\n.XX",
"output": "YES"
},
{
"input": ".X.\n.X.\n.X.",
"output": "YES"
},
{
"input": "XXX\nXXX\nXXX",
"output": "YES"
},
{
"input": "XXX\nX.X\nXXX",
"output": "YES"
},
{
"input": "X..\n.X.\n..X",
"output": "YES"
},
{
"input": "...\n... | 1,670,403,375 | 2,147,483,647 | Python 3 | OK | TESTS | 40 | 92 | 0 | l = [i for i in input()]
l += [i for i in input()]
l += [i for i in input()]
result = 'YES'
for i in range(4):
if l[i] != l[8-i]:
result = 'NO'
break
print(result) | Title: Super Agent
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
There is a very secret base in Potatoland where potato mash is made according to a special recipe. The neighbours from Porridgia decided to seize this recipe and to sell it to Pilauland. For this mission they have been preparin... | ```python
l = [i for i in input()]
l += [i for i in input()]
l += [i for i in input()]
result = 'YES'
for i in range(4):
if l[i] != l[8-i]:
result = 'NO'
break
print(result)
``` | 3.977 | MatrixStudio/Codeforces-Python-Submissions |
675 | A | Infinite Sequence | PROGRAMMING | 1,100 | [
"math"
] | null | null | Vasya likes everything infinite. Now he is studying the properties of a sequence *s*, such that its first element is equal to *a* (*s*1<==<=*a*), and the difference between any two neighbouring elements is equal to *c* (*s**i*<=-<=*s**i*<=-<=1<==<=*c*). In particular, Vasya wonders if his favourite integer *b* appears ... | The first line of the input contain three integers *a*, *b* and *c* (<=-<=109<=≤<=*a*,<=*b*,<=*c*<=≤<=109) — the first element of the sequence, Vasya's favorite number and the difference between any two neighbouring elements of the sequence, respectively. | If *b* appears in the sequence *s* print "YES" (without quotes), otherwise print "NO" (without quotes). | [
"1 7 3\n",
"10 10 0\n",
"1 -4 5\n",
"0 60 50\n"
] | [
"YES\n",
"YES\n",
"NO\n",
"NO\n"
] | In the first sample, the sequence starts from integers 1, 4, 7, so 7 is its element.
In the second sample, the favorite integer of Vasya is equal to the first element of the sequence.
In the third sample all elements of the sequence are greater than Vasya's favorite integer.
In the fourth sample, the sequence starts... | 500 | [
{
"input": "1 7 3",
"output": "YES"
},
{
"input": "10 10 0",
"output": "YES"
},
{
"input": "1 -4 5",
"output": "NO"
},
{
"input": "0 60 50",
"output": "NO"
},
{
"input": "1 -4 -5",
"output": "YES"
},
{
"input": "0 1 0",
"output": "NO"
},
{
... | 1,593,770,152 | 2,147,483,647 | Python 3 | OK | TESTS | 178 | 109 | 0 | (a,b,c) = list(int(x) for x in input().split())
if c>0 and b>=a:
if (b-a)%c==0:
print('YES')
else:
print("NO")
elif c<0 and b<=a:
if (a-b)%abs(c)==0:
print('YES')
else:
print('NO')
elif c==0 and a==b:
print('YES')
else:
print('NO') | Title: Infinite Sequence
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vasya likes everything infinite. Now he is studying the properties of a sequence *s*, such that its first element is equal to *a* (*s*1<==<=*a*), and the difference between any two neighbouring elements is equal to *c... | ```python
(a,b,c) = list(int(x) for x in input().split())
if c>0 and b>=a:
if (b-a)%c==0:
print('YES')
else:
print("NO")
elif c<0 and b<=a:
if (a-b)%abs(c)==0:
print('YES')
else:
print('NO')
elif c==0 and a==b:
print('YES')
else:
print('NO')
``` | 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,507,836,541 | 661 | PyPy 3 | OK | TESTS | 88 | 1,263 | 105,881,600 | n=int(input())
l=[int(i) for i in input().split()]
s=0
for i in l:
s= (s+i)%2
if (s==1):
print ('First')
else:
f=0
for i in l:
if (i%2!=0):
f=1
break
if (f==1):
print ('First')
else:
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())
l=[int(i) for i in input().split()]
s=0
for i in l:
s= (s+i)%2
if (s==1):
print ('First')
else:
f=0
for i in l:
if (i%2!=0):
f=1
break
if (f==1):
print ('First')
else:
print ('Second')
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
791 | A | Bear and Big Brother | PROGRAMMING | 800 | [
"implementation"
] | null | null | Bear Limak wants to become the largest of bears, or at least to become larger than his brother Bob.
Right now, Limak and Bob weigh *a* and *b* respectively. It's guaranteed that Limak's weight is smaller than or equal to his brother's weight.
Limak eats a lot and his weight is tripled after every year, while Bob's we... | The only line of the input contains two integers *a* and *b* (1<=≤<=*a*<=≤<=*b*<=≤<=10) — the weight of Limak and the weight of Bob respectively. | Print one integer, denoting the integer number of years after which Limak will become strictly larger than Bob. | [
"4 7\n",
"4 9\n",
"1 1\n"
] | [
"2\n",
"3\n",
"1\n"
] | In the first sample, Limak weighs 4 and Bob weighs 7 initially. After one year their weights are 4·3 = 12 and 7·2 = 14 respectively (one weight is tripled while the other one is doubled). Limak isn't larger than Bob yet. After the second year weights are 36 and 28, so the first weight is greater than the second one. Li... | 500 | [
{
"input": "4 7",
"output": "2"
},
{
"input": "4 9",
"output": "3"
},
{
"input": "1 1",
"output": "1"
},
{
"input": "4 6",
"output": "2"
},
{
"input": "1 10",
"output": "6"
},
{
"input": "1 1",
"output": "1"
},
{
"input": "1 2",
"output... | 1,697,792,678 | 2,147,483,647 | Python 3 | OK | TESTS | 62 | 46 | 0 | a, b = map(int, input().split())
# Initialize year counter
years = 0
# Simulate the growth of weights
while a <= b:
a *= 3
b *= 2
years += 1
# Print the number of years
print(years) | Title: Bear and Big Brother
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Bear Limak wants to become the largest of bears, or at least to become larger than his brother Bob.
Right now, Limak and Bob weigh *a* and *b* respectively. It's guaranteed that Limak's weight is smaller than or e... | ```python
a, b = map(int, input().split())
# Initialize year counter
years = 0
# Simulate the growth of weights
while a <= b:
a *= 3
b *= 2
years += 1
# Print the number of years
print(years)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
61 | A | Ultra-Fast Mathematician | PROGRAMMING | 800 | [
"implementation"
] | A. Ultra-Fast Mathematician | 2 | 256 | Shapur was an extremely gifted student. He was great at everything including Combinatorics, Algebra, Number Theory, Geometry, Calculus, etc. He was not only smart but extraordinarily fast! He could manage to sum 1018 numbers in a single second.
One day in 230 AD Shapur was trying to find out if any one can possibly do... | There are two lines in each input. Each of them contains a single number. It is guaranteed that the numbers are made from 0 and 1 only and that their length is same. The numbers may start with 0. The length of each number doesn't exceed 100. | Write one line — the corresponding answer. Do not omit the leading 0s. | [
"1010100\n0100101\n",
"000\n111\n",
"1110\n1010\n",
"01110\n01100\n"
] | [
"1110001\n",
"111\n",
"0100\n",
"00010\n"
] | none | 500 | [
{
"input": "1010100\n0100101",
"output": "1110001"
},
{
"input": "000\n111",
"output": "111"
},
{
"input": "1110\n1010",
"output": "0100"
},
{
"input": "01110\n01100",
"output": "00010"
},
{
"input": "011101\n000001",
"output": "011100"
},
{
"input": "... | 1,634,391,068 | 2,147,483,647 | Python 3 | OK | TESTS | 102 | 46 | 0 | a = str(input())
b = str(input())
ans = []
n = int(len(a))
for i in range(0,n) :
if a[i] != b[i] :
ans.append(1)
if a[i] == b[i] :
ans.append(0)
for i in ans :
print(i,end="")
print("\n") | Title: Ultra-Fast Mathematician
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Shapur was an extremely gifted student. He was great at everything including Combinatorics, Algebra, Number Theory, Geometry, Calculus, etc. He was not only smart but extraordinarily fast! He could manage to sum 10... | ```python
a = str(input())
b = str(input())
ans = []
n = int(len(a))
for i in range(0,n) :
if a[i] != b[i] :
ans.append(1)
if a[i] == b[i] :
ans.append(0)
for i in ans :
print(i,end="")
print("\n")
``` | 3.9885 | MatrixStudio/Codeforces-Python-Submissions |
32 | B | Borze | PROGRAMMING | 800 | [
"expression parsing",
"implementation"
] | B. Borze | 2 | 256 | Ternary numeric notation is quite popular in Berland. To telegraph the ternary number the Borze alphabet is used. Digit 0 is transmitted as «.», 1 as «-.» and 2 as «--». You are to decode the Borze code, i.e. to find out the ternary number given its representation in Borze alphabet. | The first line contains a number in Borze code. The length of the string is between 1 and 200 characters. It's guaranteed that the given string is a valid Borze code of some ternary number (this number can have leading zeroes). | Output the decoded ternary number. It can have leading zeroes. | [
".-.--\n",
"--.\n",
"-..-.--\n"
] | [
"012",
"20",
"1012"
] | none | 1,000 | [
{
"input": ".-.--",
"output": "012"
},
{
"input": "--.",
"output": "20"
},
{
"input": "-..-.--",
"output": "1012"
},
{
"input": "---..",
"output": "210"
},
{
"input": "..--.---..",
"output": "0020210"
},
{
"input": "-.....----.",
"output": "1000022... | 1,609,083,982 | 2,147,483,647 | Python 3 | OK | TESTS | 30 | 218 | 0 | string = input()
length = len(string)
rs = ''
i = 0
while i < length:
if string[i] == '.':
rs += '0'
if string[i] == '-':
if string[i + 1] == '.':
rs += '1'
else:
rs += '2'
i += 1
i += 1
print(rs)
| Title: Borze
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Ternary numeric notation is quite popular in Berland. To telegraph the ternary number the Borze alphabet is used. Digit 0 is transmitted as «.», 1 as «-.» and 2 as «--». You are to decode the Borze code, i.e. to find out the ternary ... | ```python
string = input()
length = len(string)
rs = ''
i = 0
while i < length:
if string[i] == '.':
rs += '0'
if string[i] == '-':
if string[i + 1] == '.':
rs += '1'
else:
rs += '2'
i += 1
i += 1
print(rs)
``` | 3.9455 | MatrixStudio/Codeforces-Python-Submissions |
233 | A | Perfect Permutation | PROGRAMMING | 800 | [
"implementation",
"math"
] | null | null | A permutation is a sequence of integers *p*1,<=*p*2,<=...,<=*p**n*, consisting of *n* distinct positive integers, each of them doesn't exceed *n*. Let's denote the *i*-th element of permutation *p* as *p**i*. We'll call number *n* the size of permutation *p*1,<=*p*2,<=...,<=*p**n*.
Nickolas adores permutations. He lik... | A single line contains a single integer *n* (1<=≤<=*n*<=≤<=100) — the permutation size. | If a perfect permutation of size *n* doesn't exist, print a single integer -1. Otherwise print *n* distinct integers from 1 to *n*, *p*1,<=*p*2,<=...,<=*p**n* — permutation *p*, that is perfect. Separate printed numbers by whitespaces. | [
"1\n",
"2\n",
"4\n"
] | [
"-1\n",
"2 1 \n",
"2 1 4 3 \n"
] | none | 500 | [
{
"input": "1",
"output": "-1"
},
{
"input": "2",
"output": "2 1 "
},
{
"input": "4",
"output": "2 1 4 3 "
},
{
"input": "3",
"output": "-1"
},
{
"input": "5",
"output": "-1"
},
{
"input": "6",
"output": "2 1 4 3 6 5 "
},
{
"input": "7",
... | 1,695,559,130 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 62 | 0 | n = int(input())
range_list = list(range(1, n+1))
if len(range_list) % 2 != 0:
print(-1)
else:
for i in range(n):
if i % 2 == 0:
a, b = range_list[i], range_list[i+1]
range_list[i+1] = a
range_list[i] = b
print(', '.join(map(str, rang... | Title: Perfect Permutation
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
A permutation is a sequence of integers *p*1,<=*p*2,<=...,<=*p**n*, consisting of *n* distinct positive integers, each of them doesn't exceed *n*. Let's denote the *i*-th element of permutation *p* as *p**i*. We'll ... | ```python
n = int(input())
range_list = list(range(1, n+1))
if len(range_list) % 2 != 0:
print(-1)
else:
for i in range(n):
if i % 2 == 0:
a, b = range_list[i], range_list[i+1]
range_list[i+1] = a
range_list[i] = b
print(', '.join(map... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
545 | A | Toy Cars | PROGRAMMING | 900 | [
"implementation"
] | null | null | Little Susie, thanks to her older brother, likes to play with cars. Today she decided to set up a tournament between them. The process of a tournament is described in the next paragraph.
There are *n* toy cars. Each pair collides. The result of a collision can be one of the following: no car turned over, one car turne... | The first line contains integer *n* (1<=≤<=*n*<=≤<=100) — the number of cars.
Each of the next *n* lines contains *n* space-separated integers that determine matrix *A*.
It is guaranteed that on the main diagonal there are <=-<=1, and <=-<=1 doesn't appear anywhere else in the matrix.
It is guaranteed that the inpu... | Print the number of good cars and in the next line print their space-separated indices in the increasing order. | [
"3\n-1 0 0\n0 -1 1\n0 2 -1\n",
"4\n-1 3 3 3\n3 -1 3 3\n3 3 -1 3\n3 3 3 -1\n"
] | [
"2\n1 3 ",
"0\n"
] | none | 500 | [
{
"input": "3\n-1 0 0\n0 -1 1\n0 2 -1",
"output": "2\n1 3 "
},
{
"input": "4\n-1 3 3 3\n3 -1 3 3\n3 3 -1 3\n3 3 3 -1",
"output": "0"
},
{
"input": "1\n-1",
"output": "1\n1 "
},
{
"input": "2\n-1 0\n0 -1",
"output": "2\n1 2 "
},
{
"input": "2\n-1 1\n2 -1",
"out... | 1,682,962,420 | 2,147,483,647 | Python 3 | OK | TESTS | 35 | 46 | 0 | n = int(input())
arr = []
for i in range(n):
row = list(map(int, input().split()))
arr.append(row)
mp = {}
for i in range(n):
for j in range(i+1, n):
if arr[i][j] == 1:
mp[i] = True
continue
if arr[i][j] == 2:
mp[j] = True
co... | Title: Toy Cars
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Little Susie, thanks to her older brother, likes to play with cars. Today she decided to set up a tournament between them. The process of a tournament is described in the next paragraph.
There are *n* toy cars. Each pair coll... | ```python
n = int(input())
arr = []
for i in range(n):
row = list(map(int, input().split()))
arr.append(row)
mp = {}
for i in range(n):
for j in range(i+1, n):
if arr[i][j] == 1:
mp[i] = True
continue
if arr[i][j] == 2:
mp[j] = True
... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
703 | A | Mishka and Game | PROGRAMMING | 800 | [
"implementation"
] | null | null | Mishka is a little polar bear. As known, little bears loves spending their free time playing dice for chocolates. Once in a wonderful sunny morning, walking around blocks of ice, Mishka met her friend Chris, and they started playing the game.
Rules of the game are very simple: at first number of rounds *n* is defined.... | The first line of the input contains single integer *n* *n* (1<=≤<=*n*<=≤<=100) — the number of game rounds.
The next *n* lines contains rounds description. *i*-th of them contains pair of integers *m**i* and *c**i* (1<=≤<=*m**i*,<=<=*c**i*<=≤<=6) — values on dice upper face after Mishka's and Chris' throws in *i*-th ... | If Mishka is the winner of the game, print "Mishka" (without quotes) in the only line.
If Chris is the winner of the game, print "Chris" (without quotes) in the only line.
If the result of the game is draw, print "Friendship is magic!^^" (without quotes) in the only line. | [
"3\n3 5\n2 1\n4 2\n",
"2\n6 1\n1 6\n",
"3\n1 5\n3 3\n2 2\n"
] | [
"Mishka",
"Friendship is magic!^^",
"Chris"
] | In the first sample case Mishka loses the first round, but wins second and third rounds and thus she is the winner of the game.
In the second sample case Mishka wins the first round, Chris wins the second round, and the game ends with draw with score 1:1.
In the third sample case Chris wins the first round, but there... | 500 | [
{
"input": "3\n3 5\n2 1\n4 2",
"output": "Mishka"
},
{
"input": "2\n6 1\n1 6",
"output": "Friendship is magic!^^"
},
{
"input": "3\n1 5\n3 3\n2 2",
"output": "Chris"
},
{
"input": "6\n4 1\n4 2\n5 3\n5 1\n5 3\n4 1",
"output": "Mishka"
},
{
"input": "8\n2 4\n1 4\n1 ... | 1,689,659,179 | 2,147,483,647 | Python 3 | OK | TESTS | 69 | 46 | 0 | m=0
c=0
for i in range(int(input())):
a,b=map(int,input().split())
if(a > b):
m = m+1
elif a==b:
continue
else:
c = c+1
if(m > c):
print("Mishka")
elif(m<c):
print("Chris")
else:
print("Friendship is magic!^^")
| Title: Mishka and Game
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Mishka is a little polar bear. As known, little bears loves spending their free time playing dice for chocolates. Once in a wonderful sunny morning, walking around blocks of ice, Mishka met her friend Chris, and they st... | ```python
m=0
c=0
for i in range(int(input())):
a,b=map(int,input().split())
if(a > b):
m = m+1
elif a==b:
continue
else:
c = c+1
if(m > c):
print("Mishka")
elif(m<c):
print("Chris")
else:
print("Friendship is magic!^^")
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
49 | A | Sleuth | PROGRAMMING | 800 | [
"implementation"
] | A. Sleuth | 2 | 256 | Vasya plays the sleuth with his friends. The rules of the game are as follows: those who play for the first time, that is Vasya is the sleuth, he should investigate a "crime" and find out what is happening. He can ask any questions whatsoever that can be answered with "Yes" or "No". All the rest agree beforehand to ans... | The single line contains a question represented by a non-empty line consisting of large and small Latin letters, spaces and a question mark. The line length does not exceed 100. It is guaranteed that the question mark occurs exactly once in the line — as the last symbol and that the line contains at least one letter. | Print answer for the question in a single line: YES if the answer is "Yes", NO if the answer is "No".
Remember that in the reply to the question the last letter, not the last character counts. I. e. the spaces and the question mark do not count as letters. | [
"Is it a melon?\n",
"Is it an apple?\n",
"Is it a banana ?\n",
"Is it an apple and a banana simultaneouSLY?\n"
] | [
"NO\n",
"YES\n",
"YES\n",
"YES\n"
] | none | 500 | [
{
"input": "Is it a melon?",
"output": "NO"
},
{
"input": "Is it an apple?",
"output": "YES"
},
{
"input": " Is it a banana ?",
"output": "YES"
},
{
"input": "Is it an apple and a banana simultaneouSLY?",
"output": "YES"
},
{
"input": "oHtSbDwzHb?",
... | 1,616,976,779 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 92 | 0 | s=input()
x="AOUIEYaouiey"
if s[-2] in x:
print("YES")
else:
print("NO") | Title: Sleuth
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Vasya plays the sleuth with his friends. The rules of the game are as follows: those who play for the first time, that is Vasya is the sleuth, he should investigate a "crime" and find out what is happening. He can ask any questions ... | ```python
s=input()
x="AOUIEYaouiey"
if s[-2] in x:
print("YES")
else:
print("NO")
``` | 0 | MatrixStudio/Codeforces-Python-Submissions |
25 | A | IQ test | PROGRAMMING | 1,300 | [
"brute force"
] | A. IQ test | 2 | 256 | Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given *n* numbers differs from the others. Bob observed that one number usually differs from the others in evenness. Help Bob — to check his answers, he needs a program that among the given *n* numbers finds one that i... | The first line contains integer *n* (3<=≤<=*n*<=≤<=100) — amount of numbers in the task. The second line contains *n* space-separated natural numbers, not exceeding 100. It is guaranteed, that exactly one of these numbers differs from the others in evenness. | Output index of number that differs from the others in evenness. Numbers are numbered from 1 in the input order. | [
"5\n2 4 7 8 10\n",
"4\n1 2 1 1\n"
] | [
"3\n",
"2\n"
] | none | 0 | [
{
"input": "5\n2 4 7 8 10",
"output": "3"
},
{
"input": "4\n1 2 1 1",
"output": "2"
},
{
"input": "3\n1 2 2",
"output": "1"
},
{
"input": "3\n100 99 100",
"output": "2"
},
{
"input": "3\n5 3 2",
"output": "3"
},
{
"input": "4\n43 28 1 91",
"output"... | 1,483,102,509 | 2,147,483,647 | Python 3 | OK | TESTS | 32 | 184 | 4,608,000 | n=int(input())
l=[int(x)%2 for x in input().split()]
print(l.index(0)+1 if l.count(0)==1 else l.index(1)+1)
| Title: IQ test
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given *n* numbers differs from the others. Bob observed that one number usually differs from the others in evenness. Help Bob — t... | ```python
n=int(input())
l=[int(x)%2 for x in input().split()]
print(l.index(0)+1 if l.count(0)==1 else l.index(1)+1)
``` | 3.945417 | MatrixStudio/Codeforces-Python-Submissions |
313 | B | Ilya and Queries | PROGRAMMING | 1,100 | [
"dp",
"implementation"
] | null | null | Ilya the Lion wants to help all his friends with passing exams. They need to solve the following problem to pass the IT exam.
You've got string *s*<==<=*s*1*s*2... *s**n* (*n* is the length of the string), consisting only of characters "." and "#" and *m* queries. Each query is described by a pair of integers *l**i*,<... | The first line contains string *s* of length *n* (2<=≤<=*n*<=≤<=105). It is guaranteed that the given string only consists of characters "." and "#".
The next line contains integer *m* (1<=≤<=*m*<=≤<=105) — the number of queries. Each of the next *m* lines contains the description of the corresponding query. The *i*-t... | Print *m* integers — the answers to the queries in the order in which they are given in the input. | [
"......\n4\n3 4\n2 3\n1 6\n2 6\n",
"#..###\n5\n1 3\n5 6\n1 5\n3 6\n3 4\n"
] | [
"1\n1\n5\n4\n",
"1\n1\n2\n2\n0\n"
] | none | 1,000 | [
{
"input": "......\n4\n3 4\n2 3\n1 6\n2 6",
"output": "1\n1\n5\n4"
},
{
"input": "#..###\n5\n1 3\n5 6\n1 5\n3 6\n3 4",
"output": "1\n1\n2\n2\n0"
},
{
"input": ".#...#..\n6\n1 5\n2 3\n6 7\n2 4\n2 5\n1 3",
"output": "2\n0\n0\n1\n2\n0"
},
{
"input": "#.#.#..\n5\n3 4\n4 5\n5 7\n5... | 1,692,367,095 | 2,147,483,647 | Python 3 | OK | TESTS | 37 | 1,496 | 5,222,400 | s = input()
n = len(s)
consecutive_counts = [0]
for i in range(1, n):
if s[i] == s[i - 1]:
consecutive_counts.append(consecutive_counts[i - 1] + 1)
else:
consecutive_counts.append(consecutive_counts[i - 1])
m = int(input())
for _ in range(m):
li, ri = map(int, input().split())
... | Title: Ilya and Queries
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Ilya the Lion wants to help all his friends with passing exams. They need to solve the following problem to pass the IT exam.
You've got string *s*<==<=*s*1*s*2... *s**n* (*n* is the length of the string), consisting ... | ```python
s = input()
n = len(s)
consecutive_counts = [0]
for i in range(1, n):
if s[i] == s[i - 1]:
consecutive_counts.append(consecutive_counts[i - 1] + 1)
else:
consecutive_counts.append(consecutive_counts[i - 1])
m = int(input())
for _ in range(m):
li, ri = map(int, input()... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
344 | A | Magnets | PROGRAMMING | 800 | [
"implementation"
] | null | null | Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together at a close distance, then the like poles will repel each other and the oppo... | The first line of the input contains an integer *n* (1<=≤<=*n*<=≤<=100000) — the number of magnets. Then *n* lines follow. The *i*-th line (1<=≤<=*i*<=≤<=*n*) contains either characters "01", if Mike put the *i*-th magnet in the "plus-minus" position, or characters "10", if Mike put the magnet in the "minus-plus" posit... | On the single line of the output print the number of groups of magnets. | [
"6\n10\n10\n10\n01\n10\n10\n",
"4\n01\n01\n10\n10\n"
] | [
"3\n",
"2\n"
] | The first testcase corresponds to the figure. The testcase has three groups consisting of three, one and two magnets.
The second testcase has two groups, each consisting of two magnets. | 500 | [
{
"input": "6\n10\n10\n10\n01\n10\n10",
"output": "3"
},
{
"input": "4\n01\n01\n10\n10",
"output": "2"
},
{
"input": "1\n10",
"output": "1"
},
{
"input": "2\n01\n10",
"output": "2"
},
{
"input": "2\n10\n10",
"output": "1"
},
{
"input": "3\n10\n01\n10",... | 1,695,920,077 | 2,147,483,647 | Python 3 | OK | TESTS | 31 | 218 | 0 | n = int(input())
i = 1
y = input()
for z in range(1, n):
x = input()
if x != y:
i += 1
y = x
print(i)
| Title: Magnets
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets... | ```python
n = int(input())
i = 1
y = input()
for z in range(1, n):
x = input()
if x != y:
i += 1
y = x
print(i)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
659 | D | Bicycle Race | PROGRAMMING | 1,500 | [
"geometry",
"implementation",
"math"
] | null | null | Maria participates in a bicycle race.
The speedway takes place on the shores of Lake Lucerne, just repeating its contour. As you know, the lake shore consists only of straight sections, directed to the north, south, east or west.
Let's introduce a system of coordinates, directing the *Ox* axis from west to east, and ... | The first line of the input contains an integer *n* (4<=≤<=*n*<=≤<=1000) — the number of straight sections of the track.
The following (*n*<=+<=1)-th line contains pairs of integers (*x**i*,<=*y**i*) (<=-<=10<=000<=≤<=*x**i*,<=*y**i*<=≤<=10<=000). The first of these points is the starting position. The *i*-th straight... | Print a single integer — the number of dangerous turns on the track. | [
"6\n0 0\n0 1\n1 1\n1 2\n2 2\n2 0\n0 0\n",
"16\n1 1\n1 5\n3 5\n3 7\n2 7\n2 9\n6 9\n6 7\n5 7\n5 3\n4 3\n4 4\n3 4\n3 2\n5 2\n5 1\n1 1\n"
] | [
"1\n",
"6\n"
] | The first sample corresponds to the picture:
The picture shows that you can get in the water under unfortunate circumstances only at turn at the point (1, 1). Thus, the answer is 1. | 1,250 | [
{
"input": "6\n0 0\n0 1\n1 1\n1 2\n2 2\n2 0\n0 0",
"output": "1"
},
{
"input": "16\n1 1\n1 5\n3 5\n3 7\n2 7\n2 9\n6 9\n6 7\n5 7\n5 3\n4 3\n4 4\n3 4\n3 2\n5 2\n5 1\n1 1",
"output": "6"
},
{
"input": "4\n-10000 -10000\n-10000 10000\n10000 10000\n10000 -10000\n-10000 -10000",
"output": ... | 1,623,762,632 | 2,147,483,647 | PyPy 3 | OK | TESTS | 22 | 108 | 1,331,200 | for _ in range(1):
n=int(input())
for i in range(n):
a,b=map(int,input().split())
print((n-4)//2) | Title: Bicycle Race
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Maria participates in a bicycle race.
The speedway takes place on the shores of Lake Lucerne, just repeating its contour. As you know, the lake shore consists only of straight sections, directed to the north, south, east ... | ```python
for _ in range(1):
n=int(input())
for i in range(n):
a,b=map(int,input().split())
print((n-4)//2)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
80 | A | Panoramix's Prediction | PROGRAMMING | 800 | [
"brute force"
] | A. Panoramix's Prediction | 2 | 256 | A prime number is a number which has exactly two distinct divisors: one and itself. For example, numbers 2, 7, 3 are prime, and 1, 6, 4 are not.
The next prime number after *x* is the smallest prime number greater than *x*. For example, the next prime number after 2 is 3, and the next prime number after 3 is 5. Note t... | The first and only input line contains two positive integers — *n* and *m* (2<=≤<=*n*<=<<=*m*<=≤<=50). It is guaranteed that *n* is prime.
Pretests contain all the cases with restrictions 2<=≤<=*n*<=<<=*m*<=≤<=4. | Print YES, if *m* is the next prime number after *n*, or NO otherwise. | [
"3 5\n",
"7 11\n",
"7 9\n"
] | [
"YES",
"YES",
"NO"
] | none | 500 | [
{
"input": "3 5",
"output": "YES"
},
{
"input": "7 11",
"output": "YES"
},
{
"input": "7 9",
"output": "NO"
},
{
"input": "2 3",
"output": "YES"
},
{
"input": "2 4",
"output": "NO"
},
{
"input": "3 4",
"output": "NO"
},
{
"input": "3 5",
... | 1,610,072,378 | 3,878 | Python 3 | OK | TESTS | 45 | 218 | 307,200 | def checkPrime ( num ):
n = num - 1
while n > 1:
if num % n == 0:
return False
n = n - 1
return True
n , m = input().split()
n = int (n)
m = int (m)
i = n + 1
p = 0
if checkPrime(m) == True:
while i < m:
if checkPrime(i) == True:
p = p +... | Title: Panoramix's Prediction
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
A prime number is a number which has exactly two distinct divisors: one and itself. For example, numbers 2, 7, 3 are prime, and 1, 6, 4 are not.
The next prime number after *x* is the smallest prime number greater t... | ```python
def checkPrime ( num ):
n = num - 1
while n > 1:
if num % n == 0:
return False
n = n - 1
return True
n , m = input().split()
n = int (n)
m = int (m)
i = n + 1
p = 0
if checkPrime(m) == True:
while i < m:
if checkPrime(i) == True:
... | 3.944928 | MatrixStudio/Codeforces-Python-Submissions |
34 | B | Sale | PROGRAMMING | 900 | [
"greedy",
"sortings"
] | B. Sale | 2 | 256 | Once Bob got to a sale of old TV sets. There were *n* TV sets at that sale. TV set with index *i* costs *a**i* bellars. Some TV sets have a negative price — their owners are ready to pay Bob if he buys their useless apparatus. Bob can «buy» any TV sets he wants. Though he's very strong, Bob can carry at most *m* TV set... | The first line contains two space-separated integers *n* and *m* (1<=≤<=*m*<=≤<=*n*<=≤<=100) — amount of TV sets at the sale, and amount of TV sets that Bob can carry. The following line contains *n* space-separated integers *a**i* (<=-<=1000<=≤<=*a**i*<=≤<=1000) — prices of the TV sets. | Output the only number — the maximum sum of money that Bob can earn, given that he can carry at most *m* TV sets. | [
"5 3\n-6 0 35 -2 4\n",
"4 2\n7 0 0 -7\n"
] | [
"8\n",
"7\n"
] | none | 1,000 | [
{
"input": "5 3\n-6 0 35 -2 4",
"output": "8"
},
{
"input": "4 2\n7 0 0 -7",
"output": "7"
},
{
"input": "6 6\n756 -611 251 -66 572 -818",
"output": "1495"
},
{
"input": "5 5\n976 437 937 788 518",
"output": "0"
},
{
"input": "5 3\n-2 -2 -2 -2 -2",
"output": "... | 1,657,448,833 | 2,147,483,647 | PyPy 3-64 | RUNTIME_ERROR | TESTS | 0 | 184 | 5,734,400 | n,m=map(int,input())
l=list(map(int,input().split()))
l.sort()
if m>n:
m=n
sumtv=0
for i in range(0,m):
if l[i]<=0:
sumtv+=l[i]
print(sumtv) | Title: Sale
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Once Bob got to a sale of old TV sets. There were *n* TV sets at that sale. TV set with index *i* costs *a**i* bellars. Some TV sets have a negative price — their owners are ready to pay Bob if he buys their useless apparatus. Bob can... | ```python
n,m=map(int,input())
l=list(map(int,input().split()))
l.sort()
if m>n:
m=n
sumtv=0
for i in range(0,m):
if l[i]<=0:
sumtv+=l[i]
print(sumtv)
``` | -1 | 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,667,282,824 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 3 | 31 | 0 | a,b=map(int,input().split())
c=[]
s=[]
for i in range(1,b+1):
if b%i==0:
c=c+[i]
c=c[len(c)//2:len(c)]
for i in range(len(c)):
if c[i]<=a:
s=s+[c[i]]
print(len(s)*2)
| 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
a,b=map(int,input().split())
c=[]
s=[]
for i in range(1,b+1):
if b%i==0:
c=c+[i]
c=c[len(c)//2:len(c)]
for i in range(len(c)):
if c[i]<=a:
s=s+[c[i]]
print(len(s)*2)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
616 | A | Comparing Two Long Integers | PROGRAMMING | 900 | [
"implementation",
"strings"
] | null | null | You are given two very long integers *a*,<=*b* (leading zeroes are allowed). You should check what number *a* or *b* is greater or determine that they are equal.
The input size is very large so don't use the reading of symbols one by one. Instead of that use the reading of a whole line or token.
As input/output can r... | The first line contains a non-negative integer *a*.
The second line contains a non-negative integer *b*.
The numbers *a*,<=*b* may contain leading zeroes. Each of them contains no more than 106 digits. | Print the symbol "<" if *a*<=<<=*b* and the symbol ">" if *a*<=><=*b*. If the numbers are equal print the symbol "=". | [
"9\n10\n",
"11\n10\n",
"00012345\n12345\n",
"0123\n9\n",
"0123\n111\n"
] | [
"<\n",
">\n",
"=\n",
">\n",
">\n"
] | none | 0 | [
{
"input": "9\n10",
"output": "<"
},
{
"input": "11\n10",
"output": ">"
},
{
"input": "00012345\n12345",
"output": "="
},
{
"input": "0123\n9",
"output": ">"
},
{
"input": "0123\n111",
"output": ">"
},
{
"input": "9\n9",
"output": "="
},
{
... | 1,640,356,978 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 6 | 46 | 0 | a=str(input())
b=str(input())
arr1=list(a)
arr2=list(b)
check=0
for i in arr1:
if arr1[check]=='0':
del arr1[check]
for i in arr2:
if arr2[check]=='0':
del arr2[check]
final_a=''
for i in arr1:
final_a+=i
final_b=''
for i in arr2:
final_b+=i
A=int(final_a)
B=int(final_b)
if A<B:
print("<")
elif ... | Title: Comparing Two Long Integers
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given two very long integers *a*,<=*b* (leading zeroes are allowed). You should check what number *a* or *b* is greater or determine that they are equal.
The input size is very large so don't use th... | ```python
a=str(input())
b=str(input())
arr1=list(a)
arr2=list(b)
check=0
for i in arr1:
if arr1[check]=='0':
del arr1[check]
for i in arr2:
if arr2[check]=='0':
del arr2[check]
final_a=''
for i in arr1:
final_a+=i
final_b=''
for i in arr2:
final_b+=i
A=int(final_a)
B=int(final_b)
if A<B:
print(... | -1 | MatrixStudio/Codeforces-Python-Submissions | |
888 | B | Buggy Robot | PROGRAMMING | 1,000 | [
"greedy"
] | null | null | Ivan has a robot which is situated on an infinite grid. Initially the robot is standing in the starting cell (0,<=0). The robot can process commands. There are four types of commands it can perform:
- U — move from the cell (*x*,<=*y*) to (*x*,<=*y*<=+<=1); - D — move from (*x*,<=*y*) to (*x*,<=*y*<=-<=1); - L — mo... | The first line contains one number *n* — the length of sequence of commands entered by Ivan (1<=≤<=*n*<=≤<=100).
The second line contains the sequence itself — a string consisting of *n* characters. Each character can be U, D, L or R. | Print the maximum possible number of commands from the sequence the robot could perform to end up in the starting cell. | [
"4\nLDUR\n",
"5\nRRRUU\n",
"6\nLLRRRR\n"
] | [
"4\n",
"0\n",
"4\n"
] | none | 0 | [
{
"input": "4\nLDUR",
"output": "4"
},
{
"input": "5\nRRRUU",
"output": "0"
},
{
"input": "6\nLLRRRR",
"output": "4"
},
{
"input": "88\nLLUUULRDRRURDDLURRLRDRLLRULRUUDDLLLLRRDDURDURRLDURRLDRRRUULDDLRRRDDRRLUULLURDURUDDDDDLDR",
"output": "76"
},
{
"input": "89\nLDL... | 1,520,382,070 | 2,147,483,647 | PyPy 3 | OK | TESTS | 25 | 77 | 19,968,000 |
n = int(input())
A = {
'L': 0,
'R': 0,
'D': 0,
'U': 0
}
for x in input():
A[x] += 1
print(n - abs(A['L'] - A['R']) - abs(A['D'] - A['U']))
| Title: Buggy Robot
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Ivan has a robot which is situated on an infinite grid. Initially the robot is standing in the starting cell (0,<=0). The robot can process commands. There are four types of commands it can perform:
- U — move from the ce... | ```python
n = int(input())
A = {
'L': 0,
'R': 0,
'D': 0,
'U': 0
}
for x in input():
A[x] += 1
print(n - abs(A['L'] - A['R']) - abs(A['D'] - A['U']))
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
734 | A | Anton and Danik | PROGRAMMING | 800 | [
"implementation",
"strings"
] | null | null | Anton likes to play chess, and so does his friend Danik.
Once they have played *n* games in a row. For each game it's known who was the winner — Anton or Danik. None of the games ended with a tie.
Now Anton wonders, who won more games, he or Danik? Help him determine this. | The first line of the input contains a single integer *n* (1<=≤<=*n*<=≤<=100<=000) — the number of games played.
The second line contains a string *s*, consisting of *n* uppercase English letters 'A' and 'D' — the outcome of each of the games. The *i*-th character of the string is equal to 'A' if the Anton won the *i*... | If Anton won more games than Danik, print "Anton" (without quotes) in the only line of the output.
If Danik won more games than Anton, print "Danik" (without quotes) in the only line of the output.
If Anton and Danik won the same number of games, print "Friendship" (without quotes). | [
"6\nADAAAA\n",
"7\nDDDAADA\n",
"6\nDADADA\n"
] | [
"Anton\n",
"Danik\n",
"Friendship\n"
] | In the first sample, Anton won 6 games, while Danik — only 1. Hence, the answer is "Anton".
In the second sample, Anton won 3 games and Danik won 4 games, so the answer is "Danik".
In the third sample, both Anton and Danik won 3 games and the answer is "Friendship". | 500 | [
{
"input": "6\nADAAAA",
"output": "Anton"
},
{
"input": "7\nDDDAADA",
"output": "Danik"
},
{
"input": "6\nDADADA",
"output": "Friendship"
},
{
"input": "10\nDDDDADDADD",
"output": "Danik"
},
{
"input": "40\nAAAAAAAAADDAAAAAAAAAAADADDAAAAAAAAAAADAA",
"output": ... | 1,692,629,410 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 25 | 62 | 1,740,800 | amount_of_parties = int(input())
cell = input()
toxa = 0
danik = 0
for i in range(amount_of_parties):
if cell[i] == 'A':
toxa += 1
if cell[i] == 'D':
danik += 1
if toxa == danik:
print('Friendship')
if toxa > danik:
print('Anton')
if toxa < danik:
print('Danik') | Title: Anton and Danik
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Anton likes to play chess, and so does his friend Danik.
Once they have played *n* games in a row. For each game it's known who was the winner — Anton or Danik. None of the games ended with a tie.
Now Anton wonders, w... | ```python
amount_of_parties = int(input())
cell = input()
toxa = 0
danik = 0
for i in range(amount_of_parties):
if cell[i] == 'A':
toxa += 1
if cell[i] == 'D':
danik += 1
if toxa == danik:
print('Friendship')
if toxa > danik:
print('Anton')
if toxa < danik:
print('D... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
433 | B | Kuriyama Mirai's Stones | PROGRAMMING | 1,200 | [
"dp",
"implementation",
"sortings"
] | null | null | Kuriyama Mirai has killed many monsters and got many (namely *n*) stones. She numbers the stones from 1 to *n*. The cost of the *i*-th stone is *v**i*. Kuriyama Mirai wants to know something about these stones so she will ask you two kinds of questions:
1. She will tell you two numbers, *l* and *r* (1<=≤<=*l*<=≤<=*r*... | The first line contains an integer *n* (1<=≤<=*n*<=≤<=105). The second line contains *n* integers: *v*1,<=*v*2,<=...,<=*v**n* (1<=≤<=*v**i*<=≤<=109) — costs of the stones.
The third line contains an integer *m* (1<=≤<=*m*<=≤<=105) — the number of Kuriyama Mirai's questions. Then follow *m* lines, each line contains t... | Print *m* lines. Each line must contain an integer — the answer to Kuriyama Mirai's question. Print the answers to the questions in the order of input. | [
"6\n6 4 2 7 2 7\n3\n2 3 6\n1 3 4\n1 1 6\n",
"4\n5 5 2 3\n10\n1 2 4\n2 1 4\n1 1 1\n2 1 4\n2 1 2\n1 1 1\n1 3 3\n1 1 3\n1 4 4\n1 2 2\n"
] | [
"24\n9\n28\n",
"10\n15\n5\n15\n5\n5\n2\n12\n3\n5\n"
] | Please note that the answers to the questions may overflow 32-bit integer type. | 1,500 | [
{
"input": "6\n6 4 2 7 2 7\n3\n2 3 6\n1 3 4\n1 1 6",
"output": "24\n9\n28"
},
{
"input": "4\n5 5 2 3\n10\n1 2 4\n2 1 4\n1 1 1\n2 1 4\n2 1 2\n1 1 1\n1 3 3\n1 1 3\n1 4 4\n1 2 2",
"output": "10\n15\n5\n15\n5\n5\n2\n12\n3\n5"
},
{
"input": "4\n2 2 3 6\n9\n2 2 3\n1 1 3\n2 2 3\n2 2 3\n2 2 2\n1... | 1,646,301,788 | 2,147,483,647 | Python 3 | OK | TESTS | 46 | 1,076 | 9,216,000 | n = int(input())
*v, = map(int, input().split())
u = sorted(v)
for i in range(1, n):
v[i] += v[i-1]
u[i] += u[i-1]
for _ in range(int(input())):
t, l, r = map(int, input().split())
if t == 2:
print(u[r-1]-u[l-2] if l-1 != 0 else u[r-1])
else:
print(v[r-1]-v[l-2] if l-1 != ... | Title: Kuriyama Mirai's Stones
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Kuriyama Mirai has killed many monsters and got many (namely *n*) stones. She numbers the stones from 1 to *n*. The cost of the *i*-th stone is *v**i*. Kuriyama Mirai wants to know something about these stones s... | ```python
n = int(input())
*v, = map(int, input().split())
u = sorted(v)
for i in range(1, n):
v[i] += v[i-1]
u[i] += u[i-1]
for _ in range(int(input())):
t, l, r = map(int, input().split())
if t == 2:
print(u[r-1]-u[l-2] if l-1 != 0 else u[r-1])
else:
print(v[r-1]-v[l-2] ... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
443 | A | Anton and Letters | PROGRAMMING | 800 | [
"constructive algorithms",
"implementation"
] | null | null | Recently, Anton has found a set. The set consists of small English letters. Anton carefully wrote out all the letters from the set in one line, separated by a comma. He also added an opening curved bracket at the beginning of the line and a closing curved bracket at the end of the line.
Unfortunately, from time to ti... | The first and the single line contains the set of letters. The length of the line doesn't exceed 1000. It is guaranteed that the line starts from an opening curved bracket and ends with a closing curved bracket. Between them, small English letters are listed, separated by a comma. Each comma is followed by a space. | Print a single number — the number of distinct letters in Anton's set. | [
"{a, b, c}\n",
"{b, a, b, a}\n",
"{}\n"
] | [
"3\n",
"2\n",
"0\n"
] | none | 500 | [
{
"input": "{a, b, c}",
"output": "3"
},
{
"input": "{b, a, b, a}",
"output": "2"
},
{
"input": "{}",
"output": "0"
},
{
"input": "{a, a, c, b, b, b, c, c, c, c}",
"output": "3"
},
{
"input": "{a, c, b, b}",
"output": "3"
},
{
"input": "{a, b}",
"o... | 1,698,431,951 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 0 | 62 | 0 | n=list(input())
n.pop(0)
n.pop(-1)
x=set(n)
count=0
for i in range(len(x)):
if n[i]<n[i-1]:
count+=1
if count>=0:
print(count+1)
else:
print(-1) | Title: Anton and Letters
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Recently, Anton has found a set. The set consists of small English letters. Anton carefully wrote out all the letters from the set in one line, separated by a comma. He also added an opening curved bracket at the begi... | ```python
n=list(input())
n.pop(0)
n.pop(-1)
x=set(n)
count=0
for i in range(len(x)):
if n[i]<n[i-1]:
count+=1
if count>=0:
print(count+1)
else:
print(-1)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
63 | A | Sinking Ship | PROGRAMMING | 900 | [
"implementation",
"sortings",
"strings"
] | A. Sinking Ship | 2 | 256 | The ship crashed into a reef and is sinking. Now the entire crew must be evacuated. All *n* crew members have already lined up in a row (for convenience let's label them all from left to right with positive integers from 1 to *n*) and await further instructions. However, one should evacuate the crew properly, in a stri... | The first line contains an integer *n*, which is the number of people in the crew (1<=≤<=*n*<=≤<=100). Then follow *n* lines. The *i*-th of those lines contains two words — the name of the crew member who is *i*-th in line, and his status on the ship. The words are separated by exactly one space. There are no other spa... | Print *n* lines. The *i*-th of them should contain the name of the crew member who must be the *i*-th one to leave the ship. | [
"6\nJack captain\nAlice woman\nCharlie man\nTeddy rat\nBob child\nJulia woman\n"
] | [
"Teddy\nAlice\nBob\nJulia\nCharlie\nJack\n"
] | none | 500 | [
{
"input": "6\nJack captain\nAlice woman\nCharlie man\nTeddy rat\nBob child\nJulia woman",
"output": "Teddy\nAlice\nBob\nJulia\nCharlie\nJack"
},
{
"input": "1\nA captain",
"output": "A"
},
{
"input": "1\nAbcdefjhij captain",
"output": "Abcdefjhij"
},
{
"input": "5\nA captain... | 1,593,070,523 | 2,147,483,647 | Python 3 | OK | TESTS | 26 | 218 | 6,963,200 | people = int(input())
womansOrChilds = []
mans = []
rats = []
captains = []
for _ in range(people):
s = input()
s = s.split()
if s[1] == 'rat':
rats.append(s[0])
if s[1] == 'man':
mans.append(s[0])
if s[1] == 'woman':
womansOrChilds.append(s[0])
if s[1... | Title: Sinking Ship
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
The ship crashed into a reef and is sinking. Now the entire crew must be evacuated. All *n* crew members have already lined up in a row (for convenience let's label them all from left to right with positive integers from 1 to ... | ```python
people = int(input())
womansOrChilds = []
mans = []
rats = []
captains = []
for _ in range(people):
s = input()
s = s.split()
if s[1] == 'rat':
rats.append(s[0])
if s[1] == 'man':
mans.append(s[0])
if s[1] == 'woman':
womansOrChilds.append(s[0])
... | 3.93253 | MatrixStudio/Codeforces-Python-Submissions |
120 | A | Elevator | PROGRAMMING | 1,000 | [
"brute force",
"implementation",
"math"
] | null | null | A sky scraper with 1000 floors has been built in the city of N. It has modern superfast elevators to help to travel from one floor to another. Each elevator has two doors, the front one and the back one. If one goes in through the front door, he goes out through the back one and vice versa. The elevator has two rails n... | The first line indicates the door through which the very important person entered the elevator. It contains "front" if the person enters the elevator through the front door and "back" if he entered the elevator through the back door. The second line contains integer *a* (1<=≤<=*a*<=≤<=2) which denotes the number of the... | Print character "R" if the VIP is right-handed or "L" if he is left-handed. | [
"front\n1\n"
] | [
"L\n"
] | none | 0 | [
{
"input": "front\n1",
"output": "L"
},
{
"input": "back\n1",
"output": "R"
},
{
"input": "front\n2",
"output": "R"
},
{
"input": "back\n2",
"output": "L"
}
] | 1,685,790,206 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 30 | 0 | s = input()
n = int(input())
| Title: Elevator
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
A sky scraper with 1000 floors has been built in the city of N. It has modern superfast elevators to help to travel from one floor to another. Each elevator has two doors, the front one and the back one. If one goes in through... | ```python
s = input()
n = int(input())
``` | -1 | MatrixStudio/Codeforces-Python-Submissions | |
948 | A | Protect Sheep | PROGRAMMING | 900 | [
"brute force",
"dfs and similar",
"graphs",
"implementation"
] | null | null | Bob is a farmer. He has a large pasture with many sheep. Recently, he has lost some of them due to wolf attacks. He thus decided to place some shepherd dogs in such a way that all his sheep are protected.
The pasture is a rectangle consisting of *R*<=×<=*C* cells. Each cell is either empty, contains a sheep, a wolf or... | First line contains two integers *R* (1<=≤<=*R*<=≤<=500) and *C* (1<=≤<=*C*<=≤<=500), denoting the number of rows and the numbers of columns respectively.
Each of the following *R* lines is a string consisting of exactly *C* characters, representing one row of the pasture. Here, 'S' means a sheep, 'W' a wolf and '.' a... | If it is impossible to protect all sheep, output a single line with the word "No".
Otherwise, output a line with the word "Yes". Then print *R* lines, representing the pasture after placing dogs. Again, 'S' means a sheep, 'W' a wolf, 'D' is a dog and '.' an empty space. You are not allowed to move, remove or add a she... | [
"6 6\n..S...\n..S.W.\n.S....\n..W...\n...W..\n......\n",
"1 2\nSW\n",
"5 5\n.S...\n...S.\nS....\n...S.\n.S...\n"
] | [
"Yes\n..SD..\n..SDW.\n.SD...\n.DW...\nDD.W..\n......\n",
"No\n",
"Yes\n.S...\n...S.\nS.D..\n...S.\n.S...\n"
] | In the first example, we can split the pasture into two halves, one containing wolves and one containing sheep. Note that the sheep at (2,1) is safe, as wolves cannot move diagonally.
In the second example, there are no empty spots to put dogs that would guard the lone sheep.
In the third example, there are no wolves... | 500 | [
{
"input": "1 2\nSW",
"output": "No"
},
{
"input": "10 10\n....W.W.W.\n.........S\n.S.S...S..\nW.......SS\n.W..W.....\n.W...W....\nS..S...S.S\n....W...S.\n..S..S.S.S\nSS.......S",
"output": "Yes\nDDDDWDWDWD\nDDDDDDDDDS\nDSDSDDDSDD\nWDDDDDDDSS\nDWDDWDDDDD\nDWDDDWDDDD\nSDDSDDDSDS\nDDDDWDDDSD\nDDSD... | 1,632,912,487 | 2,147,483,647 | PyPy 3 | OK | TESTS | 98 | 171 | 27,852,800 | # rectangle of r*c cells
# empty, sheep, wolf or dog
# sheep and dogs stay in place, wolves roam
def solve(r, c, p):
for i in range(r):
for j in range(c):
if p[i][j] == "S":
# left/right
if j > 0 and j < c-1:
... | Title: Protect Sheep
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Bob is a farmer. He has a large pasture with many sheep. Recently, he has lost some of them due to wolf attacks. He thus decided to place some shepherd dogs in such a way that all his sheep are protected.
The pasture is ... | ```python
# rectangle of r*c cells
# empty, sheep, wolf or dog
# sheep and dogs stay in place, wolves roam
def solve(r, c, p):
for i in range(r):
for j in range(c):
if p[i][j] == "S":
# left/right
if j > 0 and j < c-1:
... | 3 | 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,686,191,500 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 4 | 62 | 0 | n , t = map(int , input().split())
a = sorted(list(map(int , input().split())))
count = 0
for i in range(n):
if a[i] < t:
t = t - a[i]
count = count + 1
print(count) | 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 = sorted(list(map(int , input().split())))
count = 0
for i in range(n):
if a[i] < t:
t = t - a[i]
count = count + 1
print(count)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
909 | A | Generate Login | PROGRAMMING | 1,000 | [
"brute force",
"greedy",
"sortings"
] | null | null | The preferred way to generate user login in Polygon is to concatenate a prefix of the user's first name and a prefix of their last name, in that order. Each prefix must be non-empty, and any of the prefixes can be the full name. Typically there are multiple possible logins for each person.
You are given the first and ... | The input consists of a single line containing two space-separated strings: the first and the last names. Each character of each string is a lowercase English letter. The length of each string is between 1 and 10, inclusive. | Output a single string — alphabetically earliest possible login formed from these names. The output should be given in lowercase as well. | [
"harry potter\n",
"tom riddle\n"
] | [
"hap\n",
"tomr\n"
] | none | 500 | [
{
"input": "harry potter",
"output": "hap"
},
{
"input": "tom riddle",
"output": "tomr"
},
{
"input": "a qdpinbmcrf",
"output": "aq"
},
{
"input": "wixjzniiub ssdfodfgap",
"output": "wis"
},
{
"input": "z z",
"output": "zz"
},
{
"input": "ertuyivhfg v"... | 1,520,947,855 | 1,855 | Python 3 | WRONG_ANSWER | TESTS | 3 | 62 | 5,632,000 | inp = input()
inp = inp.split()
ans = ""
p = False
for i in range(0,len(inp[0])):
for j in range(0,len(inp[1])):
if inp[0][i] == inp[1][j]:
p = True
if p == False:
ans = ans + inp[0][i]
ans += inp[1][0]
print(ans) | Title: Generate Login
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The preferred way to generate user login in Polygon is to concatenate a prefix of the user's first name and a prefix of their last name, in that order. Each prefix must be non-empty, and any of the prefixes can be the fu... | ```python
inp = input()
inp = inp.split()
ans = ""
p = False
for i in range(0,len(inp[0])):
for j in range(0,len(inp[1])):
if inp[0][i] == inp[1][j]:
p = True
if p == False:
ans = ans + inp[0][i]
ans += inp[1][0]
print(ans)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
31 | B | Sysadmin Bob | PROGRAMMING | 1,500 | [
"greedy",
"implementation",
"strings"
] | B. Sysadmin Bob | 0 | 256 | Email address in Berland is a string of the form *A*@*B*, where *A* and *B* are arbitrary strings consisting of small Latin letters.
Bob is a system administrator in «Bersoft» company. He keeps a list of email addresses of the company's staff. This list is as a large string, where all addresses are written in arbitra... | The first line contains the list of addresses without separators. The length of this string is between 1 and 200, inclusive. The string consists only from small Latin letters and characters «@». | If there is no list of the valid (according to the Berland rules) email addresses such that after removing all commas it coincides with the given string, output No solution. In the other case, output the list. The same address can be written in this list more than once. If there are several solutions, output any of the... | [
"a@aa@a\n",
"a@a@a\n",
"@aa@a\n"
] | [
"a@a,a@a\n",
"No solution\n",
"No solution\n"
] | none | 1,000 | [
{
"input": "a@aa@a",
"output": "a@a,a@a"
},
{
"input": "a@a@a",
"output": "No solution"
},
{
"input": "@aa@a",
"output": "No solution"
},
{
"input": "aba@caba@daba",
"output": "aba@c,aba@daba"
},
{
"input": "asd@qwasd@qwasd@qwasd@qwasd@qw",
"output": "asd@q,wa... | 1,508,624,980 | 2,147,483,647 | Python 3 | OK | TESTS | 76 | 77 | 5,529,600 | n = input().split('@')
arr = len(n) - 1
i = 1
while i < arr:
if len(n[i]) < 2:
n = False
break
n[i] = n[i][0] + ',' + n[i][1: ]
i += 1
if arr > 0 and n and n[0] and n[arr]:
print('@'.join(n))
else:
print('No solution') | Title: Sysadmin Bob
Time Limit: 0 seconds
Memory Limit: 256 megabytes
Problem Description:
Email address in Berland is a string of the form *A*@*B*, where *A* and *B* are arbitrary strings consisting of small Latin letters.
Bob is a system administrator in «Bersoft» company. He keeps a list of email addresses of t... | ```python
n = input().split('@')
arr = len(n) - 1
i = 1
while i < arr:
if len(n[i]) < 2:
n = False
break
n[i] = n[i][0] + ',' + n[i][1: ]
i += 1
if arr > 0 and n and n[0] and n[arr]:
print('@'.join(n))
else:
print('No solution')
``` | 3 | MatrixStudio/Codeforces-Python-Submissions |
102 | B | Sum of Digits | PROGRAMMING | 1,000 | [
"implementation"
] | B. Sum of Digits | 2 | 265 | Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number *n*. How many times can Gerald put a spell on it until the number becomes one-... | The first line contains the only integer *n* (0<=≤<=*n*<=≤<=10100000). It is guaranteed that *n* doesn't contain any leading zeroes. | Print the number of times a number can be replaced by the sum of its digits until it only contains one digit. | [
"0\n",
"10\n",
"991\n"
] | [
"0\n",
"1\n",
"3\n"
] | In the first sample the number already is one-digit — Herald can't cast a spell.
The second test contains number 10. After one casting of a spell it becomes 1, and here the process is completed. Thus, Gerald can only cast the spell once.
The third test contains number 991. As one casts a spell the following transform... | 1,000 | [
{
"input": "0",
"output": "0"
},
{
"input": "10",
"output": "1"
},
{
"input": "991",
"output": "3"
},
{
"input": "99",
"output": "2"
},
{
"input": "100",
"output": "1"
},
{
"input": "123456789",
"output": "2"
},
{
"input": "32",
"output... | 1,659,343,044 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 3 | 92 | 0 | n = int(input())
ans = 0
while len(set(str(n))) != 1:
z = 0
ans += 1
for i in str(n):
z += int(i)
n = z
print(ans)
| Title: Sum of Digits
Time Limit: 2 seconds
Memory Limit: 265 megabytes
Problem Description:
Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came... | ```python
n = int(input())
ans = 0
while len(set(str(n))) != 1:
z = 0
ans += 1
for i in str(n):
z += int(i)
n = z
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,638,166,253 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 19 | 187 | 13,721,600 | n, k = map(int, input().split())
p, mx, a = -1, 100000000000, list(map(int, input().split()))
for x in range(k):
if n % a[x] < mx: p, mx = x, n % a[x]
print(p + 1, n // a[p]) | 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())
p, mx, a = -1, 100000000000, list(map(int, input().split()))
for x in range(k):
if n % a[x] < mx: p, mx = x, n % a[x]
print(p + 1, n // a[p])
``` | 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,679,966,735 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 4 | 92 | 0 | n,k=map(int,input().split())
s=n*k
if s%2==0:
print(int(s/2))
else:
print(round(s/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
n,k=map(int,input().split())
s=n*k
if s%2==0:
print(int(s/2))
else:
print(round(s/2))
``` | 0 | MatrixStudio/Codeforces-Python-Submissions |
574 | A | Bear and Elections | PROGRAMMING | 1,200 | [
"greedy",
"implementation"
] | null | null | Limak is a grizzly bear who desires power and adoration. He wants to win in upcoming elections and rule over the Bearland.
There are *n* candidates, including Limak. We know how many citizens are going to vote for each candidate. Now *i*-th candidate would get *a**i* votes. Limak is candidate number 1. To win in elect... | The first line contains single integer *n* (2<=≤<=*n*<=≤<=100) - number of candidates.
The second line contains *n* space-separated integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=1000) - number of votes for each candidate. Limak is candidate number 1.
Note that after bribing number of votes for some candidate ... | Print the minimum number of citizens Limak must bribe to have strictly more votes than any other candidate. | [
"5\n5 1 11 2 8\n",
"4\n1 8 8 8\n",
"2\n7 6\n"
] | [
"4\n",
"6\n",
"0\n"
] | In the first sample Limak has 5 votes. One of the ways to achieve victory is to bribe 4 citizens who want to vote for the third candidate. Then numbers of votes would be 9, 1, 7, 2, 8 (Limak would have 9 votes). Alternatively, Limak could steal only 3 votes from the third candidate and 1 vote from the second candidate ... | 500 | [
{
"input": "5\n5 1 11 2 8",
"output": "4"
},
{
"input": "4\n1 8 8 8",
"output": "6"
},
{
"input": "2\n7 6",
"output": "0"
},
{
"input": "2\n1 1",
"output": "1"
},
{
"input": "10\n100 200 57 99 1 1000 200 200 200 500",
"output": "451"
},
{
"input": "16\... | 1,593,806,262 | 2,147,483,647 | Python 3 | OK | TESTS | 35 | 109 | 0 | c = int(input())
lst = list(map(int,input().split()))
limak = lst[0]
org = lst[0]
del lst[0]
while limak <= max(lst) :
lst.append(max(lst) - 1)
lst.remove(max(lst))
limak += 1
print(limak - org)
| Title: Bear and Elections
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Limak is a grizzly bear who desires power and adoration. He wants to win in upcoming elections and rule over the Bearland.
There are *n* candidates, including Limak. We know how many citizens are going to vote for e... | ```python
c = int(input())
lst = list(map(int,input().split()))
limak = lst[0]
org = lst[0]
del lst[0]
while limak <= max(lst) :
lst.append(max(lst) - 1)
lst.remove(max(lst))
limak += 1
print(limak - org)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
17 | C | Balance | PROGRAMMING | 2,500 | [
"dp"
] | C. Balance | 3 | 128 | Nick likes strings very much, he likes to rotate them, sort them, rearrange characters within a string... Once he wrote a random string of characters a, b, c on a piece of paper and began to perform the following operations:
- to take two adjacent characters and replace the second character with the first one, - to... | The first line contains integer *n* (1<=≤<=*n*<=≤<=150) — the length of the given string *s*. Next line contains the given string *s*. The initial string can be balanced as well, in this case it should be counted too. The given string *s* consists only of characters a, b and c. | Output the only number — the number of different balanced strings that can be obtained by performing the described operations, perhaps multiple times, on the given string *s*, modulo 51123987. | [
"4\nabca\n",
"4\nabbc\n",
"2\nab\n"
] | [
"7\n",
"3\n",
"1\n"
] | In the first sample it is possible to get 51 different strings through the described operations, but only 7 of them are balanced: «abca», «bbca», «bcca», «bcaa», «abcc», «abbc», «aabc». In the second sample: «abbc», «aabc», «abcc». In the third sample there is only one balanced string — «ab» itself. | 0 | [] | 1,689,173,844 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 0 | 92 | 0 | print("_RANDOM_GUESS_1689173844.500288")# 1689173844.500305 | Title: Balance
Time Limit: 3 seconds
Memory Limit: 128 megabytes
Problem Description:
Nick likes strings very much, he likes to rotate them, sort them, rearrange characters within a string... Once he wrote a random string of characters a, b, c on a piece of paper and began to perform the following operations:
- t... | ```python
print("_RANDOM_GUESS_1689173844.500288")# 1689173844.500305
``` | 0 | MatrixStudio/Codeforces-Python-Submissions |
794 | B | Cutting Carrot | PROGRAMMING | 1,200 | [
"geometry",
"math"
] | null | null | Igor the analyst has adopted *n* little bunnies. As we all know, bunnies love carrots. Thus, Igor has bought a carrot to be shared between his bunnies. Igor wants to treat all the bunnies equally, and thus he wants to cut the carrot into *n* pieces of equal area.
Formally, the carrot can be viewed as an isosceles tri... | The first and only line of input contains two space-separated integers, *n* and *h* (2<=≤<=*n*<=≤<=1000, 1<=≤<=*h*<=≤<=105). | The output should contain *n*<=-<=1 real numbers *x*1,<=*x*2,<=...,<=*x**n*<=-<=1. The number *x**i* denotes that the *i*-th cut must be made *x**i* units away from the apex of the carrot. In addition, 0<=<<=*x*1<=<<=*x*2<=<<=...<=<<=*x**n*<=-<=1<=<<=*h* must hold.
Your output will be considered correc... | [
"3 2\n",
"2 100000\n"
] | [
"1.154700538379 1.632993161855\n",
"70710.678118654752\n"
] | Definition of isosceles triangle: [https://en.wikipedia.org/wiki/Isosceles_triangle](https://en.wikipedia.org/wiki/Isosceles_triangle). | 1,000 | [
{
"input": "3 2",
"output": "1.154700538379 1.632993161855"
},
{
"input": "2 100000",
"output": "70710.678118654752"
},
{
"input": "1000 100000",
"output": "3162.277660168379 4472.135954999579 5477.225575051661 6324.555320336759 7071.067811865475 7745.966692414834 8366.600265340755 8... | 1,628,036,624 | 2,147,483,647 | Python 3 | COMPILATION_ERROR | TESTS | 0 | 0 | 0 | #include<bits/stdc++.h>
using namespace std;
int main(){
} | Title: Cutting Carrot
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Igor the analyst has adopted *n* little bunnies. As we all know, bunnies love carrots. Thus, Igor has bought a carrot to be shared between his bunnies. Igor wants to treat all the bunnies equally, and thus he wants to cu... | ```python
#include<bits/stdc++.h>
using namespace std;
int main(){
}
``` | -1 | 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,683,258,989 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 30 | 122 | 0 | word = input()
list = []
up = 0
low = 0
nod = ""
for x in word:
list.append(x)
le = len(list)
for x in range(le):
nod = list[x]
if nod.isupper() == True:
up += 1
else:
low += 1
if up > low:
print(word.upper())
elif low > up:
print(word.lower())
elif lo... | 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()
list = []
up = 0
low = 0
nod = ""
for x in word:
list.append(x)
le = len(list)
for x in range(le):
nod = list[x]
if nod.isupper() == True:
up += 1
else:
low += 1
if up > low:
print(word.upper())
elif low > up:
print(word.lower()... | 3.9695 | MatrixStudio/Codeforces-Python-Submissions |
804 | B | Minimum number of steps | PROGRAMMING | 1,400 | [
"combinatorics",
"greedy",
"implementation",
"math"
] | null | null | We have a string of letters 'a' and 'b'. We want to perform some operations on it. On each step we choose one of substrings "ab" in the string and replace it with the string "bba". If we have no "ab" as a substring, our job is done. Print the minimum number of steps we should perform to make our job done modulo 109<=+<... | The first line contains the initial string consisting of letters 'a' and 'b' only with length from 1 to 106. | Print the minimum number of steps modulo 109<=+<=7. | [
"ab\n",
"aab\n"
] | [
"1\n",
"3\n"
] | The first example: "ab" → "bba".
The second example: "aab" → "abba" → "bbaba" → "bbbbaa". | 1,000 | [
{
"input": "ab",
"output": "1"
},
{
"input": "aab",
"output": "3"
},
{
"input": "aaaaabaabababaaaaaba",
"output": "17307"
},
{
"input": "abaabaaabbabaabab",
"output": "1795"
},
{
"input": "abbaa",
"output": "2"
},
{
"input": "abbaaabaabaaaaabbbbaababaa... | 1,619,759,948 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 2 | 78 | 0 | s = input()
n = len(s)
# First a
a_idx = -1
for i in range(n):
if s[i] == 'a':
a_idx = i
break
# Last b.
b_idx = -1
for i in range(n - 1, -1, -1):
if s[i] == 'b':
b_idx = i
break
found_a = False
cnt = 0
for i in range(a_idx + 1, b_idx + 1):
if s[i] ==... | Title: Minimum number of steps
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
We have a string of letters 'a' and 'b'. We want to perform some operations on it. On each step we choose one of substrings "ab" in the string and replace it with the string "bba". If we have no "ab" as a substr... | ```python
s = input()
n = len(s)
# First a
a_idx = -1
for i in range(n):
if s[i] == 'a':
a_idx = i
break
# Last b.
b_idx = -1
for i in range(n - 1, -1, -1):
if s[i] == 'b':
b_idx = i
break
found_a = False
cnt = 0
for i in range(a_idx + 1, b_idx + 1):
... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
228 | A | Is your horseshoe on the other hoof? | PROGRAMMING | 800 | [
"implementation"
] | null | null | Valera the Horse is going to the party with friends. He has been following the fashion trends for a while, and he knows that it is very popular to wear all horseshoes of different color. Valera has got four horseshoes left from the last year, but maybe some of them have the same color. In this case he needs to go to th... | The first line contains four space-separated integers *s*1,<=*s*2,<=*s*3,<=*s*4 (1<=≤<=*s*1,<=*s*2,<=*s*3,<=*s*4<=≤<=109) — the colors of horseshoes Valera has.
Consider all possible colors indexed with integers. | Print a single integer — the minimum number of horseshoes Valera needs to buy. | [
"1 7 3 3\n",
"7 7 7 7\n"
] | [
"1\n",
"3\n"
] | none | 500 | [
{
"input": "1 7 3 3",
"output": "1"
},
{
"input": "7 7 7 7",
"output": "3"
},
{
"input": "81170865 673572653 756938629 995577259",
"output": "0"
},
{
"input": "3491663 217797045 522540872 715355328",
"output": "0"
},
{
"input": "251590420 586975278 916631563 58697... | 1,696,103,040 | 2,147,483,647 | Python 3 | OK | TESTS | 34 | 92 | 307,200 | from collections import Counter
num = list(map(int,input().split()))
count = Counter(num)
ans = 0
for x in count:
ans += count[x] - 1
print(ans)
| Title: Is your horseshoe on the other hoof?
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Valera the Horse is going to the party with friends. He has been following the fashion trends for a while, and he knows that it is very popular to wear all horseshoes of different color. Valera has ... | ```python
from collections import Counter
num = list(map(int,input().split()))
count = Counter(num)
ans = 0
for x in count:
ans += count[x] - 1
print(ans)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
77 | A | Heroes | PROGRAMMING | 1,400 | [
"brute force",
"implementation"
] | A. Heroes | 2 | 256 | The year of 2012 is coming...
According to an ancient choradrican legend in this very year, in 2012, Diablo and his brothers Mephisto and Baal will escape from hell, and innumerable hordes of demons will enslave the human world. But seven brave heroes have already gathered on the top of a mountain Arreat to protect us... | The first line contains a single non-negative integer *n* (0<=≤<=*n*<=≤<=42) — amount of liking between the heroes. Next *n* lines describe liking in the form "p likes q", meaning that the hero p likes the hero q (p <=≠<= q). Every liking is described in the input exactly once, no hero likes himself.
In the last line ... | Print two integers — the minimal difference in the experience between two heroes who will receive the maximum and minimum number of experience points, and the maximal total amount of liking in teams (the number of friendships between heroes that end up in one team).
When calculating the second answer, the team divisio... | [
"3\nTroll likes Dracul\nDracul likes Anka\nSnowy likes Hexadecimal\n210 200 180\n",
"2\nAnka likes Chapay\nChapay likes Anka\n10000 50 50\n"
] | [
"30 3\n",
"1950 2\n"
] | A note to first example: it the first team should be Dracul, Troll and Anka, in the second one Hexadecimal and Snowy, and in the third Cleo и Chapay. | 500 | [
{
"input": "3\nTroll likes Dracul\nDracul likes Anka\nSnowy likes Hexadecimal\n210 200 180",
"output": "30 3"
},
{
"input": "2\nAnka likes Chapay\nChapay likes Anka\n10000 50 50",
"output": "1950 2"
},
{
"input": "11\nSnowy likes Dracul\nAnka likes Dracul\nChapay likes Snowy\nHexadecimal... | 1,424,458,524 | 2,724 | Python 3 | OK | TESTS | 64 | 218 | 307,200 | from itertools import product
n = int(input())
names_to_index = {
'Anka': 0,
'Chapay': 1,
'Cleo': 2,
'Troll': 3,
'Dracul': 4,
'Snowy': 5,
'Hexadecimal': 6,
}
liking = set()
for i in range(n):
a, b, c = input().split()
liking.add( (names_to_inde... | Title: Heroes
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
The year of 2012 is coming...
According to an ancient choradrican legend in this very year, in 2012, Diablo and his brothers Mephisto and Baal will escape from hell, and innumerable hordes of demons will enslave the human world. Bu... | ```python
from itertools import product
n = int(input())
names_to_index = {
'Anka': 0,
'Chapay': 1,
'Cleo': 2,
'Troll': 3,
'Dracul': 4,
'Snowy': 5,
'Hexadecimal': 6,
}
liking = set()
for i in range(n):
a, b, c = input().split()
liking.add( (nam... | 3.944928 | MatrixStudio/Codeforces-Python-Submissions |
239 | A | Two Bags of Potatoes | PROGRAMMING | 1,200 | [
"greedy",
"implementation",
"math"
] | null | null | Valera had two bags of potatoes, the first of these bags contains *x* (*x*<=≥<=1) potatoes, and the second — *y* (*y*<=≥<=1) potatoes. Valera — very scattered boy, so the first bag of potatoes (it contains *x* potatoes) Valera lost. Valera remembers that the total amount of potatoes (*x*<=+<=*y*) in the two bags, first... | The first line of input contains three integers *y*, *k*, *n* (1<=≤<=*y*,<=*k*,<=*n*<=≤<=109; <=≤<=105). | Print the list of whitespace-separated integers — all possible values of *x* in ascending order. You should print each possible value of *x* exactly once.
If there are no such values of *x* print a single integer -1. | [
"10 1 10\n",
"10 6 40\n"
] | [
"-1\n",
"2 8 14 20 26 \n"
] | none | 500 | [
{
"input": "10 1 10",
"output": "-1"
},
{
"input": "10 6 40",
"output": "2 8 14 20 26 "
},
{
"input": "10 1 20",
"output": "1 2 3 4 5 6 7 8 9 10 "
},
{
"input": "1 10000 1000000000",
"output": "9999 19999 29999 39999 49999 59999 69999 79999 89999 99999 109999 119999 12999... | 1,592,026,355 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 3 | 1,000 | 0 | y,k,n=map(int,input().split())
s=set(); x=1
while x+y<=n:
if (x+y)%k==0: s.add(x)
x+=1
if len(s)==0: print(-1)
else: print(*sorted(s)) | Title: Two Bags of Potatoes
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Valera had two bags of potatoes, the first of these bags contains *x* (*x*<=≥<=1) potatoes, and the second — *y* (*y*<=≥<=1) potatoes. Valera — very scattered boy, so the first bag of potatoes (it contains *x* pota... | ```python
y,k,n=map(int,input().split())
s=set(); x=1
while x+y<=n:
if (x+y)%k==0: s.add(x)
x+=1
if len(s)==0: print(-1)
else: print(*sorted(s))
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
801 | A | Vicious Keyboard | PROGRAMMING | 1,100 | [
"brute force"
] | null | null | Tonio has a keyboard with only two letters, "V" and "K".
One day, he has typed out a string *s* with only these two letters. He really likes it when the string "VK" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maxi... | The first line will contain a string *s* consisting only of uppercase English letters "V" and "K" with length not less than 1 and not greater than 100. | Output a single integer, the maximum number of times "VK" can appear as a substring of the given string after changing at most one character. | [
"VK\n",
"VV\n",
"V\n",
"VKKKKKKKKKVVVVVVVVVK\n",
"KVKV\n"
] | [
"1\n",
"1\n",
"0\n",
"3\n",
"1\n"
] | For the first case, we do not change any letters. "VK" appears once, which is the maximum number of times it could appear.
For the second case, we can change the second character from a "V" to a "K". This will give us the string "VK". This has one occurrence of the string "VK" as a substring.
For the fourth case, we ... | 500 | [
{
"input": "VK",
"output": "1"
},
{
"input": "VV",
"output": "1"
},
{
"input": "V",
"output": "0"
},
{
"input": "VKKKKKKKKKVVVVVVVVVK",
"output": "3"
},
{
"input": "KVKV",
"output": "1"
},
{
"input": "VKKVVVKVKVK",
"output": "5"
},
{
"input... | 1,527,990,561 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 2 | 93 | 21,401,600 | s=input()
ans=0
b=0
x=0
f=0
for i in s:
if(i=='V'):
b+=1
x=0
else:
if(b!=0):
ans+=1;
b=0;
x+=1
if(b>=3 or x>=3):
f=1
if(s[0]=='K' and s[1]=='K'):
f=1
len=s.__len__()
if(s[len-1]=='V' and s[len-2]=='V'):
f=1
print(ans+f)
| Title: Vicious Keyboard
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Tonio has a keyboard with only two letters, "V" and "K".
One day, he has typed out a string *s* with only these two letters. He really likes it when the string "VK" appears, so he wishes to change at most one letter i... | ```python
s=input()
ans=0
b=0
x=0
f=0
for i in s:
if(i=='V'):
b+=1
x=0
else:
if(b!=0):
ans+=1;
b=0;
x+=1
if(b>=3 or x>=3):
f=1
if(s[0]=='K' and s[1]=='K'):
f=1
len=s.__len__()
if(s[len-1]=='V' and s[len-2]=='V'):
f=1
print(ans+f)
``` | 0 | 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,510,506,228 | 3,528 | Python 3 | RUNTIME_ERROR | PRETESTS | 1 | 77 | 512,000 | from random import randint
a , b , c , d , e , f = map(int, input().split())
spisok = [a,b,c,d,e,f]
summa = (a + b + c + d + e + f) // 2
for i in range(0,6):
for j in range(0,6):
for h in range(0,6):
if spisok[i] + spisok[j] + spisok[h] == summa:
q = i
w = j
r = h
if spisok[q] + spis... | 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
from random import randint
a , b , c , d , e , f = map(int, input().split())
spisok = [a,b,c,d,e,f]
summa = (a + b + c + d + e + f) // 2
for i in range(0,6):
for j in range(0,6):
for h in range(0,6):
if spisok[i] + spisok[j] + spisok[h] == summa:
q = i
w = j
r = h
if spisok... | -1 | MatrixStudio/Codeforces-Python-Submissions | |
769 | B | News About Credit | PROGRAMMING | 1,200 | [
"*special",
"greedy",
"two pointers"
] | null | null | Polycarp studies at the university in the group which consists of *n* students (including himself). All they are registrated in the social net "TheContacnt!".
Not all students are equally sociable. About each student you know the value *a**i* — the maximum number of messages which the *i*-th student is agree to send p... | The first line contains the positive integer *n* (2<=≤<=*n*<=≤<=100) — the number of students.
The second line contains the sequence *a*1,<=*a*2,<=...,<=*a**n* (0<=≤<=*a**i*<=≤<=100), where *a**i* equals to the maximum number of messages which can the *i*-th student agree to send. Consider that Polycarp always has th... | Print -1 to the first line if it is impossible to inform all students about credit.
Otherwise, in the first line print the integer *k* — the number of messages which will be sent. In each of the next *k* lines print two distinct integers *f* and *t*, meaning that the student number *f* sent the message with news to t... | [
"4\n1 2 1 0\n",
"6\n2 0 1 3 2 0\n",
"3\n0 2 2\n"
] | [
"3\n1 2\n2 4\n2 3\n",
"6\n1 3\n3 4\n1 2\n4 5\n5 6\n4 6\n",
"-1\n"
] | In the first test Polycarp (the student number 1) can send the message to the student number 2, who after that can send the message to students number 3 and 4. Thus, all students knew about the credit. | 1,000 | [
{
"input": "4\n1 2 1 0",
"output": "3\n1 2\n2 3\n2 4"
},
{
"input": "6\n2 0 1 3 2 0",
"output": "5\n1 4\n1 5\n4 3\n4 2\n4 6"
},
{
"input": "3\n0 2 2",
"output": "-1"
},
{
"input": "2\n0 0",
"output": "-1"
},
{
"input": "2\n1 0",
"output": "1\n1 2"
},
{
... | 1,488,905,384 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 9 | 62 | 4,608,000 | n = int(input())
a = list(map(int, input().split()))
b = [0] * n
b[0] = 1 if a[0] else 0
i = 0
res = []
flag = True
if a[0] != 0:
while set(b) != set([1]):
if a[i] > 0:
for j in range(len(b)):
if b[j] == 0:
b[j] = 1
a[i] -= 1
... | Title: News About Credit
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Polycarp studies at the university in the group which consists of *n* students (including himself). All they are registrated in the social net "TheContacnt!".
Not all students are equally sociable. About each student... | ```python
n = int(input())
a = list(map(int, input().split()))
b = [0] * n
b[0] = 1 if a[0] else 0
i = 0
res = []
flag = True
if a[0] != 0:
while set(b) != set([1]):
if a[i] > 0:
for j in range(len(b)):
if b[j] == 0:
b[j] = 1
a... | -1 | MatrixStudio/Codeforces-Python-Submissions | |
611 | D | New Year and Ancient Prophecy | PROGRAMMING | 2,000 | [
"dp",
"hashing",
"strings"
] | null | null | Limak is a little polar bear. In the snow he found a scroll with the ancient prophecy. Limak doesn't know any ancient languages and thus is unable to understand the prophecy. But he knows digits!
One fragment of the prophecy is a sequence of *n* digits. The first digit isn't zero. Limak thinks that it's a list of some... | The first line of the input contains a single integer *n* (1<=≤<=*n*<=≤<=5000) — the number of digits.
The second line contains a string of digits and has length equal to *n*. It's guaranteed that the first digit is not '0'. | Print the number of ways to correctly split the given sequence modulo 109<=+<=7. | [
"6\n123434\n",
"8\n20152016\n"
] | [
"8\n",
"4\n"
] | In the first sample there are 8 ways to split the sequence:
- "123434" = "123434" (maybe the given sequence is just one big number) - "123434" = "1" + "23434" - "123434" = "12" + "3434" - "123434" = "123" + "434" - "123434" = "1" + "23" + "434" - "123434" = "1" + "2" + "3434" - "123434" = "1" + "2" + "3" + "434... | 1,750 | [] | 1,641,903,670 | 2,147,483,647 | Python 3 | COMPILATION_ERROR | TESTS | 0 | 0 | 0 | n = int(input())
s = input()
s += '1' #
bg = 10**9+7
#print ind, l
num = [ [0 for i in range(n+2)] for j in range(n+2) ]
cnum = [ [0 for i in range(n+2)] for j in range(n+2) ]
adad = [ [0 for i in range(n+2)] for j in range(n+2) ]
mogh = [ [0 for i in range(n+2)] for j in range(n+2) ]
num[0][n] = 1
... | Title: New Year and Ancient Prophecy
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Limak is a little polar bear. In the snow he found a scroll with the ancient prophecy. Limak doesn't know any ancient languages and thus is unable to understand the prophecy. But he knows digits!
One frag... | ```python
n = int(input())
s = input()
s += '1' #
bg = 10**9+7
#print ind, l
num = [ [0 for i in range(n+2)] for j in range(n+2) ]
cnum = [ [0 for i in range(n+2)] for j in range(n+2) ]
adad = [ [0 for i in range(n+2)] for j in range(n+2) ]
mogh = [ [0 for i in range(n+2)] for j in range(n+2) ]
num[0... | -1 | MatrixStudio/Codeforces-Python-Submissions | |
430 | B | Balls Game | PROGRAMMING | 1,400 | [
"brute force",
"two pointers"
] | null | null | Iahub is training for the IOI. What is a better way to train than playing a Zuma-like game?
There are *n* balls put in a row. Each ball is colored in one of *k* colors. Initially the row doesn't contain three or more contiguous balls with the same color. Iahub has a single ball of color *x*. He can insert his ball at... | The first line of input contains three integers: *n* (1<=≤<=*n*<=≤<=100), *k* (1<=≤<=*k*<=≤<=100) and *x* (1<=≤<=*x*<=≤<=*k*). The next line contains *n* space-separated integers *c*1,<=*c*2,<=...,<=*c**n* (1<=≤<=*c**i*<=≤<=*k*). Number *c**i* means that the *i*-th ball in the row has color *c**i*.
It is guaranteed th... | Print a single integer — the maximum number of balls Iahub can destroy. | [
"6 2 2\n1 1 2 2 1 1\n",
"1 1 1\n1\n"
] | [
"6\n",
"0\n"
] | none | 1,000 | [
{
"input": "6 2 2\n1 1 2 2 1 1",
"output": "6"
},
{
"input": "1 1 1\n1",
"output": "0"
},
{
"input": "10 2 1\n2 1 2 2 1 2 2 1 1 2",
"output": "5"
},
{
"input": "50 2 1\n1 1 2 2 1 2 1 1 2 2 1 2 1 2 1 1 2 2 1 2 1 2 2 1 2 1 2 1 2 2 1 1 2 2 1 1 2 2 1 2 1 1 2 1 1 2 2 1 1 2",
"... | 1,617,016,126 | 2,147,483,647 | PyPy 3 | OK | TESTS | 18 | 109 | 0 | n,k,x=map(int,input().split())
q=list(map(int,input().split()))
w=0
for i in range(n):
if q[i]!=x: continue
l,r=i,i
v=0
while q[l]==q[r]:
c=2
while l>0 and q[l]==q[l-1]:
c+=1
l-=1
while r<n-1 and q[r]==q[r+1]:
c+=1
r+=... | Title: Balls Game
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Iahub is training for the IOI. What is a better way to train than playing a Zuma-like game?
There are *n* balls put in a row. Each ball is colored in one of *k* colors. Initially the row doesn't contain three or more conti... | ```python
n,k,x=map(int,input().split())
q=list(map(int,input().split()))
w=0
for i in range(n):
if q[i]!=x: continue
l,r=i,i
v=0
while q[l]==q[r]:
c=2
while l>0 and q[l]==q[l-1]:
c+=1
l-=1
while r<n-1 and q[r]==q[r+1]:
c+=1
... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
402 | B | Trees in a Row | PROGRAMMING | 1,400 | [
"brute force",
"implementation"
] | null | null | The Queen of England has *n* trees growing in a row in her garden. At that, the *i*-th (1<=≤<=*i*<=≤<=*n*) tree from the left has height *a**i* meters. Today the Queen decided to update the scenery of her garden. She wants the trees' heights to meet the condition: for all *i* (1<=≤<=*i*<=<<=*n*), *a**i*<=+<=1<=-<=*a... | The first line contains two space-separated integers: *n*, *k* (1<=≤<=*n*,<=*k*<=≤<=1000). The second line contains *n* space-separated integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=1000) — the heights of the trees in the row. | In the first line print a single integer *p* — the minimum number of minutes the gardener needs. In the next *p* lines print the description of his actions.
If the gardener needs to increase the height of the *j*-th (1<=≤<=*j*<=≤<=*n*) tree from the left by *x* (*x*<=≥<=1) meters, then print in the corresponding line... | [
"4 1\n1 2 1 5\n",
"4 1\n1 2 3 4\n"
] | [
"2\n+ 3 2\n- 4 1\n",
"0\n"
] | none | 1,000 | [
{
"input": "4 1\n1 2 1 5",
"output": "2\n+ 3 2\n- 4 1"
},
{
"input": "4 1\n1 2 3 4",
"output": "0"
},
{
"input": "50 1\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50",
"output": "0"
},
... | 1,650,723,459 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 2 | 93 | 3,379,200 | n, k = map(int, input().split())
a = [int(x) for x in input().split()]
a = [(a[i],i+1)for i in range(n)]
ans = []
min_h = float('inf')
min_c = float('inf')
for i in range(1, 1000 + 1):
not_good = 0
for j in a:
not_good += j[0] != k*(i-1) + i
if not_good < min_c:
min_c = not_good
... | Title: Trees in a Row
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The Queen of England has *n* trees growing in a row in her garden. At that, the *i*-th (1<=≤<=*i*<=≤<=*n*) tree from the left has height *a**i* meters. Today the Queen decided to update the scenery of her garden. She wan... | ```python
n, k = map(int, input().split())
a = [int(x) for x in input().split()]
a = [(a[i],i+1)for i in range(n)]
ans = []
min_h = float('inf')
min_c = float('inf')
for i in range(1, 1000 + 1):
not_good = 0
for j in a:
not_good += j[0] != k*(i-1) + i
if not_good < min_c:
min_c = ... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
363 | B | Fence | PROGRAMMING | 1,100 | [
"brute force",
"dp"
] | null | null | There is a fence in front of Polycarpus's home. The fence consists of *n* planks of the same width which go one after another from left to right. The height of the *i*-th plank is *h**i* meters, distinct planks can have distinct heights.
Polycarpus has bought a posh piano and is thinking about how to get it into the h... | The first line of the input contains integers *n* and *k* (1<=≤<=*n*<=≤<=1.5·105,<=1<=≤<=*k*<=≤<=*n*) — the number of planks in the fence and the width of the hole for the piano. The second line contains the sequence of integers *h*1,<=*h*2,<=...,<=*h**n* (1<=≤<=*h**i*<=≤<=100), where *h**i* is the height of the *i*-th... | Print such integer *j* that the sum of the heights of planks *j*, *j*<=+<=1, ..., *j*<=+<=*k*<=-<=1 is the minimum possible. If there are multiple such *j*'s, print any of them. | [
"7 3\n1 2 6 1 1 7 1\n"
] | [
"3\n"
] | In the sample, your task is to find three consecutive planks with the minimum sum of heights. In the given case three planks with indexes 3, 4 and 5 have the required attribute, their total height is 8. | 1,000 | [
{
"input": "7 3\n1 2 6 1 1 7 1",
"output": "3"
},
{
"input": "1 1\n100",
"output": "1"
},
{
"input": "2 1\n10 20",
"output": "1"
},
{
"input": "10 5\n1 2 3 1 2 2 3 1 4 5",
"output": "1"
},
{
"input": "10 2\n3 1 4 1 4 6 2 1 4 6",
"output": "7"
},
{
"inp... | 1,689,078,782 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 6 | 1,000 | 5,632,000 | # Read the number of planks and the width of the hole
n, k = map(int, input().split())
# Read the heights of the planks
heights = list(map(int, input().split()))
# Initialize the minimum sum and the starting index
min_sum = float('inf')
start_index = 0
# Iterate over the planks to find the minimum sum
for i in range... | Title: Fence
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
There is a fence in front of Polycarpus's home. The fence consists of *n* planks of the same width which go one after another from left to right. The height of the *i*-th plank is *h**i* meters, distinct planks can have distinct ... | ```python
# Read the number of planks and the width of the hole
n, k = map(int, input().split())
# Read the heights of the planks
heights = list(map(int, input().split()))
# Initialize the minimum sum and the starting index
min_sum = float('inf')
start_index = 0
# Iterate over the planks to find the minimum sum
for ... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
976 | A | Minimum Binary Number | PROGRAMMING | 800 | [
"implementation"
] | null | null | String can be called correct if it consists of characters "0" and "1" and there are no redundant leading zeroes. Here are some examples: "0", "10", "1001".
You are given a correct string *s*.
You can perform two different operations on this string:
1. swap any pair of adjacent characters (for example, "101" "110"... | The first line contains integer number *n* (1<=≤<=*n*<=≤<=100) — the length of string *s*.
The second line contains the string *s* consisting of characters "0" and "1". It is guaranteed that the string *s* is correct. | Print one string — the minimum correct string that you can obtain from the given one. | [
"4\n1001\n",
"1\n1\n"
] | [
"100\n",
"1\n"
] | In the first example you can obtain the answer by the following sequence of operations: "1001" <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/70a0795f45d32287dba0eb83fc4a3f470c6e5537.png" style="max-width: 100.0%;max-height: 100.0%;"/> "1010" <img align="middle" class="tex-formula" src="ht... | 0 | [
{
"input": "4\n1001",
"output": "100"
},
{
"input": "1\n1",
"output": "1"
},
{
"input": "100\n1110111100001111011111111010110011111111011110000111101101011100110110001011000000101010110101011100",
"output": "1000000000000000000000000000000000000000"
},
{
"input": "100\n100000... | 1,582,690,615 | 2,147,483,647 | PyPy 3 | OK | TESTS | 14 | 140 | 0 | l=int(input());a=str(input())
a=sorted(a);b=a[len(a)-1];i=0
while i<len(a)-1:
if a[i]=='0':
b+=a[i]
i+=1
print(b) | Title: Minimum Binary Number
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
String can be called correct if it consists of characters "0" and "1" and there are no redundant leading zeroes. Here are some examples: "0", "10", "1001".
You are given a correct string *s*.
You can perform two... | ```python
l=int(input());a=str(input())
a=sorted(a);b=a[len(a)-1];i=0
while i<len(a)-1:
if a[i]=='0':
b+=a[i]
i+=1
print(b)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
0 | none | none | none | 0 | [
"none"
] | null | null | The last stage of Football World Cup is played using the play-off system.
There are *n* teams left in this stage, they are enumerated from 1 to *n*. Several rounds are held, in each round the remaining teams are sorted in the order of their ids, then the first in this order plays with the second, the third — with the ... | The only line contains three integers *n*, *a* and *b* (2<=≤<=*n*<=≤<=256, 1<=≤<=*a*,<=*b*<=≤<=*n*) — the total number of teams, and the ids of the teams that Arkady is interested in.
It is guaranteed that *n* is such that in each round an even number of team advance, and that *a* and *b* are not equal. | In the only line print "Final!" (without quotes), if teams *a* and *b* can meet in the Final.
Otherwise, print a single integer — the number of the round in which teams *a* and *b* can meet. The round are enumerated from 1. | [
"4 1 2\n",
"8 2 6\n",
"8 7 5\n"
] | [
"1\n",
"Final!\n",
"2\n"
] | In the first example teams 1 and 2 meet in the first round.
In the second example teams 2 and 6 can only meet in the third round, which is the Final, if they win all their opponents in earlier rounds.
In the third example the teams with ids 7 and 5 can meet in the second round, if they win their opponents in the firs... | 0 | [
{
"input": "4 1 2",
"output": "1"
},
{
"input": "8 2 6",
"output": "Final!"
},
{
"input": "8 7 5",
"output": "2"
},
{
"input": "128 30 98",
"output": "Final!"
},
{
"input": "256 128 256",
"output": "Final!"
},
{
"input": "256 2 127",
"output": "7"
... | 1,608,824,308 | 208 | PyPy 3 | OK | TESTS | 64 | 171 | 0 | n,a,b = list(map(int,input().split()))
a-=1
b-=1
iter = 0
while a!=b:
iter+=1
a//=2
b//=2
if (2**iter == n):
print("Final!")
else:
print(iter) | Title: none
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The last stage of Football World Cup is played using the play-off system.
There are *n* teams left in this stage, they are enumerated from 1 to *n*. Several rounds are held, in each round the remaining teams are sorted in the ord... | ```python
n,a,b = list(map(int,input().split()))
a-=1
b-=1
iter = 0
while a!=b:
iter+=1
a//=2
b//=2
if (2**iter == n):
print("Final!")
else:
print(iter)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
791 | A | Bear and Big Brother | PROGRAMMING | 800 | [
"implementation"
] | null | null | Bear Limak wants to become the largest of bears, or at least to become larger than his brother Bob.
Right now, Limak and Bob weigh *a* and *b* respectively. It's guaranteed that Limak's weight is smaller than or equal to his brother's weight.
Limak eats a lot and his weight is tripled after every year, while Bob's we... | The only line of the input contains two integers *a* and *b* (1<=≤<=*a*<=≤<=*b*<=≤<=10) — the weight of Limak and the weight of Bob respectively. | Print one integer, denoting the integer number of years after which Limak will become strictly larger than Bob. | [
"4 7\n",
"4 9\n",
"1 1\n"
] | [
"2\n",
"3\n",
"1\n"
] | In the first sample, Limak weighs 4 and Bob weighs 7 initially. After one year their weights are 4·3 = 12 and 7·2 = 14 respectively (one weight is tripled while the other one is doubled). Limak isn't larger than Bob yet. After the second year weights are 36 and 28, so the first weight is greater than the second one. Li... | 500 | [
{
"input": "4 7",
"output": "2"
},
{
"input": "4 9",
"output": "3"
},
{
"input": "1 1",
"output": "1"
},
{
"input": "4 6",
"output": "2"
},
{
"input": "1 10",
"output": "6"
},
{
"input": "1 1",
"output": "1"
},
{
"input": "1 2",
"output... | 1,697,458,928 | 2,147,483,647 | Python 3 | OK | TESTS | 62 | 46 | 0 | a, b = map(int,input().split())
years = 0
while a<=b:
years+=1
a*=3
b*=2
print(years) | Title: Bear and Big Brother
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Bear Limak wants to become the largest of bears, or at least to become larger than his brother Bob.
Right now, Limak and Bob weigh *a* and *b* respectively. It's guaranteed that Limak's weight is smaller than or e... | ```python
a, b = map(int,input().split())
years = 0
while a<=b:
years+=1
a*=3
b*=2
print(years)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
180 | C | Letter | PROGRAMMING | 1,400 | [
"dp"
] | null | null | Patrick has just finished writing a message to his sweetheart Stacey when he noticed that the message didn't look fancy. Patrick was nervous while writing the message, so some of the letters there were lowercase and some of them were uppercase.
Patrick believes that a message is fancy if any uppercase letter stands to... | The only line of the input contains a non-empty string consisting of uppercase and lowercase letters. The string's length does not exceed 105. | Print a single number — the least number of actions needed to make the message fancy. | [
"PRuvetSTAaYA\n",
"OYPROSTIYAOPECHATALSYAPRIVETSTASYA\n",
"helloworld\n"
] | [
"5\n",
"0\n",
"0\n"
] | none | 0 | [
{
"input": "PRuvetSTAaYA",
"output": "5"
},
{
"input": "OYPROSTIYAOPECHATALSYAPRIVETSTASYA",
"output": "0"
},
{
"input": "helloworld",
"output": "0"
},
{
"input": "P",
"output": "0"
},
{
"input": "t",
"output": "0"
},
{
"input": "XdJ",
"output": "1... | 1,685,627,172 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 60 | 0 | def modify_count(s):
upper_count = 0
lower_count = 0
for c in s:
if c.isupper():
upper_count += 1
else:
lower_count += 1
return min(upper_count, lower_count)
| Title: Letter
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Patrick has just finished writing a message to his sweetheart Stacey when he noticed that the message didn't look fancy. Patrick was nervous while writing the message, so some of the letters there were lowercase and some of them... | ```python
def modify_count(s):
upper_count = 0
lower_count = 0
for c in s:
if c.isupper():
upper_count += 1
else:
lower_count += 1
return min(upper_count, lower_count)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
106 | C | Buns | PROGRAMMING | 1,700 | [
"dp"
] | C. Buns | 2 | 256 | Lavrenty, a baker, is going to make several buns with stuffings and sell them.
Lavrenty has *n* grams of dough as well as *m* different stuffing types. The stuffing types are numerated from 1 to *m*. Lavrenty knows that he has *a**i* grams left of the *i*-th stuffing. It takes exactly *b**i* grams of stuffing *i* and ... | The first line contains 4 integers *n*, *m*, *c*0 and *d*0 (1<=≤<=*n*<=≤<=1000, 1<=≤<=*m*<=≤<=10, 1<=≤<=*c*0,<=*d*0<=≤<=100). Each of the following *m* lines contains 4 integers. The *i*-th line contains numbers *a**i*, *b**i*, *c**i* and *d**i* (1<=≤<=*a**i*,<=*b**i*,<=*c**i*,<=*d**i*<=≤<=100). | Print the only number — the maximum number of tugriks Lavrenty can earn. | [
"10 2 2 1\n7 3 2 100\n12 3 1 10\n",
"100 1 25 50\n15 5 20 10\n"
] | [
"241",
"200"
] | To get the maximum number of tugriks in the first sample, you need to cook 2 buns with stuffing 1, 4 buns with stuffing 2 and a bun without any stuffing.
In the second sample Lavrenty should cook 4 buns without stuffings. | 1,500 | [
{
"input": "10 2 2 1\n7 3 2 100\n12 3 1 10",
"output": "241"
},
{
"input": "100 1 25 50\n15 5 20 10",
"output": "200"
},
{
"input": "10 1 5 2\n100 1 2 3",
"output": "15"
},
{
"input": "10 1 5 11\n3 1 3 8",
"output": "24"
},
{
"input": "10 2 11 5\n100 1 3 10\n100 1... | 1,544,396,709 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 2 | 310 | 0 | R = lambda: map(int, input().split())
n, m, c0, d0 = R()
a, b, c, d = [0], [0], [0], [0]
for i in range(m):
t1, t2, t3, t4 = R()
a.append(t1)
b.append(t2)
c.append(t3)
d.append(t4)
dp = [[0] * (n + 1) for i in range(m + 1)]
for j in range(n + 1):
dp[0][j] = j // c0 * d0
for i in rang... | Title: Buns
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Lavrenty, a baker, is going to make several buns with stuffings and sell them.
Lavrenty has *n* grams of dough as well as *m* different stuffing types. The stuffing types are numerated from 1 to *m*. Lavrenty knows that he has *a**i*... | ```python
R = lambda: map(int, input().split())
n, m, c0, d0 = R()
a, b, c, d = [0], [0], [0], [0]
for i in range(m):
t1, t2, t3, t4 = R()
a.append(t1)
b.append(t2)
c.append(t3)
d.append(t4)
dp = [[0] * (n + 1) for i in range(m + 1)]
for j in range(n + 1):
dp[0][j] = j // c0 * d0
for... | 0 | MatrixStudio/Codeforces-Python-Submissions |
185 | A | Plant | PROGRAMMING | 1,300 | [
"math"
] | null | null | Dwarfs have planted a very interesting plant, which is a triangle directed "upwards". This plant has an amusing feature. After one year a triangle plant directed "upwards" divides into four triangle plants: three of them will point "upwards" and one will point "downwards". After another year, each triangle plant divide... | The first line contains a single integer *n* (0<=≤<=*n*<=≤<=1018) — the number of full years when the plant grew.
Please do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specifier. | Print a single integer — the remainder of dividing the number of plants that will point "upwards" in *n* years by 1000000007 (109<=+<=7). | [
"1\n",
"2\n"
] | [
"3\n",
"10\n"
] | The first test sample corresponds to the second triangle on the figure in the statement. The second test sample corresponds to the third one. | 500 | [
{
"input": "1",
"output": "3"
},
{
"input": "2",
"output": "10"
},
{
"input": "385599124",
"output": "493875375"
},
{
"input": "989464295",
"output": "31966163"
},
{
"input": "376367012",
"output": "523204186"
},
{
"input": "529357306",
"output": "... | 1,560,497,268 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 2 | 2,000 | 45,260,800 | n = int(input())
m = 2 ** n
print(m*(m+1)//2 % 1000000007)
| Title: Plant
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Dwarfs have planted a very interesting plant, which is a triangle directed "upwards". This plant has an amusing feature. After one year a triangle plant directed "upwards" divides into four triangle plants: three of them will poi... | ```python
n = int(input())
m = 2 ** n
print(m*(m+1)//2 % 1000000007)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
78 | B | Easter Eggs | PROGRAMMING | 1,200 | [
"constructive algorithms",
"implementation"
] | B. Easter Eggs | 2 | 256 | The Easter Rabbit laid *n* eggs in a circle and is about to paint them.
Each egg should be painted one color out of 7: red, orange, yellow, green, blue, indigo or violet. Also, the following conditions should be satisfied:
- Each of the seven colors should be used to paint at least one egg. - Any four eggs lying s... | The only line contains an integer *n* — the amount of eggs (7<=≤<=*n*<=≤<=100). | Print one line consisting of *n* characters. The *i*-th character should describe the color of the *i*-th egg in the order they lie in the circle. The colors should be represented as follows: "R" stands for red, "O" stands for orange, "Y" stands for yellow, "G" stands for green, "B" stands for blue, "I" stands for indi... | [
"8\n",
"13\n"
] | [
"ROYGRBIV\n",
"ROYGBIVGBIVYG\n"
] | The way the eggs will be painted in the first sample is shown on the picture: | 1,000 | [
{
"input": "8",
"output": "ROYGBIVG"
},
{
"input": "13",
"output": "ROYGBIVOYGBIV"
},
{
"input": "7",
"output": "ROYGBIV"
},
{
"input": "10",
"output": "ROYGBIVYGB"
},
{
"input": "14",
"output": "ROYGBIVROYGBIV"
},
{
"input": "50",
"output": "ROYGB... | 1,550,078,418 | 2,147,483,647 | Python 3 | OK | TESTS | 34 | 216 | 0 | print('BIV' + ''.join('ROYG'[i%4] for i in range(int(input())-3))) | Title: Easter Eggs
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
The Easter Rabbit laid *n* eggs in a circle and is about to paint them.
Each egg should be painted one color out of 7: red, orange, yellow, green, blue, indigo or violet. Also, the following conditions should be satisfied:
-... | ```python
print('BIV' + ''.join('ROYG'[i%4] for i in range(int(input())-3)))
``` | 3.946 | MatrixStudio/Codeforces-Python-Submissions |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.