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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
834 | B | The Festive Evening | PROGRAMMING | 1,100 | [
"data structures",
"implementation"
] | null | null | It's the end of July – the time when a festive evening is held at Jelly Castle! Guests from all over the kingdom gather here to discuss new trends in the world of confectionery. Yet some of the things discussed here are not supposed to be disclosed to the general public: the information can cause discord in the kingdom... | Two integers are given in the first string: the number of guests *n* and the number of guards *k* (1<=≤<=*n*<=≤<=106, 1<=≤<=*k*<=≤<=26).
In the second string, *n* uppercase English letters *s*1*s*2... *s**n* are given, where *s**i* is the entrance used by the *i*-th guest. | Output «YES» if at least one door was unguarded during some time, and «NO» otherwise.
You can output each letter in arbitrary case (upper or lower). | [
"5 1\nAABBB\n",
"5 1\nABABB\n"
] | [
"NO\n",
"YES\n"
] | In the first sample case, the door A is opened right before the first guest's arrival and closed when the second guest enters the castle. The door B is opened right before the arrival of the third guest, and closed after the fifth one arrives. One guard can handle both doors, as the first one is closed before the secon... | 1,000 | [
{
"input": "5 1\nAABBB",
"output": "NO"
},
{
"input": "5 1\nABABB",
"output": "YES"
},
{
"input": "26 1\nABCDEFGHIJKLMNOPQRSTUVWXYZ",
"output": "NO"
},
{
"input": "27 1\nABCDEFGHIJKLMNOPQRSTUVWXYZA",
"output": "YES"
},
{
"input": "5 2\nABACA",
"output": "NO"
... | 1,501,429,786 | 4,486 | Python 3 | WRONG_ANSWER | PRETESTS | 3 | 46 | 4,608,000 | import sys
x = sys.stdin.readline().split()
y = sys.stdin.readline().rstrip("\n")
nums = list(map(int, x))
k = nums[1]
e = list(map(str, y))
s = list(set(e))
s.sort()
c = []
for x in range(len(s)):
cnt = e.count(s[x])
c.append(cnt)
sec = [0]*len(c)
count = 0
for y in range(len(e)):
... | Title: The Festive Evening
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
It's the end of July – the time when a festive evening is held at Jelly Castle! Guests from all over the kingdom gather here to discuss new trends in the world of confectionery. Yet some of the things discussed here... | ```python
import sys
x = sys.stdin.readline().split()
y = sys.stdin.readline().rstrip("\n")
nums = list(map(int, x))
k = nums[1]
e = list(map(str, y))
s = list(set(e))
s.sort()
c = []
for x in range(len(s)):
cnt = e.count(s[x])
c.append(cnt)
sec = [0]*len(c)
count = 0
for y in range(len(... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
656 | A | Da Vinci Powers | PROGRAMMING | 1,900 | [
"*special"
] | null | null | The input contains a single integer *a* (0<=≤<=*a*<=≤<=35).
Output a single integer. | The input contains a single integer *a* (0<=≤<=*a*<=≤<=35). | Output a single integer. | [
"3\n",
"10\n"
] | [
"8\n",
"1024\n"
] | none | 0 | [
{
"input": "3",
"output": "8"
},
{
"input": "10",
"output": "1024"
},
{
"input": "35",
"output": "33940307968"
},
{
"input": "0",
"output": "1"
},
{
"input": "1",
"output": "2"
},
{
"input": "2",
"output": "4"
},
{
"input": "4",
"output... | 1,500,238,931 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 46 | 4,608,000 | a = input()
print(2 ** int(a)) | Title: Da Vinci Powers
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The input contains a single integer *a* (0<=≤<=*a*<=≤<=35).
Output a single integer.
Input Specification:
The input contains a single integer *a* (0<=≤<=*a*<=≤<=35).
Output Specification:
Output a single integer.
De... | ```python
a = input()
print(2 ** int(a))
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
832 | A | Sasha and Sticks | PROGRAMMING | 800 | [
"games",
"math"
] | null | null | It's one more school day now. Sasha doesn't like classes and is always bored at them. So, each day he invents some game and plays in it alone or with friends.
Today he invented one simple game to play with Lena, with whom he shares a desk. The rules are simple. Sasha draws *n* sticks in a row. After that the players t... | The first line contains two integers *n* and *k* (1<=≤<=*n*,<=*k*<=≤<=1018, *k*<=≤<=*n*) — the number of sticks drawn by Sasha and the number *k* — the number of sticks to be crossed out on each turn. | If Sasha wins, print "YES" (without quotes), otherwise print "NO" (without quotes).
You can print each letter in arbitrary case (upper of lower). | [
"1 1\n",
"10 4\n"
] | [
"YES\n",
"NO\n"
] | In the first example Sasha crosses out 1 stick, and then there are no sticks. So Lena can't make a move, and Sasha wins.
In the second example Sasha crosses out 4 sticks, then Lena crosses out 4 sticks, and after that there are only 2 sticks left. Sasha can't make a move. The players make equal number of moves, so Sas... | 500 | [
{
"input": "1 1",
"output": "YES"
},
{
"input": "10 4",
"output": "NO"
},
{
"input": "251656215122324104 164397544865601257",
"output": "YES"
},
{
"input": "963577813436662285 206326039287271924",
"output": "NO"
},
{
"input": "1000000000000000000 1",
"output":... | 1,623,940,542 | 2,147,483,647 | Python 3 | OK | TESTS | 62 | 62 | 0 | a,m = map(int,input().split())
print("YES" if(a//m)%2==1 else "NO")
| Title: Sasha and Sticks
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
It's one more school day now. Sasha doesn't like classes and is always bored at them. So, each day he invents some game and plays in it alone or with friends.
Today he invented one simple game to play with Lena, with ... | ```python
a,m = map(int,input().split())
print("YES" if(a//m)%2==1 else "NO")
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
276 | A | Lunch Rush | PROGRAMMING | 900 | [
"implementation"
] | null | null | Having written another programming contest, three Rabbits decided to grab some lunch. The coach gave the team exactly *k* time units for the lunch break.
The Rabbits have a list of *n* restaurants to lunch in: the *i*-th restaurant is characterized by two integers *f**i* and *t**i*. Value *t**i* shows the time the Rab... | The first line contains two space-separated integers — *n* (1<=≤<=*n*<=≤<=104) and *k* (1<=≤<=*k*<=≤<=109) — the number of restaurants in the Rabbits' list and the time the coach has given them to lunch, correspondingly. Each of the next *n* lines contains two space-separated integers — *f**i* (1<=≤<=*f**i*<=≤<=109) an... | In a single line print a single integer — the maximum joy value that the Rabbits will get from the lunch. | [
"2 5\n3 3\n4 5\n",
"4 6\n5 8\n3 6\n2 3\n2 2\n",
"1 5\n1 7\n"
] | [
"4\n",
"3\n",
"-1\n"
] | none | 500 | [
{
"input": "2 5\n3 3\n4 5",
"output": "4"
},
{
"input": "4 6\n5 8\n3 6\n2 3\n2 2",
"output": "3"
},
{
"input": "1 5\n1 7",
"output": "-1"
},
{
"input": "4 9\n10 13\n4 18\n13 3\n10 6",
"output": "13"
},
{
"input": "1 1\n1 1000000000",
"output": "-999999998"
}... | 1,682,837,077 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 8 | 124 | 307,200 | n , k = map(int,input().split())
f = [0] * n
t = [0] * n
for i in range(n):
a , b = map(int,input().split())
f[i] = a
t[i] = b
joy = 0
max = -9999
for i in range(n):
if t[i] > k :
joy = f[i] - (t[i] - k)
if t[i] <= k:
joy = f[i]
if joy > max:
max = joy
pri... | Title: Lunch Rush
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Having written another programming contest, three Rabbits decided to grab some lunch. The coach gave the team exactly *k* time units for the lunch break.
The Rabbits have a list of *n* restaurants to lunch in: the *i*-th re... | ```python
n , k = map(int,input().split())
f = [0] * n
t = [0] * n
for i in range(n):
a , b = map(int,input().split())
f[i] = a
t[i] = b
joy = 0
max = -9999
for i in range(n):
if t[i] > k :
joy = f[i] - (t[i] - k)
if t[i] <= k:
joy = f[i]
if joy > max:
max ... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
588 | A | Duff and Meat | PROGRAMMING | 900 | [
"greedy"
] | null | null | Duff is addicted to meat! Malek wants to keep her happy for *n* days. In order to be happy in *i*-th day, she needs to eat exactly *a**i* kilograms of meat.
There is a big shop uptown and Malek wants to buy meat for her from there. In *i*-th day, they sell meat for *p**i* dollars per kilogram. Malek knows all numbers ... | The first line of input contains integer *n* (1<=≤<=*n*<=≤<=105), the number of days.
In the next *n* lines, *i*-th line contains two integers *a**i* and *p**i* (1<=≤<=*a**i*,<=*p**i*<=≤<=100), the amount of meat Duff needs and the cost of meat in that day. | Print the minimum money needed to keep Duff happy for *n* days, in one line. | [
"3\n1 3\n2 2\n3 1\n",
"3\n1 3\n2 1\n3 2\n"
] | [
"10\n",
"8\n"
] | In the first sample case: An optimal way would be to buy 1 kg on the first day, 2 kg on the second day and 3 kg on the third day.
In the second sample case: An optimal way would be to buy 1 kg on the first day and 5 kg (needed meat for the second and third day) on the second day. | 750 | [
{
"input": "3\n1 3\n2 2\n3 1",
"output": "10"
},
{
"input": "3\n1 3\n2 1\n3 2",
"output": "8"
},
{
"input": "1\n39 52",
"output": "2028"
},
{
"input": "2\n25 56\n94 17",
"output": "2998"
},
{
"input": "5\n39 21\n95 89\n73 90\n9 55\n85 32",
"output": "6321"
}... | 1,514,135,816 | 2,147,483,647 | Python 3 | OK | TESTS | 30 | 483 | 13,312,000 | days=int(input())
list1=[]
for t in range(days):
list1.append(list(map(int,input().split())))
for p in range(len(list1)):
if p==len(list1)-1:
pass
else:
if list1[p][1]<list1[p+1][1]:
list1[p+1][1]=list1[p][1]
else:continue
results=0
for i in range(len(list1)):... | Title: Duff and Meat
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Duff is addicted to meat! Malek wants to keep her happy for *n* days. In order to be happy in *i*-th day, she needs to eat exactly *a**i* kilograms of meat.
There is a big shop uptown and Malek wants to buy meat for her ... | ```python
days=int(input())
list1=[]
for t in range(days):
list1.append(list(map(int,input().split())))
for p in range(len(list1)):
if p==len(list1)-1:
pass
else:
if list1[p][1]<list1[p+1][1]:
list1[p+1][1]=list1[p][1]
else:continue
results=0
for i in range(le... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
820 | A | Mister B and Book Reading | PROGRAMMING | 900 | [
"implementation"
] | null | null | Mister B once received a gift: it was a book about aliens, which he started read immediately. This book had *c* pages.
At first day Mister B read *v*0 pages, but after that he started to speed up. Every day, starting from the second, he read *a* pages more than on the previous day (at first day he read *v*0 pages, at ... | First and only line contains five space-separated integers: *c*, *v*0, *v*1, *a* and *l* (1<=≤<=*c*<=≤<=1000, 0<=≤<=*l*<=<<=*v*0<=≤<=*v*1<=≤<=1000, 0<=≤<=*a*<=≤<=1000) — the length of the book in pages, the initial reading speed, the maximum reading speed, the acceleration in reading speed and the number of pages fo... | Print one integer — the number of days Mister B needed to finish the book. | [
"5 5 10 5 4\n",
"12 4 12 4 1\n",
"15 1 100 0 0\n"
] | [
"1\n",
"3\n",
"15\n"
] | In the first sample test the book contains 5 pages, so Mister B read it right at the first day.
In the second sample test at first day Mister B read pages number 1 - 4, at second day — 4 - 11, at third day — 11 - 12 and finished the book.
In third sample test every day Mister B read 1 page of the book, so he finished... | 500 | [
{
"input": "5 5 10 5 4",
"output": "1"
},
{
"input": "12 4 12 4 1",
"output": "3"
},
{
"input": "15 1 100 0 0",
"output": "15"
},
{
"input": "1 1 1 0 0",
"output": "1"
},
{
"input": "1000 999 1000 1000 998",
"output": "2"
},
{
"input": "1000 2 2 5 1",
... | 1,596,641,049 | 2,147,483,647 | PyPy 3 | OK | TESTS | 110 | 186 | 20,172,800 | c, v0, v1, a, l=map(int, input().split())
days=1
pages_read=v0
count=1
while pages_read<c:
pages_read+=min(v1, v0+a*count)
pages_read-=l
days+=1
count+=1
print(days) | Title: Mister B and Book Reading
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Mister B once received a gift: it was a book about aliens, which he started read immediately. This book had *c* pages.
At first day Mister B read *v*0 pages, but after that he started to speed up. Every day, ... | ```python
c, v0, v1, a, l=map(int, input().split())
days=1
pages_read=v0
count=1
while pages_read<c:
pages_read+=min(v1, v0+a*count)
pages_read-=l
days+=1
count+=1
print(days)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
284 | B | Cows and Poker Game | PROGRAMMING | 1,000 | [
"brute force",
"implementation"
] | null | null | There are *n* cows playing poker at a table. For the current betting phase, each player's status is either "ALLIN", "IN", or "FOLDED", and does not change throughout the phase. To increase the suspense, a player whose current status is not "FOLDED" may show his/her hand to the table. However, so as not to affect any be... | The first line contains a single integer, *n* (2<=≤<=*n*<=≤<=2·105). The second line contains *n* characters, each either "A", "I", or "F". The *i*-th character is "A" if the *i*-th player's status is "ALLIN", "I" if the *i*-th player's status is "IN", or "F" if the *i*-th player's status is "FOLDED". | The first line should contain a single integer denoting the number of players that can currently show their hands. | [
"6\nAFFAAA\n",
"3\nAFI\n"
] | [
"4\n",
"1\n"
] | In the first sample, cows 1, 4, 5, and 6 can show their hands. In the second sample, only cow 3 can show her hand. | 1,000 | [
{
"input": "6\nAFFAAA",
"output": "4"
},
{
"input": "3\nAFI",
"output": "1"
},
{
"input": "3\nFFF",
"output": "0"
},
{
"input": "3\nFIF",
"output": "1"
},
{
"input": "3\nAAA",
"output": "3"
},
{
"input": "3\nIII",
"output": "0"
},
{
"input"... | 1,619,689,980 | 2,147,483,647 | Python 3 | OK | TESTS | 66 | 530 | 921,600 | from collections import Counter
n = int(input())
s = input()
c = Counter(s)
res = 0
for i in s:
c[i] -= 1
if i in 'AI':
if c['I'] == 0:
res += 1
c[i] += 1
print(res)
| Title: Cows and Poker Game
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
There are *n* cows playing poker at a table. For the current betting phase, each player's status is either "ALLIN", "IN", or "FOLDED", and does not change throughout the phase. To increase the suspense, a player who... | ```python
from collections import Counter
n = int(input())
s = input()
c = Counter(s)
res = 0
for i in s:
c[i] -= 1
if i in 'AI':
if c['I'] == 0:
res += 1
c[i] += 1
print(res)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
276 | A | Lunch Rush | PROGRAMMING | 900 | [
"implementation"
] | null | null | Having written another programming contest, three Rabbits decided to grab some lunch. The coach gave the team exactly *k* time units for the lunch break.
The Rabbits have a list of *n* restaurants to lunch in: the *i*-th restaurant is characterized by two integers *f**i* and *t**i*. Value *t**i* shows the time the Rab... | The first line contains two space-separated integers — *n* (1<=≤<=*n*<=≤<=104) and *k* (1<=≤<=*k*<=≤<=109) — the number of restaurants in the Rabbits' list and the time the coach has given them to lunch, correspondingly. Each of the next *n* lines contains two space-separated integers — *f**i* (1<=≤<=*f**i*<=≤<=109) an... | In a single line print a single integer — the maximum joy value that the Rabbits will get from the lunch. | [
"2 5\n3 3\n4 5\n",
"4 6\n5 8\n3 6\n2 3\n2 2\n",
"1 5\n1 7\n"
] | [
"4\n",
"3\n",
"-1\n"
] | none | 500 | [
{
"input": "2 5\n3 3\n4 5",
"output": "4"
},
{
"input": "4 6\n5 8\n3 6\n2 3\n2 2",
"output": "3"
},
{
"input": "1 5\n1 7",
"output": "-1"
},
{
"input": "4 9\n10 13\n4 18\n13 3\n10 6",
"output": "13"
},
{
"input": "1 1\n1 1000000000",
"output": "-999999998"
}... | 1,644,152,136 | 2,147,483,647 | Python 3 | OK | TESTS | 35 | 92 | 0 | n, k = input().split()
n, k = int(n), int(k)
ma = None
for i in range(n):
a, b = input().split()
a, b = int(a), int(b)
if b > k:
joy = a - b + k
else:
joy = a
if ma is None:
ma = joy
else:
if ma < joy:
ma = joy
print(ma)
| Title: Lunch Rush
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Having written another programming contest, three Rabbits decided to grab some lunch. The coach gave the team exactly *k* time units for the lunch break.
The Rabbits have a list of *n* restaurants to lunch in: the *i*-th re... | ```python
n, k = input().split()
n, k = int(n), int(k)
ma = None
for i in range(n):
a, b = input().split()
a, b = int(a), int(b)
if b > k:
joy = a - b + k
else:
joy = a
if ma is None:
ma = joy
else:
if ma < joy:
ma = joy
print(ma)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
347 | B | Fixed Points | PROGRAMMING | 1,100 | [
"brute force",
"implementation",
"math"
] | null | null | A permutation of length *n* is an integer sequence such that each integer from 0 to (*n*<=-<=1) appears exactly once in it. For example, sequence [0,<=2,<=1] is a permutation of length 3 while both [0,<=2,<=2] and [1,<=2,<=3] are not.
A fixed point of a function is a point that is mapped to itself by the function. A p... | The first line contains a single integer *n* (1<=≤<=*n*<=≤<=105). The second line contains *n* integers *a*0,<=*a*1,<=...,<=*a**n*<=-<=1 — the given permutation. | Print a single integer — the maximum possible number of fixed points in the permutation after at most one swap operation. | [
"5\n0 1 3 4 2\n"
] | [
"3\n"
] | none | 1,000 | [
{
"input": "5\n0 1 3 4 2",
"output": "3"
},
{
"input": "10\n6 9 4 7 8 2 3 5 0 1",
"output": "2"
},
{
"input": "100\n99 5 40 32 4 31 38 57 94 47 26 16 89 72 9 80 55 86 78 90 42 41 46 74 56 97 21 48 66 27 93 85 88 59 64 95 10 45 12 22 84 60 8 98 62 51 14 65 39 30 11 71 92 19 76 43 87 54 15... | 1,685,009,521 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 10 | 156 | 13,926,400 | import sys
input = sys.stdin.readline
############ ---- Input Functions ---- ############
def inp():
return(int(input()))
def inlt():
return(list(map(int,input().split())))
def insr():
s = input()
return(list(s[:len(s) - 1]))
def invr():
return(map(int,input().split()))
############ --... | Title: Fixed Points
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
A permutation of length *n* is an integer sequence such that each integer from 0 to (*n*<=-<=1) appears exactly once in it. For example, sequence [0,<=2,<=1] is a permutation of length 3 while both [0,<=2,<=2] and [1,<=2,<... | ```python
import sys
input = sys.stdin.readline
############ ---- Input Functions ---- ############
def inp():
return(int(input()))
def inlt():
return(list(map(int,input().split())))
def insr():
s = input()
return(list(s[:len(s) - 1]))
def invr():
return(map(int,input().split()))
#####... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
633 | A | Ebony and Ivory | PROGRAMMING | 1,100 | [
"brute force",
"math",
"number theory"
] | null | null | Dante is engaged in a fight with "The Savior". Before he can fight it with his sword, he needs to break its shields. He has two guns, Ebony and Ivory, each of them is able to perform any non-negative number of shots.
For every bullet that hits the shield, Ebony deals *a* units of damage while Ivory deals *b* units of ... | The first line of the input contains three integers *a*, *b*, *c* (1<=≤<=*a*,<=*b*<=≤<=100,<=1<=≤<=*c*<=≤<=10<=000) — the number of units of damage dealt by Ebony gun and Ivory gun, and the total number of damage required to break the shield, respectively. | Print "Yes" (without quotes) if Dante can deal exactly *c* damage to the shield and "No" (without quotes) otherwise. | [
"4 6 15\n",
"3 2 7\n",
"6 11 6\n"
] | [
"No\n",
"Yes\n",
"Yes\n"
] | In the second sample, Dante can fire 1 bullet from Ebony and 2 from Ivory to deal exactly 1·3 + 2·2 = 7 damage. In the third sample, Dante can fire 1 bullet from ebony and no bullets from ivory to do 1·6 + 0·11 = 6 damage. | 250 | [
{
"input": "4 6 15",
"output": "No"
},
{
"input": "3 2 7",
"output": "Yes"
},
{
"input": "6 11 6",
"output": "Yes"
},
{
"input": "3 12 15",
"output": "Yes"
},
{
"input": "5 5 10",
"output": "Yes"
},
{
"input": "6 6 7",
"output": "No"
},
{
"... | 1,461,315,224 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 46 | 4,608,000 | a, b, c = input()
"""
a=100
b=40
c=500001
"""
pist1 = [x for x in range(c) if x % a == 0]
pist2 = [y for y in range(c) if y % b == 0]
shot = {r+s for r in pist1 for s in pist2 if r+s <= c and r+s > c-a-b}
#set(sort)
#d = set.symmetric_difference(pist1, pist2)
'''
for num in set(shot):
if num == c... | Title: Ebony and Ivory
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Dante is engaged in a fight with "The Savior". Before he can fight it with his sword, he needs to break its shields. He has two guns, Ebony and Ivory, each of them is able to perform any non-negative number of shots.
F... | ```python
a, b, c = input()
"""
a=100
b=40
c=500001
"""
pist1 = [x for x in range(c) if x % a == 0]
pist2 = [y for y in range(c) if y % b == 0]
shot = {r+s for r in pist1 for s in pist2 if r+s <= c and r+s > c-a-b}
#set(sort)
#d = set.symmetric_difference(pist1, pist2)
'''
for num in set(shot):
i... | -1 | MatrixStudio/Codeforces-Python-Submissions | |
6 | A | Triangle | PROGRAMMING | 900 | [
"brute force",
"geometry"
] | A. Triangle | 2 | 64 | Johnny has a younger sister Anne, who is very clever and smart. As she came home from the kindergarten, she told his brother about the task that her kindergartener asked her to solve. The task was just to construct a triangle out of four sticks of different colours. Naturally, one of the sticks is extra. It is not allo... | The first line of the input contains four space-separated positive integer numbers not exceeding 100 — lengthes of the sticks. | Output TRIANGLE if it is possible to construct a non-degenerate triangle. Output SEGMENT if the first case cannot take place and it is possible to construct a degenerate triangle. Output IMPOSSIBLE if it is impossible to construct any triangle. Remember that you are to use three sticks. It is not allowed to break the s... | [
"4 2 1 3\n",
"7 2 2 4\n",
"3 5 9 1\n"
] | [
"TRIANGLE\n",
"SEGMENT\n",
"IMPOSSIBLE\n"
] | none | 0 | [
{
"input": "4 2 1 3",
"output": "TRIANGLE"
},
{
"input": "7 2 2 4",
"output": "SEGMENT"
},
{
"input": "3 5 9 1",
"output": "IMPOSSIBLE"
},
{
"input": "3 1 5 1",
"output": "IMPOSSIBLE"
},
{
"input": "10 10 10 10",
"output": "TRIANGLE"
},
{
"input": "11 ... | 1,695,821,713 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 83 | 124 | 28,774,400 | arr=input()
a=[int(n) for n in arr.split()]
a.sort()
if a[0]+a[1]>a[2] or a[1]+a[2]>a[3]:
print("TRIANGLE")
elif a[0]+a[1]==a[2] or a[1]+a[2]==a[3]:
print("SEGMENT")
else:
print("IMPOSSIBLE") | Title: Triangle
Time Limit: 2 seconds
Memory Limit: 64 megabytes
Problem Description:
Johnny has a younger sister Anne, who is very clever and smart. As she came home from the kindergarten, she told his brother about the task that her kindergartener asked her to solve. The task was just to construct a triangle out o... | ```python
arr=input()
a=[int(n) for n in arr.split()]
a.sort()
if a[0]+a[1]>a[2] or a[1]+a[2]>a[3]:
print("TRIANGLE")
elif a[0]+a[1]==a[2] or a[1]+a[2]==a[3]:
print("SEGMENT")
else:
print("IMPOSSIBLE")
``` | 3.754614 | MatrixStudio/Codeforces-Python-Submissions |
57 | C | Array | PROGRAMMING | 1,900 | [
"combinatorics",
"math"
] | C. Array | 2 | 256 | Chris the Rabbit has been interested in arrays ever since he was a child. At the moment he is researching arrays with the length of *n*, containing only integers from 1 to *n*. He is not good at math, that's why some simple things drive him crazy. For example, yesterday he grew keen on counting how many different beaut... | The single line contains an integer *n* which is the size of the array (1<=≤<=*n*<=≤<=105). | You must print the answer on a single line. As it can be rather long, you should print it modulo 1000000007. | [
"2\n",
"3\n"
] | [
"4\n",
"17\n"
] | none | 1,500 | [
{
"input": "2",
"output": "4"
},
{
"input": "3",
"output": "17"
},
{
"input": "12",
"output": "2704144"
},
{
"input": "19",
"output": "345263536"
},
{
"input": "20",
"output": "846527841"
},
{
"input": "26",
"output": "529476652"
},
{
"inpu... | 1,402,512,458 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 53 | 404 | 0 | def po(a,b,m):
if b == 0:
return 1
if b % 2 == 0:
return (po(a, b // 2, m) ** 2) % m
return (po(a, b - 1, m) * a) % m
def rev(a,m):
return po(a, m - 2, m)
def fact(a, m):
t = a
for i in range(1, a):
t=(t * i) % m
return t
def main(n):
m = 10... | Title: Array
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Chris the Rabbit has been interested in arrays ever since he was a child. At the moment he is researching arrays with the length of *n*, containing only integers from 1 to *n*. He is not good at math, that's why some simple things dr... | ```python
def po(a,b,m):
if b == 0:
return 1
if b % 2 == 0:
return (po(a, b // 2, m) ** 2) % m
return (po(a, b - 1, m) * a) % m
def rev(a,m):
return po(a, m - 2, m)
def fact(a, m):
t = a
for i in range(1, a):
t=(t * i) % m
return t
def main(n):
... | 0 | MatrixStudio/Codeforces-Python-Submissions |
701 | A | Cards | PROGRAMMING | 800 | [
"greedy",
"implementation"
] | null | null | There are *n* cards (*n* is even) in the deck. Each card has a positive integer written on it. *n*<=/<=2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards ... | The first line of the input contains integer *n* (2<=≤<=*n*<=≤<=100) — the number of cards in the deck. It is guaranteed that *n* is even.
The second line contains the sequence of *n* positive integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=100), where *a**i* is equal to the number written on the *i*-th card. | Print *n*<=/<=2 pairs of integers, the *i*-th pair denote the cards that should be given to the *i*-th player. Each card should be given to exactly one player. Cards are numbered in the order they appear in the input.
It is guaranteed that solution exists. If there are several correct answers, you are allowed to print... | [
"6\n1 5 7 4 4 3\n",
"4\n10 10 10 10\n"
] | [
"1 3\n6 2\n4 5\n",
"1 2\n3 4\n"
] | In the first sample, cards are distributed in such a way that each player has the sum of numbers written on his cards equal to 8.
In the second sample, all values *a*<sub class="lower-index">*i*</sub> are equal. Thus, any distribution is acceptable. | 500 | [
{
"input": "6\n1 5 7 4 4 3",
"output": "1 3\n6 2\n4 5"
},
{
"input": "4\n10 10 10 10",
"output": "1 4\n2 3"
},
{
"input": "100\n2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ... | 1,625,213,907 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 6 | 109 | 0 | n=int(int(input()));l=list(map(int,input().split()));b=sorted(l)
if b[0]==b[-1]:
for i in range(1,n+1,2):print(i,i+1)
else:
for i in range(n//2):
if b[i]==b[n-i-1]:print(l.index(b[i])+1,n-l[::-1].index(b[n-i-1]))
else:print(l.index(b[i])+1,l.index(b[n-i-1])+1) | Title: Cards
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
There are *n* cards (*n* is even) in the deck. Each card has a positive integer written on it. *n*<=/<=2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one p... | ```python
n=int(int(input()));l=list(map(int,input().split()));b=sorted(l)
if b[0]==b[-1]:
for i in range(1,n+1,2):print(i,i+1)
else:
for i in range(n//2):
if b[i]==b[n-i-1]:print(l.index(b[i])+1,n-l[::-1].index(b[n-i-1]))
else:print(l.index(b[i])+1,l.index(b[n-i-1])+1)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
816 | B | Karen and Coffee | PROGRAMMING | 1,400 | [
"binary search",
"data structures",
"implementation"
] | null | null | To stay woke and attentive during classes, Karen needs some coffee!
Karen, a coffee aficionado, wants to know the optimal temperature for brewing the perfect cup of coffee. Indeed, she has spent some time reading several recipe books, including the universally acclaimed "The Art of the Covfefe".
She knows *n* coffee ... | The first line of input contains three integers, *n*, *k* (1<=≤<=*k*<=≤<=*n*<=≤<=200000), and *q* (1<=≤<=*q*<=≤<=200000), the number of recipes, the minimum number of recipes a certain temperature must be recommended by to be admissible, and the number of questions Karen has, respectively.
The next *n* lines describe ... | For each question, output a single integer on a line by itself, the number of admissible integer temperatures between *a* and *b* degrees, inclusive. | [
"3 2 4\n91 94\n92 97\n97 99\n92 94\n93 97\n95 96\n90 100\n",
"2 1 1\n1 1\n200000 200000\n90 100\n"
] | [
"3\n3\n0\n4\n",
"0\n"
] | In the first test case, Karen knows 3 recipes.
1. The first one recommends brewing the coffee between 91 and 94 degrees, inclusive. 1. The second one recommends brewing the coffee between 92 and 97 degrees, inclusive. 1. The third one recommends brewing the coffee between 97 and 99 degrees, inclusive.
A temperatur... | 1,000 | [
{
"input": "3 2 4\n91 94\n92 97\n97 99\n92 94\n93 97\n95 96\n90 100",
"output": "3\n3\n0\n4"
},
{
"input": "2 1 1\n1 1\n200000 200000\n90 100",
"output": "0"
},
{
"input": "1 1 1\n1 1\n1 1",
"output": "1"
},
{
"input": "1 1 1\n200000 200000\n200000 200000",
"output": "1"
... | 1,699,240,621 | 2,147,483,647 | PyPy 3-64 | TIME_LIMIT_EXCEEDED | TESTS | 9 | 2,500 | 12,697,600 | import sys,os
# sys.stdin = open("input","r")
from collections import *
from heapq import *
from functools import *
from types import GeneratorType
# from math import *
from itertools import *
from math import *
from string import ascii_lowercase
from types import GeneratorType
def bootstrap(f, stack=[]):
def... | Title: Karen and Coffee
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
To stay woke and attentive during classes, Karen needs some coffee!
Karen, a coffee aficionado, wants to know the optimal temperature for brewing the perfect cup of coffee. Indeed, she has spent some time reading seve... | ```python
import sys,os
# sys.stdin = open("input","r")
from collections import *
from heapq import *
from functools import *
from types import GeneratorType
# from math import *
from itertools import *
from math import *
from string import ascii_lowercase
from types import GeneratorType
def bootstrap(f, stack=[]... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
572 | A | Arrays | PROGRAMMING | 900 | [
"sortings"
] | null | null | You are given two arrays *A* and *B* consisting of integers, sorted in non-decreasing order. Check whether it is possible to choose *k* numbers in array *A* and choose *m* numbers in array *B* so that any number chosen in the first array is strictly less than any number chosen in the second array. | The first line contains two integers *n**A*,<=*n**B* (1<=≤<=*n**A*,<=*n**B*<=≤<=105), separated by a space — the sizes of arrays *A* and *B*, correspondingly.
The second line contains two integers *k* and *m* (1<=≤<=*k*<=≤<=*n**A*,<=1<=≤<=*m*<=≤<=*n**B*), separated by a space.
The third line contains *n**A* numbers *... | Print "YES" (without the quotes), if you can choose *k* numbers in array *A* and *m* numbers in array *B* so that any number chosen in array *A* was strictly less than any number chosen in array *B*. Otherwise, print "NO" (without the quotes). | [
"3 3\n2 1\n1 2 3\n3 4 5\n",
"3 3\n3 3\n1 2 3\n3 4 5\n",
"5 2\n3 1\n1 1 1 1 1\n2 2\n"
] | [
"YES\n",
"NO\n",
"YES\n"
] | In the first sample test you can, for example, choose numbers 1 and 2 from array *A* and number 3 from array *B* (1 < 3 and 2 < 3).
In the second sample test the only way to choose *k* elements in the first array and *m* elements in the second one is to choose all numbers in both arrays, but then not all the num... | 500 | [
{
"input": "3 3\n2 1\n1 2 3\n3 4 5",
"output": "YES"
},
{
"input": "3 3\n3 3\n1 2 3\n3 4 5",
"output": "NO"
},
{
"input": "5 2\n3 1\n1 1 1 1 1\n2 2",
"output": "YES"
},
{
"input": "3 5\n1 1\n5 5 5\n5 5 5 5 5",
"output": "NO"
},
{
"input": "1 1\n1 1\n1\n1",
"ou... | 1,549,981,538 | 2,147,483,647 | Python 3 | OK | TESTS | 52 | 171 | 10,956,800 | n,m = list(map(int,input().split()))
a,b = list(map(int,input().split()))
c = list(map(int,input().split()))
d = list(map(int,input().split()))
if c[a-1]<d[m-b]:
print("YES")
else:
print("NO") | Title: Arrays
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given two arrays *A* and *B* consisting of integers, sorted in non-decreasing order. Check whether it is possible to choose *k* numbers in array *A* and choose *m* numbers in array *B* so that any number chosen in the fi... | ```python
n,m = list(map(int,input().split()))
a,b = list(map(int,input().split()))
c = list(map(int,input().split()))
d = list(map(int,input().split()))
if c[a-1]<d[m-b]:
print("YES")
else:
print("NO")
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
659 | A | Round House | PROGRAMMING | 1,000 | [
"implementation",
"math"
] | null | null | Vasya lives in a round building, whose entrances are numbered sequentially by integers from 1 to *n*. Entrance *n* and entrance 1 are adjacent.
Today Vasya got bored and decided to take a walk in the yard. Vasya lives in entrance *a* and he decided that during his walk he will move around the house *b* entrances in th... | The single line of the input contains three space-separated integers *n*, *a* and *b* (1<=≤<=*n*<=≤<=100,<=1<=≤<=*a*<=≤<=*n*,<=<=-<=100<=≤<=*b*<=≤<=100) — the number of entrances at Vasya's place, the number of his entrance and the length of his walk, respectively. | Print a single integer *k* (1<=≤<=*k*<=≤<=*n*) — the number of the entrance where Vasya will be at the end of his walk. | [
"6 2 -5\n",
"5 1 3\n",
"3 2 7\n"
] | [
"3\n",
"4\n",
"3\n"
] | The first example is illustrated by the picture in the statements. | 500 | [
{
"input": "6 2 -5",
"output": "3"
},
{
"input": "5 1 3",
"output": "4"
},
{
"input": "3 2 7",
"output": "3"
},
{
"input": "1 1 0",
"output": "1"
},
{
"input": "1 1 -1",
"output": "1"
},
{
"input": "1 1 1",
"output": "1"
},
{
"input": "100 ... | 1,589,693,233 | 2,147,483,647 | PyPy 3 | RUNTIME_ERROR | TESTS | 4 | 202 | 22,220,800 | n , a , b = map(int, input().split())
x = [i for i in range(1, n+1)]
y = x[::-1]
if b<0:
z = y.index(a)
ans = y[z:]
if len(ans)>=abs(b):
print(ans[abs(b)])
else:
p = (abs(b)%n)
q = p - len(ans)
ans = ans + y[:q+1]
print(ans[-1])
else:
ans = x+x
... | Title: Round House
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vasya lives in a round building, whose entrances are numbered sequentially by integers from 1 to *n*. Entrance *n* and entrance 1 are adjacent.
Today Vasya got bored and decided to take a walk in the yard. Vasya lives in e... | ```python
n , a , b = map(int, input().split())
x = [i for i in range(1, n+1)]
y = x[::-1]
if b<0:
z = y.index(a)
ans = y[z:]
if len(ans)>=abs(b):
print(ans[abs(b)])
else:
p = (abs(b)%n)
q = p - len(ans)
ans = ans + y[:q+1]
print(ans[-1])
else:
a... | -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,616,066,026 | 2,147,483,647 | Python 3 | OK | TESTS | 30 | 124 | 0 | s=str(input())
q=0
w=0
for i in range(len(s)):
if s[i]==s[i].upper():
q=q+1
elif s[i]==s[i].lower():
w=w+1
if q>w:
print(s.upper())
elif q<w:
print(s.lower())
elif q==w:
print(s.lower()) | Title: Word
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Vasya is very upset that many people on the Net mix uppercase and lowercase letters in one word. That's why he decided to invent an extension for his favorite browser that would change the letters' register in every word so that it ei... | ```python
s=str(input())
q=0
w=0
for i in range(len(s)):
if s[i]==s[i].upper():
q=q+1
elif s[i]==s[i].lower():
w=w+1
if q>w:
print(s.upper())
elif q<w:
print(s.lower())
elif q==w:
print(s.lower())
``` | 3.969 | 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,634,181,897 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 30 | 0 | m,n=map(int , input().split(' '))
ans=m*n/2
print(ans) | Title: Domino piling
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
You are given a rectangular board of *M*<=×<=*N* squares. Also you are given an unlimited number of standard domino pieces of 2<=×<=1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as p... | ```python
m,n=map(int , input().split(' '))
ans=m*n/2
print(ans)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions |
0 | none | none | none | 0 | [
"none"
] | null | null | Valentin participates in a show called "Shockers". The rules are quite easy: jury selects one letter which Valentin doesn't know. He should make a small speech, but every time he pronounces a word that contains the selected letter, he receives an electric shock. He can make guesses which letter is selected, but for eac... | The first line contains a single integer *n* (1<=≤<=*n*<=≤<=105) — the number of actions Valentin did.
The next *n* lines contain descriptions of his actions, each line contains description of one action. Each action can be of one of three types:
1. Valentin pronounced some word and didn't get an electric shock. Th... | Output a single integer — the number of electric shocks that Valentin could have avoided if he had told the selected letter just after it became uniquely determined. | [
"5\n! abc\n. ad\n. b\n! cd\n? c\n",
"8\n! hello\n! codeforces\n? c\n. o\n? d\n? h\n. l\n? e\n",
"7\n! ababahalamaha\n? a\n? b\n? a\n? b\n? a\n? h\n"
] | [
"1\n",
"2\n",
"0\n"
] | In the first test case after the first action it becomes clear that the selected letter is one of the following: *a*, *b*, *c*. After the second action we can note that the selected letter is not *a*. Valentin tells word "b" and doesn't get a shock. After that it is clear that the selected letter is *c*, but Valentin p... | 0 | [
{
"input": "5\n! abc\n. ad\n. b\n! cd\n? c",
"output": "1"
},
{
"input": "8\n! hello\n! codeforces\n? c\n. o\n? d\n? h\n. l\n? e",
"output": "2"
},
{
"input": "7\n! ababahalamaha\n? a\n? b\n? a\n? b\n? a\n? h",
"output": "0"
},
{
"input": "4\n! abcd\n! cdef\n? d\n? c",
"o... | 1,514,272,357 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 46 | 5,529,600 | #!/usr/bin/env python3
n = int(input())
mp = [0 for i in range(26)]
det = -1
for i in range(n):
mark, word = input().split(' ')
if det>=0:
continue
if mark=='!':
assign = 1
else:
assign = -1
for j in range(len(word)):
pos = int(ord(word[j])-ord('a'))
if ... | Title: none
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Valentin participates in a show called "Shockers". The rules are quite easy: jury selects one letter which Valentin doesn't know. He should make a small speech, but every time he pronounces a word that contains the selected letter... | ```python
#!/usr/bin/env python3
n = int(input())
mp = [0 for i in range(26)]
det = -1
for i in range(n):
mark, word = input().split(' ')
if det>=0:
continue
if mark=='!':
assign = 1
else:
assign = -1
for j in range(len(word)):
pos = int(ord(word[j])-ord('a'))
... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
610 | A | Pasha and Stick | PROGRAMMING | 1,000 | [
"combinatorics",
"math"
] | null | null | Pasha has a wooden stick of some positive integer length *n*. He wants to perform exactly three cuts to get four parts of the stick. Each part must have some positive integer length and the sum of these lengths will obviously be *n*.
Pasha likes rectangles but hates squares, so he wonders, how many ways are there to ... | The first line of the input contains a positive integer *n* (1<=≤<=*n*<=≤<=2·109) — the length of Pasha's stick. | The output should contain a single integer — the number of ways to split Pasha's stick into four parts of positive integer length so that it's possible to make a rectangle by connecting the ends of these parts, but is impossible to form a square. | [
"6\n",
"20\n"
] | [
"1\n",
"4\n"
] | There is only one way to divide the stick in the first sample {1, 1, 2, 2}.
Four ways to divide the stick in the second sample are {1, 1, 9, 9}, {2, 2, 8, 8}, {3, 3, 7, 7} and {4, 4, 6, 6}. Note that {5, 5, 5, 5} doesn't work. | 500 | [
{
"input": "6",
"output": "1"
},
{
"input": "20",
"output": "4"
},
{
"input": "1",
"output": "0"
},
{
"input": "2",
"output": "0"
},
{
"input": "3",
"output": "0"
},
{
"input": "4",
"output": "0"
},
{
"input": "2000000000",
"output": "4... | 1,622,617,718 | 2,147,483,647 | Python 3 | OK | TESTS | 76 | 109 | 0 | n = int(input())
if n%2!=0:
print(0)
else:
n = n//2
ans = n-1
print(ans//2) | Title: Pasha and Stick
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Pasha has a wooden stick of some positive integer length *n*. He wants to perform exactly three cuts to get four parts of the stick. Each part must have some positive integer length and the sum of these lengths will obv... | ```python
n = int(input())
if n%2!=0:
print(0)
else:
n = n//2
ans = n-1
print(ans//2)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
929 | C | Красивая команда | PROGRAMMING | 1,700 | [
"*special",
"combinatorics",
"math"
] | null | null | Завтра у хоккейной команды, которой руководит Евгений, важный матч. Евгению нужно выбрать шесть игроков, которые выйдут на лед в стартовом составе: один вратарь, два защитника и три нападающих.
Так как это стартовый состав, Евгения больше волнует, насколько красива будет команда на льду, чем способности игроков. А име... | Первая строка содержит три целых числа *g*, *d* и *f* (1<=≤<=*g*<=≤<=1<=000, 1<=≤<=*d*<=≤<=1<=000, 1<=≤<=*f*<=≤<=1<=000) — число вратарей, защитников и нападающих в команде Евгения.
Вторая строка содержит *g* целых чисел, каждое в пределах от 1 до 100<=000 — номера вратарей.
Третья строка содержит *d* целых чисел, к... | Выведите одно целое число — количество возможных стартовых составов. | [
"1 2 3\n15\n10 19\n20 11 13\n",
"2 3 4\n16 40\n20 12 19\n13 21 11 10\n"
] | [
"1\n",
"6\n"
] | В первом примере всего один вариант для выбора состава, который удовлетворяет описанным условиям, поэтому ответ 1.
Во втором примере подходят следующие игровые сочетания (в порядке вратарь-защитник-защитник-нападающий-нападающий-нападающий):
- 16 20 12 13 21 11 - 16 20 12 13 11 10 - 16 20 19 13 21 11 - 16 20 19 1... | 1,750 | [
{
"input": "1 2 3\n15\n10 19\n20 11 13",
"output": "1"
},
{
"input": "2 3 4\n16 40\n20 12 19\n13 21 11 10",
"output": "6"
},
{
"input": "4 4 5\n15 16 19 6\n8 11 9 18\n5 3 1 12 14",
"output": "0"
},
{
"input": "6 7 7\n32 35 26 33 16 23\n4 40 36 12 28 24 3\n39 11 31 37 1 25 6",... | 1,520,075,556 | 70,656 | Python 3 | OK | TESTS | 65 | 265 | 6,246,400 | from math import factorial
def bin_search(l, r, x):
while l < r - 1:
m = (l+r)//2
if players[m][0] == x:
return m
if players[m][0] < x:
l = m
else:
r = m
return l
def cmds_in_range(rang):
roles = []
temp_rang = [i[1] for i in rang]
for i in range(3):
roles.append(temp_rang.cou... | Title: Красивая команда
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Завтра у хоккейной команды, которой руководит Евгений, важный матч. Евгению нужно выбрать шесть игроков, которые выйдут на лед в стартовом составе: один вратарь, два защитника и три нападающих.
Так как это стартовый с... | ```python
from math import factorial
def bin_search(l, r, x):
while l < r - 1:
m = (l+r)//2
if players[m][0] == x:
return m
if players[m][0] < x:
l = m
else:
r = m
return l
def cmds_in_range(rang):
roles = []
temp_rang = [i[1] for i in rang]
for i in range(3):
roles.append(tem... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
0 | none | none | none | 0 | [
"none"
] | null | null | Santa Claus is the first who came to the Christmas Olympiad, and he is going to be the first to take his place at a desk! In the classroom there are *n* lanes of *m* desks each, and there are two working places at each of the desks. The lanes are numbered from 1 to *n* from the left to the right, the desks in a lane ar... | The only line contains three integers *n*, *m* and *k* (1<=≤<=*n*,<=*m*<=≤<=10<=000, 1<=≤<=*k*<=≤<=2*nm*) — the number of lanes, the number of desks in each lane and the number of Santa Claus' place. | Print two integers: the number of lane *r*, the number of desk *d*, and a character *s*, which stands for the side of the desk Santa Claus. The character *s* should be "L", if Santa Clause should sit on the left, and "R" if his place is on the right. | [
"4 3 9\n",
"4 3 24\n",
"2 4 4\n"
] | [
"2 2 L\n",
"4 3 R\n",
"1 2 R\n"
] | The first and the second samples are shown on the picture. The green place corresponds to Santa Claus' place in the first example, the blue place corresponds to Santa Claus' place in the second example.
In the third sample there are two lanes with four desks in each, and Santa Claus has the fourth place. Thus, his pla... | 0 | [
{
"input": "4 3 9",
"output": "2 2 L"
},
{
"input": "4 3 24",
"output": "4 3 R"
},
{
"input": "2 4 4",
"output": "1 2 R"
},
{
"input": "3 10 24",
"output": "2 2 R"
},
{
"input": "10 3 59",
"output": "10 3 L"
},
{
"input": "10000 10000 160845880",
"... | 1,483,696,020 | 2,147,483,647 | Python 3 | OK | TESTS | 46 | 61 | 4,608,000 | n, m, k = [int(i) for i in input().split()]
o = [None, None, None]
o[2] = "L" if k % 2 else "R"
k += -(1 - (k % 2)) - 1
k //= 2
o[0] = k // m + 1
o[1] = k % m + 1
print(' '.join([str(i) for i in o]))
| Title: none
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Santa Claus is the first who came to the Christmas Olympiad, and he is going to be the first to take his place at a desk! In the classroom there are *n* lanes of *m* desks each, and there are two working places at each of the desk... | ```python
n, m, k = [int(i) for i in input().split()]
o = [None, None, None]
o[2] = "L" if k % 2 else "R"
k += -(1 - (k % 2)) - 1
k //= 2
o[0] = k // m + 1
o[1] = k % m + 1
print(' '.join([str(i) for i in o]))
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
535 | B | Tavas and SaDDas | PROGRAMMING | 1,100 | [
"bitmasks",
"brute force",
"combinatorics",
"implementation"
] | null | null | Once again Tavas started eating coffee mix without water! Keione told him that it smells awful, but he didn't stop doing that. That's why Keione told his smart friend, SaDDas to punish him! SaDDas took Tavas' headphones and told him: "If you solve the following problem, I'll return it to you."
The problem is:
You ar... | The first and only line of input contains a lucky number *n* (1<=≤<=*n*<=≤<=109). | Print the index of *n* among all lucky numbers. | [
"4\n",
"7\n",
"77\n"
] | [
"1\n",
"2\n",
"6\n"
] | none | 1,000 | [
{
"input": "4",
"output": "1"
},
{
"input": "7",
"output": "2"
},
{
"input": "77",
"output": "6"
},
{
"input": "4",
"output": "1"
},
{
"input": "474744",
"output": "83"
},
{
"input": "777774",
"output": "125"
},
{
"input": "447",
"outpu... | 1,594,177,836 | 2,147,483,647 | Python 3 | OK | TESTS | 33 | 108 | 6,656,000 | s = '1' + input().replace('4','0').replace('7','1')
print(int(s,2)-1) | Title: Tavas and SaDDas
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Once again Tavas started eating coffee mix without water! Keione told him that it smells awful, but he didn't stop doing that. That's why Keione told his smart friend, SaDDas to punish him! SaDDas took Tavas' headphone... | ```python
s = '1' + input().replace('4','0').replace('7','1')
print(int(s,2)-1)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
546 | A | Soldier and Bananas | PROGRAMMING | 800 | [
"brute force",
"implementation",
"math"
] | null | null | A soldier wants to buy *w* bananas in the shop. He has to pay *k* dollars for the first banana, 2*k* dollars for the second one and so on (in other words, he has to pay *i*·*k* dollars for the *i*-th banana).
He has *n* dollars. How many dollars does he have to borrow from his friend soldier to buy *w* bananas? | The first line contains three positive integers *k*,<=*n*,<=*w* (1<=<=≤<=<=*k*,<=*w*<=<=≤<=<=1000, 0<=≤<=*n*<=≤<=109), the cost of the first banana, initial number of dollars the soldier has and number of bananas he wants. | Output one integer — the amount of dollars that the soldier must borrow from his friend. If he doesn't have to borrow money, output 0. | [
"3 17 4\n"
] | [
"13"
] | none | 500 | [
{
"input": "3 17 4",
"output": "13"
},
{
"input": "1 2 1",
"output": "0"
},
{
"input": "1 1 1",
"output": "0"
},
{
"input": "1 5 6",
"output": "16"
},
{
"input": "1 1000000000 1",
"output": "0"
},
{
"input": "1000 0 1000",
"output": "500500000"
}... | 1,698,520,553 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 15 | 62 | 0 | d, h_d, w = map(int, input().split())
ans = 0
cnt = 0
while cnt < w:
cnt += 1
ans = ans + d * cnt
if ans - h_d > 0:
print(ans - h_d)
else:
print(0) | Title: Soldier and Bananas
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
A soldier wants to buy *w* bananas in the shop. He has to pay *k* dollars for the first banana, 2*k* dollars for the second one and so on (in other words, he has to pay *i*·*k* dollars for the *i*-th banana).
He h... | ```python
d, h_d, w = map(int, input().split())
ans = 0
cnt = 0
while cnt < w:
cnt += 1
ans = ans + d * cnt
if ans - h_d > 0:
print(ans - h_d)
else:
print(0)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
614 | A | Link/Cut Tree | PROGRAMMING | 1,500 | [
"brute force",
"implementation"
] | null | null | Programmer Rostislav got seriously interested in the Link/Cut Tree data structure, which is based on Splay trees. Specifically, he is now studying the *expose* procedure.
Unfortunately, Rostislav is unable to understand the definition of this procedure, so he decided to ask programmer Serezha to help him. Serezha agre... | The first line of the input contains three space-separated integers *l*, *r* and *k* (1<=≤<=*l*<=≤<=*r*<=≤<=1018, 2<=≤<=*k*<=≤<=109). | Print all powers of number *k*, that lie within range from *l* to *r* in the increasing order. If there are no such numbers, print "-1" (without the quotes). | [
"1 10 2\n",
"2 4 5\n"
] | [
"1 2 4 8 ",
"-1"
] | Note to the first sample: numbers 2<sup class="upper-index">0</sup> = 1, 2<sup class="upper-index">1</sup> = 2, 2<sup class="upper-index">2</sup> = 4, 2<sup class="upper-index">3</sup> = 8 lie within the specified range. The number 2<sup class="upper-index">4</sup> = 16 is greater then 10, thus it shouldn't be printed. | 500 | [
{
"input": "1 10 2",
"output": "1 2 4 8 "
},
{
"input": "2 4 5",
"output": "-1"
},
{
"input": "18102 43332383920 28554",
"output": "28554 815330916 "
},
{
"input": "19562 31702689720 17701",
"output": "313325401 "
},
{
"input": "11729 55221128400 313",
"output... | 1,557,770,350 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 77 | 0 | l, r, k = map(int, input().split())
sols = []
i = 1
while i <= r:
if i >= l:
sols.append(str(i))
i *= k
print(' '.join(sols)) | Title: Link/Cut Tree
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Programmer Rostislav got seriously interested in the Link/Cut Tree data structure, which is based on Splay trees. Specifically, he is now studying the *expose* procedure.
Unfortunately, Rostislav is unable to understand ... | ```python
l, r, k = map(int, input().split())
sols = []
i = 1
while i <= r:
if i >= l:
sols.append(str(i))
i *= k
print(' '.join(sols))
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
393 | A | Nineteen | PROGRAMMING | 0 | [] | null | null | Alice likes word "nineteen" very much. She has a string *s* and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.
For example, if she has string "xiineteenppnnnewtnee", she can get string "xnineteenppnineteenw", containing (the occurrences marked) ... | The first line contains a non-empty string *s*, consisting only of lowercase English letters. The length of string *s* doesn't exceed 100. | Print a single integer — the maximum number of "nineteen"s that she can get in her string. | [
"nniinneetteeeenn\n",
"nneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n",
"nineteenineteen\n"
] | [
"2",
"2",
"2"
] | none | 500 | [
{
"input": "nniinneetteeeenn",
"output": "2"
},
{
"input": "nneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii",
"output": "2"
},
{
"input": "nineteenineteen",
"output": "2"
},
{
"input": "nssemsnnsitjtihtthij",
"output": "0"
},
{
"input": "eehihnttehtherjsihihn... | 1,586,956,433 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 9 | 93 | 0 | a=input().count
print(max(0,min((a('n')-1//2,a('i'),a('t'),a('e')//3))))
| Title: Nineteen
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Alice likes word "nineteen" very much. She has a string *s* and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.
For example, if she has string "xiinetee... | ```python
a=input().count
print(max(0,min((a('n')-1//2,a('i'),a('t'),a('e')//3))))
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
745 | A | Hongcow Learns the Cyclic Shift | PROGRAMMING | 900 | [
"implementation",
"strings"
] | null | null | Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word.
Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last character ... | The first line of input will be a single string *s* (1<=≤<=|*s*|<=≤<=50), the word Hongcow initially learns how to spell. The string *s* consists only of lowercase English letters ('a'–'z'). | Output a single integer equal to the number of distinct strings that Hongcow can obtain by applying the cyclic shift arbitrarily many times to the given string. | [
"abcd\n",
"bbb\n",
"yzyz\n"
] | [
"4\n",
"1\n",
"2\n"
] | For the first sample, the strings Hongcow can generate are "abcd", "dabc", "cdab", and "bcda".
For the second sample, no matter how many times Hongcow does the cyclic shift, Hongcow can only generate "bbb".
For the third sample, the two strings Hongcow can generate are "yzyz" and "zyzy". | 500 | [
{
"input": "abcd",
"output": "4"
},
{
"input": "bbb",
"output": "1"
},
{
"input": "yzyz",
"output": "2"
},
{
"input": "abcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxy",
"output": "25"
},
{
"input": "zclkjadoprqronzclkjadoprqronzclkjadoprqron",
"output": "14... | 1,501,655,413 | 2,147,483,647 | Python 3 | OK | TESTS | 28 | 62 | 5,120,000 | from collections import Counter
s = input()
z = set()
for i in range(len(s)):
s = s[1:] + s[:1]
z.add(s)
print(len(Counter(z))) | Title: Hongcow Learns the Cyclic Shift
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word.
Hongcow has decided to try to m... | ```python
from collections import Counter
s = input()
z = set()
for i in range(len(s)):
s = s[1:] + s[:1]
z.add(s)
print(len(Counter(z)))
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
9 | A | Die Roll | PROGRAMMING | 800 | [
"math",
"probabilities"
] | A. Die Roll | 1 | 64 | Yakko, Wakko and Dot, world-famous animaniacs, decided to rest from acting in cartoons, and take a leave to travel a bit. Yakko dreamt to go to Pennsylvania, his Motherland and the Motherland of his ancestors. Wakko thought about Tasmania, its beaches, sun and sea. Dot chose Transylvania as the most mysterious and unpr... | The only line of the input file contains two natural numbers Y and W — the results of Yakko's and Wakko's die rolls. | Output the required probability in the form of irreducible fraction in format «A/B», where A — the numerator, and B — the denominator. If the required probability equals to zero, output «0/1». If the required probability equals to 1, output «1/1». | [
"4 2\n"
] | [
"1/2\n"
] | Dot will go to Transylvania, if she is lucky to roll 4, 5 or 6 points. | 0 | [
{
"input": "4 2",
"output": "1/2"
},
{
"input": "1 1",
"output": "1/1"
},
{
"input": "1 2",
"output": "5/6"
},
{
"input": "1 3",
"output": "2/3"
},
{
"input": "1 4",
"output": "1/2"
},
{
"input": "1 5",
"output": "1/3"
},
{
"input": "1 6",
... | 1,650,359,725 | 2,147,483,647 | Python 3 | OK | TESTS | 36 | 122 | 409,600 | from fractions import Fraction
i = input()
j = i.split()
numerator = 0
if int(j[0]) > int(j[1]):
numerator += 6 - int(j[0]) + 1
elif int(j[0]) < int(j[1]):
numerator += 6 - int(j[1]) + 1
else:
numerator += 6 - int(j[0]) + 1
w = Fraction(numerator, 6)
if str(w) == '1':
w = '1/1'
elif str(w) ==... | Title: Die Roll
Time Limit: 1 seconds
Memory Limit: 64 megabytes
Problem Description:
Yakko, Wakko and Dot, world-famous animaniacs, decided to rest from acting in cartoons, and take a leave to travel a bit. Yakko dreamt to go to Pennsylvania, his Motherland and the Motherland of his ancestors. Wakko thought about T... | ```python
from fractions import Fraction
i = input()
j = i.split()
numerator = 0
if int(j[0]) > int(j[1]):
numerator += 6 - int(j[0]) + 1
elif int(j[0]) < int(j[1]):
numerator += 6 - int(j[1]) + 1
else:
numerator += 6 - int(j[0]) + 1
w = Fraction(numerator, 6)
if str(w) == '1':
w = '1/1'
elif... | 3.935948 | MatrixStudio/Codeforces-Python-Submissions |
79 | A | Bus Game | PROGRAMMING | 1,200 | [
"greedy"
] | A. Bus Game | 2 | 256 | After Fox Ciel won an onsite round of a programming contest, she took a bus to return to her castle. The fee of the bus was 220 yen. She met Rabbit Hanako in the bus. They decided to play the following game because they got bored in the bus.
- Initially, there is a pile that contains *x* 100-yen coins and *y* 10-yen ... | The first line contains two integers *x* (0<=≤<=*x*<=≤<=106) and *y* (0<=≤<=*y*<=≤<=106), separated by a single space. | If Ciel wins, print "Ciel". Otherwise, print "Hanako". | [
"2 2\n",
"3 22\n"
] | [
"Ciel\n",
"Hanako\n"
] | In the first turn (Ciel's turn), she will choose 2 100-yen coins and 2 10-yen coins. In the second turn (Hanako's turn), she will choose 1 100-yen coin and 12 10-yen coins. In the third turn (Ciel's turn), she can't pay exactly 220 yen, so Ciel will lose. | 500 | [
{
"input": "2 2",
"output": "Ciel"
},
{
"input": "3 22",
"output": "Hanako"
},
{
"input": "0 22",
"output": "Ciel"
},
{
"input": "1000 1000",
"output": "Ciel"
},
{
"input": "0 0",
"output": "Hanako"
},
{
"input": "0 21",
"output": "Hanako"
},
{... | 1,668,438,878 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 3 | 92 | 0 | class solve:
def __init__(self):
x,y=map(int,input().split())
turn=0
flag=0
ans=0
while 100*x+10*y>=220:
if turn==0:
amt=0
if x>=2:
amt=200
x-=2
else:
... | Title: Bus Game
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
After Fox Ciel won an onsite round of a programming contest, she took a bus to return to her castle. The fee of the bus was 220 yen. She met Rabbit Hanako in the bus. They decided to play the following game because they got bored ... | ```python
class solve:
def __init__(self):
x,y=map(int,input().split())
turn=0
flag=0
ans=0
while 100*x+10*y>=220:
if turn==0:
amt=0
if x>=2:
amt=200
x-=2
else:
... | 0 | MatrixStudio/Codeforces-Python-Submissions |
780 | A | Andryusha and Socks | PROGRAMMING | 800 | [
"implementation"
] | null | null | Andryusha is an orderly boy and likes to keep things in their place.
Today he faced a problem to put his socks in the wardrobe. He has *n* distinct pairs of socks which are initially in a bag. The pairs are numbered from 1 to *n*. Andryusha wants to put paired socks together and put them in the wardrobe. He takes the ... | The first line contains the single integer *n* (1<=≤<=*n*<=≤<=105) — the number of sock pairs.
The second line contains 2*n* integers *x*1,<=*x*2,<=...,<=*x*2*n* (1<=≤<=*x**i*<=≤<=*n*), which describe the order in which Andryusha took the socks from the bag. More precisely, *x**i* means that the *i*-th sock Andryusha ... | Print single integer — the maximum number of socks that were on the table at the same time. | [
"1\n1 1\n",
"3\n2 1 1 3 2 3\n"
] | [
"1\n",
"2\n"
] | In the first example Andryusha took a sock from the first pair and put it on the table. Then he took the next sock which is from the first pair as well, so he immediately puts both socks to the wardrobe. Thus, at most one sock was on the table at the same time.
In the second example Andryusha behaved as follows:
- ... | 500 | [
{
"input": "1\n1 1",
"output": "1"
},
{
"input": "3\n2 1 1 3 2 3",
"output": "2"
},
{
"input": "5\n5 1 3 2 4 3 1 2 4 5",
"output": "5"
},
{
"input": "10\n4 2 6 3 4 8 7 1 1 5 2 10 6 8 3 5 10 9 9 7",
"output": "6"
},
{
"input": "50\n30 47 31 38 37 50 36 43 9 23 2 2 ... | 1,489,341,719 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 3 | 2,000 | 18,227,200 | pr = int(input())
s = list(map(int, input().split()))
f = []
size = 0
for x in s:
if x in f:
f.remove(x)
else:
f.append(x)
if len(f) > size:
size = len(f)
print (size) | Title: Andryusha and Socks
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Andryusha is an orderly boy and likes to keep things in their place.
Today he faced a problem to put his socks in the wardrobe. He has *n* distinct pairs of socks which are initially in a bag. The pairs are numbere... | ```python
pr = int(input())
s = list(map(int, input().split()))
f = []
size = 0
for x in s:
if x in f:
f.remove(x)
else:
f.append(x)
if len(f) > size:
size = len(f)
print (size)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
58 | A | Chat room | PROGRAMMING | 1,000 | [
"greedy",
"strings"
] | A. Chat room | 1 | 256 | Vasya has recently learned to type and log on to the Internet. He immediately entered a chat room and decided to say hello to everybody. Vasya typed the word *s*. It is considered that Vasya managed to say hello if several letters can be deleted from the typed word so that it resulted in the word "hello". For example, ... | The first and only line contains the word *s*, which Vasya typed. This word consisits of small Latin letters, its length is no less that 1 and no more than 100 letters. | If Vasya managed to say hello, print "YES", otherwise print "NO". | [
"ahhellllloou\n",
"hlelo\n"
] | [
"YES\n",
"NO\n"
] | none | 500 | [
{
"input": "ahhellllloou",
"output": "YES"
},
{
"input": "hlelo",
"output": "NO"
},
{
"input": "helhcludoo",
"output": "YES"
},
{
"input": "hehwelloho",
"output": "YES"
},
{
"input": "pnnepelqomhhheollvlo",
"output": "YES"
},
{
"input": "tymbzjyqhymeda... | 1,621,916,587 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 15 | 0 | s=list(input())
m=list('hello')
x=0
for i in range(len(s)):
if s[i]==m[x]:
x+=1
if x==5:
print('YES')
else:
print('NO') | Title: Chat room
Time Limit: 1 seconds
Memory Limit: 256 megabytes
Problem Description:
Vasya has recently learned to type and log on to the Internet. He immediately entered a chat room and decided to say hello to everybody. Vasya typed the word *s*. It is considered that Vasya managed to say hello if several letter... | ```python
s=list(input())
m=list('hello')
x=0
for i in range(len(s)):
if s[i]==m[x]:
x+=1
if x==5:
print('YES')
else:
print('NO')
``` | -1 | MatrixStudio/Codeforces-Python-Submissions |
271 | A | Beautiful Year | PROGRAMMING | 800 | [
"brute force"
] | null | null | It seems like the year of 2013 came only yesterday. Do you know a curious fact? The year of 2013 is the first year after the old 1987 with only distinct digits.
Now you are suggested to solve the following problem: given a year number, find the minimum year number which is strictly larger than the given one and has on... | The single line contains integer *y* (1000<=≤<=*y*<=≤<=9000) — the year number. | Print a single integer — the minimum year number that is strictly larger than *y* and all it's digits are distinct. It is guaranteed that the answer exists. | [
"1987\n",
"2013\n"
] | [
"2013\n",
"2014\n"
] | none | 500 | [
{
"input": "1987",
"output": "2013"
},
{
"input": "2013",
"output": "2014"
},
{
"input": "1000",
"output": "1023"
},
{
"input": "1001",
"output": "1023"
},
{
"input": "1234",
"output": "1235"
},
{
"input": "5555",
"output": "5601"
},
{
"inp... | 1,694,698,454 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 62 | 0 | y = int(input())
if y < 2013:
print(2013)
else:
y +=1
print(y)
| Title: Beautiful Year
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
It seems like the year of 2013 came only yesterday. Do you know a curious fact? The year of 2013 is the first year after the old 1987 with only distinct digits.
Now you are suggested to solve the following problem: give... | ```python
y = int(input())
if y < 2013:
print(2013)
else:
y +=1
print(y)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
0 | none | none | none | 0 | [
"none"
] | null | null | Gennady is one of the best child dentists in Berland. Today *n* children got an appointment with him, they lined up in front of his office.
All children love to cry loudly at the reception at the dentist. We enumerate the children with integers from 1 to *n* in the order they go in the line. Every child is associated ... | The first line of the input contains a positive integer *n* (1<=≤<=*n*<=≤<=4000) — the number of kids in the line.
Next *n* lines contain three integers each *v**i*,<=*d**i*,<=*p**i* (1<=≤<=*v**i*,<=*d**i*,<=*p**i*<=≤<=106) — the volume of the cry in the doctor's office, the volume of the cry in the hall and the conf... | In the first line print number *k* — the number of children whose teeth Gennady will cure.
In the second line print *k* integers — the numbers of the children who will make it to the end of the line in the increasing order. | [
"5\n4 2 2\n4 1 2\n5 2 4\n3 3 5\n5 1 2\n",
"5\n4 5 1\n5 3 9\n4 1 2\n2 1 8\n4 1 9\n"
] | [
"2\n1 3 ",
"4\n1 2 4 5 "
] | In the first example, Gennady first treats the teeth of the first child who will cry with volume 4. The confidences of the remaining children will get equal to - 2, 1, 3, 1, respectively. Thus, the second child also cries at the volume of 1 and run to the exit. The confidence of the remaining children will be equal to... | 0 | [
{
"input": "5\n4 2 2\n4 1 2\n5 2 4\n3 3 5\n5 1 2",
"output": "2\n1 3 "
},
{
"input": "5\n4 5 1\n5 3 9\n4 1 2\n2 1 8\n4 1 9",
"output": "4\n1 2 4 5 "
},
{
"input": "10\n10 7 10\n3 6 11\n8 4 10\n10 1 11\n7 3 13\n7 2 13\n7 6 14\n3 4 17\n9 4 20\n5 2 24",
"output": "3\n1 2 5 "
},
{
... | 1,444,643,363 | 2,363 | PyPy 3 | WRONG_ANSWER | TESTS | 11 | 108 | 409,600 | import sys
read = lambda: list(map(int, sys.stdin.readline().split()))
n, = read()
vdp = [read() for _ in range(n)]
treated = []
for i in range(n):
if vdp[i][2] < 0:
for j in range(i+1, n):
vdp[j][2] -= vdp[i][1]
else:
treated.append(i)
for j in range(i+1, min(i+1+vdp[i][0],n)):
... | Title: none
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Gennady is one of the best child dentists in Berland. Today *n* children got an appointment with him, they lined up in front of his office.
All children love to cry loudly at the reception at the dentist. We enumerate the childre... | ```python
import sys
read = lambda: list(map(int, sys.stdin.readline().split()))
n, = read()
vdp = [read() for _ in range(n)]
treated = []
for i in range(n):
if vdp[i][2] < 0:
for j in range(i+1, n):
vdp[j][2] -= vdp[i][1]
else:
treated.append(i)
for j in range(i+1, min(i+1+vdp[i][0],n... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
540 | A | Combination Lock | PROGRAMMING | 800 | [
"implementation"
] | null | null | Scrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to put there the treasures that he's earned fair and square, he has to open the lock.
The combination lock is represented by *n* rotating disks with digits from 0 to 9 written on them. Scrooge McDuck has to turn ... | The first line contains a single integer *n* (1<=≤<=*n*<=≤<=1000) — the number of disks on the combination lock.
The second line contains a string of *n* digits — the original state of the disks.
The third line contains a string of *n* digits — Scrooge McDuck's combination that opens the lock. | Print a single integer — the minimum number of moves Scrooge McDuck needs to open the lock. | [
"5\n82195\n64723\n"
] | [
"13\n"
] | In the sample he needs 13 moves:
- 1 disk: <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/b8967f65a723782358b93eff9ce69f336817cf70.png" style="max-width: 100.0%;max-height: 100.0%;"/> - 2 disk: <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/07fa58573ece0d32... | 500 | [
{
"input": "5\n82195\n64723",
"output": "13"
},
{
"input": "12\n102021090898\n010212908089",
"output": "16"
},
{
"input": "1\n8\n1",
"output": "3"
},
{
"input": "2\n83\n57",
"output": "7"
},
{
"input": "10\n0728592530\n1362615763",
"output": "27"
},
{
... | 1,653,661,283 | 2,147,483,647 | Python 3 | OK | TESTS | 43 | 46 | 0 | n = int(input())
a = input()
b = input()
c = int(a) - int(b)
d = str(c)
l = [ ]
p= [ ]
for i in range(n):
k = abs(int(a[i]) - int(b[i]))
p.append(k)
for j in range(n):
if p[j]<=5:
l.append(p[j])
else:
l.append(10-p[j])
print(sum(l))
| Title: Combination Lock
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Scrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to put there the treasures that he's earned fair and square, he has to open the lock.
The combination lock is ... | ```python
n = int(input())
a = input()
b = input()
c = int(a) - int(b)
d = str(c)
l = [ ]
p= [ ]
for i in range(n):
k = abs(int(a[i]) - int(b[i]))
p.append(k)
for j in range(n):
if p[j]<=5:
l.append(p[j])
else:
l.append(10-p[j])
print(sum(l))
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
366 | A | Dima and Guards | PROGRAMMING | 1,100 | [
"implementation"
] | null | null | Nothing has changed since the last round. Dima and Inna still love each other and want to be together. They've made a deal with Seryozha and now they need to make a deal with the dorm guards...
There are four guardposts in Dima's dorm. Each post contains two guards (in Russia they are usually elderly women). You can b... | The first line of the input contains integer *n* (1<=≤<=*n*<=≤<=105) — the money Dima wants to spend. Then follow four lines describing the guardposts. Each line contains four integers *a*,<=*b*,<=*c*,<=*d* (1<=≤<=*a*,<=*b*,<=*c*,<=*d*<=≤<=105) — the minimum price of the chocolate and the minimum price of the juice for... | In a single line of the output print three space-separated integers: the number of the guardpost, the cost of the first present and the cost of the second present. If there is no guardpost Dima can sneak Inna through at such conditions, print -1 in a single line.
The guardposts are numbered from 1 to 4 according to t... | [
"10\n5 6 5 6\n6 6 7 7\n5 8 6 6\n9 9 9 9\n",
"10\n6 6 6 6\n7 7 7 7\n4 4 4 4\n8 8 8 8\n",
"5\n3 3 3 3\n3 3 3 3\n3 3 3 3\n3 3 3 3\n"
] | [
"1 5 5\n",
"3 4 6\n",
"-1\n"
] | Explanation of the first example.
The only way to spend 10 rubles to buy the gifts that won't be less than the minimum prices is to buy two 5 ruble chocolates to both guards from the first guardpost.
Explanation of the second example.
Dima needs 12 rubles for the first guardpost, 14 for the second one, 16 for the fo... | 500 | [
{
"input": "10\n5 6 5 6\n6 6 7 7\n5 8 6 6\n9 9 9 9",
"output": "1 5 5"
},
{
"input": "10\n6 6 6 6\n7 7 7 7\n4 4 4 4\n8 8 8 8",
"output": "3 4 6"
},
{
"input": "5\n3 3 3 3\n3 3 3 3\n3 3 3 3\n3 3 3 3",
"output": "-1"
},
{
"input": "100000\n100000 100000 100000 100000\n100000 10... | 1,385,308,014 | 1,014 | Python 3 | WRONG_ANSWER | PRETESTS | 9 | 46 | 307,200 | money=input()
r1=input().split(' ')
r2=input().split(' ')
r3=input().split(' ')
r4=input().split(' ')
r1min=int(min(r1[0], r1[1]))
r1min2=int(min(r1[2], r1[3]))
r2min=int(min(r2[0], r2[1]))
r2min2=int(min(r2[2], r2[3]))
r3min=int(min(r3[0], r3[1]))
r3min2=int(min(r3[2], r3[3]))
r4min=int(min(r4[0], r... | Title: Dima and Guards
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Nothing has changed since the last round. Dima and Inna still love each other and want to be together. They've made a deal with Seryozha and now they need to make a deal with the dorm guards...
There are four guardpost... | ```python
money=input()
r1=input().split(' ')
r2=input().split(' ')
r3=input().split(' ')
r4=input().split(' ')
r1min=int(min(r1[0], r1[1]))
r1min2=int(min(r1[2], r1[3]))
r2min=int(min(r2[0], r2[1]))
r2min2=int(min(r2[2], r2[3]))
r3min=int(min(r3[0], r3[1]))
r3min2=int(min(r3[2], r3[3]))
r4min=int(mi... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
131 | A | cAPS lOCK | PROGRAMMING | 1,000 | [
"implementation",
"strings"
] | null | null | wHAT DO WE NEED cAPS LOCK FOR?
Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage.
Let's consider that a word has been typed with the Caps lock key accidentall... | The first line of the input data contains a word consisting of uppercase and lowercase Latin letters. The word's length is from 1 to 100 characters, inclusive. | Print the result of the given word's processing. | [
"cAPS\n",
"Lock\n"
] | [
"Caps",
"Lock\n"
] | none | 500 | [
{
"input": "cAPS",
"output": "Caps"
},
{
"input": "Lock",
"output": "Lock"
},
{
"input": "cAPSlOCK",
"output": "cAPSlOCK"
},
{
"input": "CAPs",
"output": "CAPs"
},
{
"input": "LoCK",
"output": "LoCK"
},
{
"input": "OOPS",
"output": "oops"
},
{
... | 1,696,789,577 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 56 | 62 | 0 | n=input()
if len(n)==1:
print(n.swapcase())
else:
if n.isupper():
print(n.lower())
else:
if n[1:].isupper():
print(n.capitalize())
else:
print(n) | Title: cAPS lOCK
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
wHAT DO WE NEED cAPS LOCK FOR?
Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in th... | ```python
n=input()
if len(n)==1:
print(n.swapcase())
else:
if n.isupper():
print(n.lower())
else:
if n[1:].isupper():
print(n.capitalize())
else:
print(n)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
897 | B | Chtholly's request | PROGRAMMING | 1,300 | [
"brute force"
] | null | null | — I experienced so many great things.
— You gave me memories like dreams... But I have to leave now...
— One last request, can you...
— Help me solve a Codeforces problem?
— ......
— What?
Chtholly has been thinking about a problem for days:
If a number is palindrome and length of its decimal representation with... | The first line contains two integers *k* and *p* (1<=≤<=*k*<=≤<=105,<=1<=≤<=*p*<=≤<=109). | Output single integer — answer to the problem. | [
"2 100\n",
"5 30\n"
] | [
"33\n",
"15\n"
] | In the first example, the smallest zcy number is 11, and the second smallest zcy number is 22.
In the second example, <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/68fffad54395f7d920ad0384e07c6215ddc64141.png" style="max-width: 100.0%;max-height: 100.0%;"/>. | 1,000 | [
{
"input": "2 100",
"output": "33"
},
{
"input": "5 30",
"output": "15"
},
{
"input": "42147 412393322",
"output": "251637727"
},
{
"input": "77809 868097296",
"output": "440411873"
},
{
"input": "5105 443422097",
"output": "363192634"
},
{
"input": "7... | 1,512,906,212 | 2,611 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 2 | 2,000 | 41,574,400 | # def is_zcy(n):
# list_n = []
# while n > 0:
# list_n.append(n % 10)
# n = int(n / 10)
# # print("list_n = " + str(list_n))
# if len(list_n) % 2 == 1:
# return False
# for i in range(int(n/2) +1):
# if list_n[i] != list_n[n-1 - i]:
# return False
# return True
k, p = input().strip().split()
k, p =... | Title: Chtholly's request
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
— I experienced so many great things.
— You gave me memories like dreams... But I have to leave now...
— One last request, can you...
— Help me solve a Codeforces problem?
— ......
— What?
Chtholly has been thi... | ```python
# def is_zcy(n):
# list_n = []
# while n > 0:
# list_n.append(n % 10)
# n = int(n / 10)
# # print("list_n = " + str(list_n))
# if len(list_n) % 2 == 1:
# return False
# for i in range(int(n/2) +1):
# if list_n[i] != list_n[n-1 - i]:
# return False
# return True
k, p = input().strip().spli... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
598 | A | Tricky Sum | PROGRAMMING | 900 | [
"math"
] | null | null | In this problem you are to calculate the sum of all integers from 1 to *n*, but you should take all powers of two with minus in the sum.
For example, for *n*<==<=4 the sum is equal to <=-<=1<=-<=2<=+<=3<=-<=4<==<=<=-<=4, because 1, 2 and 4 are 20, 21 and 22 respectively.
Calculate the answer for *t* values of *n*. | The first line of the input contains a single integer *t* (1<=≤<=*t*<=≤<=100) — the number of values of *n* to be processed.
Each of next *t* lines contains a single integer *n* (1<=≤<=*n*<=≤<=109). | Print the requested sum for each of *t* integers *n* given in the input. | [
"2\n4\n1000000000\n"
] | [
"-4\n499999998352516354\n"
] | The answer for the first sample is explained in the statement. | 0 | [
{
"input": "2\n4\n1000000000",
"output": "-4\n499999998352516354"
},
{
"input": "10\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10",
"output": "-1\n-3\n0\n-4\n1\n7\n14\n6\n15\n25"
},
{
"input": "10\n10\n9\n47\n33\n99\n83\n62\n1\n100\n53",
"output": "25\n15\n1002\n435\n4696\n3232\n1827\n-1\n4796\n130... | 1,633,359,676 | 2,147,483,647 | PyPy 3 | OK | TESTS | 21 | 108 | 21,401,600 | for case in range(int(input())):
n = int(input())
sum = n * (n + 1) // 2
i = 0
r = 0
while( r <= n ):
i = i + 1
r = 2**i
r = 2**i - 1
sum = sum - 2 * r
print(sum)
| Title: Tricky Sum
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
In this problem you are to calculate the sum of all integers from 1 to *n*, but you should take all powers of two with minus in the sum.
For example, for *n*<==<=4 the sum is equal to <=-<=1<=-<=2<=+<=3<=-<=4<==<=<=-<=4, be... | ```python
for case in range(int(input())):
n = int(input())
sum = n * (n + 1) // 2
i = 0
r = 0
while( r <= n ):
i = i + 1
r = 2**i
r = 2**i - 1
sum = sum - 2 * r
print(sum)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
45 | C | Dancing Lessons | PROGRAMMING | 1,900 | [
"data structures"
] | C. Dancing Lessons | 2 | 256 | There are *n* people taking dancing lessons. Every person is characterized by his/her dancing skill *a**i*. At the beginning of the lesson they line up from left to right. While there is at least one couple of a boy and a girl in the line, the following process is repeated: the boy and girl who stand next to each other... | The first line contains an integer *n* (1<=≤<=*n*<=≤<=2·105) — the number of people. The next line contains *n* symbols B or G without spaces. B stands for a boy, G stands for a girl. The third line contains *n* space-separated integers *a**i* (1<=≤<=*a**i*<=≤<=107) — the dancing skill. People are specified from left t... | Print the resulting number of couples *k*. Then print *k* lines containing two numerals each — the numbers of people forming the couple. The people are numbered with integers from 1 to *n* from left to right. When a couple leaves to dance you shouldn't renumber the people. The numbers in one couple should be sorted in ... | [
"4\nBGBG\n4 2 4 3\n",
"4\nBBGG\n4 6 1 5\n",
"4\nBGBB\n1 1 2 3\n"
] | [
"2\n3 4\n1 2\n",
"2\n2 3\n1 4\n",
"1\n1 2\n"
] | none | 0 | [
{
"input": "4\nBGBG\n4 2 4 3",
"output": "2\n3 4\n1 2"
},
{
"input": "4\nBBGG\n4 6 1 5",
"output": "2\n2 3\n1 4"
},
{
"input": "4\nBGBB\n1 1 2 3",
"output": "1\n1 2"
},
{
"input": "1\nB\n490297",
"output": "0"
},
{
"input": "2\nBB\n2518190 6313112",
"output": ... | 1,462,811,088 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 1 | 46 | 4,812,800 | import heapq as hq
n=int(input())
gen=input()
a=list(map(int,input().split()))
left=[i for i in range(n-1)]
right=[i+1 for i in range(n-1)]
exist=[True for i in range(n)]
d=[]
for i in range(n-1):
if gen[i]!=gen[i+1]:
d+=[[abs(a[i]-a[i+1]),i,i+1]]
hq.heapify(d)
ans=[]
while d!=[]:
gap,le,r... | Title: Dancing Lessons
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
There are *n* people taking dancing lessons. Every person is characterized by his/her dancing skill *a**i*. At the beginning of the lesson they line up from left to right. While there is at least one couple of a boy and a g... | ```python
import heapq as hq
n=int(input())
gen=input()
a=list(map(int,input().split()))
left=[i for i in range(n-1)]
right=[i+1 for i in range(n-1)]
exist=[True for i in range(n)]
d=[]
for i in range(n-1):
if gen[i]!=gen[i+1]:
d+=[[abs(a[i]-a[i+1]),i,i+1]]
hq.heapify(d)
ans=[]
while d!=[]:
... | -1 | MatrixStudio/Codeforces-Python-Submissions |
515 | C | Drazil and Factorial | PROGRAMMING | 1,400 | [
"greedy",
"math",
"sortings"
] | null | null | Drazil is playing a math game with Varda.
Let's define for positive integer *x* as a product of factorials of its digits. For example, .
First, they choose a decimal number *a* consisting of *n* digits that contains at least one digit larger than 1. This number may possibly start with leading zeroes. Then they shoul... | The first line contains an integer *n* (1<=≤<=*n*<=≤<=15) — the number of digits in *a*.
The second line contains *n* digits of *a*. There is at least one digit in *a* that is larger than 1. Number *a* may possibly contain leading zeroes. | Output a maximum possible integer satisfying the conditions above. There should be no zeroes and ones in this number decimal representation. | [
"4\n1234\n",
"3\n555\n"
] | [
"33222\n",
"555\n"
] | In the first case, <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/f5a4207f23215fddce977ab5ea9e9d2e7578fb52.png" style="max-width: 100.0%;max-height: 100.0%;"/> | 1,000 | [
{
"input": "4\n1234",
"output": "33222"
},
{
"input": "3\n555",
"output": "555"
},
{
"input": "15\n012345781234578",
"output": "7777553333222222222222"
},
{
"input": "1\n8",
"output": "7222"
},
{
"input": "10\n1413472614",
"output": "75333332222222"
},
{
... | 1,650,286,155 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 2 | 62 | 512,000 | n=int(input())
num=input()
i=0
while num[i]==0:
i+=1
num=num[i:]
mydict={'2':0,'3':0,'4':0,'5':0,'6':0,'7':0,'8':0,'9':0}
for i in num:
if int(i)>1:
for j in range(2,int(i)+1):
mydict[str(j)]+=1
print('7'*mydict['7']+'5'*(mydict['5']-mydict['7'])+'3'*(mydict['9']*2 +mydict['6']+my... | Title: Drazil and Factorial
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Drazil is playing a math game with Varda.
Let's define for positive integer *x* as a product of factorials of its digits. For example, .
First, they choose a decimal number *a* consisting of *n* digits that cont... | ```python
n=int(input())
num=input()
i=0
while num[i]==0:
i+=1
num=num[i:]
mydict={'2':0,'3':0,'4':0,'5':0,'6':0,'7':0,'8':0,'9':0}
for i in num:
if int(i)>1:
for j in range(2,int(i)+1):
mydict[str(j)]+=1
print('7'*mydict['7']+'5'*(mydict['5']-mydict['7'])+'3'*(mydict['9']*2 +mydi... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
903 | C | Boxes Packing | PROGRAMMING | 1,200 | [
"greedy"
] | null | null | Mishka has got *n* empty boxes. For every *i* (1<=≤<=*i*<=≤<=*n*), *i*-th box is a cube with side length *a**i*.
Mishka can put a box *i* into another box *j* if the following conditions are met:
- *i*-th box is not put into another box; - *j*-th box doesn't contain any other boxes; - box *i* is smaller than box *... | The first line contains one integer *n* (1<=≤<=*n*<=≤<=5000) — the number of boxes Mishka has got.
The second line contains *n* integers *a*1, *a*2, ..., *a**n* (1<=≤<=*a**i*<=≤<=109), where *a**i* is the side length of *i*-th box. | Print the minimum possible number of visible boxes. | [
"3\n1 2 3\n",
"4\n4 2 4 3\n"
] | [
"1\n",
"2\n"
] | In the first example it is possible to put box 1 into box 2, and 2 into 3.
In the second example Mishka can put box 2 into box 3, and box 4 into box 1. | 0 | [
{
"input": "3\n1 2 3",
"output": "1"
},
{
"input": "4\n4 2 4 3",
"output": "2"
},
{
"input": "10\n58 58 58 58 58 58 58 58 58 58",
"output": "10"
},
{
"input": "10\n86 89 89 86 86 89 86 86 89 89",
"output": "5"
},
{
"input": "100\n981 288 186 186 292 876 341 288 98... | 1,575,135,342 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 3 | 109 | 0 | l=input()
count=1
list1=sorted(list(map(int,input().split())))
for item in range(len(list1)-1):
if list1[item]<list1[item+1]:
count+=0
else:
count+=1
print(count)
| Title: Boxes Packing
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Mishka has got *n* empty boxes. For every *i* (1<=≤<=*i*<=≤<=*n*), *i*-th box is a cube with side length *a**i*.
Mishka can put a box *i* into another box *j* if the following conditions are met:
- *i*-th box is not pu... | ```python
l=input()
count=1
list1=sorted(list(map(int,input().split())))
for item in range(len(list1)-1):
if list1[item]<list1[item+1]:
count+=0
else:
count+=1
print(count)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
361 | B | Levko and Permutation | PROGRAMMING | 1,200 | [
"constructive algorithms",
"math",
"number theory"
] | null | null | Levko loves permutations very much. A permutation of length *n* is a sequence of distinct positive integers, each is at most *n*.
Let’s assume that value *gcd*(*a*,<=*b*) shows the greatest common divisor of numbers *a* and *b*. Levko assumes that element *p**i* of permutation *p*1,<=*p*2,<=... ,<=*p**n* is good if *g... | The single line contains two integers *n* and *k* (1<=≤<=*n*<=≤<=105, 0<=≤<=*k*<=≤<=*n*). | In a single line print either any beautiful permutation or -1, if such permutation doesn’t exist.
If there are multiple suitable permutations, you are allowed to print any of them. | [
"4 2\n",
"1 1\n"
] | [
"2 4 3 1",
"-1\n"
] | In the first sample elements 4 and 3 are good because *gcd*(2, 4) = 2 > 1 and *gcd*(3, 3) = 3 > 1. Elements 2 and 1 are not good because *gcd*(1, 2) = 1 and *gcd*(4, 1) = 1. As there are exactly 2 good elements, the permutation is beautiful.
The second sample has no beautiful permutations. | 1,000 | [
{
"input": "4 2",
"output": "2 1 3 4 "
},
{
"input": "1 1",
"output": "-1"
},
{
"input": "7 4",
"output": "3 1 2 4 5 6 7 "
},
{
"input": "10 9",
"output": "1 2 3 4 5 6 7 8 9 10 "
},
{
"input": "10000 5000",
"output": "5000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1... | 1,651,179,737 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 1 | 30 | 0 | import math
nnums, target = [int(x) for x in input().split()]
if target >= nnums:
print(-1)
elif target == nnums - 1:
for a in range(1, nnums + 1):
print(a, end = ' ')
else:
ans = [x for x in range(2, nnums + 1)]
ans.append(1)
if target % 2 == 1:
ans[0], ans[-1] = ans[-1], ans[0]
target -= 1
for x in rang... | Title: Levko and Permutation
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Levko loves permutations very much. A permutation of length *n* is a sequence of distinct positive integers, each is at most *n*.
Let’s assume that value *gcd*(*a*,<=*b*) shows the greatest common divisor of numb... | ```python
import math
nnums, target = [int(x) for x in input().split()]
if target >= nnums:
print(-1)
elif target == nnums - 1:
for a in range(1, nnums + 1):
print(a, end = ' ')
else:
ans = [x for x in range(2, nnums + 1)]
ans.append(1)
if target % 2 == 1:
ans[0], ans[-1] = ans[-1], ans[0]
target -= 1
for... | -1 | MatrixStudio/Codeforces-Python-Submissions | |
43 | A | Football | PROGRAMMING | 1,000 | [
"strings"
] | A. Football | 2 | 256 | One day Vasya decided to have a look at the results of Berland 1910 Football Championship’s finals. Unfortunately he didn't find the overall score of the match; however, he got hold of a profound description of the match's process. On the whole there are *n* lines in that description each of which described one goal. E... | The first line contains an integer *n* (1<=≤<=*n*<=≤<=100) — the number of lines in the description. Then follow *n* lines — for each goal the names of the teams that scored it. The names are non-empty lines consisting of uppercase Latin letters whose lengths do not exceed 10 symbols. It is guaranteed that the match di... | Print the name of the winning team. We remind you that in football the team that scores more goals is considered the winner. | [
"1\nABC\n",
"5\nA\nABA\nABA\nA\nA\n"
] | [
"ABC\n",
"A\n"
] | none | 500 | [
{
"input": "1\nABC",
"output": "ABC"
},
{
"input": "5\nA\nABA\nABA\nA\nA",
"output": "A"
},
{
"input": "2\nXTSJEP\nXTSJEP",
"output": "XTSJEP"
},
{
"input": "3\nXZYDJAEDZ\nXZYDJAEDZ\nXZYDJAEDZ",
"output": "XZYDJAEDZ"
},
{
"input": "3\nQCCYXL\nQCCYXL\nAXGLFQDD",
... | 1,640,250,007 | 2,147,483,647 | Python 3 | OK | TESTS | 34 | 92 | 0 |
d = int(input())
thislist = []
for t in range(d):
x = input()
thislist.append(x)
thisset = set(thislist)
thisthis = list(thisset)
k1 = 0
k2 = 0
if len(thisthis)== 2:
for t in thislist:
if t == thisthis[0]:
k1 += 1
if t == thisthis[1]:
k2 += 1
... | Title: Football
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
One day Vasya decided to have a look at the results of Berland 1910 Football Championship’s finals. Unfortunately he didn't find the overall score of the match; however, he got hold of a profound description of the match's process... | ```python
d = int(input())
thislist = []
for t in range(d):
x = input()
thislist.append(x)
thisset = set(thislist)
thisthis = list(thisset)
k1 = 0
k2 = 0
if len(thisthis)== 2:
for t in thislist:
if t == thisthis[0]:
k1 += 1
if t == thisthis[1]:
... | 3.977 | 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,683,811,052 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 3 | 62 | 0 | n=int(input())
ans=0
for i in range(n):
s,d=map(int,input().split())
if i==0:
ans+=(s+1)
else:
check=abs(ans-s)
if check==s:
ans+=1
else:
j=1
add=s+d*j
while j>0 and add>=ans:
add=s+d*j
... | 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
n=int(input())
ans=0
for i in range(n):
s,d=map(int,input().split())
if i==0:
ans+=(s+1)
else:
check=abs(ans-s)
if check==s:
ans+=1
else:
j=1
add=s+d*j
while j>0 and add>=ans:
add=s+d*j
... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
260 | A | Adding Digits | PROGRAMMING | 1,400 | [
"implementation",
"math"
] | null | null | Vasya has got two number: *a* and *b*. However, Vasya finds number *a* too short. So he decided to repeat the operation of lengthening number *a* *n* times.
One operation of lengthening a number means adding exactly one digit to the number (in the decimal notation) to the right provided that the resulting number is di... | The first line contains three integers: *a*,<=*b*,<=*n* (1<=≤<=*a*,<=*b*,<=*n*<=≤<=105). | In a single line print the integer without leading zeros, which Vasya can get when he applies the lengthening operations to number *a* *n* times. If no such number exists, then print number -1. If there are multiple possible answers, print any of them. | [
"5 4 5\n",
"12 11 1\n",
"260 150 10\n"
] | [
"524848\n",
"121\n",
"-1\n"
] | none | 500 | [
{
"input": "5 4 5",
"output": "524848"
},
{
"input": "12 11 1",
"output": "121"
},
{
"input": "260 150 10",
"output": "-1"
},
{
"input": "78843 5684 42717",
"output": "-1"
},
{
"input": "93248 91435 1133",
"output": "-1"
},
{
"input": "100000 10 64479"... | 1,606,040,851 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 0 | 109 | 0 | s,b,n=input().split()
add,n1,n,b='-1',0,int(n),int(b)
for i in range(0,9):
if int(s+str(i))%b==0:
add=str(i)
break
if add=='-1':print(-1)
else:
print(add)
while n1<n:
s+=add
n1+=1
print(int(s))
| Title: Adding Digits
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vasya has got two number: *a* and *b*. However, Vasya finds number *a* too short. So he decided to repeat the operation of lengthening number *a* *n* times.
One operation of lengthening a number means adding exactly one ... | ```python
s,b,n=input().split()
add,n1,n,b='-1',0,int(n),int(b)
for i in range(0,9):
if int(s+str(i))%b==0:
add=str(i)
break
if add=='-1':print(-1)
else:
print(add)
while n1<n:
s+=add
n1+=1
print(int(s))
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
220 | A | Little Elephant and Problem | PROGRAMMING | 1,300 | [
"implementation",
"sortings"
] | null | null | The Little Elephant has got a problem — somebody has been touching his sorted by non-decreasing array *a* of length *n* and possibly swapped some elements of the array.
The Little Elephant doesn't want to call the police until he understands if he could have accidentally changed the array himself. He thinks that he co... | The first line contains a single integer *n* (2<=≤<=*n*<=≤<=105) — the size of array *a*. The next line contains *n* positive integers, separated by single spaces and not exceeding 109, — array *a*.
Note that the elements of the array are not necessarily distinct numbers. | In a single line print "YES" (without the quotes) if the Little Elephant could have accidentally changed the array himself, and "NO" (without the quotes) otherwise. | [
"2\n1 2\n",
"3\n3 2 1\n",
"4\n4 3 2 1\n"
] | [
"YES\n",
"YES\n",
"NO\n"
] | In the first sample the array has already been sorted, so to sort it, we need 0 swap operations, that is not more than 1. Thus, the answer is "YES".
In the second sample we can sort the array if we swap elements 1 and 3, so we need 1 swap operation to sort the array. Thus, the answer is "YES".
In the third sample we ... | 500 | [
{
"input": "2\n1 2",
"output": "YES"
},
{
"input": "3\n3 2 1",
"output": "YES"
},
{
"input": "4\n4 3 2 1",
"output": "NO"
},
{
"input": "3\n1 3 2",
"output": "YES"
},
{
"input": "2\n2 1",
"output": "YES"
},
{
"input": "9\n7 7 8 8 10 10 10 10 1000000000... | 1,436,012,364 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 46 | 0 | n = int(input())
a = map(int, input().split())
b = list(a)
b.sort()
z = 0
for x, y in zip(a, b):
if x != y:
z += 1
if z < 3:
print("YES")
else:
print("NO") | Title: Little Elephant and Problem
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The Little Elephant has got a problem — somebody has been touching his sorted by non-decreasing array *a* of length *n* and possibly swapped some elements of the array.
The Little Elephant doesn't want to c... | ```python
n = int(input())
a = map(int, input().split())
b = list(a)
b.sort()
z = 0
for x, y in zip(a, b):
if x != y:
z += 1
if z < 3:
print("YES")
else:
print("NO")
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
92 | B | Binary Number | PROGRAMMING | 1,300 | [
"greedy"
] | B. Binary Number | 1 | 256 | Little walrus Fangy loves math very much. That's why when he is bored he plays with a number performing some operations.
Fangy takes some positive integer *x* and wants to get a number one from it. While *x* is not equal to 1, Fangy repeats the following action: if *x* is odd, then he adds 1 to it, otherwise he divide... | The first line contains a positive integer *x* in a binary system. It is guaranteed that the first digit of *x* is different from a zero and the number of its digits does not exceed 106. | Print the required number of actions. | [
"1\n",
"1001001\n",
"101110\n"
] | [
"0\n",
"12\n",
"8\n"
] | Let's consider the third sample. Number 101110 is even, which means that we should divide it by 2. After the dividing Fangy gets an odd number 10111 and adds one to it. Number 11000 can be divided by 2 three times in a row and get number 11. All that's left is to increase the number by one (we get 100), and then divide... | 1,000 | [
{
"input": "1",
"output": "0"
},
{
"input": "1001001",
"output": "12"
},
{
"input": "101110",
"output": "8"
},
{
"input": "11",
"output": "3"
},
{
"input": "11110001101",
"output": "16"
},
{
"input": "101010100100111100011111001111100001010101111110101... | 1,586,838,583 | 2,147,483,647 | Python 3 | OK | TESTS | 27 | 343 | 3,174,400 | s=input();Ans=0;s=s[::-1]
if len(s)==1 and s[0]=='1':print(0)
elif s.index('1')==len(s)-1:print(len(s)-1)
else:
t=s.index('1');
Ans+=(t+2)
for i in range(t+1,len(s)):
if s[i]=='0':Ans+=2
else:Ans+=1
print(Ans)
| Title: Binary Number
Time Limit: 1 seconds
Memory Limit: 256 megabytes
Problem Description:
Little walrus Fangy loves math very much. That's why when he is bored he plays with a number performing some operations.
Fangy takes some positive integer *x* and wants to get a number one from it. While *x* is not equal to ... | ```python
s=input();Ans=0;s=s[::-1]
if len(s)==1 and s[0]=='1':print(0)
elif s.index('1')==len(s)-1:print(len(s)-1)
else:
t=s.index('1');
Ans+=(t+2)
for i in range(t+1,len(s)):
if s[i]=='0':Ans+=2
else:Ans+=1
print(Ans)
``` | 3.822587 | MatrixStudio/Codeforces-Python-Submissions |
234 | C | Weather | PROGRAMMING | 1,300 | [
"dp",
"implementation"
] | null | null | Scientists say a lot about the problems of global warming and cooling of the Earth. Indeed, such natural phenomena strongly influence all life on our planet.
Our hero Vasya is quite concerned about the problems. He decided to try a little experiment and observe how outside daily temperature changes. He hung out a ther... | The first line contains a single integer *n* (2<=≤<=*n*<=≤<=105) — the number of days for which Vasya has been measuring the temperature.
The second line contains a sequence of *n* integers *t*1,<=*t*2,<=...,<=*t**n* (|*t**i*|<=≤<=109) — the sequence of temperature values. Numbers *t**i* are separated by single space... | Print a single integer — the answer to the given task. | [
"4\n-1 1 -2 1\n",
"5\n0 -1 1 2 -5\n"
] | [
"1\n",
"2\n"
] | Note to the first sample: there are two ways to change exactly one number so that the sequence met Vasya's condition. You can either replace the first number 1 by any negative number or replace the number -2 by any positive number. | 0 | [
{
"input": "4\n-1 1 -2 1",
"output": "1"
},
{
"input": "5\n0 -1 1 2 -5",
"output": "2"
},
{
"input": "6\n0 0 0 0 0 0",
"output": "6"
},
{
"input": "6\n-1 -2 -3 -4 5 6",
"output": "0"
},
{
"input": "8\n1 2 -1 0 10 2 12 13",
"output": "3"
},
{
"input": "... | 1,650,458,423 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 6 | 280 | 7,270,400 | import abc
import itertools
import math
from math import gcd as gcd
import sys
import queue
import itertools
from heapq import heappop, heappush
import random
def solve():
f = open("input.txt", "r")
n = int(f.readline())
t = list(map(int, f.readline().split()))
f.close()
res = ... | Title: Weather
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Scientists say a lot about the problems of global warming and cooling of the Earth. Indeed, such natural phenomena strongly influence all life on our planet.
Our hero Vasya is quite concerned about the problems. He decided to ... | ```python
import abc
import itertools
import math
from math import gcd as gcd
import sys
import queue
import itertools
from heapq import heappop, heappush
import random
def solve():
f = open("input.txt", "r")
n = int(f.readline())
t = list(map(int, f.readline().split()))
f.close()
... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
59 | A | Word | PROGRAMMING | 800 | [
"implementation",
"strings"
] | A. Word | 2 | 256 | Vasya is very upset that many people on the Net mix uppercase and lowercase letters in one word. That's why he decided to invent an extension for his favorite browser that would change the letters' register in every word so that it either only consisted of lowercase letters or, vice versa, only of uppercase ones. At th... | The first line contains a word *s* — it consists of uppercase and lowercase Latin letters and possesses the length from 1 to 100. | Print the corrected word *s*. If the given word *s* has strictly more uppercase letters, make the word written in the uppercase register, otherwise - in the lowercase one. | [
"HoUse\n",
"ViP\n",
"maTRIx\n"
] | [
"house\n",
"VIP\n",
"matrix\n"
] | none | 500 | [
{
"input": "HoUse",
"output": "house"
},
{
"input": "ViP",
"output": "VIP"
},
{
"input": "maTRIx",
"output": "matrix"
},
{
"input": "BNHWpnpawg",
"output": "bnhwpnpawg"
},
{
"input": "VTYGP",
"output": "VTYGP"
},
{
"input": "CHNenu",
"output": "chn... | 1,667,196,558 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 62 | 0 | x =input()
ls1 = list(x)
a,b=0,0
for i in ls1:
if ord(i) >97:
a+=1
else:
b+=1
if a >=b:
print(x.lower())
else:
print(x.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
x =input()
ls1 = list(x)
a,b=0,0
for i in ls1:
if ord(i) >97:
a+=1
else:
b+=1
if a >=b:
print(x.lower())
else:
print(x.upper())
``` | 0 | MatrixStudio/Codeforces-Python-Submissions |
182 | D | Common Divisors | PROGRAMMING | 1,400 | [
"brute force",
"hashing",
"implementation",
"math",
"strings"
] | null | null | Vasya has recently learned at school what a number's divisor is and decided to determine a string's divisor. Here is what he came up with.
String *a* is the divisor of string *b* if and only if there exists a positive integer *x* such that if we write out string *a* consecutively *x* times, we get string *b*. For exam... | The first input line contains a non-empty string *s*1.
The second input line contains a non-empty string *s*2.
Lengths of strings *s*1 and *s*2 are positive and do not exceed 105. The strings only consist of lowercase Latin letters. | Print the number of common divisors of strings *s*1 and *s*2. | [
"abcdabcd\nabcdabcdabcdabcd\n",
"aaa\naa\n"
] | [
"2\n",
"1\n"
] | In first sample the common divisors are strings "abcd" and "abcdabcd".
In the second sample the common divisor is a single string "a". String "aa" isn't included in the answer as it isn't a divisor of string "aaa". | 1,000 | [
{
"input": "abcdabcd\nabcdabcdabcdabcd",
"output": "2"
},
{
"input": "aaa\naa",
"output": "1"
},
{
"input": "aaaaaaaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaaaaaaa",
"output": "3"
},
{
"input": "aaaaaaaaaaaaaa\naaaaaaaaaaaaaa",
"output": "4"
},
{
"input": "a\nb",
... | 1,383,767,614 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 62 | 204,800 | def gcd(a, b):
c = a % b
return gcd(b, c) if c else b
a, b = input(), input()
if len(a) < len(b): a, b = b, a
u, v = len(a), len(b)
d = u
for i in range(1, int(u ** 0.5) + 1):
if u % i == 0 and a.count(a[: i]) * i == u:
d = i
break
if b.count(a[: d]) * d == v:
k = gcd(u // d,... | Title: Common Divisors
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vasya has recently learned at school what a number's divisor is and decided to determine a string's divisor. Here is what he came up with.
String *a* is the divisor of string *b* if and only if there exists a positive ... | ```python
def gcd(a, b):
c = a % b
return gcd(b, c) if c else b
a, b = input(), input()
if len(a) < len(b): a, b = b, a
u, v = len(a), len(b)
d = u
for i in range(1, int(u ** 0.5) + 1):
if u % i == 0 and a.count(a[: i]) * i == u:
d = i
break
if b.count(a[: d]) * d == v:
k = g... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
510 | A | Fox And Snake | PROGRAMMING | 800 | [
"implementation"
] | null | null | Fox Ciel starts to learn programming. The first task is drawing a fox! However, that turns out to be too hard for a beginner, so she decides to draw a snake instead.
A snake is a pattern on a *n* by *m* table. Denote *c*-th cell of *r*-th row as (*r*,<=*c*). The tail of the snake is located at (1,<=1), then it's body ... | The only line contains two integers: *n* and *m* (3<=≤<=*n*,<=*m*<=≤<=50).
*n* is an odd number. | Output *n* lines. Each line should contain a string consisting of *m* characters. Do not output spaces. | [
"3 3\n",
"3 4\n",
"5 3\n",
"9 9\n"
] | [
"###\n..#\n###\n",
"####\n...#\n####\n",
"###\n..#\n###\n#..\n###\n",
"#########\n........#\n#########\n#........\n#########\n........#\n#########\n#........\n#########\n"
] | none | 500 | [
{
"input": "3 3",
"output": "###\n..#\n###"
},
{
"input": "3 4",
"output": "####\n...#\n####"
},
{
"input": "5 3",
"output": "###\n..#\n###\n#..\n###"
},
{
"input": "9 9",
"output": "#########\n........#\n#########\n#........\n#########\n........#\n#########\n#........\n#... | 1,675,326,525 | 2,147,483,647 | Python 3 | OK | TESTS | 28 | 46 | 0 | list = list(map(int, input().strip().split()))
n = list[0]
m = list[1]
arr = []
for i in range(n):
a = []
for j in range(m):
a.append('#')
arr.append(a)
for i in range(1, n, 2):
a = i // 2
if a % 2 == 0:
for j in range(m - 1):
arr[i][j] = '.'
els... | Title: Fox And Snake
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Fox Ciel starts to learn programming. The first task is drawing a fox! However, that turns out to be too hard for a beginner, so she decides to draw a snake instead.
A snake is a pattern on a *n* by *m* table. Denote *c*... | ```python
list = list(map(int, input().strip().split()))
n = list[0]
m = list[1]
arr = []
for i in range(n):
a = []
for j in range(m):
a.append('#')
arr.append(a)
for i in range(1, n, 2):
a = i // 2
if a % 2 == 0:
for j in range(m - 1):
arr[i][j] = '.... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
455 | A | Boredom | PROGRAMMING | 1,500 | [
"dp"
] | null | null | Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.
Given a sequence *a* consisting of *n* integers. The player can make several steps. In a single step he can choose an element of the sequence (let's denote it *a*... | The first line contains integer *n* (1<=≤<=*n*<=≤<=105) that shows how many numbers are in Alex's sequence.
The second line contains *n* integers *a*1, *a*2, ..., *a**n* (1<=≤<=*a**i*<=≤<=105). | Print a single integer — the maximum number of points that Alex can earn. | [
"2\n1 2\n",
"3\n1 2 3\n",
"9\n1 2 1 3 2 2 2 2 3\n"
] | [
"2\n",
"4\n",
"10\n"
] | Consider the third test example. At first step we need to choose any element equal to 2. After that step our sequence looks like this [2, 2, 2, 2]. Then we do 4 steps, on each step we choose any element equals to 2. In total we earn 10 points. | 500 | [
{
"input": "2\n1 2",
"output": "2"
},
{
"input": "3\n1 2 3",
"output": "4"
},
{
"input": "9\n1 2 1 3 2 2 2 2 3",
"output": "10"
},
{
"input": "5\n3 3 4 5 4",
"output": "11"
},
{
"input": "5\n5 3 5 3 4",
"output": "16"
},
{
"input": "5\n4 2 3 2 5",
... | 1,676,730,508 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 5 | 46 | 0 |
n = int(input())
a = list(map(int, input().split(' ')))
cnt = [0] * (n + 1)
cache = [-1] * (n + 1)
for i in range(n):
cnt[a[i]]+=1
def fun(i):
if i == 0:
return 0
if i == 1:
return cnt[i];
if cache[i-2] == -1:
cache[i-2] = fun(i-2)
return max(a[i-1], cache[i-2] + cnt[i]*i)
ans =... | Title: Boredom
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.
Given a sequence *a* consisting of *n* integers. The player can make ... | ```python
n = int(input())
a = list(map(int, input().split(' ')))
cnt = [0] * (n + 1)
cache = [-1] * (n + 1)
for i in range(n):
cnt[a[i]]+=1
def fun(i):
if i == 0:
return 0
if i == 1:
return cnt[i];
if cache[i-2] == -1:
cache[i-2] = fun(i-2)
return max(a[i-1], cache[i-2] + cnt[i]*i... | 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,611,914,337 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 0 | 77 | 0 | n, m = map(int, input().split())
ost_in_n = [0]*5
ost_in_m = [0]*5
for i in range(5):
if(i==0):
ost_in_n[i] = (n-i)//5
ost_in_m[i] = (m-i)//5
else:
ost_in_n[i] = (n-i)//5+1
ost_in_m[i] = (m-i)//5+1
s = 0
print(ost_in_n, ost_in_m)
for i in range(5):
s+=ost_in_... | 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
n, m = map(int, input().split())
ost_in_n = [0]*5
ost_in_m = [0]*5
for i in range(5):
if(i==0):
ost_in_n[i] = (n-i)//5
ost_in_m[i] = (m-i)//5
else:
ost_in_n[i] = (n-i)//5+1
ost_in_m[i] = (m-i)//5+1
s = 0
print(ost_in_n, ost_in_m)
for i in range(5):
... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
623 | D | Birthday | PROGRAMMING | 2,700 | [
"greedy",
"math",
"probabilities"
] | null | null | A MIPT student named Misha has a birthday today, and he decided to celebrate it in his country house in suburban Moscow. *n* friends came by, and after a typical party they decided to play blind man's buff.
The birthday boy gets blindfolded and the other players scatter around the house. The game is played in several ... | The first line of the input contains a single integer *n* (1<=≤<=*n*<=≤<=100) — the number of Misha's friends.
The second line contains *n* integers *p**i* (), giving the probability to catch the *i*-th friend in one particular round in percent. | Print a single real value — the expectation of the number of rounds provided that Misha plays optimally. 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... | [
"2\n50 50\n",
"4\n50 20 20 10\n"
] | [
"5.0000000000\n",
"39.2846263444\n"
] | The optimal strategy in the first sample is to guess friends alternately. | 2,000 | [
{
"input": "2\n50 50",
"output": "5.0000000000"
},
{
"input": "4\n50 20 20 10",
"output": "39.2846263444"
},
{
"input": "1\n100",
"output": "1.0000000000"
},
{
"input": "2\n41 59",
"output": "5.0966935927"
},
{
"input": "6\n14 14 18 21 20 13",
"output": "83.75... | 1,689,447,481 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 0 | 30 | 0 | print("_RANDOM_GUESS_1689447481.0254164")# 1689447481.025439 | Title: Birthday
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
A MIPT student named Misha has a birthday today, and he decided to celebrate it in his country house in suburban Moscow. *n* friends came by, and after a typical party they decided to play blind man's buff.
The birthday boy g... | ```python
print("_RANDOM_GUESS_1689447481.0254164")# 1689447481.025439
``` | 0 | 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,467,654,546 | 2,147,483,647 | Python 3 | OK | TESTS | 48 | 216 | 8,704,000 | import math
y, k, n = map(int, input().split())
# x+y<n k|x+y x+y=ka ka<n a<n/k a= 0 to floor(n/k)
# ki-y>=1 i>=(y+1)/k
l = [k * i - y for i in range(math.ceil((y + 1) / k), n // k+1)]
if len(l) is 0:
print(-1)
else:
print(' '.join(map(str, l)))
| 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
import math
y, k, n = map(int, input().split())
# x+y<n k|x+y x+y=ka ka<n a<n/k a= 0 to floor(n/k)
# ki-y>=1 i>=(y+1)/k
l = [k * i - y for i in range(math.ceil((y + 1) / k), n // k+1)]
if len(l) is 0:
print(-1)
else:
print(' '.join(map(str, l)))
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
27 | B | Tournament | PROGRAMMING | 1,300 | [
"bitmasks",
"brute force",
"dfs and similar",
"greedy"
] | B. Tournament | 2 | 256 | The tournament «Sleepyhead-2010» in the rapid falling asleep has just finished in Berland. *n* best participants from the country have participated in it. The tournament consists of games, each of them is a match between two participants. *n*·(*n*<=-<=1)<=/<=2 games were played during the tournament, and each participa... | The first line contains one integer *n* (3<=≤<=*n*<=≤<=50) — the number of participants. The following *n*·(*n*<=-<=1)<=/<=2<=-<=1 lines contain the results of the games. Each game is described in a single line by two integers *x**i*,<=*y**i* (1<=≤<=*x**i*,<=*y**i*<=≤<=*n*,<=*x**i*<=≠<=*y**i*), where *x**i* и *y**i* ar... | Output two integers *x* and *y* — the missing record. If there are several solutions, output any of them. | [
"4\n4 2\n4 1\n2 3\n2 1\n3 1\n"
] | [
"4 3\n"
] | none | 1,000 | [
{
"input": "3\n3 2\n1 2",
"output": "1 3"
},
{
"input": "4\n2 4\n3 4\n1 2\n1 4\n1 3",
"output": "2 3"
},
{
"input": "5\n3 5\n2 5\n1 5\n1 4\n4 3\n1 3\n2 3\n4 5\n4 2",
"output": "1 2"
},
{
"input": "6\n3 4\n3 5\n5 4\n1 2\n5 6\n2 6\n5 2\n3 6\n3 2\n4 6\n2 4\n1 3\n1 5\n1 4",
"... | 1,627,181,311 | 2,147,483,647 | Python 3 | OK | TESTS | 35 | 124 | 7,065,600 | # _
#####################################################################################################################
def missingRecord(nParticipants, currRecord):
storage = {str(participant): set() for participant in range(1, nParticipants+1)}
for record in currRecord:
storage[record[0]].add... | Title: Tournament
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
The tournament «Sleepyhead-2010» in the rapid falling asleep has just finished in Berland. *n* best participants from the country have participated in it. The tournament consists of games, each of them is a match between two par... | ```python
# _
#####################################################################################################################
def missingRecord(nParticipants, currRecord):
storage = {str(participant): set() for participant in range(1, nParticipants+1)}
for record in currRecord:
storage[reco... | 3.955839 | MatrixStudio/Codeforces-Python-Submissions |
255 | A | Greg's Workout | PROGRAMMING | 800 | [
"implementation"
] | null | null | Greg is a beginner bodybuilder. Today the gym coach gave him the training plan. All it had was *n* integers *a*1,<=*a*2,<=...,<=*a**n*. These numbers mean that Greg needs to do exactly *n* exercises today. Besides, Greg should repeat the *i*-th in order exercise *a**i* times.
Greg now only does three types of exercise... | The first line contains integer *n* (1<=≤<=*n*<=≤<=20). The second line contains *n* integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=25) — the number of times Greg repeats the exercises. | Print word "chest" (without the quotes), if the chest gets the most exercise, "biceps" (without the quotes), if the biceps gets the most exercise and print "back" (without the quotes) if the back gets the most exercise.
It is guaranteed that the input is such that the answer to the problem is unambiguous. | [
"2\n2 8\n",
"3\n5 1 10\n",
"7\n3 3 2 7 9 6 8\n"
] | [
"biceps\n",
"back\n",
"chest\n"
] | In the first sample Greg does 2 chest, 8 biceps and zero back exercises, so the biceps gets the most exercises.
In the second sample Greg does 5 chest, 1 biceps and 10 back exercises, so the back gets the most exercises.
In the third sample Greg does 18 chest, 12 biceps and 8 back exercises, so the chest gets the mos... | 500 | [
{
"input": "2\n2 8",
"output": "biceps"
},
{
"input": "3\n5 1 10",
"output": "back"
},
{
"input": "7\n3 3 2 7 9 6 8",
"output": "chest"
},
{
"input": "4\n5 6 6 2",
"output": "chest"
},
{
"input": "5\n8 2 2 6 3",
"output": "chest"
},
{
"input": "6\n8 7 ... | 1,599,175,871 | 2,147,483,647 | Python 3 | OK | TESTS | 61 | 248 | 307,200 | if __name__ == '__main__':
n = int(input())
exeList = [int(i) for i in input().split()]
ches, bice, back, i = 0, 0, 0, 0
while i < n:
if i < n: ches, i = (ches + exeList[i]), i + 1
if i < n: bice, i = (bice + exeList[i]), i + 1
if i < n: back, i = (back + exeList[i]), i + 1
print('chest' if ches ... | Title: Greg's Workout
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Greg is a beginner bodybuilder. Today the gym coach gave him the training plan. All it had was *n* integers *a*1,<=*a*2,<=...,<=*a**n*. These numbers mean that Greg needs to do exactly *n* exercises today. Besides, Greg ... | ```python
if __name__ == '__main__':
n = int(input())
exeList = [int(i) for i in input().split()]
ches, bice, back, i = 0, 0, 0, 0
while i < n:
if i < n: ches, i = (ches + exeList[i]), i + 1
if i < n: bice, i = (bice + exeList[i]), i + 1
if i < n: back, i = (back + exeList[i]), i + 1
print('chest... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
510 | A | Fox And Snake | PROGRAMMING | 800 | [
"implementation"
] | null | null | Fox Ciel starts to learn programming. The first task is drawing a fox! However, that turns out to be too hard for a beginner, so she decides to draw a snake instead.
A snake is a pattern on a *n* by *m* table. Denote *c*-th cell of *r*-th row as (*r*,<=*c*). The tail of the snake is located at (1,<=1), then it's body ... | The only line contains two integers: *n* and *m* (3<=≤<=*n*,<=*m*<=≤<=50).
*n* is an odd number. | Output *n* lines. Each line should contain a string consisting of *m* characters. Do not output spaces. | [
"3 3\n",
"3 4\n",
"5 3\n",
"9 9\n"
] | [
"###\n..#\n###\n",
"####\n...#\n####\n",
"###\n..#\n###\n#..\n###\n",
"#########\n........#\n#########\n#........\n#########\n........#\n#########\n#........\n#########\n"
] | none | 500 | [
{
"input": "3 3",
"output": "###\n..#\n###"
},
{
"input": "3 4",
"output": "####\n...#\n####"
},
{
"input": "5 3",
"output": "###\n..#\n###\n#..\n###"
},
{
"input": "9 9",
"output": "#########\n........#\n#########\n#........\n#########\n........#\n#########\n#........\n#... | 1,683,739,347 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 2 | 31 | 0 | import sys
n, m = [int(x) for x in sys.stdin.readline().split()]
result = ''
while n > 0:
if n % 2 != 0:
result += m*'#' + '\n'
else:
t = (m-1)*'.'
if n % 4 == 0:
t = '#' + t
else:
t = t + '#'
result += t + '\n'
n -= 1
p... | Title: Fox And Snake
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Fox Ciel starts to learn programming. The first task is drawing a fox! However, that turns out to be too hard for a beginner, so she decides to draw a snake instead.
A snake is a pattern on a *n* by *m* table. Denote *c*... | ```python
import sys
n, m = [int(x) for x in sys.stdin.readline().split()]
result = ''
while n > 0:
if n % 2 != 0:
result += m*'#' + '\n'
else:
t = (m-1)*'.'
if n % 4 == 0:
t = '#' + t
else:
t = t + '#'
result += t + '\n'
n -= ... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
523 | C | Name Quest | PROGRAMMING | 1,400 | [
"*special",
"greedy"
] | null | null | A Martian boy is named *s* — he has got this name quite recently from his parents for his coming of age birthday. Now he enjoys looking for his name everywhere. If he sees that he can obtain his name from some string by removing zero or more letters (at that, the remaining letters remain in the same order), he gets hap... | The first line contains string *s*, consisting of lowercase English letters. The length of string *s* is from 1 to 1000 letters.
The second line contains string *t*, that also consists of lowercase English letters. The length of string *t* is from 1 to 106 letters. | Print the sought number of ways to cut string *t* in two so that each part made *s* happy. | [
"aba\nbaobababbah\n",
"mars\nsunvenusearthmarsjupitersaturnuranusneptune\n"
] | [
"2\n",
"0\n"
] | none | 1,500 | [
{
"input": "aba\nbaobababbah",
"output": "2"
},
{
"input": "mars\nsunvenusearthmarsjupitersaturnuranusneptune",
"output": "0"
},
{
"input": "rry\nsorrymercuryismissedabove",
"output": "3"
},
{
"input": "a\naaaaaaaaaaaaaa",
"output": "13"
},
{
"input": "abcaba\nabc... | 1,426,351,024 | 5,823 | Python 3 | WRONG_ANSWER | PRETESTS | 6 | 46 | 3,276,800 | __author__ = 'Руслан'
name = input()
finder = input()
left_pos = 0
right_pos = len(finder)
isfind = True
for i in name:
left_pos = finder.find(i, left_pos)
if left_pos == -1:
isfind = False
break
if isfind:
for i in name[::-1]:
right_pos = finder.rfind(i, 0, right_pos)... | Title: Name Quest
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
A Martian boy is named *s* — he has got this name quite recently from his parents for his coming of age birthday. Now he enjoys looking for his name everywhere. If he sees that he can obtain his name from some string by remo... | ```python
__author__ = 'Руслан'
name = input()
finder = input()
left_pos = 0
right_pos = len(finder)
isfind = True
for i in name:
left_pos = finder.find(i, left_pos)
if left_pos == -1:
isfind = False
break
if isfind:
for i in name[::-1]:
right_pos = finder.rfind(i, 0, ... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
468 | C | Hack it! | PROGRAMMING | 2,500 | [
"binary search",
"constructive algorithms",
"math"
] | null | null | Little X has met the following problem recently.
Let's define *f*(*x*) as the sum of digits in decimal representation of number *x* (for example, *f*(1234)<==<=1<=+<=2<=+<=3<=+<=4). You are to calculate
Of course Little X has solved this problem quickly, has locked it, and then has tried to hack others. He has seen... | The first line contains a single integer *a* (1<=≤<=*a*<=≤<=1018). | Print two integers: *l*,<=*r* (1<=≤<=*l*<=≤<=*r*<=<<=10200) — the required test data. Leading zeros aren't allowed. It's guaranteed that the solution exists. | [
"46\n",
"126444381000032\n"
] | [
"1 10\n",
"2333333 2333333333333\n"
] | none | 1,500 | [
{
"input": "46",
"output": "1 10"
},
{
"input": "126444381000032",
"output": "2333333 2333333333333"
},
{
"input": "69645082595",
"output": "613752823618441225798858488535 713259406474207764329704856394"
},
{
"input": "70602205995",
"output": "11 2492213340204320744986569... | 1,535,326,382 | 2,147,483,647 | Python 3 | OK | TESTS | 51 | 109 | 0 | a=int(input())
x=a-((10**21)*9)%a
print(x,10**20+x-1)
# Made By Mostafa_Khaled | Title: Hack it!
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Little X has met the following problem recently.
Let's define *f*(*x*) as the sum of digits in decimal representation of number *x* (for example, *f*(1234)<==<=1<=+<=2<=+<=3<=+<=4). You are to calculate
Of course Little X ... | ```python
a=int(input())
x=a-((10**21)*9)%a
print(x,10**20+x-1)
# Made By Mostafa_Khaled
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
810 | A | Straight <<A>> | PROGRAMMING | 900 | [
"implementation",
"math"
] | null | null | Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.
In school, where Noora is studying, teachers are putting down marks to the online class register, wh... | The first line contains two integers *n* and *k* (1<=≤<=*n*<=≤<=100,<=1<=≤<=*k*<=≤<=100) denoting the number of marks, received by Noora and the value of highest possible mark.
The second line contains *n* integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=*k*) denoting marks received by Noora before Leha's hack. | Print a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to *k*. | [
"2 10\n8 9\n",
"3 5\n4 4 4\n"
] | [
"4",
"3"
] | Consider the first example testcase.
Maximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to <img align="middle" class="tex-formula" src="https://espresso.codeforc... | 500 | [
{
"input": "2 10\n8 9",
"output": "4"
},
{
"input": "3 5\n4 4 4",
"output": "3"
},
{
"input": "3 10\n10 8 9",
"output": "3"
},
{
"input": "2 23\n21 23",
"output": "2"
},
{
"input": "5 10\n5 10 10 9 10",
"output": "7"
},
{
"input": "12 50\n18 10 26 22 2... | 1,618,421,291 | 2,147,483,647 | Python 3 | OK | TESTS | 106 | 77 | 0 | n, k = map(int, input().split())
arr = list(map(int, input().split()))
needed = k - 0.5
sm = sum(arr)
average = sm / n
ans = 0
while average < needed:
sm += k
n += 1
ans += 1
average = sm/n
print(ans)
| Title: Straight <<A>>
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.
... | ```python
n, k = map(int, input().split())
arr = list(map(int, input().split()))
needed = k - 0.5
sm = sum(arr)
average = sm / n
ans = 0
while average < needed:
sm += k
n += 1
ans += 1
average = sm/n
print(ans)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
727 | A | Transformation: from A to B | PROGRAMMING | 1,000 | [
"brute force",
"dfs and similar",
"math"
] | null | null | Vasily has a number *a*, which he wants to turn into a number *b*. For this purpose, he can do two types of operations:
- multiply the current number by 2 (that is, replace the number *x* by 2·*x*); - append the digit 1 to the right of current number (that is, replace the number *x* by 10·*x*<=+<=1).
You need to he... | The first line contains two positive integers *a* and *b* (1<=≤<=*a*<=<<=*b*<=≤<=109) — the number which Vasily has and the number he wants to have. | If there is no way to get *b* from *a*, print "NO" (without quotes).
Otherwise print three lines. On the first line print "YES" (without quotes). The second line should contain single integer *k* — the length of the transformation sequence. On the third line print the sequence of transformations *x*1,<=*x*2,<=...,<=*x... | [
"2 162\n",
"4 42\n",
"100 40021\n"
] | [
"YES\n5\n2 4 8 81 162 \n",
"NO\n",
"YES\n5\n100 200 2001 4002 40021 \n"
] | none | 1,000 | [
{
"input": "2 162",
"output": "YES\n5\n2 4 8 81 162 "
},
{
"input": "4 42",
"output": "NO"
},
{
"input": "100 40021",
"output": "YES\n5\n100 200 2001 4002 40021 "
},
{
"input": "1 111111111",
"output": "YES\n9\n1 11 111 1111 11111 111111 1111111 11111111 111111111 "
},
... | 1,618,175,601 | 2,147,483,647 | Python 3 | OK | TESTS | 33 | 108 | 0 | def transform(a, b, passos):
if(a>b):
return
elif (a == b):
passos.append(a)
print("YES")
print(len(passos))
array = ""
for i in passos:
array += str(i) + " "
print(array.strip())
return
else:
passos.append(a)
transform(2*a,b, passos)
transform((10*a) + 1,b, passo... | Title: Transformation: from A to B
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vasily has a number *a*, which he wants to turn into a number *b*. For this purpose, he can do two types of operations:
- multiply the current number by 2 (that is, replace the number *x* by 2·*x*); - app... | ```python
def transform(a, b, passos):
if(a>b):
return
elif (a == b):
passos.append(a)
print("YES")
print(len(passos))
array = ""
for i in passos:
array += str(i) + " "
print(array.strip())
return
else:
passos.append(a)
transform(2*a,b, passos)
transform((10*a) + ... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
721 | A | One-dimensional Japanese Crossword | PROGRAMMING | 800 | [
"implementation"
] | null | null | Recently Adaltik discovered japanese crosswords. Japanese crossword is a picture, represented as a table sized *a*<=×<=*b* squares, and each square is colored white or black. There are integers to the left of the rows and to the top of the columns, encrypting the corresponding row or column. The number of integers repr... | The first line of the input contains a single integer *n* (1<=≤<=*n*<=≤<=100) — the length of the row. The second line of the input contains a single string consisting of *n* characters 'B' or 'W', ('B' corresponds to black square, 'W' — to white square in the row that Adaltik drew). | The first line should contain a single integer *k* — the number of integers encrypting the row, e.g. the number of groups of black squares in the row.
The second line should contain *k* integers, encrypting the row, e.g. corresponding to sizes of groups of consecutive black squares in the order from left to right. | [
"3\nBBW\n",
"5\nBWBWB\n",
"4\nWWWW\n",
"4\nBBBB\n",
"13\nWBBBBWWBWBBBW\n"
] | [
"1\n2 ",
"3\n1 1 1 ",
"0\n",
"1\n4 ",
"3\n4 1 3 "
] | The last sample case correspond to the picture in the statement. | 500 | [
{
"input": "3\nBBW",
"output": "1\n2 "
},
{
"input": "5\nBWBWB",
"output": "3\n1 1 1 "
},
{
"input": "4\nWWWW",
"output": "0"
},
{
"input": "4\nBBBB",
"output": "1\n4 "
},
{
"input": "13\nWBBBBWWBWBBBW",
"output": "3\n4 1 3 "
},
{
"input": "1\nB",
... | 1,585,686,456 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 93 | 307,200 | #input treatment
x = int(input())# WBWB BWBW BBBB WWW
y = input()
m = 0
y += 'W'
#first output
for i in range(0,len(y)-1):
if y[i] == 'W' and y[i+1] == 'B':
m += 1
if y[0]== 'B':
m+=1
print(m)
#Second output
l = []
s = 0
if y[0] == 'B':
s +=1
for o in range(0,len(y)-1):
... | Title: One-dimensional Japanese Crossword
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Recently Adaltik discovered japanese crosswords. Japanese crossword is a picture, represented as a table sized *a*<=×<=*b* squares, and each square is colored white or black. There are integers to the... | ```python
#input treatment
x = int(input())# WBWB BWBW BBBB WWW
y = input()
m = 0
y += 'W'
#first output
for i in range(0,len(y)-1):
if y[i] == 'W' and y[i+1] == 'B':
m += 1
if y[0]== 'B':
m+=1
print(m)
#Second output
l = []
s = 0
if y[0] == 'B':
s +=1
for o in range(0,l... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
12 | B | Correct Solution? | PROGRAMMING | 1,100 | [
"implementation",
"sortings"
] | B. Correct Solution? | 2 | 256 | One cold winter evening Alice and her older brother Bob was sitting at home near the fireplace and giving each other interesting problems to solve. When it was Alice's turn, she told the number *n* to Bob and said:
—Shuffle the digits in this number in order to obtain the smallest possible number without leading zeroe... | The first line contains one integer *n* (0<=≤<=*n*<=≤<=109) without leading zeroes. The second lines contains one integer *m* (0<=≤<=*m*<=≤<=109) — Bob's answer, possibly with leading zeroes. | Print OK if Bob's answer is correct and WRONG_ANSWER otherwise. | [
"3310\n1033\n",
"4\n5\n"
] | [
"OK\n",
"WRONG_ANSWER\n"
] | none | 0 | [
{
"input": "3310\n1033",
"output": "OK"
},
{
"input": "4\n5",
"output": "WRONG_ANSWER"
},
{
"input": "40\n04",
"output": "WRONG_ANSWER"
},
{
"input": "12\n12",
"output": "OK"
},
{
"input": "432\n234",
"output": "OK"
},
{
"input": "17109\n01179",
"o... | 1,493,048,757 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 8 | 122 | 4,608,000 | s=input()
answer=input()
r=list(s)
r.sort()
s=''.join(r)
r=s.rfind('0')
if r!=-1:
s=s[r+1]+s[:r+1]+s[r+2:]
if s==answer:
print('OK')
else:
print('WRONG_ANSWER') | Title: Correct Solution?
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
One cold winter evening Alice and her older brother Bob was sitting at home near the fireplace and giving each other interesting problems to solve. When it was Alice's turn, she told the number *n* to Bob and said:
—Shuf... | ```python
s=input()
answer=input()
r=list(s)
r.sort()
s=''.join(r)
r=s.rfind('0')
if r!=-1:
s=s[r+1]+s[:r+1]+s[r+2:]
if s==answer:
print('OK')
else:
print('WRONG_ANSWER')
``` | -1 | MatrixStudio/Codeforces-Python-Submissions |
119 | B | Before Exam | PROGRAMMING | 1,900 | [
"constructive algorithms",
"implementation",
"sortings"
] | null | null | Vasya is about to take his first university exam in about several minutes. And it's not just some ordinary exam, it's on mathematical analysis. Of course, right now Vasya can only think of one thing: what the result of his talk with the examiner will be...
To prepare for the exam, one has to study proofs of *n* theore... | The first line contains two integers *n* and *k* (1<=≤<=*k*<=≤<=*n*<=≤<=100) — the number of theorems and the number of cards correspondingly. The second line contains *n* integers *a**i* (0<=≤<=*a**i*<=≤<=100), the *i*-th number (1<=≤<=*i*<=≤<=*n*) corresponds to Vasya's proficiency in the *i*-th theorem.
The third l... | Print two real numbers, representing Vasya's minimum and maximum proficiency in the card he will get on the exam. The absolute or relative error should not exceed 10<=-<=6. | [
"7 3\n7 15 0 19 10 5 12\n2\n1 6\n7 4\n",
"4 2\n10 8 1 17\n2\n2 3\n3 2\n"
] | [
"5.0000000000 15.5000000000",
"4.5000000000 13.5000000000"
] | Let's analyze the first sample. Vasya's proficiency in the cards whose content he already knows equals 6 and 15.5 correspondingly. The three theorems that are left are only enough to make one exam card. If we consider all possible variants of theorems included in the card we can see that in the best case scenario Vasya... | 1,000 | [
{
"input": "7 3\n7 15 0 19 10 5 12\n2\n1 6\n7 4",
"output": "5.0000000000 15.5000000000"
},
{
"input": "4 2\n10 8 1 17\n2\n2 3\n3 2",
"output": "4.5000000000 13.5000000000"
},
{
"input": "10 5\n3 10 0 15 45 84 67 100 46 73\n3\n1 6\n8 9\n6 1",
"output": "5.0000000000 73.0000000000"
... | 1,610,259,871 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 8 | 184 | 0 | n, k = map(int, input().split())
ar = list(map(int, input().split()))
st = set()
ar2 = []
q = int(input())
for i in range(q):
s = -1
tmp = list(map(int, input().split()))
for x in tmp:
if (x - 1) in st:
break
if s == -1:
s = 0
st.add(x - 1)
... | Title: Before Exam
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vasya is about to take his first university exam in about several minutes. And it's not just some ordinary exam, it's on mathematical analysis. Of course, right now Vasya can only think of one thing: what the result of his ... | ```python
n, k = map(int, input().split())
ar = list(map(int, input().split()))
st = set()
ar2 = []
q = int(input())
for i in range(q):
s = -1
tmp = list(map(int, input().split()))
for x in tmp:
if (x - 1) in st:
break
if s == -1:
s = 0
st.add(x -... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
607 | A | Chain Reaction | PROGRAMMING | 1,600 | [
"binary search",
"dp"
] | null | null | There are *n* beacons located at distinct positions on a number line. The *i*-th beacon has position *a**i* and power level *b**i*. When the *i*-th beacon is activated, it destroys all beacons to its left (direction of decreasing coordinates) within distance *b**i* inclusive. The beacon itself is not destroyed however.... | The first line of input contains a single integer *n* (1<=≤<=*n*<=≤<=100<=000) — the initial number of beacons.
The *i*-th of next *n* lines contains two integers *a**i* and *b**i* (0<=≤<=*a**i*<=≤<=1<=000<=000, 1<=≤<=*b**i*<=≤<=1<=000<=000) — the position and power level of the *i*-th beacon respectively. No two beac... | Print a single integer — the minimum number of beacons that could be destroyed if exactly one beacon is added. | [
"4\n1 9\n3 1\n6 1\n7 4\n",
"7\n1 1\n2 1\n3 1\n4 1\n5 1\n6 1\n7 1\n"
] | [
"1\n",
"3\n"
] | For the first sample case, the minimum number of beacons destroyed is 1. One way to achieve this is to place a beacon at position 9 with power level 2.
For the second sample case, the minimum number of beacons destroyed is 3. One way to achieve this is to place a beacon at position 1337 with power level 42. | 500 | [
{
"input": "4\n1 9\n3 1\n6 1\n7 4",
"output": "1"
},
{
"input": "7\n1 1\n2 1\n3 1\n4 1\n5 1\n6 1\n7 1",
"output": "3"
},
{
"input": "1\n0 1",
"output": "0"
},
{
"input": "1\n0 1000000",
"output": "0"
},
{
"input": "1\n1000000 1000000",
"output": "0"
},
{
... | 1,590,977,489 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 2 | 124 | 0 | import bisect
def main():
n = int(input())
beacons = []
coords = []
for i in range(n):
a,b = map(int,input().split())
beacons.append((a,b))
coords.append(a)
if n == 1:
print(1)
return
coords.sort()
beacons.sort()
dp = [0]*n
... | Title: Chain Reaction
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
There are *n* beacons located at distinct positions on a number line. The *i*-th beacon has position *a**i* and power level *b**i*. When the *i*-th beacon is activated, it destroys all beacons to its left (direction of d... | ```python
import bisect
def main():
n = int(input())
beacons = []
coords = []
for i in range(n):
a,b = map(int,input().split())
beacons.append((a,b))
coords.append(a)
if n == 1:
print(1)
return
coords.sort()
beacons.sort()
d... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
742 | A | Arpa’s hard exam and Mehrdad’s naive cheat | PROGRAMMING | 1,000 | [
"implementation",
"math",
"number theory"
] | null | null | There exists an island called Arpa’s land, some beautiful girls live there, as ugly ones do.
Mehrdad wants to become minister of Arpa’s land. Arpa has prepared an exam. Exam has only one question, given *n*, print the last digit of 1378*n*.
Mehrdad has become quite confused and wants you to help him. Please help, al... | The single line of input contains one integer *n* (0<=<=≤<=<=*n*<=<=≤<=<=109). | Print single integer — the last digit of 1378*n*. | [
"1\n",
"2\n"
] | [
"8",
"4"
] | In the first example, last digit of 1378<sup class="upper-index">1</sup> = 1378 is 8.
In the second example, last digit of 1378<sup class="upper-index">2</sup> = 1378·1378 = 1898884 is 4. | 500 | [
{
"input": "1",
"output": "8"
},
{
"input": "2",
"output": "4"
},
{
"input": "1000",
"output": "6"
},
{
"input": "3",
"output": "2"
},
{
"input": "4",
"output": "6"
},
{
"input": "1000000000",
"output": "6"
},
{
"input": "5",
"output": ... | 1,659,662,832 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 15 | 46 | 0 | print([8,4,2,6][(int(input())%4) - 1]) | Title: Arpa’s hard exam and Mehrdad’s naive cheat
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
There exists an island called Arpa’s land, some beautiful girls live there, as ugly ones do.
Mehrdad wants to become minister of Arpa’s land. Arpa has prepared an exam. Exam has only one ques... | ```python
print([8,4,2,6][(int(input())%4) - 1])
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
155 | A | I_love_\%username\% | PROGRAMMING | 800 | [
"brute force"
] | null | null | Vasya adores sport programming. He can't write programs but he loves to watch the contests' progress. Vasya even has a favorite coder and Vasya pays special attention to him.
One day Vasya decided to collect the results of all contests where his favorite coder participated and track the progress of his coolness. For e... | The first line contains the single integer *n* (1<=≤<=*n*<=≤<=1000) — the number of contests where the coder participated.
The next line contains *n* space-separated non-negative integer numbers — they are the points which the coder has earned. The points are given in the chronological order. All points do not exceed ... | Print the single number — the number of amazing performances the coder has had during his whole history of participating in the contests. | [
"5\n100 50 200 150 200\n",
"10\n4664 6496 5814 7010 5762 5736 6944 4850 3698 7242\n"
] | [
"2\n",
"4\n"
] | In the first sample the performances number 2 and 3 are amazing.
In the second sample the performances number 2, 4, 9 and 10 are amazing. | 500 | [
{
"input": "5\n100 50 200 150 200",
"output": "2"
},
{
"input": "10\n4664 6496 5814 7010 5762 5736 6944 4850 3698 7242",
"output": "4"
},
{
"input": "1\n6",
"output": "0"
},
{
"input": "2\n2 1",
"output": "1"
},
{
"input": "5\n100 36 53 7 81",
"output": "2"
... | 1,687,941,457 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 3 | 60 | 0 | num = int(input())
arr = list(map(int, input().split()))
temp=-9999
count=0
index=0
for i in arr :
if index == 0 :
temp = i
else:
if i > temp :
temp = i
count += 1
else:
temp = i
continue
index += 1
print(count) | Title: I_love_\%username\%
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vasya adores sport programming. He can't write programs but he loves to watch the contests' progress. Vasya even has a favorite coder and Vasya pays special attention to him.
One day Vasya decided to collect the re... | ```python
num = int(input())
arr = list(map(int, input().split()))
temp=-9999
count=0
index=0
for i in arr :
if index == 0 :
temp = i
else:
if i > temp :
temp = i
count += 1
else:
temp = i
continue
index += 1
print(c... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
119 | A | Epic Game | PROGRAMMING | 800 | [
"implementation"
] | null | null | Simon and Antisimon play a game. Initially each player receives one fixed positive integer that doesn't change throughout the game. Simon receives number *a* and Antisimon receives number *b*. They also have a heap of *n* stones. The players take turns to make a move and Simon starts. During a move a player should take... | The only string contains space-separated integers *a*, *b* and *n* (1<=≤<=*a*,<=*b*,<=*n*<=≤<=100) — the fixed numbers Simon and Antisimon have received correspondingly and the initial number of stones in the pile. | If Simon wins, print "0" (without the quotes), otherwise print "1" (without the quotes). | [
"3 5 9\n",
"1 1 100\n"
] | [
"0",
"1"
] | The greatest common divisor of two non-negative integers *a* and *b* is such maximum positive integer *k*, that *a* is divisible by *k* without remainder and similarly, *b* is divisible by *k* without remainder. Let *gcd*(*a*, *b*) represent the operation of calculating the greatest common divisor of numbers *a* and *b... | 500 | [
{
"input": "3 5 9",
"output": "0"
},
{
"input": "1 1 100",
"output": "1"
},
{
"input": "23 12 16",
"output": "1"
},
{
"input": "95 26 29",
"output": "1"
},
{
"input": "73 32 99",
"output": "1"
},
{
"input": "1 1 1",
"output": "0"
},
{
"inpu... | 1,585,824,827 | 2,147,483,647 | Python 3 | OK | TESTS | 45 | 216 | 0 | a, b, c = [int(x) for x in input().split()]
def nod(lhs, rhs):
if rhs==0:
return lhs
else:
return nod(rhs, lhs%rhs)
d=nod(a,c)
k=0
while c>0:
if k==0:
d=nod(a,c)
else:
d=nod(b,c)
c -= d
k = (k + 1) % 2
print((k + 1) % 2) | Title: Epic Game
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Simon and Antisimon play a game. Initially each player receives one fixed positive integer that doesn't change throughout the game. Simon receives number *a* and Antisimon receives number *b*. They also have a heap of *n* sto... | ```python
a, b, c = [int(x) for x in input().split()]
def nod(lhs, rhs):
if rhs==0:
return lhs
else:
return nod(rhs, lhs%rhs)
d=nod(a,c)
k=0
while c>0:
if k==0:
d=nod(a,c)
else:
d=nod(b,c)
c -= d
k = (k + 1) % 2
print((k + 1) % 2)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
552 | B | Vanya and Books | PROGRAMMING | 1,200 | [
"implementation",
"math"
] | null | null | Vanya got an important task — he should enumerate books in the library and label each book with its number. Each of the *n* books should be assigned with a number from 1 to *n*. Naturally, distinct books should be assigned distinct numbers.
Vanya wants to know how many digits he will have to write down as he labels th... | The first line contains integer *n* (1<=≤<=*n*<=≤<=109) — the number of books in the library. | Print the number of digits needed to number all the books. | [
"13\n",
"4\n"
] | [
"17\n",
"4\n"
] | Note to the first test. The books get numbers 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, which totals to 17 digits.
Note to the second sample. The books get numbers 1, 2, 3, 4, which totals to 4 digits. | 1,000 | [
{
"input": "13",
"output": "17"
},
{
"input": "4",
"output": "4"
},
{
"input": "100",
"output": "192"
},
{
"input": "99",
"output": "189"
},
{
"input": "1000000000",
"output": "8888888899"
},
{
"input": "1000000",
"output": "5888896"
},
{
"... | 1,609,755,132 | 2,147,483,647 | Python 3 | OK | TESTS | 55 | 124 | 0 | n = int(input())
ans = 0
for i in range(len(str(n))):
kek = 9 * (10 ** i)
if n - kek > 0:
ans += kek * (i+1)
else:
ans += n * (i+1)
n -= kek
print(ans) | Title: Vanya and Books
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vanya got an important task — he should enumerate books in the library and label each book with its number. Each of the *n* books should be assigned with a number from 1 to *n*. Naturally, distinct books should be assig... | ```python
n = int(input())
ans = 0
for i in range(len(str(n))):
kek = 9 * (10 ** i)
if n - kek > 0:
ans += kek * (i+1)
else:
ans += n * (i+1)
n -= kek
print(ans)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
771 | A | Bear and Friendship Condition | PROGRAMMING | 1,500 | [
"dfs and similar",
"dsu",
"graphs"
] | null | null | Bear Limak examines a social network. Its main functionality is that two members can become friends (then they can talk with each other and share funny pictures).
There are *n* members, numbered 1 through *n*. *m* pairs of members are friends. Of course, a member can't be a friend with themselves.
Let A-B denote that... | The first line of the input contain two integers *n* and *m* (3<=≤<=*n*<=≤<=150<=000, ) — the number of members and the number of pairs of members that are friends.
The *i*-th of the next *m* lines contains two distinct integers *a**i* and *b**i* (1<=≤<=*a**i*,<=*b**i*<=≤<=*n*,<=*a**i*<=≠<=*b**i*). Members *a**i* and ... | If the given network is reasonable, print "YES" in a single line (without the quotes). Otherwise, print "NO" in a single line (without the quotes). | [
"4 3\n1 3\n3 4\n1 4\n",
"4 4\n3 1\n2 3\n3 4\n1 2\n",
"10 4\n4 3\n5 10\n8 9\n1 2\n",
"3 2\n1 2\n2 3\n"
] | [
"YES\n",
"NO\n",
"YES\n",
"NO\n"
] | The drawings below show the situation in the first sample (on the left) and in the second sample (on the right). Each edge represents two members that are friends. The answer is "NO" in the second sample because members (2, 3) are friends and members (3, 4) are friends, while members (2, 4) are not. | 250 | [
{
"input": "4 3\n1 3\n3 4\n1 4",
"output": "YES"
},
{
"input": "4 4\n3 1\n2 3\n3 4\n1 2",
"output": "NO"
},
{
"input": "10 4\n4 3\n5 10\n8 9\n1 2",
"output": "YES"
},
{
"input": "3 2\n1 2\n2 3",
"output": "NO"
},
{
"input": "3 0",
"output": "YES"
},
{
... | 1,489,852,740 | 1,440 | Python 3 | TIME_LIMIT_EXCEEDED | PRETESTS | 11 | 1,000 | 35,123,200 |
def do():
n, m = list(map(int, input().split()))
net = {}
for i in range(m):
p1, p2 = input().split()
p1_friends = net.get(p1, set())
p2_friends = net.get(p2, set())
p1_friends.add(p2)
p2_friends.add(p1)
net[p1] = p1_friends
net[p2] = p2_friends
for k in net:
for f in net[k]:
for ff in ne... | Title: Bear and Friendship Condition
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Bear Limak examines a social network. Its main functionality is that two members can become friends (then they can talk with each other and share funny pictures).
There are *n* members, numbered 1 through... | ```python
def do():
n, m = list(map(int, input().split()))
net = {}
for i in range(m):
p1, p2 = input().split()
p1_friends = net.get(p1, set())
p2_friends = net.get(p2, set())
p1_friends.add(p2)
p2_friends.add(p1)
net[p1] = p1_friends
net[p2] = p2_friends
for k in net:
for f in net[k]:
fo... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
455 | A | Boredom | PROGRAMMING | 1,500 | [
"dp"
] | null | null | Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.
Given a sequence *a* consisting of *n* integers. The player can make several steps. In a single step he can choose an element of the sequence (let's denote it *a*... | The first line contains integer *n* (1<=≤<=*n*<=≤<=105) that shows how many numbers are in Alex's sequence.
The second line contains *n* integers *a*1, *a*2, ..., *a**n* (1<=≤<=*a**i*<=≤<=105). | Print a single integer — the maximum number of points that Alex can earn. | [
"2\n1 2\n",
"3\n1 2 3\n",
"9\n1 2 1 3 2 2 2 2 3\n"
] | [
"2\n",
"4\n",
"10\n"
] | Consider the third test example. At first step we need to choose any element equal to 2. After that step our sequence looks like this [2, 2, 2, 2]. Then we do 4 steps, on each step we choose any element equals to 2. In total we earn 10 points. | 500 | [
{
"input": "2\n1 2",
"output": "2"
},
{
"input": "3\n1 2 3",
"output": "4"
},
{
"input": "9\n1 2 1 3 2 2 2 2 3",
"output": "10"
},
{
"input": "5\n3 3 4 5 4",
"output": "11"
},
{
"input": "5\n5 3 5 3 4",
"output": "16"
},
{
"input": "5\n4 2 3 2 5",
... | 1,692,429,038 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 15 | 0 | inp = input()
seq = 0
for i in map(int,input.split()):
seq[i] += i
x = 0
y = 0
for i in seq:
x,y = max(x,i+y),y
print(y)
| Title: Boredom
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.
Given a sequence *a* consisting of *n* integers. The player can make ... | ```python
inp = input()
seq = 0
for i in map(int,input.split()):
seq[i] += i
x = 0
y = 0
for i in seq:
x,y = max(x,i+y),y
print(y)
``` | -1 | 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,602,748,385 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 93 | 0 | n = str(input())
m = str(input())
length = len(n)
r = ""
for i in range(length - 1):
if n[i] == m[i]:
r = r.replace("", "0")
else:
r = r.replace("", "1")
print(r)
| 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
n = str(input())
m = str(input())
length = len(n)
r = ""
for i in range(length - 1):
if n[i] == m[i]:
r = r.replace("", "0")
else:
r = r.replace("", "1")
print(r)
``` | 0 | 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,644,389,652 | 2,147,483,647 | Python 3 | OK | TESTS | 102 | 46 | 0 | a = input()
b= input()
n=len(a)
a=int(a,2)
b=int(b,2)
x=a^b
print(f"{x:0{n}b}") | 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 = input()
b= input()
n=len(a)
a=int(a,2)
b=int(b,2)
x=a^b
print(f"{x:0{n}b}")
``` | 3.9885 | MatrixStudio/Codeforces-Python-Submissions |
424 | A | Squats | PROGRAMMING | 900 | [
"implementation"
] | null | null | Pasha has many hamsters and he makes them work out. Today, *n* hamsters (*n* is even) came to work out. The hamsters lined up and each hamster either sat down or stood up.
For another exercise, Pasha needs exactly hamsters to stand up and the other hamsters to sit down. In one minute, Pasha can make some hamster ethe... | The first line contains integer *n* (2<=≤<=*n*<=≤<=200; *n* is even). The next line contains *n* characters without spaces. These characters describe the hamsters' position: the *i*-th character equals 'X', if the *i*-th hamster in the row is standing, and 'x', if he is sitting. | In the first line, print a single integer — the minimum required number of minutes. In the second line, print a string that describes the hamsters' position after Pasha makes the required changes. If there are multiple optimal positions, print any of them. | [
"4\nxxXx\n",
"2\nXX\n",
"6\nxXXxXx\n"
] | [
"1\nXxXx\n",
"1\nxX\n",
"0\nxXXxXx\n"
] | none | 500 | [
{
"input": "4\nxxXx",
"output": "1\nXxXx"
},
{
"input": "2\nXX",
"output": "1\nxX"
},
{
"input": "6\nxXXxXx",
"output": "0\nxXXxXx"
},
{
"input": "4\nxXXX",
"output": "1\nxxXX"
},
{
"input": "2\nXx",
"output": "0\nXx"
},
{
"input": "22\nXXxXXxxXxXxXXXX... | 1,420,278,521 | 2,147,483,647 | Python 3 | OK | TESTS | 32 | 77 | 0 | n = int(input())
s = input()
a = s.count('x')
b = s.count('X')
print(abs(a - b) // 2)
print(('X' if a > b else 'x').join(s.split('x' if a > b else 'X', abs(a - b) // 2)))
| Title: Squats
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Pasha has many hamsters and he makes them work out. Today, *n* hamsters (*n* is even) came to work out. The hamsters lined up and each hamster either sat down or stood up.
For another exercise, Pasha needs exactly hamsters to ... | ```python
n = int(input())
s = input()
a = s.count('x')
b = s.count('X')
print(abs(a - b) // 2)
print(('X' if a > b else 'x').join(s.split('x' if a > b else 'X', abs(a - b) // 2)))
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
75 | A | Life Without Zeros | PROGRAMMING | 1,000 | [
"implementation"
] | A. Life Without Zeros | 2 | 256 | Can you imagine our life if we removed all zeros from it? For sure we will have many problems.
In this problem we will have a simple example if we removed all zeros from our life, it's the addition operation. Let's assume you are given this equation *a*<=+<=*b*<==<=*c*, where *a* and *b* are positive integers, and *c*... | The input will consist of two lines, the first line will contain the integer *a*, and the second line will contain the integer *b* which are in the equation as described above (1<=≤<=*a*,<=*b*<=≤<=109). There won't be any leading zeros in both. The value of *c* should be calculated as *c*<==<=*a*<=+<=*b*. | The output will be just one line, you should print "YES" if the equation will remain correct after removing all zeros, and print "NO" otherwise. | [
"101\n102\n",
"105\n106\n"
] | [
"YES\n",
"NO\n"
] | none | 500 | [
{
"input": "101\n102",
"output": "YES"
},
{
"input": "105\n106",
"output": "NO"
},
{
"input": "544\n397",
"output": "YES"
},
{
"input": "822\n280",
"output": "NO"
},
{
"input": "101\n413",
"output": "NO"
},
{
"input": "309\n139",
"output": "NO"
}... | 1,693,583,547 | 2,147,483,647 | Python 3 | OK | TESTS | 43 | 92 | 0 | n1 = int(input())
n2 = int(input())
s1 = n1+n2
n1 = str(n1)
n2 = str(n2)
s1 = str(s1)
n1 = n1.replace('0' , '')
n2 = n2.replace('0' , '')
s1 = s1.replace('0' , '')
n1 = int(n1)
n2 = int(n2)
if n1 + n2 == int(s1):
print("YES")
else:
print("NO")
| Title: Life Without Zeros
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Can you imagine our life if we removed all zeros from it? For sure we will have many problems.
In this problem we will have a simple example if we removed all zeros from our life, it's the addition operation. Let's assu... | ```python
n1 = int(input())
n2 = int(input())
s1 = n1+n2
n1 = str(n1)
n2 = str(n2)
s1 = str(s1)
n1 = n1.replace('0' , '')
n2 = n2.replace('0' , '')
s1 = s1.replace('0' , '')
n1 = int(n1)
n2 = int(n2)
if n1 + n2 == int(s1):
print("YES")
else:
print("NO")
``` | 3.977 | 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,574,525,962 | 2,147,483,647 | PyPy 3 | OK | TESTS | 35 | 280 | 0 | s = input()
ans = 1
for i in range(len(s)):
if s[i].isalpha():
if s[i].upper() == 'A' or s[i].upper() == 'E' or s[i].upper() == 'I' or s[i].upper() == 'O' or s[i].upper() == 'U' or s[i].upper() == 'Y':
ans = 0
continue
ans = 1
if ans == 0:
print("YES")
else:
... | 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()
ans = 1
for i in range(len(s)):
if s[i].isalpha():
if s[i].upper() == 'A' or s[i].upper() == 'E' or s[i].upper() == 'I' or s[i].upper() == 'O' or s[i].upper() == 'U' or s[i].upper() == 'Y':
ans = 0
continue
ans = 1
if ans == 0:
print("YES")
... | 3.93 | MatrixStudio/Codeforces-Python-Submissions |
864 | B | Polycarp and Letters | PROGRAMMING | 1,000 | [
"brute force",
"implementation",
"strings"
] | null | null | Polycarp loves lowercase letters and dislikes uppercase ones. Once he got a string *s* consisting only of lowercase and uppercase Latin letters.
Let *A* be a set of positions in the string. Let's call it pretty if following conditions are met:
- letters on positions from *A* in the string are all distinct and lowerc... | The first line contains a single integer *n* (1<=≤<=*n*<=≤<=200) — length of string *s*.
The second line contains a string *s* consisting of lowercase and uppercase Latin letters. | Print maximum number of elements in pretty set of positions for string *s*. | [
"11\naaaaBaabAbA\n",
"12\nzACaAbbaazzC\n",
"3\nABC\n"
] | [
"2\n",
"3\n",
"0\n"
] | In the first example the desired positions might be 6 and 8 or 7 and 8. Positions 6 and 7 contain letters 'a', position 8 contains letter 'b'. The pair of positions 1 and 8 is not suitable because there is an uppercase letter 'B' between these position.
In the second example desired positions can be 7, 8 and 11. There... | 1,000 | [
{
"input": "11\naaaaBaabAbA",
"output": "2"
},
{
"input": "12\nzACaAbbaazzC",
"output": "3"
},
{
"input": "3\nABC",
"output": "0"
},
{
"input": "1\na",
"output": "1"
},
{
"input": "2\naz",
"output": "2"
},
{
"input": "200\nXbTJZqcbpYuZQEoUrbxlPXAPCtVLr... | 1,510,767,888 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 3 | 46 | 0 | n=int(input())
s=input()
c=set()
k=0
for i in s:
if i.isupper():
k=max(len(c),k)
c.clear()
else:
c.update(i)
print(k) | Title: Polycarp and Letters
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Polycarp loves lowercase letters and dislikes uppercase ones. Once he got a string *s* consisting only of lowercase and uppercase Latin letters.
Let *A* be a set of positions in the string. Let's call it pretty if... | ```python
n=int(input())
s=input()
c=set()
k=0
for i in s:
if i.isupper():
k=max(len(c),k)
c.clear()
else:
c.update(i)
print(k)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
514 | A | Chewbaсca and Number | PROGRAMMING | 1,200 | [
"greedy",
"implementation"
] | null | null | Luke Skywalker gave Chewbacca an integer number *x*. Chewbacca isn't good at numbers but he loves inverting digits in them. Inverting digit *t* means replacing it with digit 9<=-<=*t*.
Help Chewbacca to transform the initial number *x* to the minimum possible positive number by inverting some (possibly, zero) digits.... | The first line contains a single integer *x* (1<=≤<=*x*<=≤<=1018) — the number that Luke Skywalker gave to Chewbacca. | Print the minimum possible positive number that Chewbacca can obtain after inverting some digits. The number shouldn't contain leading zeroes. | [
"27\n",
"4545\n"
] | [
"22\n",
"4444\n"
] | none | 500 | [
{
"input": "27",
"output": "22"
},
{
"input": "4545",
"output": "4444"
},
{
"input": "1",
"output": "1"
},
{
"input": "9",
"output": "9"
},
{
"input": "8772",
"output": "1222"
},
{
"input": "81",
"output": "11"
},
{
"input": "71723447",
... | 1,695,105,891 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 46 | 0 | # Read the input
x = input().strip()
# Convert the first digit to an integer
first_digit = int(x[0])
# If the first digit is greater than its complement, keep it as is, else replace it
if first_digit <= 9 - first_digit:
result = str(first_digit)
else:
result = str(9 - first_digit)
# Append the complement of ... | Title: Chewbaсca and Number
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Luke Skywalker gave Chewbacca an integer number *x*. Chewbacca isn't good at numbers but he loves inverting digits in them. Inverting digit *t* means replacing it with digit 9<=-<=*t*.
Help Chewbacca to transform... | ```python
# Read the input
x = input().strip()
# Convert the first digit to an integer
first_digit = int(x[0])
# If the first digit is greater than its complement, keep it as is, else replace it
if first_digit <= 9 - first_digit:
result = str(first_digit)
else:
result = str(9 - first_digit)
# Append the comp... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
659 | A | Round House | PROGRAMMING | 1,000 | [
"implementation",
"math"
] | null | null | Vasya lives in a round building, whose entrances are numbered sequentially by integers from 1 to *n*. Entrance *n* and entrance 1 are adjacent.
Today Vasya got bored and decided to take a walk in the yard. Vasya lives in entrance *a* and he decided that during his walk he will move around the house *b* entrances in th... | The single line of the input contains three space-separated integers *n*, *a* and *b* (1<=≤<=*n*<=≤<=100,<=1<=≤<=*a*<=≤<=*n*,<=<=-<=100<=≤<=*b*<=≤<=100) — the number of entrances at Vasya's place, the number of his entrance and the length of his walk, respectively. | Print a single integer *k* (1<=≤<=*k*<=≤<=*n*) — the number of the entrance where Vasya will be at the end of his walk. | [
"6 2 -5\n",
"5 1 3\n",
"3 2 7\n"
] | [
"3\n",
"4\n",
"3\n"
] | The first example is illustrated by the picture in the statements. | 500 | [
{
"input": "6 2 -5",
"output": "3"
},
{
"input": "5 1 3",
"output": "4"
},
{
"input": "3 2 7",
"output": "3"
},
{
"input": "1 1 0",
"output": "1"
},
{
"input": "1 1 -1",
"output": "1"
},
{
"input": "1 1 1",
"output": "1"
},
{
"input": "100 ... | 1,521,411,986 | 2,147,483,647 | Python 3 | OK | TESTS | 50 | 93 | 7,065,600 | def f(l,start,step):
n=start+step
if n>=l:
n=n%l
while n<0:
n=l+n
return n+1
if __name__=='__main__':
a,b,c=map(int,input().split())
print(f(a,b-1,c)) | Title: Round House
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vasya lives in a round building, whose entrances are numbered sequentially by integers from 1 to *n*. Entrance *n* and entrance 1 are adjacent.
Today Vasya got bored and decided to take a walk in the yard. Vasya lives in e... | ```python
def f(l,start,step):
n=start+step
if n>=l:
n=n%l
while n<0:
n=l+n
return n+1
if __name__=='__main__':
a,b,c=map(int,input().split())
print(f(a,b-1,c))
``` | 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,633,196,078 | 2,147,483,647 | Python 3 | OK | TESTS | 102 | 77 | 6,758,400 | p, q = input(), input()
a = ""
for i in range(len(p)) :
if p[i] != q[i] :
a += "1"
else :
a += "0"
#ai = list(a)
#while ai[0] != "1" :
# ai.pop(ai.index(a[0]))
#aii = map(str, ai)
#af = "".join(aii)
print(a) | 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
p, q = input(), input()
a = ""
for i in range(len(p)) :
if p[i] != q[i] :
a += "1"
else :
a += "0"
#ai = list(a)
#while ai[0] != "1" :
# ai.pop(ai.index(a[0]))
#aii = map(str, ai)
#af = "".join(aii)
print(a)
``` | 3.968161 | 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,612,870,318 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 11 | 46 | 307,200 | a,b,c=map(int,input().split())
d=b*b-4*a*c
if a==0:
if b==0 and c==0: print(-1)
elif b==0: print(0)
else: print(f'1\n{-c/b}')
elif d<0: print(0)
else:
s=sorted({(-b+d**.5)/2*a,(-b-d**.5)/2*a})
print(len(s))
for i in s:
print(f'{i:.5f}') | 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
a,b,c=map(int,input().split())
d=b*b-4*a*c
if a==0:
if b==0 and c==0: print(-1)
elif b==0: print(0)
else: print(f'1\n{-c/b}')
elif d<0: print(0)
else:
s=sorted({(-b+d**.5)/2*a,(-b-d**.5)/2*a})
print(len(s))
for i in s:
print(f'{i:.5f}')
``` | 0 | MatrixStudio/Codeforces-Python-Submissions |
888 | A | Local Extrema | PROGRAMMING | 800 | [
"brute force",
"implementation"
] | null | null | You are given an array *a*. Some element of this array *a**i* is a local minimum iff it is strictly less than both of its neighbours (that is, *a**i*<=<<=*a**i*<=-<=1 and *a**i*<=<<=*a**i*<=+<=1). Also the element can be called local maximum iff it is strictly greater than its neighbours (that is, *a**i*<=><=*... | The first line contains one integer *n* (1<=≤<=*n*<=≤<=1000) — the number of elements in array *a*.
The second line contains *n* integers *a*1, *a*2, ..., *a**n* (1<=≤<=*a**i*<=≤<=1000) — the elements of array *a*. | Print the number of local extrema in the given array. | [
"3\n1 2 3\n",
"4\n1 5 2 5\n"
] | [
"0\n",
"2\n"
] | none | 0 | [
{
"input": "3\n1 2 3",
"output": "0"
},
{
"input": "4\n1 5 2 5",
"output": "2"
},
{
"input": "1\n1",
"output": "0"
},
{
"input": "1\n548",
"output": "0"
},
{
"input": "2\n1 1",
"output": "0"
},
{
"input": "3\n3 2 3",
"output": "1"
},
{
"inp... | 1,671,551,685 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 31 | 0 | n=int(input())
arr=list(map(int,input()))
ans=0
for i in range(1,n-1):
if arr[i]<arr[i-1] and arr[i]<arr[i+1]:
ans+=1
elif arr[i]>arr[i-1] and arr[i]>arr[i+1]:
ans+=1
print(ans)
| Title: Local Extrema
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given an array *a*. Some element of this array *a**i* is a local minimum iff it is strictly less than both of its neighbours (that is, *a**i*<=<<=*a**i*<=-<=1 and *a**i*<=<<=*a**i*<=+<=1). Also the element c... | ```python
n=int(input())
arr=list(map(int,input()))
ans=0
for i in range(1,n-1):
if arr[i]<arr[i-1] and arr[i]<arr[i+1]:
ans+=1
elif arr[i]>arr[i-1] and arr[i]>arr[i+1]:
ans+=1
print(ans)
``` | -1 | MatrixStudio/Codeforces-Python-Submissions | |
365 | A | Good Number | PROGRAMMING | 1,100 | [
"implementation"
] | null | null | Let's call a number *k*-good if it contains all digits not exceeding *k* (0,<=...,<=*k*). You've got a number *k* and an array *a* containing *n* numbers. Find out how many *k*-good numbers are in *a* (count each number every time it occurs in array *a*). | The first line contains integers *n* and *k* (1<=≤<=*n*<=≤<=100, 0<=≤<=*k*<=≤<=9). The *i*-th of the following *n* lines contains integer *a**i* without leading zeroes (1<=≤<=*a**i*<=≤<=109). | Print a single integer — the number of *k*-good numbers in *a*. | [
"10 6\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n",
"2 1\n1\n10\n"
] | [
"10\n",
"1\n"
] | none | 500 | [
{
"input": "10 6\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560",
"output": "10"
},
{
"input": "2 1\n1\n10",
"output": "1"
},
{
"input": "1 0\n1000000000",
"output": "1"
},
{
"input": "1 1\n1000000000",
"output": "1"
},
{
... | 1,678,821,246 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 37 | 62 | 0 | n, k = list(map(int, input().split()))
c = 0
s = set(map(str, range(k + 1)))
for i in range(n):
x = set(input())
if s.issubset(x):
c += 1
print(c) | Title: Good Number
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Let's call a number *k*-good if it contains all digits not exceeding *k* (0,<=...,<=*k*). You've got a number *k* and an array *a* containing *n* numbers. Find out how many *k*-good numbers are in *a* (count each number eve... | ```python
n, k = list(map(int, input().split()))
c = 0
s = set(map(str, range(k + 1)))
for i in range(n):
x = set(input())
if s.issubset(x):
c += 1
print(c)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
291 | A | Spyke Talks | PROGRAMMING | 800 | [
"*special",
"implementation",
"sortings"
] | null | null | Polycarpus is the director of a large corporation. There are *n* secretaries working for the corporation, each of them corresponds via the famous Spyke VoIP system during the day. We know that when two people call each other via Spyke, the Spyke network assigns a unique ID to this call, a positive integer session numbe... | The first line contains integer *n* (1<=≤<=*n*<=≤<=103) — the number of secretaries in Polycarpus's corporation. The next line contains *n* space-separated integers: *id*1,<=*id*2,<=...,<=*id**n* (0<=≤<=*id**i*<=≤<=109). Number *id**i* equals the number of the call session of the *i*-th secretary, if the secretary is t... | Print a single integer — the number of pairs of chatting secretaries, or -1 if Polycarpus's got a mistake in his records and the described situation could not have taken place. | [
"6\n0 1 7 1 7 10\n",
"3\n1 1 1\n",
"1\n0\n"
] | [
"2\n",
"-1\n",
"0\n"
] | In the first test sample there are two Spyke calls between secretaries: secretary 2 and secretary 4, secretary 3 and secretary 5.
In the second test sample the described situation is impossible as conferences aren't allowed. | 500 | [
{
"input": "6\n0 1 7 1 7 10",
"output": "2"
},
{
"input": "3\n1 1 1",
"output": "-1"
},
{
"input": "1\n0",
"output": "0"
},
{
"input": "5\n2 2 1 1 3",
"output": "2"
},
{
"input": "1\n1",
"output": "0"
},
{
"input": "10\n4 21 3 21 21 1 1 2 2 3",
"ou... | 1,589,637,043 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 3 | 186 | 6,963,200 | n = int(input())
l = list(map(int,input().split()))
p = []
q = []
count = 0
if len(set(l))==1 and l[0]!=0:
print(-1)
else:
for i in range(0,n,2):
p.append(l[i])
for i in range(1,n,2):
q.append(l[i])
setp = set(p)
setq = set(q)
for k in setp:
if p.count(k)==2:
count += 1
for k in setq:... | Title: Spyke Talks
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Polycarpus is the director of a large corporation. There are *n* secretaries working for the corporation, each of them corresponds via the famous Spyke VoIP system during the day. We know that when two people call each othe... | ```python
n = int(input())
l = list(map(int,input().split()))
p = []
q = []
count = 0
if len(set(l))==1 and l[0]!=0:
print(-1)
else:
for i in range(0,n,2):
p.append(l[i])
for i in range(1,n,2):
q.append(l[i])
setp = set(p)
setq = set(q)
for k in setp:
if p.count(k)==2:
count += 1
for ... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
500 | A | New Year Transportation | PROGRAMMING | 1,000 | [
"dfs and similar",
"graphs",
"implementation"
] | null | null | New Year is coming in Line World! In this world, there are *n* cells numbered by integers from 1 to *n*, as a 1<=×<=*n* board. People live in cells. However, it was hard to move between distinct cells, because of the difficulty of escaping the cell. People wanted to meet people who live in other cells.
So, user tncks0... | The first line contains two space-separated integers *n* (3<=≤<=*n*<=≤<=3<=×<=104) and *t* (2<=≤<=*t*<=≤<=*n*) — the number of cells, and the index of the cell which I want to go to.
The second line contains *n*<=-<=1 space-separated integers *a*1,<=*a*2,<=...,<=*a**n*<=-<=1 (1<=≤<=*a**i*<=≤<=*n*<=-<=*i*). It is guara... | If I can go to cell *t* using the transportation system, print "YES". Otherwise, print "NO". | [
"8 4\n1 2 1 2 1 2 1\n",
"8 5\n1 2 1 2 1 1 1\n"
] | [
"YES\n",
"NO\n"
] | In the first sample, the visited cells are: 1, 2, 4; so we can successfully visit the cell 4.
In the second sample, the possible cells to visit are: 1, 2, 4, 6, 7, 8; so we can't visit the cell 5, which we want to visit. | 500 | [
{
"input": "8 4\n1 2 1 2 1 2 1",
"output": "YES"
},
{
"input": "8 5\n1 2 1 2 1 1 1",
"output": "NO"
},
{
"input": "20 19\n13 16 7 6 12 1 5 7 8 6 5 7 5 5 3 3 2 2 1",
"output": "YES"
},
{
"input": "50 49\n11 7 1 41 26 36 19 16 38 14 36 35 37 27 20 27 3 6 21 2 27 11 18 17 19 16 ... | 1,673,508,341 | 2,147,483,647 | PyPy 3 | OK | TESTS | 34 | 92 | 3,891,200 | I=lambda:map(int,input().split())
n,t=I()
a=list(I())
c=0
while c<t-1:c+=a[c]
print('YNEOS'[c>=t::2]) | Title: New Year Transportation
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
New Year is coming in Line World! In this world, there are *n* cells numbered by integers from 1 to *n*, as a 1<=×<=*n* board. People live in cells. However, it was hard to move between distinct cells, because o... | ```python
I=lambda:map(int,input().split())
n,t=I()
a=list(I())
c=0
while c<t-1:c+=a[c]
print('YNEOS'[c>=t::2])
``` | 3 | 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,666,198,576 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 5 | 1,000 | 0 | n,x =map(int, input().split())
a=[]
t=0
w=0
e=((n//2)**2)
if x<=e:
for i in range(1, n//2+1):
for j in range(1, i + 1):
t = i * j
if t == x:
if i == j:
w += 1
else:
w += 2
else:
for i in range(... | Title: Multiplication Table
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Let's consider a table consisting of *n* rows and *n* columns. The cell located at the intersection of *i*-th row and *j*-th column contains number *i*<=×<=*j*. The rows and columns are numbered starting from 1.
Y... | ```python
n,x =map(int, input().split())
a=[]
t=0
w=0
e=((n//2)**2)
if x<=e:
for i in range(1, n//2+1):
for j in range(1, i + 1):
t = i * j
if t == x:
if i == j:
w += 1
else:
w += 2
else:
for i... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
540 | A | Combination Lock | PROGRAMMING | 800 | [
"implementation"
] | null | null | Scrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to put there the treasures that he's earned fair and square, he has to open the lock.
The combination lock is represented by *n* rotating disks with digits from 0 to 9 written on them. Scrooge McDuck has to turn ... | The first line contains a single integer *n* (1<=≤<=*n*<=≤<=1000) — the number of disks on the combination lock.
The second line contains a string of *n* digits — the original state of the disks.
The third line contains a string of *n* digits — Scrooge McDuck's combination that opens the lock. | Print a single integer — the minimum number of moves Scrooge McDuck needs to open the lock. | [
"5\n82195\n64723\n"
] | [
"13\n"
] | In the sample he needs 13 moves:
- 1 disk: <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/b8967f65a723782358b93eff9ce69f336817cf70.png" style="max-width: 100.0%;max-height: 100.0%;"/> - 2 disk: <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/07fa58573ece0d32... | 500 | [
{
"input": "5\n82195\n64723",
"output": "13"
},
{
"input": "12\n102021090898\n010212908089",
"output": "16"
},
{
"input": "1\n8\n1",
"output": "3"
},
{
"input": "2\n83\n57",
"output": "7"
},
{
"input": "10\n0728592530\n1362615763",
"output": "27"
},
{
... | 1,600,878,747 | 2,147,483,647 | Python 3 | OK | TESTS | 43 | 124 | 0 | n = int(input())
ori = input()
combi = input()
tot = 0
for a in range(n):
o = int(ori[a])
c = int(combi[a])
mi = min(c,o)
ma = max(c,o)
tot += min(ma-mi, 9-ma+mi+1)
print(tot)
| Title: Combination Lock
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Scrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to put there the treasures that he's earned fair and square, he has to open the lock.
The combination lock is ... | ```python
n = int(input())
ori = input()
combi = input()
tot = 0
for a in range(n):
o = int(ori[a])
c = int(combi[a])
mi = min(c,o)
ma = max(c,o)
tot += min(ma-mi, 9-ma+mi+1)
print(tot)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
723 | A | The New Year: Meeting Friends | PROGRAMMING | 800 | [
"implementation",
"math",
"sortings"
] | null | null | There are three friend living on the straight line *Ox* in Lineland. The first friend lives at the point *x*1, the second friend lives at the point *x*2, and the third friend lives at the point *x*3. They plan to celebrate the New Year together, so they need to meet at one point. What is the minimum total distance they... | The first line of the input contains three distinct integers *x*1, *x*2 and *x*3 (1<=≤<=*x*1,<=*x*2,<=*x*3<=≤<=100) — the coordinates of the houses of the first, the second and the third friends respectively. | Print one integer — the minimum total distance the friends need to travel in order to meet together. | [
"7 1 4\n",
"30 20 10\n"
] | [
"6\n",
"20\n"
] | In the first sample, friends should meet at the point 4. Thus, the first friend has to travel the distance of 3 (from the point 7 to the point 4), the second friend also has to travel the distance of 3 (from the point 1 to the point 4), while the third friend should not go anywhere because he lives at the point 4. | 500 | [
{
"input": "7 1 4",
"output": "6"
},
{
"input": "30 20 10",
"output": "20"
},
{
"input": "1 4 100",
"output": "99"
},
{
"input": "100 1 91",
"output": "99"
},
{
"input": "1 45 100",
"output": "99"
},
{
"input": "1 2 3",
"output": "2"
},
{
"... | 1,676,537,372 | 2,147,483,647 | Python 3 | OK | TESTS | 48 | 46 | 0 | x,y,z=map(int,input().split())
c=(x+z+y)-(min(x,z,y)+max(x,y,z))
print((max(x,y,z)-c)+(c-min(x,z,y)))
| Title: The New Year: Meeting Friends
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
There are three friend living on the straight line *Ox* in Lineland. The first friend lives at the point *x*1, the second friend lives at the point *x*2, and the third friend lives at the point *x*3. They ... | ```python
x,y,z=map(int,input().split())
c=(x+z+y)-(min(x,z,y)+max(x,y,z))
print((max(x,y,z)-c)+(c-min(x,z,y)))
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
0 | none | none | none | 0 | [
"none"
] | null | null | Some time ago Mister B detected a strange signal from the space, which he started to study.
After some transformation the signal turned out to be a permutation *p* of length *n* or its cyclic shift. For the further investigation Mister B need some basis, that's why he decided to choose cyclic shift of this permutation... | First line contains single integer *n* (2<=≤<=*n*<=≤<=106) — the length of the permutation.
The second line contains *n* space-separated integers *p*1,<=*p*2,<=...,<=*p**n* (1<=≤<=*p**i*<=≤<=*n*) — the elements of the permutation. It is guaranteed that all elements are distinct. | Print two integers: the minimum deviation of cyclic shifts of permutation *p* and the id of such shift. If there are multiple solutions, print any of them. | [
"3\n1 2 3\n",
"3\n2 3 1\n",
"3\n3 2 1\n"
] | [
"0 0\n",
"0 1\n",
"2 1\n"
] | In the first sample test the given permutation *p* is the identity permutation, that's why its deviation equals to 0, the shift id equals to 0 as well.
In the second sample test the deviation of *p* equals to 4, the deviation of the 1-st cyclic shift (1, 2, 3) equals to 0, the deviation of the 2-nd cyclic shift (3, 1,... | 0 | [
{
"input": "3\n1 2 3",
"output": "0 0"
},
{
"input": "3\n2 3 1",
"output": "0 1"
},
{
"input": "3\n3 2 1",
"output": "2 1"
},
{
"input": "2\n1 2",
"output": "0 0"
},
{
"input": "2\n2 1",
"output": "0 1"
},
{
"input": "10\n10 1 9 2 8 3 7 4 6 5",
"ou... | 1,498,580,441 | 6,341 | Python 3 | WRONG_ANSWER | PRETESTS | 5 | 46 | 5,529,600 | n=int(input())
data=list(map(int,input().split()))
ans=temp=c=0
for i in range(n):
temp+=data[i]-i-1
if temp>ans:
ans=temp
c=i+1
shift=n-c
shift%=n
data=data[n-shift:]+data[:n-shift]
sum=0
for i,item in enumerate(data):
sum+=abs(item-i-1)
print(sum, shift)
| Title: none
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Some time ago Mister B detected a strange signal from the space, which he started to study.
After some transformation the signal turned out to be a permutation *p* of length *n* or its cyclic shift. For the further investigation ... | ```python
n=int(input())
data=list(map(int,input().split()))
ans=temp=c=0
for i in range(n):
temp+=data[i]-i-1
if temp>ans:
ans=temp
c=i+1
shift=n-c
shift%=n
data=data[n-shift:]+data[:n-shift]
sum=0
for i,item in enumerate(data):
sum+=abs(item-i-1)
print(sum, shift)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
747 | A | Display Size | PROGRAMMING | 800 | [
"brute force",
"math"
] | null | null | A big company decided to launch a new series of rectangular displays, and decided that the display must have exactly *n* pixels.
Your task is to determine the size of the rectangular display — the number of lines (rows) of pixels *a* and the number of columns of pixels *b*, so that:
- there are exactly *n* pixels o... | The first line contains the positive integer *n* (1<=≤<=*n*<=≤<=106) — the number of pixels display should have. | Print two integers — the number of rows and columns on the display. | [
"8\n",
"64\n",
"5\n",
"999999\n"
] | [
"2 4\n",
"8 8\n",
"1 5\n",
"999 1001\n"
] | In the first example the minimum possible difference equals 2, so on the display should be 2 rows of 4 pixels.
In the second example the minimum possible difference equals 0, so on the display should be 8 rows of 8 pixels.
In the third example the minimum possible difference equals 4, so on the display should be 1 ro... | 500 | [
{
"input": "8",
"output": "2 4"
},
{
"input": "64",
"output": "8 8"
},
{
"input": "5",
"output": "1 5"
},
{
"input": "999999",
"output": "999 1001"
},
{
"input": "716539",
"output": "97 7387"
},
{
"input": "1",
"output": "1 1"
},
{
"input":... | 1,693,338,373 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 43 | 62 | 0 | a = int(input())
ref= int(a ** 0.5)
while (a % ref != 0 ):
ref-= 1
print(ref , a // ref )
| Title: Display Size
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
A big company decided to launch a new series of rectangular displays, and decided that the display must have exactly *n* pixels.
Your task is to determine the size of the rectangular display — the number of lines (rows) ... | ```python
a = int(input())
ref= int(a ** 0.5)
while (a % ref != 0 ):
ref-= 1
print(ref , a // ref )
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
218 | A | Mountain Scenery | PROGRAMMING | 1,100 | [
"brute force",
"constructive algorithms",
"implementation"
] | null | null | Little Bolek has found a picture with *n* mountain peaks painted on it. The *n* painted peaks are represented by a non-closed polyline, consisting of 2*n* segments. The segments go through 2*n*<=+<=1 points with coordinates (1,<=*y*1), (2,<=*y*2), ..., (2*n*<=+<=1,<=*y*2*n*<=+<=1), with the *i*-th segment connecting th... | The first line contains two space-separated integers *n* and *k* (1<=≤<=*k*<=≤<=*n*<=≤<=100). The next line contains 2*n*<=+<=1 space-separated integers *r*1,<=*r*2,<=...,<=*r*2*n*<=+<=1 (0<=≤<=*r**i*<=≤<=100) — the *y* coordinates of the polyline vertices on Bolek's picture.
It is guaranteed that we can obtain the gi... | Print 2*n*<=+<=1 integers *y*1,<=*y*2,<=...,<=*y*2*n*<=+<=1 — the *y* coordinates of the vertices of the polyline on the initial picture. If there are multiple answers, output any one of them. | [
"3 2\n0 5 3 5 1 5 2\n",
"1 1\n0 2 0\n"
] | [
"0 5 3 4 1 4 2 \n",
"0 1 0 \n"
] | none | 500 | [
{
"input": "3 2\n0 5 3 5 1 5 2",
"output": "0 5 3 4 1 4 2 "
},
{
"input": "1 1\n0 2 0",
"output": "0 1 0 "
},
{
"input": "1 1\n1 100 0",
"output": "1 99 0 "
},
{
"input": "3 1\n0 1 0 1 0 2 0",
"output": "0 1 0 1 0 1 0 "
},
{
"input": "3 1\n0 1 0 2 0 1 0",
"out... | 1,555,536,902 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 186 | 0 | n, k = input().split(' ')
n = int(n)
k = int(k)
rarr = input().split(' ')
rarr = list(map(lambda x: int(x), rarr))
total = 0
for i in range(n):
if total == k:
break
if rarr[2 * i] < rarr[2 * i + 1] - 1 and rarr[2 * i + 1] - 1 > rarr[2 * i + 2]:
print('@', i)
rarr[2 * i + 1] = rarr[2 * ... | Title: Mountain Scenery
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Little Bolek has found a picture with *n* mountain peaks painted on it. The *n* painted peaks are represented by a non-closed polyline, consisting of 2*n* segments. The segments go through 2*n*<=+<=1 points with coordi... | ```python
n, k = input().split(' ')
n = int(n)
k = int(k)
rarr = input().split(' ')
rarr = list(map(lambda x: int(x), rarr))
total = 0
for i in range(n):
if total == k:
break
if rarr[2 * i] < rarr[2 * i + 1] - 1 and rarr[2 * i + 1] - 1 > rarr[2 * i + 2]:
print('@', i)
rarr[2 * i + 1] =... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
32 | A | Reconnaissance | PROGRAMMING | 800 | [
"brute force"
] | A. Reconnaissance | 2 | 256 | According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most *d* centimeters. Captain Bob has *n* soldiers in his detachment. Their heights are *a*1,<=*a*2,<=...,<=*a**n* centimeters. Som... | The first line contains two integers *n* and *d* (1<=≤<=*n*<=≤<=1000,<=1<=≤<=*d*<=≤<=109) — amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains *n* space-separated integers — heights of all the soldiers in Bob's detachment. These numbers don't exceed 1... | Output one number — amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed *d*. | [
"5 10\n10 20 50 60 65\n",
"5 1\n55 30 29 31 55\n"
] | [
"6\n",
"6\n"
] | none | 500 | [
{
"input": "5 10\n10 20 50 60 65",
"output": "6"
},
{
"input": "5 1\n55 30 29 31 55",
"output": "6"
},
{
"input": "6 10\n4 6 4 1 9 3",
"output": "30"
},
{
"input": "7 100\n19 1694 261 162 1 234 513",
"output": "8"
},
{
"input": "8 42\n37 53 74 187 568 22 5 65",
... | 1,592,402,778 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 0 | 216 | 0 |
n , d = map(int,input().split())
h = list(map(int,input().split()))
h.sort()
cnt = 0
l = 0
r = 1
while(l<r) :
if h[r]-h[l] <=d :
cnt = cnt + 1
r = r + 1
else :
l = l + 1
r = l + 1
if l == n :
break
... | Title: Reconnaissance
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most *d* centimeters. Captain Bob h... | ```python
n , d = map(int,input().split())
h = list(map(int,input().split()))
h.sort()
cnt = 0
l = 0
r = 1
while(l<r) :
if h[r]-h[l] <=d :
cnt = cnt + 1
r = r + 1
else :
l = l + 1
r = l + 1
if l == n :
break
... | 0 | MatrixStudio/Codeforces-Python-Submissions |
958 | F2 | Lightsabers (medium) | PROGRAMMING | 1,800 | [
"binary search",
"two pointers"
] | null | null | There is unrest in the Galactic Senate. Several thousand solar systems have declared their intentions to leave the Republic. Master Heidi needs to select the Jedi Knights who will go on peacekeeping missions throughout the galaxy. It is well-known that the success of any peacekeeping mission depends on the colors of th... | The first line of the input contains *n* (1<=≤<=*n*<=≤<=2·105) and *m* (1<=≤<=*m*<=≤<=*n*). The second line contains *n* integers in the range {1,<=2,<=...,<=*m*} representing colors of the lightsabers of the subsequent Jedi Knights. The third line contains *m* integers *k*1,<=*k*2,<=...,<=*k**m* (with ) – the desired ... | Output one number: the minimum number of Jedi Knights that need to be removed from the sequence so that, in what remains, there is an interval with the prescribed counts of lightsaber colors. If this is not possible, output <=-<=1. | [
"8 3\n3 3 1 2 2 1 1 3\n3 1 1\n"
] | [
"1\n"
] | none | 0 | [
{
"input": "8 3\n3 3 1 2 2 1 1 3\n3 1 1",
"output": "1"
},
{
"input": "6 5\n1 2 4 2 4 3\n0 0 1 0 0",
"output": "0"
},
{
"input": "1 1\n1\n1",
"output": "0"
},
{
"input": "2 1\n1 1\n1",
"output": "0"
},
{
"input": "2 1\n1 1\n2",
"output": "0"
},
{
"inpu... | 1,594,207,023 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 8 | 93 | 6,963,200 | n,m=list(map(int,input().split()))
arr=list(map(int,input().split()))
marr=list(map(int,input().split()))
f=[0]*(m+1)
cnt=0
valid=sum(marr) #m
for i in range(n):
f[arr[i]]+=1
if f[arr[i]]<=marr[arr[i]-1]:
cnt+=1
if cnt==valid:
break
ans=(i+1)-valid
s,e=0,i
while(e<n):... | Title: Lightsabers (medium)
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
There is unrest in the Galactic Senate. Several thousand solar systems have declared their intentions to leave the Republic. Master Heidi needs to select the Jedi Knights who will go on peacekeeping missions throug... | ```python
n,m=list(map(int,input().split()))
arr=list(map(int,input().split()))
marr=list(map(int,input().split()))
f=[0]*(m+1)
cnt=0
valid=sum(marr) #m
for i in range(n):
f[arr[i]]+=1
if f[arr[i]]<=marr[arr[i]-1]:
cnt+=1
if cnt==valid:
break
ans=(i+1)-valid
s,e=0,i
w... | 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,683,193,143 | 2,147,483,647 | Python 3 | OK | TESTS | 30 | 92 | 0 | x = input()
uppercase = 0
lowercase = 0
for char in x:
if char.isupper():
uppercase += 1
else:
lowercase += 1
if uppercase > lowercase:
print(x.upper())
elif lowercase > uppercase:
print(x.lower())
else:
print(x.lower())
quit()
| 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
x = input()
uppercase = 0
lowercase = 0
for char in x:
if char.isupper():
uppercase += 1
else:
lowercase += 1
if uppercase > lowercase:
print(x.upper())
elif lowercase > uppercase:
print(x.lower())
else:
print(x.lower())
quit()
``` | 3.977 | MatrixStudio/Codeforces-Python-Submissions |
88 | B | Keyboard | PROGRAMMING | 1,500 | [
"implementation"
] | B. Keyboard | 1 | 256 | Vasya learns to type. He has an unusual keyboard at his disposal: it is rectangular and it has *n* rows of keys containing *m* keys in each row. Besides, the keys are of two types. Some of the keys have lowercase Latin letters on them and some of the keys work like the "Shift" key on standard keyboards, that is, they m... | The first line contains three integers *n*, *m*, *x* (1<=≤<=*n*,<=*m*<=≤<=30,<=1<=≤<=*x*<=≤<=50).
Next *n* lines contain descriptions of all the keyboard keys. Each line contains the descriptions of exactly *m* keys, without spaces. The letter keys are marked with the corresponding lowercase letters. The "Shift" keys ... | If Vasya can type the text, then print the minimum number of times he will have to use his other hand. Otherwise, print "-1" (without the quotes). | [
"2 2 1\nab\ncd\n1\nA\n",
"2 2 1\nab\ncd\n1\ne\n",
"2 2 1\nab\ncS\n5\nabcBA\n",
"3 9 4\nqwertyuio\nasdfghjkl\nSzxcvbnmS\n35\nTheQuIcKbRoWnFOXjummsovertHeLazYDOG\n"
] | [
"-1\n",
"-1\n",
"1\n",
"2\n"
] | In the first sample the symbol "A" is impossible to print as there's no "Shift" key on the keyboard.
In the second sample the symbol "e" is impossible to print as there's no such key on the keyboard.
In the fourth sample the symbols "T", "G" are impossible to print with one hand. The other letters that are on the key... | 1,000 | [
{
"input": "2 2 1\nab\ncd\n1\nA",
"output": "-1"
},
{
"input": "2 2 1\nab\ncd\n1\ne",
"output": "-1"
},
{
"input": "2 2 1\nab\ncS\n5\nabcBA",
"output": "1"
},
{
"input": "3 9 4\nqwertyuio\nasdfghjkl\nSzxcvbnmS\n35\nTheQuIcKbRoWnFOXjummsovertHeLazYDOG",
"output": "2"
},
... | 1,558,549,917 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 109 | 102,400 | import math
from collections import deque, defaultdict
from sys import stdin, stdout
#input = stdin.readline
# print = stdout.write
listin = lambda : list(map(int, input().split()))
mapin = lambda : map(int, input().split())
n, m, x = mapin()
a = []
for i in range(n):
a.append(input())
q = int(input())
s = input()
... | Title: Keyboard
Time Limit: 1 seconds
Memory Limit: 256 megabytes
Problem Description:
Vasya learns to type. He has an unusual keyboard at his disposal: it is rectangular and it has *n* rows of keys containing *m* keys in each row. Besides, the keys are of two types. Some of the keys have lowercase Latin letters on ... | ```python
import math
from collections import deque, defaultdict
from sys import stdin, stdout
#input = stdin.readline
# print = stdout.write
listin = lambda : list(map(int, input().split()))
mapin = lambda : map(int, input().split())
n, m, x = mapin()
a = []
for i in range(n):
a.append(input())
q = int(input())
s ... | 0 | MatrixStudio/Codeforces-Python-Submissions |
614 | A | Link/Cut Tree | PROGRAMMING | 1,500 | [
"brute force",
"implementation"
] | null | null | Programmer Rostislav got seriously interested in the Link/Cut Tree data structure, which is based on Splay trees. Specifically, he is now studying the *expose* procedure.
Unfortunately, Rostislav is unable to understand the definition of this procedure, so he decided to ask programmer Serezha to help him. Serezha agre... | The first line of the input contains three space-separated integers *l*, *r* and *k* (1<=≤<=*l*<=≤<=*r*<=≤<=1018, 2<=≤<=*k*<=≤<=109). | Print all powers of number *k*, that lie within range from *l* to *r* in the increasing order. If there are no such numbers, print "-1" (without the quotes). | [
"1 10 2\n",
"2 4 5\n"
] | [
"1 2 4 8 ",
"-1"
] | Note to the first sample: numbers 2<sup class="upper-index">0</sup> = 1, 2<sup class="upper-index">1</sup> = 2, 2<sup class="upper-index">2</sup> = 4, 2<sup class="upper-index">3</sup> = 8 lie within the specified range. The number 2<sup class="upper-index">4</sup> = 16 is greater then 10, thus it shouldn't be printed. | 500 | [
{
"input": "1 10 2",
"output": "1 2 4 8 "
},
{
"input": "2 4 5",
"output": "-1"
},
{
"input": "18102 43332383920 28554",
"output": "28554 815330916 "
},
{
"input": "19562 31702689720 17701",
"output": "313325401 "
},
{
"input": "11729 55221128400 313",
"output... | 1,652,968,052 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 3 | 46 | 4,505,600 | l,r,k = (list)(map(int , input().split()))
if l>k or k>r :
if l == 1 : print(1)
else : print(-1)
else :
mul = 1
ans = 0
while mul <= r :
if mul >= l : print(mul , end=" ")
mul *= k | Title: Link/Cut Tree
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Programmer Rostislav got seriously interested in the Link/Cut Tree data structure, which is based on Splay trees. Specifically, he is now studying the *expose* procedure.
Unfortunately, Rostislav is unable to understand ... | ```python
l,r,k = (list)(map(int , input().split()))
if l>k or k>r :
if l == 1 : print(1)
else : print(-1)
else :
mul = 1
ans = 0
while mul <= r :
if mul >= l : print(mul , end=" ")
mul *= k
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
733 | A | Grasshopper And the String | PROGRAMMING | 1,000 | [
"implementation"
] | null | null | One day, the Grasshopper was jumping on the lawn and found a piece of paper with a string. Grasshopper became interested what is the minimum jump ability he should have in order to be able to reach the far end of the string, jumping only on vowels of the English alphabet. Jump ability is the maximum possible length of ... | The first line contains non-empty string consisting of capital English letters. It is guaranteed that the length of the string does not exceed 100. | Print single integer *a* — the minimum jump ability of the Grasshopper (in the number of symbols) that is needed to overcome the given string, jumping only on vowels. | [
"ABABBBACFEYUKOTT\n",
"AAA\n"
] | [
"4",
"1"
] | none | 500 | [
{
"input": "ABABBBACFEYUKOTT",
"output": "4"
},
{
"input": "AAA",
"output": "1"
},
{
"input": "A",
"output": "1"
},
{
"input": "B",
"output": "2"
},
{
"input": "AEYUIOAEIYAEOUIYOEIUYEAOIUEOEAYOEIUYAEOUIYEOIKLMJNHGTRWSDZXCVBNMHGFDSXVWRTPPPLKMNBXIUOIUOIUOIUOOIU",
... | 1,682,567,349 | 2,147,483,647 | PyPy 3 | RUNTIME_ERROR | TESTS | 3 | 109 | 2,048,000 | vowels = {"A","E","I","O","Y","U"}
st = input()
x=0
c=1
j=[]
while x < len(st):
if set(st[x]) <= vowels:
j.append(c)
c = 1
else:
c+=1
x+=1
print(max(j)) | Title: Grasshopper And the String
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
One day, the Grasshopper was jumping on the lawn and found a piece of paper with a string. Grasshopper became interested what is the minimum jump ability he should have in order to be able to reach the far en... | ```python
vowels = {"A","E","I","O","Y","U"}
st = input()
x=0
c=1
j=[]
while x < len(st):
if set(st[x]) <= vowels:
j.append(c)
c = 1
else:
c+=1
x+=1
print(max(j))
``` | -1 | MatrixStudio/Codeforces-Python-Submissions | |
0 | none | none | none | 0 | [
"none"
] | null | null | You are given an array *a* with *n* distinct integers. Construct an array *b* by permuting *a* such that for every non-empty subset of indices *S*<==<={*x*1,<=*x*2,<=...,<=*x**k*} (1<=≤<=*x**i*<=≤<=*n*, 0<=<<=*k*<=<<=*n*) the sums of elements on that positions in *a* and *b* are different, i. e. | The first line contains one integer *n* (1<=≤<=*n*<=≤<=22) — the size of the array.
The second line contains *n* space-separated distinct integers *a*1,<=*a*2,<=...,<=*a**n* (0<=≤<=*a**i*<=≤<=109) — the elements of the array. | If there is no such array *b*, print -1.
Otherwise in the only line print *n* space-separated integers *b*1,<=*b*2,<=...,<=*b**n*. Note that *b* must be a permutation of *a*.
If there are multiple answers, print any of them. | [
"2\n1 2\n",
"4\n1000 100 10 1\n"
] | [
"2 1 \n",
"100 1 1000 10\n"
] | An array *x* is a permutation of *y*, if we can shuffle elements of *y* such that it will coincide with *x*.
Note that the empty subset and the subset containing all indices are not counted. | 0 | [
{
"input": "2\n1 2",
"output": "2 1 "
},
{
"input": "4\n1000 100 10 1",
"output": "100 1 1000 10"
},
{
"input": "5\n1 3 4 5 2",
"output": "5 2 3 4 1 "
},
{
"input": "1\n10000000",
"output": "10000000 "
},
{
"input": "4\n1 5 8 4",
"output": "8 4 5 1 "
},
{
... | 1,510,945,920 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 46 | 0 | n = int(input())
a = list(map(int, input().split()))
ca = sorted(a)
ca = [a[-1]] + a[:-1]
if ca == a:
print(-1)
exit()
print(' '.join([str(i) for i in a])) | Title: none
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given an array *a* with *n* distinct integers. Construct an array *b* by permuting *a* such that for every non-empty subset of indices *S*<==<={*x*1,<=*x*2,<=...,<=*x**k*} (1<=≤<=*x**i*<=≤<=*n*, 0<=<<=*k*<=<<=*n*) th... | ```python
n = int(input())
a = list(map(int, input().split()))
ca = sorted(a)
ca = [a[-1]] + a[:-1]
if ca == a:
print(-1)
exit()
print(' '.join([str(i) for i in a]))
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
740 | B | Alyona and flowers | PROGRAMMING | 1,200 | [
"constructive algorithms"
] | null | null | Little Alyona is celebrating Happy Birthday! Her mother has an array of *n* flowers. Each flower has some mood, the mood of *i*-th flower is *a**i*. The mood can be positive, zero or negative.
Let's define a subarray as a segment of consecutive flowers. The mother suggested some set of subarrays. Alyona wants to choos... | The first line contains two integers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=100) — the number of flowers and the number of subarrays suggested by the mother.
The second line contains the flowers moods — *n* integers *a*1,<=*a*2,<=...,<=*a**n* (<=-<=100<=≤<=*a**i*<=≤<=100).
The next *m* lines contain the description of the ... | Print single integer — the maximum possible value added to the Alyona's happiness. | [
"5 4\n1 -2 1 3 -4\n1 2\n4 5\n3 4\n1 4\n",
"4 3\n1 2 3 4\n1 3\n2 4\n1 1\n",
"2 2\n-1 -2\n1 1\n1 2\n"
] | [
"7\n",
"16\n",
"0\n"
] | The first example is the situation described in the statements.
In the second example Alyona should choose all subarrays.
The third example has answer 0 because Alyona can choose none of the subarrays. | 1,000 | [
{
"input": "5 4\n1 -2 1 3 -4\n1 2\n4 5\n3 4\n1 4",
"output": "7"
},
{
"input": "4 3\n1 2 3 4\n1 3\n2 4\n1 1",
"output": "16"
},
{
"input": "2 2\n-1 -2\n1 1\n1 2",
"output": "0"
},
{
"input": "5 6\n1 1 1 -1 0\n2 4\n1 3\n4 5\n1 5\n1 4\n4 5",
"output": "8"
},
{
"inpu... | 1,589,896,064 | 2,147,483,647 | Python 3 | OK | TESTS | 53 | 108 | 0 |
n, m = map(int, input().split())
li = list(map(int, input().split()))
ans = 0
for _ in range(m):
l, r = map(int, input().split())
ans += max(0, sum(li[l - 1:r]))
print(ans) | Title: Alyona and flowers
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Little Alyona is celebrating Happy Birthday! Her mother has an array of *n* flowers. Each flower has some mood, the mood of *i*-th flower is *a**i*. The mood can be positive, zero or negative.
Let's define a subarra... | ```python
n, m = map(int, input().split())
li = list(map(int, input().split()))
ans = 0
for _ in range(m):
l, r = map(int, input().split())
ans += max(0, sum(li[l - 1:r]))
print(ans)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.