contestId int64 0 1.01k | index stringclasses 57
values | name stringlengths 2 58 | type stringclasses 2
values | rating int64 0 3.5k | tags listlengths 0 11 | title stringclasses 522
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 3 65.5k | prompt stringlengths 262 8.2k | response stringlengths 17 65.5k | score float64 -1 3.99 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
525 | A | Vitaliy and Pie | PROGRAMMING | 1,100 | [
"greedy",
"hashing",
"strings"
] | null | null | After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with *n* room located in a line and numbered starting from one from left to right. You can go from the first room to the second room, from the second room to the third ... | The first line of the input contains a positive integer *n* (2<=≤<=*n*<=≤<=105) — the number of rooms in the house.
The second line of the input contains string *s* of length 2·*n*<=-<=2. Let's number the elements of the string from left to right, starting from one.
The odd positions in the given string *s* contain ... | Print the only integer — the minimum number of keys that Vitaly needs to buy to surely get from room one to room *n*. | [
"3\naAbB\n",
"4\naBaCaB\n",
"5\nxYyXzZaZ\n"
] | [
"0\n",
"3\n",
"2\n"
] | none | 250 | [
{
"input": "3\naAbB",
"output": "0"
},
{
"input": "4\naBaCaB",
"output": "3"
},
{
"input": "5\nxYyXzZaZ",
"output": "2"
},
{
"input": "26\naAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyY",
"output": "0"
},
{
"input": "26\nzAyBxCwDvEuFtGsHrIqJpKoLnMmNlOkPjQiRhSg... | 1,663,954,291 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 30 | 0 | n = int(input())
s = input()
s = list(s)
print(s)
doors_keys = []
qtt_keys = 0
for i in range(len(s)):
if(i%2 == 0):
try:
index = doors_keys.index(s[i])
doors_keys[index+1] += 1
except: # não encontrou valor na lista
doors_keys.append(s[i])
doors_keys... | Title: Vitaliy and Pie
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with *n* room located in a line and numbered starting from one from... | ```python
n = int(input())
s = input()
s = list(s)
print(s)
doors_keys = []
qtt_keys = 0
for i in range(len(s)):
if(i%2 == 0):
try:
index = doors_keys.index(s[i])
doors_keys[index+1] += 1
except: # não encontrou valor na lista
doors_keys.append(s[i])
... | 0 | |
580 | A | Kefa and First Steps | PROGRAMMING | 900 | [
"brute force",
"dp",
"implementation"
] | null | null | Kefa decided to make some money doing business on the Internet for exactly *n* days. He knows that on the *i*-th day (1<=≤<=*i*<=≤<=*n*) he makes *a**i* money. Kefa loves progress, that's why he wants to know the length of the maximum non-decreasing subsegment in sequence *a**i*. Let us remind you that the subsegment o... | The first line contains integer *n* (1<=≤<=*n*<=≤<=105).
The second line contains *n* integers *a*1,<=<=*a*2,<=<=...,<=<=*a**n* (1<=≤<=*a**i*<=≤<=109). | Print a single integer — the length of the maximum non-decreasing subsegment of sequence *a*. | [
"6\n2 2 1 3 4 1\n",
"3\n2 2 9\n"
] | [
"3",
"3"
] | In the first test the maximum non-decreasing subsegment is the numbers from the third to the fifth one.
In the second test the maximum non-decreasing subsegment is the numbers from the first to the third one. | 750 | [
{
"input": "6\n2 2 1 3 4 1",
"output": "3"
},
{
"input": "3\n2 2 9",
"output": "3"
},
{
"input": "5\n10 100 111 1 2",
"output": "3"
},
{
"input": "10\n1 2 3 4 1 2 3 4 5 6",
"output": "6"
},
{
"input": "50\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... | 1,687,073,492 | 2,147,483,647 | Python 3 | OK | TESTS | 28 | 78 | 13,926,400 | testcases = int(input())
sequence = list(map(int, input().split()))
max_len = 1
current_len = 1
for i in range(1, testcases):
if sequence[i] >= sequence[i-1]:
current_len += 1
else:
max_len = max(max_len, current_len)
current_len = 1
max_len = max(max_len, current_len)
pri... | Title: Kefa and First Steps
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Kefa decided to make some money doing business on the Internet for exactly *n* days. He knows that on the *i*-th day (1<=≤<=*i*<=≤<=*n*) he makes *a**i* money. Kefa loves progress, that's why he wants to know the l... | ```python
testcases = int(input())
sequence = list(map(int, input().split()))
max_len = 1
current_len = 1
for i in range(1, testcases):
if sequence[i] >= sequence[i-1]:
current_len += 1
else:
max_len = max(max_len, current_len)
current_len = 1
max_len = max(max_len, current... | 3 | |
375 | D | Tree and Queries | PROGRAMMING | 2,400 | [
"data structures",
"dfs and similar",
"trees"
] | null | null | You have a rooted tree consisting of *n* vertices. Each vertex of the tree has some color. We will assume that the tree vertices are numbered by integers from 1 to *n*. Then we represent the color of vertex *v* as *c**v*. The tree root is a vertex with number 1.
In this problem you need to answer to *m* queries. Each ... | The first line contains two integers *n* and *m* (2<=≤<=*n*<=≤<=105; 1<=≤<=*m*<=≤<=105). The next line contains a sequence of integers *c*1,<=*c*2,<=...,<=*c**n* (1<=≤<=*c**i*<=≤<=105). The next *n*<=-<=1 lines contain the edges of the tree. The *i*-th line contains the numbers *a**i*,<=*b**i* (1<=≤<=*a**i*,<=*b**i*<=≤... | Print *m* integers — the answers to the queries in the order the queries appear in the input. | [
"8 5\n1 2 2 3 3 2 3 3\n1 2\n1 5\n2 3\n2 4\n5 6\n5 7\n5 8\n1 2\n1 3\n1 4\n2 3\n5 3\n",
"4 1\n1 2 3 4\n1 2\n2 3\n3 4\n1 1\n"
] | [
"2\n2\n1\n0\n1\n",
"4\n"
] | A subtree of vertex *v* in a rooted tree with root *r* is a set of vertices {*u* : *dist*(*r*, *v*) + *dist*(*v*, *u*) = *dist*(*r*, *u*)}. Where *dist*(*x*, *y*) is the length (in edges) of the shortest path between vertices *x* and *y*. | 2,000 | [
{
"input": "8 5\n1 2 2 3 3 2 3 3\n1 2\n1 5\n2 3\n2 4\n5 6\n5 7\n5 8\n1 2\n1 3\n1 4\n2 3\n5 3",
"output": "2\n2\n1\n0\n1"
},
{
"input": "4 1\n1 2 3 4\n1 2\n2 3\n3 4\n1 1",
"output": "4"
}
] | 1,464,490,738 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 3 | 62 | 4,608,000 | (n, m) = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
edges = []
for i in range(n):
edges.append([])
for i in range(n - 1):
(a, b) = [int(x) - 1 for x in input().split()]
edges[a].append(b)
def query(v, k):
q = [v]
colors = {}
while len(q) > 0:
node = q[0]
... | Title: Tree and Queries
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You have a rooted tree consisting of *n* vertices. Each vertex of the tree has some color. We will assume that the tree vertices are numbered by integers from 1 to *n*. Then we represent the color of vertex *v* as *c**... | ```python
(n, m) = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
edges = []
for i in range(n):
edges.append([])
for i in range(n - 1):
(a, b) = [int(x) - 1 for x in input().split()]
edges[a].append(b)
def query(v, k):
q = [v]
colors = {}
while len(q) > 0:
nod... | 0 | |
483 | A | Counterexample | PROGRAMMING | 1,100 | [
"brute force",
"implementation",
"math",
"number theory"
] | null | null | Your friend has recently learned about coprime numbers. A pair of numbers {*a*,<=*b*} is called coprime if the maximum number that divides both *a* and *b* is equal to one.
Your friend often comes up with different statements. He has recently supposed that if the pair (*a*,<=*b*) is coprime and the pair (*b*,<=*c*) i... | The single line contains two positive space-separated integers *l*, *r* (1<=≤<=*l*<=≤<=*r*<=≤<=1018; *r*<=-<=*l*<=≤<=50). | Print three positive space-separated integers *a*, *b*, *c* — three distinct numbers (*a*,<=*b*,<=*c*) that form the counterexample. If there are several solutions, you are allowed to print any of them. The numbers must be printed in ascending order.
If the counterexample does not exist, print the single number -1. | [
"2 4\n",
"10 11\n",
"900000000000000009 900000000000000029\n"
] | [
"2 3 4\n",
"-1\n",
"900000000000000009 900000000000000010 900000000000000021\n"
] | In the first sample pair (2, 4) is not coprime and pairs (2, 3) and (3, 4) are.
In the second sample you cannot form a group of three distinct integers, so the answer is -1.
In the third sample it is easy to see that numbers 900000000000000009 and 900000000000000021 are divisible by three. | 500 | [
{
"input": "2 4",
"output": "2 3 4"
},
{
"input": "10 11",
"output": "-1"
},
{
"input": "900000000000000009 900000000000000029",
"output": "900000000000000009 900000000000000010 900000000000000021"
},
{
"input": "640097987171091791 640097987171091835",
"output": "64009798... | 1,645,872,202 | 2,147,483,647 | Python 3 | OK | TESTS | 42 | 46 | 0 | import math as m
import sys
l,r=list(map(int,input().split()))
for i in range(l,r+1):
for j in range(i+1,r+1):
for k in range(j+1,r+1):
if m.gcd(i,j)==1 and m.gcd(j,k)==1 and m.gcd(i,k)!=1:
print(i,j,k)
sys.exit()
else:
print(-1) | Title: Counterexample
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Your friend has recently learned about coprime numbers. A pair of numbers {*a*,<=*b*} is called coprime if the maximum number that divides both *a* and *b* is equal to one.
Your friend often comes up with different st... | ```python
import math as m
import sys
l,r=list(map(int,input().split()))
for i in range(l,r+1):
for j in range(i+1,r+1):
for k in range(j+1,r+1):
if m.gcd(i,j)==1 and m.gcd(j,k)==1 and m.gcd(i,k)!=1:
print(i,j,k)
sys.exit()
else:
print(-1)
``` | 3 | |
69 | A | Young Physicist | PROGRAMMING | 1,000 | [
"implementation",
"math"
] | A. Young Physicist | 2 | 256 | A guy named Vasya attends the final grade of a high school. One day Vasya decided to watch a match of his favorite hockey team. And, as the boy loves hockey very much, even more than physics, he forgot to do the homework. Specifically, he forgot to complete his physics tasks. Next day the teacher got very angry at Vasy... | The first line contains a positive integer *n* (1<=≤<=*n*<=≤<=100), then follow *n* lines containing three integers each: the *x**i* coordinate, the *y**i* coordinate and the *z**i* coordinate of the force vector, applied to the body (<=-<=100<=≤<=*x**i*,<=*y**i*,<=*z**i*<=≤<=100). | Print the word "YES" if the body is in equilibrium, or the word "NO" if it is not. | [
"3\n4 1 7\n-2 4 -1\n1 -5 -3\n",
"3\n3 -1 7\n-5 2 -4\n2 -1 -3\n"
] | [
"NO",
"YES"
] | none | 500 | [
{
"input": "3\n4 1 7\n-2 4 -1\n1 -5 -3",
"output": "NO"
},
{
"input": "3\n3 -1 7\n-5 2 -4\n2 -1 -3",
"output": "YES"
},
{
"input": "10\n21 32 -46\n43 -35 21\n42 2 -50\n22 40 20\n-27 -9 38\n-4 1 1\n-40 6 -31\n-13 -2 34\n-21 34 -12\n-32 -29 41",
"output": "NO"
},
{
"input": "10... | 1,640,796,668 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 80 | 92 | 0 | t=int(input())
count=0
for i in range(t):
list1=list(map(int,input().split()))
count+=sum(list1)
if count==0:
print("YES")
else:
print("NO")
| Title: Young Physicist
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
A guy named Vasya attends the final grade of a high school. One day Vasya decided to watch a match of his favorite hockey team. And, as the boy loves hockey very much, even more than physics, he forgot to do the homework. S... | ```python
t=int(input())
count=0
for i in range(t):
list1=list(map(int,input().split()))
count+=sum(list1)
if count==0:
print("YES")
else:
print("NO")
``` | 0 |
609 | B | The Best Gift | PROGRAMMING | 1,100 | [
"constructive algorithms",
"implementation"
] | null | null | Emily's birthday is next week and Jack has decided to buy a present for her. He knows she loves books so he goes to the local bookshop, where there are *n* books on sale from one of *m* genres.
In the bookshop, Jack decides to buy two books of different genres.
Based on the genre of books on sale in the shop, find th... | The first line contains two positive integers *n* and *m* (2<=≤<=*n*<=≤<=2·105,<=2<=≤<=*m*<=≤<=10) — the number of books in the bookstore and the number of genres.
The second line contains a sequence *a*1,<=*a*2,<=...,<=*a**n*, where *a**i* (1<=≤<=*a**i*<=≤<=*m*) equals the genre of the *i*-th book.
It is guaranteed ... | Print the only integer — the number of ways in which Jack can choose books.
It is guaranteed that the answer doesn't exceed the value 2·109. | [
"4 3\n2 1 3 1\n",
"7 4\n4 2 3 1 2 4 3\n"
] | [
"5\n",
"18\n"
] | The answer to the first test sample equals 5 as Sasha can choose:
1. the first and second books, 1. the first and third books, 1. the first and fourth books, 1. the second and third books, 1. the third and fourth books. | 0 | [
{
"input": "4 3\n2 1 3 1",
"output": "5"
},
{
"input": "7 4\n4 2 3 1 2 4 3",
"output": "18"
},
{
"input": "2 2\n1 2",
"output": "1"
},
{
"input": "3 2\n1 2 2",
"output": "2"
},
{
"input": "10 10\n1 2 3 4 5 6 7 8 9 10",
"output": "45"
},
{
"input": "9 2... | 1,547,630,390 | 2,147,483,647 | Python 3 | OK | TESTS | 42 | 187 | 3,993,600 | #609 B Best Gift
#1. Create a list of genre and count how many book of each genre
#2. with each genre, number of way to choose gift: number_of_books_in_this_genre * (number_of_books_of_other_genres)
number_of_books, number_of_genres = map(int, input().split())
count_genres = number_of_genres*[0]
type_of_each... | Title: The Best Gift
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Emily's birthday is next week and Jack has decided to buy a present for her. He knows she loves books so he goes to the local bookshop, where there are *n* books on sale from one of *m* genres.
In the bookshop, Jack deci... | ```python
#609 B Best Gift
#1. Create a list of genre and count how many book of each genre
#2. with each genre, number of way to choose gift: number_of_books_in_this_genre * (number_of_books_of_other_genres)
number_of_books, number_of_genres = map(int, input().split())
count_genres = number_of_genres*[0]
ty... | 3 | |
445 | A | DZY Loves Chessboard | PROGRAMMING | 1,200 | [
"dfs and similar",
"implementation"
] | null | null | DZY loves chessboard, and he enjoys playing with it.
He has a chessboard of *n* rows and *m* columns. Some cells of the chessboard are bad, others are good. For every good cell, DZY wants to put a chessman on it. Each chessman is either white or black. After putting all chessmen, DZY wants that no two chessmen with th... | The first line contains two space-separated integers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=100).
Each of the next *n* lines contains a string of *m* characters: the *j*-th character of the *i*-th string is either "." or "-". A "." means that the corresponding cell (in the *i*-th row and the *j*-th column) is good, while a ... | Output must contain *n* lines, each line must contain a string of *m* characters. The *j*-th character of the *i*-th string should be either "W", "B" or "-". Character "W" means the chessman on the cell is white, "B" means it is black, "-" means the cell is a bad cell.
If multiple answers exist, print any of them. It ... | [
"1 1\n.\n",
"2 2\n..\n..\n",
"3 3\n.-.\n---\n--."
] | [
"B\n",
"BW\nWB\n",
"B-B\n---\n--B"
] | In the first sample, DZY puts a single black chessman. Of course putting a white one is also OK.
In the second sample, all 4 cells are good. No two same chessmen share an edge in the sample output.
In the third sample, no good cells are adjacent. So you can just put 3 chessmen, no matter what their colors are. | 500 | [
{
"input": "1 1\n.",
"output": "B"
},
{
"input": "2 2\n..\n..",
"output": "BW\nWB"
},
{
"input": "3 3\n.-.\n---\n--.",
"output": "B-B\n---\n--B"
},
{
"input": "3 1\n-\n.\n.",
"output": "-\nW\nB"
},
{
"input": "11 11\n-----------\n-----------\n-----------\n--------... | 1,647,798,866 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 4 | 77 | 3,993,600 | import sys
import math
from collections import deque
import heapq as hq
def inp(): return sys.stdin.readline().rstrip()
def mpp(): return map(int,inp().split())
def lis(): return list(mpp())
def pr(obj): sys.stdout.write((obj)+"\n")
def issafe(i,j,n,m):
return i>=0 and i<n and j>=0 and j<m
def sol(arr,vis... | Title: DZY Loves Chessboard
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
DZY loves chessboard, and he enjoys playing with it.
He has a chessboard of *n* rows and *m* columns. Some cells of the chessboard are bad, others are good. For every good cell, DZY wants to put a chessman on it. ... | ```python
import sys
import math
from collections import deque
import heapq as hq
def inp(): return sys.stdin.readline().rstrip()
def mpp(): return map(int,inp().split())
def lis(): return list(mpp())
def pr(obj): sys.stdout.write((obj)+"\n")
def issafe(i,j,n,m):
return i>=0 and i<n and j>=0 and j<m
def s... | 0 | |
61 | E | Enemy is weak | PROGRAMMING | 1,900 | [
"data structures",
"trees"
] | E. Enemy is weak | 5 | 256 | The Romans have attacked again. This time they are much more than the Persians but Shapur is ready to defeat them. He says: "A lion is never afraid of a hundred sheep".
Nevertheless Shapur has to find weaknesses in the Roman army to defeat them. So he gives the army a weakness number.
In Shapur's opinion the weaknes... | The first line of input contains a single number *n* (3<=≤<=*n*<=≤<=106) — the number of men in Roman army. Next line contains *n* different positive integers *a**i* (1<=≤<=*i*<=≤<=*n*,<=1<=≤<=*a**i*<=≤<=109) — powers of men in the Roman army. | A single integer number, the weakness of the Roman army.
Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cout (also you may use %I64d). | [
"3\n3 2 1\n",
"3\n2 3 1\n",
"4\n10 8 3 1\n",
"4\n1 5 4 3\n"
] | [
"1\n",
"0\n",
"4\n",
"1\n"
] | none | 2,500 | [
{
"input": "3\n3 2 1",
"output": "1"
},
{
"input": "3\n2 3 1",
"output": "0"
},
{
"input": "4\n10 8 3 1",
"output": "4"
},
{
"input": "4\n1 5 4 3",
"output": "1"
},
{
"input": "9\n10 9 5 6 8 3 4 7 11",
"output": "20"
},
{
"input": "7\n11 3 8 4 2 9 6",
... | 1,592,001,252 | 2,147,483,647 | PyPy 3 | OK | TESTS | 70 | 4,944 | 125,235,200 | from sys import stdin,stdout
def binarysearch(x,first,last,b):
mid=(first+last)/2
mid=int(mid)
if(b[first]==x):
return first
if(b[last]==x):
return last
if(b[mid]==x):
return mid
if(b[mid]<x):
return binarysearch(x,mid,last,b)
return binarysearch... | Title: Enemy is weak
Time Limit: 5 seconds
Memory Limit: 256 megabytes
Problem Description:
The Romans have attacked again. This time they are much more than the Persians but Shapur is ready to defeat them. He says: "A lion is never afraid of a hundred sheep".
Nevertheless Shapur has to find weaknesses in the Roma... | ```python
from sys import stdin,stdout
def binarysearch(x,first,last,b):
mid=(first+last)/2
mid=int(mid)
if(b[first]==x):
return first
if(b[last]==x):
return last
if(b[mid]==x):
return mid
if(b[mid]<x):
return binarysearch(x,mid,last,b)
return bi... | 3.272331 |
892 | B | Wrath | PROGRAMMING | 1,200 | [
"greedy",
"implementation",
"two pointers"
] | null | null | Hands that shed innocent blood!
There are *n* guilty people in a line, the *i*-th of them holds a claw with length *L**i*. The bell rings and every person kills some of people in front of him. All people kill others at the same time. Namely, the *i*-th person kills the *j*-th person if and only if *j*<=<<=*i* and *... | The first line contains one integer *n* (1<=≤<=*n*<=≤<=106) — the number of guilty people.
Second line contains *n* space-separated integers *L*1,<=*L*2,<=...,<=*L**n* (0<=≤<=*L**i*<=≤<=109), where *L**i* is the length of the *i*-th person's claw. | Print one integer — the total number of alive people after the bell rings. | [
"4\n0 1 0 10\n",
"2\n0 0\n",
"10\n1 1 3 0 0 0 2 1 0 3\n"
] | [
"1\n",
"2\n",
"3\n"
] | In first sample the last person kills everyone in front of him. | 1,000 | [
{
"input": "4\n0 1 0 10",
"output": "1"
},
{
"input": "2\n0 0",
"output": "2"
},
{
"input": "10\n1 1 3 0 0 0 2 1 0 3",
"output": "3"
},
{
"input": "10\n0 0 2 0 0 3 3 2 2 0",
"output": "2"
},
{
"input": "1\n0",
"output": "1"
},
{
"input": "5\n0 0 0 1 0"... | 1,513,150,946 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 8 | 2,000 | 62,976,000 | n=int(input())
a=input().split()
l=[]
for i in range(len(a)):
l.append(1)
a[i]=int(a[i])
for i in range(n) :
if a[i]>=i:
for k in range(i):
l[k]-=1
else:
for k in range(i-a[i],i):
l[k]-=1
sum=0
for i in range(len(a)):
if int(l[i])>=1:
sum+=1
print(sum)
... | Title: Wrath
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Hands that shed innocent blood!
There are *n* guilty people in a line, the *i*-th of them holds a claw with length *L**i*. The bell rings and every person kills some of people in front of him. All people kill others at the same ... | ```python
n=int(input())
a=input().split()
l=[]
for i in range(len(a)):
l.append(1)
a[i]=int(a[i])
for i in range(n) :
if a[i]>=i:
for k in range(i):
l[k]-=1
else:
for k in range(i-a[i],i):
l[k]-=1
sum=0
for i in range(len(a)):
if int(l[i])>=1:
sum+=1
pr... | 0 | |
764 | A | Taymyr is calling you | PROGRAMMING | 800 | [
"brute force",
"implementation",
"math"
] | null | null | Comrade Dujikov is busy choosing artists for Timofey's birthday and is recieving calls from Taymyr from Ilia-alpinist.
Ilia-alpinist calls every *n* minutes, i.e. in minutes *n*, 2*n*, 3*n* and so on. Artists come to the comrade every *m* minutes, i.e. in minutes *m*, 2*m*, 3*m* and so on. The day is *z* minutes long,... | The only string contains three integers — *n*, *m* and *z* (1<=≤<=*n*,<=*m*,<=*z*<=≤<=104). | Print single integer — the minimum number of artists that should be killed so that there are no artists in the room when Ilia calls. | [
"1 1 10\n",
"1 2 5\n",
"2 3 9\n"
] | [
"10\n",
"2\n",
"1\n"
] | Taymyr is a place in the north of Russia.
In the first test the artists come each minute, as well as the calls, so we need to kill all of them.
In the second test we need to kill artists which come on the second and the fourth minutes.
In the third test — only the artist which comes on the sixth minute. | 500 | [
{
"input": "1 1 10",
"output": "10"
},
{
"input": "1 2 5",
"output": "2"
},
{
"input": "2 3 9",
"output": "1"
},
{
"input": "4 8 9",
"output": "1"
},
{
"input": "7 9 2",
"output": "0"
},
{
"input": "10000 10000 10000",
"output": "1"
},
{
"i... | 1,647,668,128 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 31 | 0 | n, m, x = map(int, input().split())
sum = 0
i = 1
for i in range(n, x + 1):
if i % m == 0:
sum = sum + 1
print(sum)
| Title: Taymyr is calling you
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Comrade Dujikov is busy choosing artists for Timofey's birthday and is recieving calls from Taymyr from Ilia-alpinist.
Ilia-alpinist calls every *n* minutes, i.e. in minutes *n*, 2*n*, 3*n* and so on. Artists com... | ```python
n, m, x = map(int, input().split())
sum = 0
i = 1
for i in range(n, x + 1):
if i % m == 0:
sum = sum + 1
print(sum)
``` | 0 | |
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,594,319,150 | 2,147,483,647 | Python 3 | OK | TESTS | 45 | 218 | 6,963,200 | def gcd(a,b):
if(b==0):
return a
return gcd(b, a%b)
a,b,n = map(int, input().split())
count = 0
while(True):
if(count%2==0):
x = gcd(a,n)
if x<=n:
n-=x
count += 1
else:
print("1")
break
else:
y = gcd(b,n)
if y<=n:
n-=y
count+=1
else:
print("0")
break
| 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
def gcd(a,b):
if(b==0):
return a
return gcd(b, a%b)
a,b,n = map(int, input().split())
count = 0
while(True):
if(count%2==0):
x = gcd(a,n)
if x<=n:
n-=x
count += 1
else:
print("1")
break
else:
y = gcd(b,n)
if y<=n:
n-=y
count+=1
else:
print("0")
... | 3 | |
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,694,568,329 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 8 | 1,000 | 14,028,800 | n=int(input())
data0=input().split()
result=[]
score=0
def bore(data):
global score
score0=score
if data==[]:
result.append(score)
for i in range(len(data)):
data1=data[:]
score=score0
delet=[]
num=int(data[i])
for j in range(len(data)):
... | 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())
data0=input().split()
result=[]
score=0
def bore(data):
global score
score0=score
if data==[]:
result.append(score)
for i in range(len(data)):
data1=data[:]
score=score0
delet=[]
num=int(data[i])
for j in range(len(da... | 0 | |
41 | A | Translation | PROGRAMMING | 800 | [
"implementation",
"strings"
] | A. Translation | 2 | 256 | The translation from the Berland language into the Birland language is not an easy task. Those languages are very similar: a berlandish word differs from a birlandish word with the same meaning a little: it is spelled (and pronounced) reversely. For example, a Berlandish word code corresponds to a Birlandish word edoc.... | The first line contains word *s*, the second line contains word *t*. The words consist of lowercase Latin letters. The input data do not consist unnecessary spaces. The words are not empty and their lengths do not exceed 100 symbols. | If the word *t* is a word *s*, written reversely, print YES, otherwise print NO. | [
"code\nedoc\n",
"abb\naba\n",
"code\ncode\n"
] | [
"YES\n",
"NO\n",
"NO\n"
] | none | 500 | [
{
"input": "code\nedoc",
"output": "YES"
},
{
"input": "abb\naba",
"output": "NO"
},
{
"input": "code\ncode",
"output": "NO"
},
{
"input": "abacaba\nabacaba",
"output": "YES"
},
{
"input": "q\nq",
"output": "YES"
},
{
"input": "asrgdfngfnmfgnhweratgjkk... | 1,668,240,507 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 9 | 92 | 0 | s = input()
t = input()
x = s[::-1]
if len(s) <= 100 and len(s) == len(t):
if t == x:
print("YES")
else:
print("NO")
| Title: Translation
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
The translation from the Berland language into the Birland language is not an easy task. Those languages are very similar: a berlandish word differs from a birlandish word with the same meaning a little: it is spelled (and pron... | ```python
s = input()
t = input()
x = s[::-1]
if len(s) <= 100 and len(s) == len(t):
if t == x:
print("YES")
else:
print("NO")
``` | 0 |
236 | A | Boy or Girl | PROGRAMMING | 800 | [
"brute force",
"implementation",
"strings"
] | null | null | Those days, many boys use beautiful girls' photos as avatars in forums. So it is pretty hard to tell the gender of a user at the first glance. Last year, our hero went to a forum and had a nice chat with a beauty (he thought so). After that they talked very often and eventually they became a couple in the network.
Bu... | The first line contains a non-empty string, that contains only lowercase English letters — the user name. This string contains at most 100 letters. | If it is a female by our hero's method, print "CHAT WITH HER!" (without the quotes), otherwise, print "IGNORE HIM!" (without the quotes). | [
"wjmzbmr\n",
"xiaodao\n",
"sevenkplus\n"
] | [
"CHAT WITH HER!\n",
"IGNORE HIM!\n",
"CHAT WITH HER!\n"
] | For the first example. There are 6 distinct characters in "wjmzbmr". These characters are: "w", "j", "m", "z", "b", "r". So wjmzbmr is a female and you should print "CHAT WITH HER!". | 500 | [
{
"input": "wjmzbmr",
"output": "CHAT WITH HER!"
},
{
"input": "xiaodao",
"output": "IGNORE HIM!"
},
{
"input": "sevenkplus",
"output": "CHAT WITH HER!"
},
{
"input": "pezu",
"output": "CHAT WITH HER!"
},
{
"input": "wnemlgppy",
"output": "CHAT WITH HER!"
},... | 1,697,558,186 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 30 | 0 | name =input()
a = name.lower()
b = len(name)
if b%2==0 and b<=100:
print("CHAT WITH HER!")
else:
print("IGNORE HIM!") | Title: Boy or Girl
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Those days, many boys use beautiful girls' photos as avatars in forums. So it is pretty hard to tell the gender of a user at the first glance. Last year, our hero went to a forum and had a nice chat with a beauty (he though... | ```python
name =input()
a = name.lower()
b = len(name)
if b%2==0 and b<=100:
print("CHAT WITH HER!")
else:
print("IGNORE HIM!")
``` | 0 | |
105 | A | Transmigration | PROGRAMMING | 1,700 | [
"implementation"
] | A. Transmigration | 2 | 256 | In Disgaea as in most role-playing games, characters have skills that determine the character's ability to use certain weapons or spells. If the character does not have the necessary skill, he cannot use it. The skill level is represented as an integer that increases when you use this skill. Different character classes... | The first line contains three numbers *n*, *m* and *k* — the number of skills the current character has, the number of skills specific for the class into which the character is going to transmigrate and the reducing coefficient respectively; *n* and *m* are integers, and *k* is a real number with exactly two digits aft... | Print on the first line number *z* — the number of skills the character will have after the transmigration. Then print *z* lines, on each of which print a skill's name and level, separated by a single space. The skills should be given in the lexicographical order. | [
"5 4 0.75\naxe 350\nimpaler 300\nionize 80\nmegafire 120\nmagicboost 220\nheal\nmegafire\nshield\nmagicboost\n"
] | [
"6\naxe 262\nheal 0\nimpaler 225\nmagicboost 165\nmegafire 0\nshield 0\n"
] | none | 500 | [
{
"input": "5 4 0.75\naxe 350\nimpaler 300\nionize 80\nmegafire 120\nmagicboost 220\nheal\nmegafire\nshield\nmagicboost",
"output": "6\naxe 262\nheal 0\nimpaler 225\nmagicboost 165\nmegafire 0\nshield 0"
},
{
"input": "1 1 0.50\nstaff 1005\nionize",
"output": "2\nionize 0\nstaff 502"
},
{
... | 1,644,137,909 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 30 | 622 | 14,336,000 | import math
import sys
import queue
import itertools
from heapq import heappop, heappush
import random
def solve():
n, m, k = map(float, input().split())
n, m = int(n), int(m)
new_build = {}
for i in range(n):
name, exp = map(str, input().split())
exp = int(exp)
... | Title: Transmigration
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
In Disgaea as in most role-playing games, characters have skills that determine the character's ability to use certain weapons or spells. If the character does not have the necessary skill, he cannot use it. The skill level ... | ```python
import math
import sys
import queue
import itertools
from heapq import heappop, heappush
import random
def solve():
n, m, k = map(float, input().split())
n, m = int(n), int(m)
new_build = {}
for i in range(n):
name, exp = map(str, input().split())
exp = int(... | 0 |
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,703,326 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 4 | 62 | 4,608,000 | a, b, c = map(int, input().split())
if c %2 != 0:
p = 'L'
else:
p = 'R'
nes = (c//(2*b))+1
if (c%(2*b) == 0):
nes -=1
ost = round((c%(nes*b))/2)
if(ost == 0):
ost = (c%(2*b*nes))//2
if ost == 0:
ost = b
print(nes, ost, p)
| 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
a, b, c = map(int, input().split())
if c %2 != 0:
p = 'L'
else:
p = 'R'
nes = (c//(2*b))+1
if (c%(2*b) == 0):
nes -=1
ost = round((c%(nes*b))/2)
if(ost == 0):
ost = (c%(2*b*nes))//2
if ost == 0:
ost = b
print(nes, ost, p)
``` | 0 | |
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,526,703,569 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 12 | 93 | 0 | from math import ceil
n = int(input())
days, _ = map(int, input().split())
for i in range(n-1):
a, d = map(int, input().split())
days = a + ceil((days+1-a)/d)*d
print(days) | 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
from math import ceil
n = int(input())
days, _ = map(int, input().split())
for i in range(n-1):
a, d = map(int, input().split())
days = a + ceil((days+1-a)/d)*d
print(days)
``` | 0 | |
883 | F | Lost in Transliteration | PROGRAMMING | 1,300 | [
"implementation"
] | null | null | There are some ambiguities when one writes Berland names with the letters of the Latin alphabet.
For example, the Berland sound u can be written in the Latin alphabet as "u", and can be written as "oo". For this reason, two words "ulyana" and "oolyana" denote the same name.
The second ambiguity is about the Berland s... | The first line contains integer number *n* (2<=≤<=*n*<=≤<=400) — number of the words in the list.
The following *n* lines contain words, one word per line. Each word consists of only lowercase Latin letters. The length of each word is between 1 and 20 letters inclusive. | Print the minimal number of groups where the words in each group denote the same name. | [
"10\nmihail\noolyana\nkooooper\nhoon\nulyana\nkoouper\nmikhail\nkhun\nkuooper\nkkkhoon\n",
"9\nhariton\nhkariton\nbuoi\nkkkhariton\nboooi\nbui\nkhariton\nboui\nboi\n",
"2\nalex\nalex\n"
] | [
"4\n",
"5\n",
"1\n"
] | There are four groups of words in the first example. Words in each group denote same name:
1. "mihail", "mikhail" 1. "oolyana", "ulyana" 1. "kooooper", "koouper" 1. "hoon", "khun", "kkkhoon"
There are five groups of words in the second example. Words in each group denote same name:
1. "hariton", "kkkhariton", "... | 0 | [
{
"input": "10\nmihail\noolyana\nkooooper\nhoon\nulyana\nkoouper\nmikhail\nkhun\nkuooper\nkkkhoon",
"output": "4"
},
{
"input": "9\nhariton\nhkariton\nbuoi\nkkkhariton\nboooi\nbui\nkhariton\nboui\nboi",
"output": "5"
},
{
"input": "2\nalex\nalex",
"output": "1"
},
{
"input": ... | 1,509,693,271 | 2,147,483,647 | Python 3 | OK | TESTS | 81 | 78 | 409,600 | import re
print(len(set(map(lambda v:re.sub("k*h","h",input()).replace("u","oo"),range(int(input()))))))
| Title: Lost in Transliteration
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
There are some ambiguities when one writes Berland names with the letters of the Latin alphabet.
For example, the Berland sound u can be written in the Latin alphabet as "u", and can be written as "oo". For thi... | ```python
import re
print(len(set(map(lambda v:re.sub("k*h","h",input()).replace("u","oo"),range(int(input()))))))
``` | 3 | |
384 | A | Coder | PROGRAMMING | 800 | [
"implementation"
] | null | null | Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (*x*,<=*y*), he can move to (or attack) positions (*x*<=+<=1,<=*y*), (*x*–1,<=*y*), (*x*,<=*y*<=+<=1) and (*x*,<=*y*–1).
... | The first line contains an integer *n* (1<=≤<=*n*<=≤<=1000). | On the first line print an integer, the maximum number of Coders that can be placed on the chessboard.
On each of the next *n* lines print *n* characters, describing the configuration of the Coders. For an empty cell print an '.', and for a Coder print a 'C'.
If there are multiple correct answers, you can print any. | [
"2\n"
] | [
"2\nC.\n.C\n"
] | none | 500 | [
{
"input": "2",
"output": "2\nC.\n.C"
},
{
"input": "3",
"output": "5\nC.C\n.C.\nC.C"
},
{
"input": "4",
"output": "8\nC.C.\n.C.C\nC.C.\n.C.C"
},
{
"input": "10",
"output": "50\nC.C.C.C.C.\n.C.C.C.C.C\nC.C.C.C.C.\n.C.C.C.C.C\nC.C.C.C.C.\n.C.C.C.C.C\nC.C.C.C.C.\n.C.C.C.C.C... | 1,431,018,910 | 2,147,483,647 | Python 3 | COMPILATION_ERROR | TESTS | 0 | 0 | 0 | #include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <list>
#include<iterator>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<math.h>
#include <numeric>
#include<sstream>
#include<stdlib.h>
#include <queue>
#include<stack>
#include<set>
#include<map>
//i... | Title: Coder
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (*x*,<=*y*), he can move to (or... | ```python
#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <list>
#include<iterator>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<math.h>
#include <numeric>
#include<sstream>
#include<stdlib.h>
#include <queue>
#include<stack>
#include<set>
#include<m... | -1 | |
445 | A | DZY Loves Chessboard | PROGRAMMING | 1,200 | [
"dfs and similar",
"implementation"
] | null | null | DZY loves chessboard, and he enjoys playing with it.
He has a chessboard of *n* rows and *m* columns. Some cells of the chessboard are bad, others are good. For every good cell, DZY wants to put a chessman on it. Each chessman is either white or black. After putting all chessmen, DZY wants that no two chessmen with th... | The first line contains two space-separated integers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=100).
Each of the next *n* lines contains a string of *m* characters: the *j*-th character of the *i*-th string is either "." or "-". A "." means that the corresponding cell (in the *i*-th row and the *j*-th column) is good, while a ... | Output must contain *n* lines, each line must contain a string of *m* characters. The *j*-th character of the *i*-th string should be either "W", "B" or "-". Character "W" means the chessman on the cell is white, "B" means it is black, "-" means the cell is a bad cell.
If multiple answers exist, print any of them. It ... | [
"1 1\n.\n",
"2 2\n..\n..\n",
"3 3\n.-.\n---\n--."
] | [
"B\n",
"BW\nWB\n",
"B-B\n---\n--B"
] | In the first sample, DZY puts a single black chessman. Of course putting a white one is also OK.
In the second sample, all 4 cells are good. No two same chessmen share an edge in the sample output.
In the third sample, no good cells are adjacent. So you can just put 3 chessmen, no matter what their colors are. | 500 | [
{
"input": "1 1\n.",
"output": "B"
},
{
"input": "2 2\n..\n..",
"output": "BW\nWB"
},
{
"input": "3 3\n.-.\n---\n--.",
"output": "B-B\n---\n--B"
},
{
"input": "3 1\n-\n.\n.",
"output": "-\nW\nB"
},
{
"input": "11 11\n-----------\n-----------\n-----------\n--------... | 1,634,545,885 | 2,147,483,647 | PyPy 3 | RUNTIME_ERROR | TESTS | 6 | 139 | 6,246,400 | from sys import stdin as f
n, m = map(int, next(f).split())
field = []
for i in range(n):
field.append(list(next(f).strip()))
# for line in field:
# print(line)
def dfs(i, j, col):
# if visited[i][j]:
# return
field[i][j] = col
new_col = 'W' if col == 'B' else 'B'
if i != 0 and field... | Title: DZY Loves Chessboard
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
DZY loves chessboard, and he enjoys playing with it.
He has a chessboard of *n* rows and *m* columns. Some cells of the chessboard are bad, others are good. For every good cell, DZY wants to put a chessman on it. ... | ```python
from sys import stdin as f
n, m = map(int, next(f).split())
field = []
for i in range(n):
field.append(list(next(f).strip()))
# for line in field:
# print(line)
def dfs(i, j, col):
# if visited[i][j]:
# return
field[i][j] = col
new_col = 'W' if col == 'B' else 'B'
if i != 0... | -1 | |
915 | A | Garden | PROGRAMMING | 900 | [
"implementation"
] | null | null | Luba thinks about watering her garden. The garden can be represented as a segment of length *k*. Luba has got *n* buckets, the *i*-th bucket allows her to water some continuous subsegment of garden of length exactly *a**i* each hour. Luba can't water any parts of the garden that were already watered, also she can't wat... | The first line of input contains two integer numbers *n* and *k* (1<=≤<=*n*,<=*k*<=≤<=100) — the number of buckets and the length of the garden, respectively.
The second line of input contains *n* integer numbers *a**i* (1<=≤<=*a**i*<=≤<=100) — the length of the segment that can be watered by the *i*-th bucket in one ... | Print one integer number — the minimum number of hours required to water the garden. | [
"3 6\n2 3 5\n",
"6 7\n1 2 3 4 5 6\n"
] | [
"2\n",
"7\n"
] | In the first test the best option is to choose the bucket that allows to water the segment of length 3. We can't choose the bucket that allows to water the segment of length 5 because then we can't water the whole garden.
In the second test we can choose only the bucket that allows us to water the segment of length 1. | 0 | [
{
"input": "3 6\n2 3 5",
"output": "2"
},
{
"input": "6 7\n1 2 3 4 5 6",
"output": "7"
},
{
"input": "5 97\n1 10 50 97 2",
"output": "1"
},
{
"input": "5 97\n1 10 50 100 2",
"output": "97"
},
{
"input": "100 100\n2 46 24 18 86 90 31 38 84 49 58 28 15 80 14 24 87 5... | 1,516,230,323 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 46 | 5,632,000 | L=[]
L2=[]
n=int(input())
k=int(input())
for i in range(1,n+1):
a=int(input())
L.append(a)
for i in range (0,n):
if k%L[i]==0 :
L2.append(k//a)
print("nombre d'heures",max(L2))
| Title: Garden
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Luba thinks about watering her garden. The garden can be represented as a segment of length *k*. Luba has got *n* buckets, the *i*-th bucket allows her to water some continuous subsegment of garden of length exactly *a**i* each ... | ```python
L=[]
L2=[]
n=int(input())
k=int(input())
for i in range(1,n+1):
a=int(input())
L.append(a)
for i in range (0,n):
if k%L[i]==0 :
L2.append(k//a)
print("nombre d'heures",max(L2))
``` | -1 | |
160 | A | Twins | PROGRAMMING | 900 | [
"greedy",
"sortings"
] | null | null | Imagine that you have a twin brother or sister. Having another person that looks exactly like you seems very unusual. It's hard to say if having something of an alter ego is good or bad. And if you do have a twin, then you very well know what it's like.
Now let's imagine a typical morning in your family. You haven't w... | The first line contains integer *n* (1<=≤<=*n*<=≤<=100) — the number of coins. The second line contains a sequence of *n* integers *a*1, *a*2, ..., *a**n* (1<=≤<=*a**i*<=≤<=100) — the coins' values. All numbers are separated with spaces. | In the single line print the single number — the minimum needed number of coins. | [
"2\n3 3\n",
"3\n2 1 2\n"
] | [
"2\n",
"2\n"
] | In the first sample you will have to take 2 coins (you and your twin have sums equal to 6, 0 correspondingly). If you take 1 coin, you get sums 3, 3. If you take 0 coins, you get sums 0, 6. Those variants do not satisfy you as your sum should be strictly more that your twins' sum.
In the second sample one coin isn't e... | 500 | [
{
"input": "2\n3 3",
"output": "2"
},
{
"input": "3\n2 1 2",
"output": "2"
},
{
"input": "1\n5",
"output": "1"
},
{
"input": "5\n4 2 2 2 2",
"output": "3"
},
{
"input": "7\n1 10 1 2 1 1 1",
"output": "1"
},
{
"input": "5\n3 2 3 3 1",
"output": "3"
... | 1,688,652,379 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 3 | 92 | 0 | n = int(input())
x = []
sum = 0
y =input()
for i in range(0,n+1,2):
x.append(y[i])
sum += int(y[i])
x.sort()
mina = (sum/2).__floor__() +1
ans_sum = 0
while mina >= 0 :
ans_sum = ans_sum + 1
mina -= int(x[-1])
x.pop()
print (ans_sum)
| Title: Twins
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Imagine that you have a twin brother or sister. Having another person that looks exactly like you seems very unusual. It's hard to say if having something of an alter ego is good or bad. And if you do have a twin, then you very w... | ```python
n = int(input())
x = []
sum = 0
y =input()
for i in range(0,n+1,2):
x.append(y[i])
sum += int(y[i])
x.sort()
mina = (sum/2).__floor__() +1
ans_sum = 0
while mina >= 0 :
ans_sum = ans_sum + 1
mina -= int(x[-1])
x.pop()
print (ans_sum)
``` | 0 | |
574 | A | Bear and Elections | PROGRAMMING | 1,200 | [
"greedy",
"implementation"
] | null | null | Limak is a grizzly bear who desires power and adoration. He wants to win in upcoming elections and rule over the Bearland.
There are *n* candidates, including Limak. We know how many citizens are going to vote for each candidate. Now *i*-th candidate would get *a**i* votes. Limak is candidate number 1. To win in elect... | The first line contains single integer *n* (2<=≤<=*n*<=≤<=100) - number of candidates.
The second line contains *n* space-separated integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=1000) - number of votes for each candidate. Limak is candidate number 1.
Note that after bribing number of votes for some candidate ... | Print the minimum number of citizens Limak must bribe to have strictly more votes than any other candidate. | [
"5\n5 1 11 2 8\n",
"4\n1 8 8 8\n",
"2\n7 6\n"
] | [
"4\n",
"6\n",
"0\n"
] | In the first sample Limak has 5 votes. One of the ways to achieve victory is to bribe 4 citizens who want to vote for the third candidate. Then numbers of votes would be 9, 1, 7, 2, 8 (Limak would have 9 votes). Alternatively, Limak could steal only 3 votes from the third candidate and 1 vote from the second candidate ... | 500 | [
{
"input": "5\n5 1 11 2 8",
"output": "4"
},
{
"input": "4\n1 8 8 8",
"output": "6"
},
{
"input": "2\n7 6",
"output": "0"
},
{
"input": "2\n1 1",
"output": "1"
},
{
"input": "10\n100 200 57 99 1 1000 200 200 200 500",
"output": "451"
},
{
"input": "16\... | 1,444,865,779 | 2,147,483,647 | Python 3 | OK | TESTS | 35 | 62 | 0 | n = int(input())
votes = list(map(int, input().split()))
bear = votes[0]
votes.pop(0)
votes.sort()
votes.reverse()
result = 0
while bear <= votes[0]:
top = votes[0]
for i, vote in enumerate(votes):
if bear > votes[i] or votes[i] != top:
break
votes[i] -= 1
result += 1
bear += 1
print(result)... | Title: Bear and Elections
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Limak is a grizzly bear who desires power and adoration. He wants to win in upcoming elections and rule over the Bearland.
There are *n* candidates, including Limak. We know how many citizens are going to vote for e... | ```python
n = int(input())
votes = list(map(int, input().split()))
bear = votes[0]
votes.pop(0)
votes.sort()
votes.reverse()
result = 0
while bear <= votes[0]:
top = votes[0]
for i, vote in enumerate(votes):
if bear > votes[i] or votes[i] != top:
break
votes[i] -= 1
result += 1
bear += 1
pri... | 3 | |
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,686,841,308 | 2,147,483,647 | Python 3 | OK | TESTS | 48 | 46 | 0 | numbers = list(map(int, input().split()))
max_power = max(numbers)
min_power = min(numbers)
final_power = max_power - min_power
print(final_power)
| 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
numbers = list(map(int, input().split()))
max_power = max(numbers)
min_power = min(numbers)
final_power = max_power - min_power
print(final_power)
``` | 3 | |
887 | A | Div. 64 | PROGRAMMING | 1,000 | [
"implementation"
] | null | null | Top-model Izabella participates in the competition. She wants to impress judges and show her mathematical skills.
Her problem is following: for given string, consisting of only 0 and 1, tell if it's possible to remove some digits in such a way, that remaining number is a representation of some positive integer, divisi... | In the only line given a non-empty binary string *s* with length up to 100. | Print «yes» (without quotes) if it's possible to remove digits required way and «no» otherwise. | [
"100010001\n",
"100\n"
] | [
"yes",
"no"
] | In the first test case, you can get string 1 000 000 after removing two ones which is a representation of number 64 in the binary numerical system.
You can read more about binary numeral system representation here: [https://en.wikipedia.org/wiki/Binary_system](https://en.wikipedia.org/wiki/Binary_system) | 500 | [
{
"input": "100010001",
"output": "yes"
},
{
"input": "100",
"output": "no"
},
{
"input": "0000001000000",
"output": "yes"
},
{
"input": "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111",
"output": "no"
},
{
"in... | 1,509,951,828 | 2,147,483,647 | Python 3 | OK | TESTS | 98 | 62 | 0 | print("yes") if input().lstrip("0").count("0") >= 6 else print("no") | Title: Div. 64
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Top-model Izabella participates in the competition. She wants to impress judges and show her mathematical skills.
Her problem is following: for given string, consisting of only 0 and 1, tell if it's possible to remove some dig... | ```python
print("yes") if input().lstrip("0").count("0") >= 6 else print("no")
``` | 3 | |
269 | B | Greenhouse Effect | PROGRAMMING | 1,700 | [
"dp"
] | null | null | Emuskald is an avid horticulturist and owns the world's longest greenhouse — it is effectively infinite in length.
Over the years Emuskald has cultivated *n* plants in his greenhouse, of *m* different plant species numbered from 1 to *m*. His greenhouse is very narrow and can be viewed as an infinite line, with each p... | The first line of input contains two space-separated integers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=5000, *n*<=≥<=*m*), the number of plants and the number of different species. Each of the following *n* lines contain two space-separated numbers: one integer number *s**i* (1<=≤<=*s**i*<=≤<=*m*), and one real number *x**i* (... | Output a single integer — the minimum number of plants to be replanted. | [
"3 2\n2 1\n1 2.0\n1 3.100\n",
"3 3\n1 5.0\n2 5.5\n3 6.0\n",
"6 3\n1 14.284235\n2 17.921382\n1 20.328172\n3 20.842331\n1 25.790145\n1 27.204125\n"
] | [
"1\n",
"0\n",
"2\n"
] | In the first test case, Emuskald can replant the first plant to the right of the last plant, so the answer is 1.
In the second test case, the species are already in the correct order, so no replanting is needed. | 1,000 | [
{
"input": "3 2\n2 1\n1 2.0\n1 3.100",
"output": "1"
},
{
"input": "3 3\n1 5.0\n2 5.5\n3 6.0",
"output": "0"
},
{
"input": "6 3\n1 14.284235\n2 17.921382\n1 20.328172\n3 20.842331\n1 25.790145\n1 27.204125",
"output": "2"
},
{
"input": "1 1\n1 0",
"output": "0"
},
{
... | 1,617,361,376 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 6 | 92 | 0 | n, m = map(int, input().split())
lst = []
for i in range(n):
a, b = map(str, input().split())
lst.append(a)
check = sorted(lst)
ans = 0
for x, y in zip(lst, check):
if x != y:
ans += 1
print(ans // 2)
| Title: Greenhouse Effect
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Emuskald is an avid horticulturist and owns the world's longest greenhouse — it is effectively infinite in length.
Over the years Emuskald has cultivated *n* plants in his greenhouse, of *m* different plant species n... | ```python
n, m = map(int, input().split())
lst = []
for i in range(n):
a, b = map(str, input().split())
lst.append(a)
check = sorted(lst)
ans = 0
for x, y in zip(lst, check):
if x != y:
ans += 1
print(ans // 2)
``` | 0 | |
218 | B | Airport | PROGRAMMING | 1,100 | [
"implementation"
] | null | null | Lolek and Bolek are about to travel abroad by plane. The local airport has a special "Choose Your Plane" offer. The offer's conditions are as follows:
- it is up to a passenger to choose a plane to fly on; - if the chosen plane has *x* (*x*<=><=0) empty seats at the given moment, then the ticket for such a plane ... | The first line contains two integers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=1000) — the number of passengers in the queue and the number of planes in the airport, correspondingly. The next line contains *m* integers *a*1,<=*a*2,<=...,<=*a**m* (1<=≤<=*a**i*<=≤<=1000) — *a**i* stands for the number of empty seats in the *i*-th... | Print two integers — the maximum and the minimum number of zlotys that the airport administration can earn, correspondingly. | [
"4 3\n2 1 1\n",
"4 3\n2 2 2\n"
] | [
"5 5\n",
"7 6\n"
] | In the first test sample the number of passengers is equal to the number of empty seats, so regardless of the way the planes are chosen, the administration will earn the same sum.
In the second sample the sum is maximized if the 1-st person in the queue buys a ticket to the 1-st plane, the 2-nd person — to the 2-nd pl... | 500 | [
{
"input": "4 3\n2 1 1",
"output": "5 5"
},
{
"input": "4 3\n2 2 2",
"output": "7 6"
},
{
"input": "10 5\n10 3 3 1 2",
"output": "58 26"
},
{
"input": "10 1\n10",
"output": "55 55"
},
{
"input": "10 1\n100",
"output": "955 955"
},
{
"input": "10 2\n4 7... | 1,640,968,651 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 5 | 62 | 0 | n, m = map(int, input().split())
planes = [int(i) for i in input().split()]
temp_1 = planes[:]
temp_2 = planes[:]
maximum = 0
minimum = 0
while n > 0:
maxX = 0
for i in range(m):
if temp_1[i] > temp_1[maxX]:
maxX = i
maximum += temp_1[maxX]
temp_1[maxX] -= 1 ... | Title: Airport
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Lolek and Bolek are about to travel abroad by plane. The local airport has a special "Choose Your Plane" offer. The offer's conditions are as follows:
- it is up to a passenger to choose a plane to fly on; - if the chosen pl... | ```python
n, m = map(int, input().split())
planes = [int(i) for i in input().split()]
temp_1 = planes[:]
temp_2 = planes[:]
maximum = 0
minimum = 0
while n > 0:
maxX = 0
for i in range(m):
if temp_1[i] > temp_1[maxX]:
maxX = i
maximum += temp_1[maxX]
temp_1[max... | -1 | |
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,686,219,950 | 2,147,483,647 | Python 3 | OK | TESTS | 28 | 46 | 0 | # https://codeforces.com/problemset/problem/510/A
class SnakePrinter:
def __init__(self, n: int, m: int):
if (n < 3) or (n % 2 == 0) or (m > 50):
raise ValueError(f"Parameter n={n} or m={m} is out of range")
self.n = n
self.m = m
def print(self) -> None:
... | 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
# https://codeforces.com/problemset/problem/510/A
class SnakePrinter:
def __init__(self, n: int, m: int):
if (n < 3) or (n % 2 == 0) or (m > 50):
raise ValueError(f"Parameter n={n} or m={m} is out of range")
self.n = n
self.m = m
def print(self) -> None... | 3 | |
999 | C | Alphabetic Removals | PROGRAMMING | 1,200 | [
"implementation"
] | null | null | You are given a string $s$ consisting of $n$ lowercase Latin letters. Polycarp wants to remove exactly $k$ characters ($k \le n$) from the string $s$. Polycarp uses the following algorithm $k$ times:
- if there is at least one letter 'a', remove the leftmost occurrence and stop the algorithm, otherwise go to next ite... | The first line of input contains two integers $n$ and $k$ ($1 \le k \le n \le 4 \cdot 10^5$) — the length of the string and the number of letters Polycarp will remove.
The second line contains the string $s$ consisting of $n$ lowercase Latin letters. | Print the string that will be obtained from $s$ after Polycarp removes exactly $k$ letters using the above algorithm $k$ times.
If the resulting string is empty, print nothing. It is allowed to print nothing or an empty line (line break). | [
"15 3\ncccaabababaccbc\n",
"15 9\ncccaabababaccbc\n",
"1 1\nu\n"
] | [
"cccbbabaccbc\n",
"cccccc\n",
""
] | none | 0 | [
{
"input": "15 3\ncccaabababaccbc",
"output": "cccbbabaccbc"
},
{
"input": "15 9\ncccaabababaccbc",
"output": "cccccc"
},
{
"input": "5 2\nzyzyx",
"output": "zzy"
},
{
"input": "4 3\nhack",
"output": "k"
},
{
"input": "4 3\nzzzz",
"output": "z"
},
{
"i... | 1,693,277,351 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 44 | 124 | 28,262,400 | # https://codeforces.com/contest/999
import sys
input = lambda: sys.stdin.readline().rstrip() # faster!
def chr2idx(c):
return ord(c) - 97
n, k = map(int, input().split())
s = input()
cnt = [0] * 26
for c in s:
cnt[chr2idx(c)] += 1
remove = [0] * 26
for i in range(26):
remove[i] = min(k, cnt[i])
... | Title: Alphabetic Removals
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given a string $s$ consisting of $n$ lowercase Latin letters. Polycarp wants to remove exactly $k$ characters ($k \le n$) from the string $s$. Polycarp uses the following algorithm $k$ times:
- if there is... | ```python
# https://codeforces.com/contest/999
import sys
input = lambda: sys.stdin.readline().rstrip() # faster!
def chr2idx(c):
return ord(c) - 97
n, k = map(int, input().split())
s = input()
cnt = [0] * 26
for c in s:
cnt[chr2idx(c)] += 1
remove = [0] * 26
for i in range(26):
remove[i] = min(k, ... | 3 | |
4 | A | Watermelon | PROGRAMMING | 800 | [
"brute force",
"math"
] | A. Watermelon | 1 | 64 | One hot summer day Pete and his friend Billy decided to buy a watermelon. They chose the biggest and the ripest one, in their opinion. After that the watermelon was weighed, and the scales showed *w* kilos. They rushed home, dying of thirst, and decided to divide the berry, however they faced a hard problem.
Pete and ... | The first (and the only) input line contains integer number *w* (1<=≤<=*w*<=≤<=100) — the weight of the watermelon bought by the boys. | Print YES, if the boys can divide the watermelon into two parts, each of them weighing even number of kilos; and NO in the opposite case. | [
"8\n"
] | [
"YES\n"
] | For example, the boys can divide the watermelon into two parts of 2 and 6 kilos respectively (another variant — two parts of 4 and 4 kilos). | 0 | [
{
"input": "8",
"output": "YES"
},
{
"input": "5",
"output": "NO"
},
{
"input": "4",
"output": "YES"
},
{
"input": "3",
"output": "NO"
},
{
"input": "2",
"output": "NO"
},
{
"input": "1",
"output": "NO"
},
{
"input": "7",
"output": "NO"... | 1,693,759,243 | 2,147,483,647 | Python 3 | OK | TESTS | 20 | 92 | 0 | x = int(input())
y = x + 1
if y % 2 == 0 :
print("no")
elif y % 2 != 0 and y >3:
print("yes")
else :
print("no") | Title: Watermelon
Time Limit: 1 seconds
Memory Limit: 64 megabytes
Problem Description:
One hot summer day Pete and his friend Billy decided to buy a watermelon. They chose the biggest and the ripest one, in their opinion. After that the watermelon was weighed, and the scales showed *w* kilos. They rushed home, dyin... | ```python
x = int(input())
y = x + 1
if y % 2 == 0 :
print("no")
elif y % 2 != 0 and y >3:
print("yes")
else :
print("no")
``` | 3.954 |
287 | B | Pipeline | PROGRAMMING | 1,700 | [
"binary search",
"math"
] | null | null | Vova, the Ultimate Thule new shaman, wants to build a pipeline. As there are exactly *n* houses in Ultimate Thule, Vova wants the city to have exactly *n* pipes, each such pipe should be connected to the water supply. A pipe can be connected to the water supply if there's water flowing out of it. Initially Vova has onl... | The first line contains two space-separated integers *n* and *k* (1<=≤<=*n*<=≤<=1018, 2<=≤<=*k*<=≤<=109).
Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. | Print a single integer — the minimum number of splitters needed to build the pipeline. If it is impossible to build a pipeline with the given splitters, print -1. | [
"4 3\n",
"5 5\n",
"8 4\n"
] | [
"2\n",
"1\n",
"-1\n"
] | none | 1,500 | [
{
"input": "4 3",
"output": "2"
},
{
"input": "5 5",
"output": "1"
},
{
"input": "8 4",
"output": "-1"
},
{
"input": "1000000000000000000 1000000000",
"output": "-1"
},
{
"input": "499999998500000001 1000000000",
"output": "999955279"
},
{
"input": "49... | 1,660,557,727 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 6 | 46 | 0 | n,k=map(int,input().split())
cnt=0
def sum1(n):
return (n*(n+1))/2
s=sum1(k-1)
if s<n-1:
print(-1)
else:
low=0
high=k-1
ans=0
while low<=high:
mid=(low+high)>>1
if s-sum1(mid)>=n-1:
low=mid+1
else:
high=mid-1
print(k-1-high)
| Title: Pipeline
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vova, the Ultimate Thule new shaman, wants to build a pipeline. As there are exactly *n* houses in Ultimate Thule, Vova wants the city to have exactly *n* pipes, each such pipe should be connected to the water supply. A pipe c... | ```python
n,k=map(int,input().split())
cnt=0
def sum1(n):
return (n*(n+1))/2
s=sum1(k-1)
if s<n-1:
print(-1)
else:
low=0
high=k-1
ans=0
while low<=high:
mid=(low+high)>>1
if s-sum1(mid)>=n-1:
low=mid+1
else:
high=mid-1
print(k-1-high)
``` | 0 | |
841 | B | Godsend | PROGRAMMING | 1,100 | [
"games",
"math"
] | null | null | Leha somehow found an array consisting of *n* integers. Looking at it, he came up with a task. Two players play the game on the array. Players move one by one. The first player can choose for his move a subsegment of non-zero length with an odd sum of numbers and remove it from the array, after that the remaining parts... | First line of input data contains single integer *n* (1<=≤<=*n*<=≤<=106) — length of the array.
Next line contains *n* integers *a*1,<=*a*2,<=...,<=*a**n* (0<=≤<=*a**i*<=≤<=109). | Output answer in single line. "First", if first player wins, and "Second" otherwise (without quotes). | [
"4\n1 3 2 3\n",
"2\n2 2\n"
] | [
"First\n",
"Second\n"
] | In first sample first player remove whole array in one move and win.
In second sample first player can't make a move and lose. | 1,000 | [
{
"input": "4\n1 3 2 3",
"output": "First"
},
{
"input": "2\n2 2",
"output": "Second"
},
{
"input": "4\n2 4 6 8",
"output": "Second"
},
{
"input": "5\n1 1 1 1 1",
"output": "First"
},
{
"input": "4\n720074544 345031254 849487632 80870826",
"output": "Second"
... | 1,573,119,894 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 4 | 93 | 0 | n=int(input())
p=[int(x) for x in input().split()]
if sum(p)%2!=0:
print('First')
else:
print('Second')
| Title: Godsend
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Leha somehow found an array consisting of *n* integers. Looking at it, he came up with a task. Two players play the game on the array. Players move one by one. The first player can choose for his move a subsegment of non-zero l... | ```python
n=int(input())
p=[int(x) for x in input().split()]
if sum(p)%2!=0:
print('First')
else:
print('Second')
``` | 0 | |
907 | A | Masha and Bears | PROGRAMMING | 1,300 | [
"brute force",
"implementation"
] | null | null | A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larg... | You are given four integers *V*1, *V*2, *V*3, *V**m*(1<=≤<=*V**i*<=≤<=100) — sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that *V*1<=><=*V*2<=><=*V*3. | Output three integers — sizes of father bear's car, mother bear's car and son bear's car, respectively.
If there are multiple possible solutions, print any.
If there is no solution, print "-1" (without quotes). | [
"50 30 10 10\n",
"100 50 10 21\n"
] | [
"50\n30\n10\n",
"-1\n"
] | In first test case all conditions for cars' sizes are satisfied.
In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20. | 500 | [
{
"input": "50 30 10 10",
"output": "50\n30\n10"
},
{
"input": "100 50 10 21",
"output": "-1"
},
{
"input": "100 50 19 10",
"output": "100\n50\n19"
},
{
"input": "99 50 25 49",
"output": "100\n99\n49"
},
{
"input": "3 2 1 1",
"output": "4\n3\n1"
},
{
"... | 1,514,040,181 | 2,281 | Python 3 | WRONG_ANSWER | PRETESTS | 3 | 46 | 5,529,600 | v1,v2,v3,vm=map(int,input().split())
l=[v1,v2,v3,vm]
l.sort()
if 2*l[0]>=l[1]:
print(l[3])
print(l[2])
print(l[1])
else:
print(-1)
| Title: Masha and Bears
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son b... | ```python
v1,v2,v3,vm=map(int,input().split())
l=[v1,v2,v3,vm]
l.sort()
if 2*l[0]>=l[1]:
print(l[3])
print(l[2])
print(l[1])
else:
print(-1)
``` | 0 | |
777 | B | Game of Credit Cards | PROGRAMMING | 1,300 | [
"data structures",
"dp",
"greedy",
"sortings"
] | null | null | After the fourth season Sherlock and Moriary have realized the whole foolishness of the battle between them and decided to continue their competitions in peaceful game of Credit Cards.
Rules of this game are simple: each player bring his favourite *n*-digit credit card. Then both players name the digits written on the... | The first line of the input contains a single integer *n* (1<=≤<=*n*<=≤<=1000) — the number of digits in the cards Sherlock and Moriarty are going to use.
The second line contains *n* digits — Sherlock's credit card number.
The third line contains *n* digits — Moriarty's credit card number. | First print the minimum possible number of flicks Moriarty will get. Then print the maximum possible number of flicks that Sherlock can get from Moriarty. | [
"3\n123\n321\n",
"2\n88\n00\n"
] | [
"0\n2\n",
"2\n0\n"
] | First sample is elaborated in the problem statement. In the second sample, there is no way Moriarty can avoid getting two flicks. | 1,000 | [
{
"input": "3\n123\n321",
"output": "0\n2"
},
{
"input": "2\n88\n00",
"output": "2\n0"
},
{
"input": "1\n4\n5",
"output": "0\n1"
},
{
"input": "1\n8\n7",
"output": "1\n0"
},
{
"input": "2\n55\n55",
"output": "0\n0"
},
{
"input": "3\n534\n432",
"out... | 1,487,939,004 | 2,147,483,647 | Python 3 | OK | TESTS | 55 | 592 | 4,608,000 | n = int(input())
a = sorted(map(int, input()))
b = sorted(map(int, input()))
was = [0] * n
cnt1 = cnt2 = 0
for i in range(n):
mn = 10
ind = -1
for j in range(n):
if not was[j] and a[j] <= b[i] < mn:
mn = a[j]
ind = j
if ind != -1: was[ind] = 1
else: cnt1 ... | Title: Game of Credit Cards
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
After the fourth season Sherlock and Moriary have realized the whole foolishness of the battle between them and decided to continue their competitions in peaceful game of Credit Cards.
Rules of this game are simpl... | ```python
n = int(input())
a = sorted(map(int, input()))
b = sorted(map(int, input()))
was = [0] * n
cnt1 = cnt2 = 0
for i in range(n):
mn = 10
ind = -1
for j in range(n):
if not was[j] and a[j] <= b[i] < mn:
mn = a[j]
ind = j
if ind != -1: was[ind] = 1
e... | 3 | |
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,617,293,527 | 2,147,483,647 | Python 3 | OK | TESTS | 40 | 62 | 0 | s = input()
cs, ci = 'hello', 0
for i in range(len(s)):
if s[i] == cs[ci]:
ci += 1
if ci == 5:
print('YES')
exit(0)
print('NO')
# s = [s[i] for i in range(len(s) - 1) if s[i] != s[i - 1]]
# pass
| Title: Chat room
Time Limit: 1 seconds
Memory Limit: 256 megabytes
Problem Description:
Vasya has recently learned to type and log on to the Internet. He immediately entered a chat room and decided to say hello to everybody. Vasya typed the word *s*. It is considered that Vasya managed to say hello if several letter... | ```python
s = input()
cs, ci = 'hello', 0
for i in range(len(s)):
if s[i] == cs[ci]:
ci += 1
if ci == 5:
print('YES')
exit(0)
print('NO')
# s = [s[i] for i in range(len(s) - 1) if s[i] != s[i - 1]]
# pass
``` | 3.969 |
479 | A | Expression | PROGRAMMING | 1,000 | [
"brute force",
"math"
] | null | null | Petya studies in a school and he adores Maths. His class has been studying arithmetic expressions. On the last class the teacher wrote three positive integers *a*, *b*, *c* on the blackboard. The task was to insert signs of operations '+' and '*', and probably brackets between the numbers so that the value of the resul... | The input contains three integers *a*, *b* and *c*, each on a single line (1<=≤<=*a*,<=*b*,<=*c*<=≤<=10). | Print the maximum value of the expression that you can obtain. | [
"1\n2\n3\n",
"2\n10\n3\n"
] | [
"9\n",
"60\n"
] | none | 500 | [
{
"input": "1\n2\n3",
"output": "9"
},
{
"input": "2\n10\n3",
"output": "60"
},
{
"input": "1\n1\n1",
"output": "3"
},
{
"input": "1\n2\n1",
"output": "4"
},
{
"input": "10\n10\n10",
"output": "1000"
},
{
"input": "5\n1\n3",
"output": "20"
},
{... | 1,698,764,230 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 31 | 0 | a = int(input())
b = int(input())
c = int(input())
wynik1 = a*b*c
wynik2 = (a+b)*c
wynik3 = a*(b+c)
maxoption = max(wynik1,wynik2,wynik3)
print(maxoption)
| Title: Expression
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Petya studies in a school and he adores Maths. His class has been studying arithmetic expressions. On the last class the teacher wrote three positive integers *a*, *b*, *c* on the blackboard. The task was to insert signs of ... | ```python
a = int(input())
b = int(input())
c = int(input())
wynik1 = a*b*c
wynik2 = (a+b)*c
wynik3 = a*(b+c)
maxoption = max(wynik1,wynik2,wynik3)
print(maxoption)
``` | 0 | |
812 | B | Sagheer, the Hausmeister | PROGRAMMING | 1,600 | [
"bitmasks",
"brute force",
"dp"
] | null | null | Some people leave the lights at their workplaces on when they leave that is a waste of resources. As a hausmeister of DHBW, Sagheer waits till all students and professors leave the university building, then goes and turns all the lights off.
The building consists of *n* floors with stairs at the left and the right sid... | The first line contains two integers *n* and *m* (1<=≤<=*n*<=≤<=15 and 1<=≤<=*m*<=≤<=100) — the number of floors and the number of rooms in each floor, respectively.
The next *n* lines contains the building description. Each line contains a binary string of length *m*<=+<=2 representing a floor (the left stairs, then ... | Print a single integer — the minimum total time needed to turn off all the lights. | [
"2 2\n0010\n0100\n",
"3 4\n001000\n000010\n000010\n",
"4 3\n01110\n01110\n01110\n01110\n"
] | [
"5\n",
"12\n",
"18\n"
] | In the first example, Sagheer will go to room 1 in the ground floor, then he will go to room 2 in the second floor using the left or right stairs.
In the second example, he will go to the fourth room in the ground floor, use right stairs, go to the fourth room in the second floor, use right stairs again, then go to th... | 1,000 | [
{
"input": "2 2\n0010\n0100",
"output": "5"
},
{
"input": "3 4\n001000\n000010\n000010",
"output": "12"
},
{
"input": "4 3\n01110\n01110\n01110\n01110",
"output": "18"
},
{
"input": "3 2\n0000\n0100\n0100",
"output": "4"
},
{
"input": "1 89\n0000000000000000000000... | 1,496,684,524 | 2,147,483,647 | PyPy 3 | OK | TESTS | 72 | 140 | 2,867,200 | floors, rooms = map(int, input().split())
m = []
for i in range(floors):
m.append(input())
def solve(current, f=1, cost=0, lastFloor=0):
if f == lastFloor:
return cost
currentFloor = floors - f - 1
first, last = m[currentFloor - 1].find("1"), m[currentFloor - 1].rfind("1")
if first == -1... | Title: Sagheer, the Hausmeister
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Some people leave the lights at their workplaces on when they leave that is a waste of resources. As a hausmeister of DHBW, Sagheer waits till all students and professors leave the university building, then goe... | ```python
floors, rooms = map(int, input().split())
m = []
for i in range(floors):
m.append(input())
def solve(current, f=1, cost=0, lastFloor=0):
if f == lastFloor:
return cost
currentFloor = floors - f - 1
first, last = m[currentFloor - 1].find("1"), m[currentFloor - 1].rfind("1")
if f... | 3 | |
12 | A | Super Agent | PROGRAMMING | 800 | [
"implementation"
] | A. Super Agent | 2 | 256 | There is a very secret base in Potatoland where potato mash is made according to a special recipe. The neighbours from Porridgia decided to seize this recipe and to sell it to Pilauland. For this mission they have been preparing special agent Pearlo for many years. When, finally, Pearlo learned all secrets of espionage... | Input contains the matrix of three rows of three symbols each. Symbol «X» means that the corresponding button was pressed, and «.» means that is was not pressed. The matrix may contain no «X», also it may contain no «.». | Print YES if the password is symmetric with respect to the central button of the terminal and NO otherwise. | [
"XX.\n...\n.XX\n",
"X.X\nX..\n...\n"
] | [
"YES\n",
"NO\n"
] | If you are not familiar with the term «central symmetry», you may look into http://en.wikipedia.org/wiki/Central_symmetry | 0 | [
{
"input": "XX.\n...\n.XX",
"output": "YES"
},
{
"input": ".X.\n.X.\n.X.",
"output": "YES"
},
{
"input": "XXX\nXXX\nXXX",
"output": "YES"
},
{
"input": "XXX\nX.X\nXXX",
"output": "YES"
},
{
"input": "X..\n.X.\n..X",
"output": "YES"
},
{
"input": "...\n... | 1,609,662,406 | 2,147,483,647 | Python 3 | OK | TESTS | 40 | 248 | 307,200 | q=[]
z=[]
w=3
while w>0 :
a=str(input())
q+=a;
z+=a;
w-=1
q[0],q[2]=q[2],q[0]
q[6],q[8]=q[8],q[6]
q[5],q[3]=q[3],q[5]
q[0],q[6],q[1],q[7],q[2],q[8]=q[6],q[0],q[7],q[1],q[8],q[2]
if(z==q):print("YES")
else: print("NO")
| Title: Super Agent
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
There is a very secret base in Potatoland where potato mash is made according to a special recipe. The neighbours from Porridgia decided to seize this recipe and to sell it to Pilauland. For this mission they have been preparin... | ```python
q=[]
z=[]
w=3
while w>0 :
a=str(input())
q+=a;
z+=a;
w-=1
q[0],q[2]=q[2],q[0]
q[6],q[8]=q[8],q[6]
q[5],q[3]=q[3],q[5]
q[0],q[6],q[1],q[7],q[2],q[8]=q[6],q[0],q[7],q[1],q[8],q[2]
if(z==q):print("YES")
else: print("NO")
``` | 3.937428 |
676 | C | Vasya and String | PROGRAMMING | 1,500 | [
"binary search",
"dp",
"strings",
"two pointers"
] | null | null | High school student Vasya got a string of length *n* as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than *k* characters of the original strin... | The first line of the input contains two integers *n* and *k* (1<=≤<=*n*<=≤<=100<=000,<=0<=≤<=*k*<=≤<=*n*) — the length of the string and the maximum number of characters to change.
The second line contains the string, consisting of letters 'a' and 'b' only. | Print the only integer — the maximum beauty of the string Vasya can achieve by changing no more than *k* characters. | [
"4 2\nabba\n",
"8 1\naabaabaa\n"
] | [
"4\n",
"5\n"
] | In the first sample, Vasya can obtain both strings "aaaa" and "bbbb".
In the second sample, the optimal answer is obtained with the string "aaaaabaa" or with the string "aabaaaaa". | 1,500 | [
{
"input": "4 2\nabba",
"output": "4"
},
{
"input": "8 1\naabaabaa",
"output": "5"
},
{
"input": "1 0\na",
"output": "1"
},
{
"input": "1 1\nb",
"output": "1"
},
{
"input": "1 0\nb",
"output": "1"
},
{
"input": "1 1\na",
"output": "1"
},
{
... | 1,696,071,171 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 7 | 62 | 0 | # Author : //- kibrom Hailu -\\
import sys
# from typing import Counter
from collections import Counter, defaultdict, deque
# from math import ceil, floor, gcd, inf, sqrt
# from itertools import permutations, combinations, accumulate
# from bisect import bisect_left, bisect_right
# from heapq imortt heapify ,... | Title: Vasya and String
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
High school student Vasya got a string of length *n* as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequ... | ```python
# Author : //- kibrom Hailu -\\
import sys
# from typing import Counter
from collections import Counter, defaultdict, deque
# from math import ceil, floor, gcd, inf, sqrt
# from itertools import permutations, combinations, accumulate
# from bisect import bisect_left, bisect_right
# from heapq imortt... | 0 | |
208 | A | Dubstep | PROGRAMMING | 900 | [
"strings"
] | null | null | Vasya works as a DJ in the best Berland nightclub, and he often uses dubstep music in his performance. Recently, he has decided to take a couple of old songs and make dubstep remixes from them.
Let's assume that a song consists of some number of words. To make the dubstep remix of this song, Vasya inserts a certain nu... | The input consists of a single non-empty string, consisting only of uppercase English letters, the string's length doesn't exceed 200 characters. It is guaranteed that before Vasya remixed the song, no word contained substring "WUB" in it; Vasya didn't change the word order. It is also guaranteed that initially the son... | Print the words of the initial song that Vasya used to make a dubsteb remix. Separate the words with a space. | [
"WUBWUBABCWUB\n",
"WUBWEWUBAREWUBWUBTHEWUBCHAMPIONSWUBMYWUBFRIENDWUB\n"
] | [
"ABC ",
"WE ARE THE CHAMPIONS MY FRIEND "
] | In the first sample: "WUBWUBABCWUB" = "WUB" + "WUB" + "ABC" + "WUB". That means that the song originally consisted of a single word "ABC", and all words "WUB" were added by Vasya.
In the second sample Vasya added a single word "WUB" between all neighbouring words, in the beginning and in the end, except for words "ARE... | 500 | [
{
"input": "WUBWUBABCWUB",
"output": "ABC "
},
{
"input": "WUBWEWUBAREWUBWUBTHEWUBCHAMPIONSWUBMYWUBFRIENDWUB",
"output": "WE ARE THE CHAMPIONS MY FRIEND "
},
{
"input": "WUBWUBWUBSR",
"output": "SR "
},
{
"input": "RWUBWUBWUBLWUB",
"output": "R L "
},
{
"input": "... | 1,689,314,858 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 30 | 0 | s = input()
split_ = s.split('WUB')
check = split_.replace(" ","")
print(check) | Title: Dubstep
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vasya works as a DJ in the best Berland nightclub, and he often uses dubstep music in his performance. Recently, he has decided to take a couple of old songs and make dubstep remixes from them.
Let's assume that a song consist... | ```python
s = input()
split_ = s.split('WUB')
check = split_.replace(" ","")
print(check)
``` | -1 | |
938 | A | Word Correction | PROGRAMMING | 800 | [
"implementation"
] | null | null | Victor tries to write his own text editor, with word correction included. However, the rules of word correction are really strange.
Victor thinks that if a word contains two consecutive vowels, then it's kinda weird and it needs to be replaced. So the word corrector works in such a way: as long as there are two consec... | The first line contains one integer *n* (1<=≤<=*n*<=≤<=100) — the number of letters in word *s* before the correction.
The second line contains a string *s* consisting of exactly *n* lowercase Latin letters — the word before the correction. | Output the word *s* after the correction. | [
"5\nweird\n",
"4\nword\n",
"5\naaeaa\n"
] | [
"werd\n",
"word\n",
"a\n"
] | Explanations of the examples:
1. There is only one replace: weird <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/70a0795f45d32287dba0eb83fc4a3f470c6e5537.png" style="max-width: 100.0%;max-height: 100.0%;"/> werd;1. No replace needed since there are no two consecutive vowels;1. aaeaa <i... | 0 | [
{
"input": "5\nweird",
"output": "werd"
},
{
"input": "4\nword",
"output": "word"
},
{
"input": "5\naaeaa",
"output": "a"
},
{
"input": "100\naaaaabbbbboyoyoyoyoyacadabbbbbiuiufgiuiuaahjabbbklboyoyoyoyoyaaaaabbbbbiuiuiuiuiuaaaaabbbbbeyiyuyzyw",
"output": "abbbbbocadabbbbb... | 1,679,683,000 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 49 | 62 | 0 | n = int(input())
a = input()
res = a[0]
s = ["a", "e", "i", "o", "u", "y"]
for i in a[1:]:
if i in s and res[-1] not in s:
res += i
elif i not in s:
res += i
print(res) | Title: Word Correction
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Victor tries to write his own text editor, with word correction included. However, the rules of word correction are really strange.
Victor thinks that if a word contains two consecutive vowels, then it's kinda weird an... | ```python
n = int(input())
a = input()
res = a[0]
s = ["a", "e", "i", "o", "u", "y"]
for i in a[1:]:
if i in s and res[-1] not in s:
res += i
elif i not in s:
res += i
print(res)
``` | 3 | |
600 | C | Make Palindrome | PROGRAMMING | 1,800 | [
"constructive algorithms",
"greedy",
"strings"
] | null | null | A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "abb" and "ij" are not.
You are given string *s* consisting of lowercase Latin letters. At once you can choose any position in ... | The only line contains string *s* (1<=≤<=|*s*|<=≤<=2·105) consisting of only lowercase Latin letters. | Print the lexicographically smallest palindrome that can be obtained with the minimal number of changes. | [
"aabc\n",
"aabcd\n"
] | [
"abba\n",
"abcba\n"
] | none | 0 | [
{
"input": "aabc",
"output": "abba"
},
{
"input": "aabcd",
"output": "abcba"
},
{
"input": "u",
"output": "u"
},
{
"input": "ttttt",
"output": "ttttt"
},
{
"input": "xxxvvvxxvv",
"output": "vvvxxxxvvv"
},
{
"input": "wrwrwfrrfrffrrwwwffffwrfrrwfrrfrwwf... | 1,689,432,298 | 2,147,483,647 | PyPy 3 | COMPILATION_ERROR | TESTS | 0 | 0 | 0 | #include "bits/stdc++.h"
#include <iostream>
using namespace std;
#define max(a, b) (a < b ? b : a)
#define min(a, b) ((a > b) ? b : a)
#define mod 1e9 + 7
#define FOR(a, c) for (long long(a) = 0; (a) < (c); (a)++)
#define FORL(i, start, end) for (long long(i) = (start); (i) <= (end); (i)++)
#define FORR(i, end, start... | Title: Make Palindrome
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "abb" and "ij" are not.
Yo... | ```python
#include "bits/stdc++.h"
#include <iostream>
using namespace std;
#define max(a, b) (a < b ? b : a)
#define min(a, b) ((a > b) ? b : a)
#define mod 1e9 + 7
#define FOR(a, c) for (long long(a) = 0; (a) < (c); (a)++)
#define FORL(i, start, end) for (long long(i) = (start); (i) <= (end); (i)++)
#define FORR(i, ... | -1 | |
23 | C | Oranges and Apples | PROGRAMMING | 2,500 | [
"constructive algorithms",
"sortings"
] | C. Oranges and Apples | 1 | 256 | In 2*N*<=-<=1 boxes there are apples and oranges. Your task is to choose *N* boxes so, that they will contain not less than half of all the apples and not less than half of all the oranges. | The first input line contains one number *T* — amount of tests. The description of each test starts with a natural number *N* — amount of boxes. Each of the following 2*N*<=-<=1 lines contains numbers *a**i* and *o**i* — amount of apples and oranges in the *i*-th box (0<=≤<=*a**i*,<=*o**i*<=≤<=109). The sum of *N* in a... | For each test output two lines. In the first line output YES, if it's possible to choose *N* boxes, or NO otherwise. If the answer is positive output in the second line *N* numbers — indexes of the chosen boxes. Boxes are numbered from 1 in the input order. Otherwise leave the second line empty. Separate the numbers wi... | [
"2\n2\n10 15\n5 7\n20 18\n1\n0 0\n"
] | [
"YES\n1 3\nYES\n1\n"
] | none | 0 | [
{
"input": "2\n2\n10 15\n5 7\n20 18\n1\n0 0",
"output": "YES\n3 1\nYES\n1"
}
] | 1,661,856,231 | 2,147,483,647 | Python 3 | OK | TESTS | 25 | 1,294 | 24,371,200 |
t=int(input())
for _ in range(t):
n=int(input())
nums=[]
for i in range(2*n-1):
a,b=map(int,input().split())
nums.append([b,a,i+1])
nums=sorted(nums)[::-1]
vals=[nums[0][2]]
i=1
while(i+1<len(nums)):
c=i
if(nums[i][1]<nums[i+1][1]):
c=i+1
... | Title: Oranges and Apples
Time Limit: 1 seconds
Memory Limit: 256 megabytes
Problem Description:
In 2*N*<=-<=1 boxes there are apples and oranges. Your task is to choose *N* boxes so, that they will contain not less than half of all the apples and not less than half of all the oranges.
Input Specification:
The firs... | ```python
t=int(input())
for _ in range(t):
n=int(input())
nums=[]
for i in range(2*n-1):
a,b=map(int,input().split())
nums.append([b,a,i+1])
nums=sorted(nums)[::-1]
vals=[nums[0][2]]
i=1
while(i+1<len(nums)):
c=i
if(nums[i][1]<nums[i+1][1]):
c=i+... | 3.307605 |
967 | A | Mind the Gap | PROGRAMMING | 1,100 | [
"implementation"
] | null | null | These days Arkady works as an air traffic controller at a large airport. He controls a runway which is usually used for landings only. Thus, he has a schedule of planes that are landing in the nearest future, each landing lasts $1$ minute.
He was asked to insert one takeoff in the schedule. The takeoff takes $1$ minut... | The first line of input contains two integers $n$ and $s$ ($1 \le n \le 100$, $1 \le s \le 60$) — the number of landings on the schedule and the minimum allowed time (in minutes) between a landing and a takeoff.
Each of next $n$ lines contains two integers $h$ and $m$ ($0 \le h \le 23$, $0 \le m \le 59$) — the time, i... | Print two integers $h$ and $m$ — the hour and the minute from the current moment of the earliest time Arkady can insert the takeoff. | [
"6 60\n0 0\n1 20\n3 21\n5 0\n19 30\n23 40\n",
"16 50\n0 30\n1 20\n3 0\n4 30\n6 10\n7 50\n9 30\n11 10\n12 50\n14 30\n16 10\n17 50\n19 30\n21 10\n22 50\n23 59\n",
"3 17\n0 30\n1 0\n12 0\n"
] | [
"6 1\n",
"24 50\n",
"0 0\n"
] | In the first example note that there is not enough time between 1:20 and 3:21, because each landing and the takeoff take one minute.
In the second example there is no gaps in the schedule, so Arkady can only add takeoff after all landings. Note that it is possible that one should wait more than $24$ hours to insert th... | 500 | [
{
"input": "6 60\n0 0\n1 20\n3 21\n5 0\n19 30\n23 40",
"output": "6 1"
},
{
"input": "16 50\n0 30\n1 20\n3 0\n4 30\n6 10\n7 50\n9 30\n11 10\n12 50\n14 30\n16 10\n17 50\n19 30\n21 10\n22 50\n23 59",
"output": "24 50"
},
{
"input": "3 17\n0 30\n1 0\n12 0",
"output": "0 0"
},
{
... | 1,619,128,404 | 2,147,483,647 | PyPy 3 | OK | TESTS | 34 | 108 | 0 | n, s = map(int, input().split())
flights = []
for plane in range(n):
h, m = map(int, input().split())
flights.append(h * 60 + m)
#print(flights)
gapneeded = (s + 1) * 2
if flights[0] > s:
print(0, 0)
exit()
flights.insert(0, 0)
for x in range(n):
if flights[x + 1] - flights[x... | Title: Mind the Gap
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
These days Arkady works as an air traffic controller at a large airport. He controls a runway which is usually used for landings only. Thus, he has a schedule of planes that are landing in the nearest future, each landing ... | ```python
n, s = map(int, input().split())
flights = []
for plane in range(n):
h, m = map(int, input().split())
flights.append(h * 60 + m)
#print(flights)
gapneeded = (s + 1) * 2
if flights[0] > s:
print(0, 0)
exit()
flights.insert(0, 0)
for x in range(n):
if flights[x + 1] -... | 3 | |
258 | A | Little Elephant and Bits | PROGRAMMING | 1,100 | [
"greedy",
"math"
] | null | null | The Little Elephant has an integer *a*, written in the binary notation. He wants to write this number on a piece of paper.
To make sure that the number *a* fits on the piece of paper, the Little Elephant ought to delete exactly one any digit from number *a* in the binary record. At that a new number appears. It consis... | The single line contains integer *a*, written in the binary notation without leading zeroes. This number contains more than 1 and at most 105 digits. | In the single line print the number that is written without leading zeroes in the binary notation — the answer to the problem. | [
"101\n",
"110010\n"
] | [
"11\n",
"11010\n"
] | In the first sample the best strategy is to delete the second digit. That results in number 11<sub class="lower-index">2</sub> = 3<sub class="lower-index">10</sub>.
In the second sample the best strategy is to delete the third or fourth digits — that results in number 11010<sub class="lower-index">2</sub> = 26<sub cla... | 500 | [
{
"input": "101",
"output": "11"
},
{
"input": "110010",
"output": "11010"
},
{
"input": "10000",
"output": "1000"
},
{
"input": "1111111110",
"output": "111111111"
},
{
"input": "10100101011110101",
"output": "1100101011110101"
},
{
"input": "11101001... | 1,536,112,178 | 2,147,483,647 | Python 3 | OK | TESTS | 37 | 248 | 307,200 | s = input( )
idx = max( 0 , s.find( '0' ) )
print( s[ : idx ] + s[idx + 1 : ] ) | Title: Little Elephant and Bits
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The Little Elephant has an integer *a*, written in the binary notation. He wants to write this number on a piece of paper.
To make sure that the number *a* fits on the piece of paper, the Little Elephant ought... | ```python
s = input( )
idx = max( 0 , s.find( '0' ) )
print( s[ : idx ] + s[idx + 1 : ] )
``` | 3 | |
821 | B | Okabe and Banana Trees | PROGRAMMING | 1,300 | [
"brute force",
"math"
] | null | null | Okabe needs bananas for one of his experiments for some strange reason. So he decides to go to the forest and cut banana trees.
Consider the point (*x*,<=*y*) in the 2D plane such that *x* and *y* are integers and 0<=≤<=*x*,<=*y*. There is a tree in such a point, and it has *x*<=+<=*y* bananas. There are no trees nor ... | The first line of input contains two space-separated integers *m* and *b* (1<=≤<=*m*<=≤<=1000, 1<=≤<=*b*<=≤<=10000). | Print the maximum number of bananas Okabe can get from the trees he cuts. | [
"1 5\n",
"2 3\n"
] | [
"30\n",
"25\n"
] | The graph above corresponds to sample test 1. The optimal rectangle is shown in red and has 30 bananas. | 1,000 | [
{
"input": "1 5",
"output": "30"
},
{
"input": "2 3",
"output": "25"
},
{
"input": "4 6",
"output": "459"
},
{
"input": "6 3",
"output": "171"
},
{
"input": "1 1",
"output": "1"
},
{
"input": "10 1",
"output": "55"
},
{
"input": "20 10",
... | 1,498,534,944 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 7 | 2,000 | 6,041,600 | A=list(map(int,input().split()))
m,b=A[0],A[1]
l=[]
x=0
y=-x//m+b
l+=[(y,x)]
x=1*m ; i=1
while y>0:
y=-x//m+b
l+=[(y,x)]
i+=1
x=m*i
if l[0][0]==1:
s=0
for i in range(l[0][0]):
s+=i
def banana(x,y):
s=0
for i in range(x+1):
s+=i
banan=0
for i i... | Title: Okabe and Banana Trees
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Okabe needs bananas for one of his experiments for some strange reason. So he decides to go to the forest and cut banana trees.
Consider the point (*x*,<=*y*) in the 2D plane such that *x* and *y* are integers a... | ```python
A=list(map(int,input().split()))
m,b=A[0],A[1]
l=[]
x=0
y=-x//m+b
l+=[(y,x)]
x=1*m ; i=1
while y>0:
y=-x//m+b
l+=[(y,x)]
i+=1
x=m*i
if l[0][0]==1:
s=0
for i in range(l[0][0]):
s+=i
def banana(x,y):
s=0
for i in range(x+1):
s+=i
banan=0
... | 0 | |
976 | A | Minimum Binary Number | PROGRAMMING | 800 | [
"implementation"
] | null | null | String can be called correct if it consists of characters "0" and "1" and there are no redundant leading zeroes. Here are some examples: "0", "10", "1001".
You are given a correct string *s*.
You can perform two different operations on this string:
1. swap any pair of adjacent characters (for example, "101" "110"... | The first line contains integer number *n* (1<=≤<=*n*<=≤<=100) — the length of string *s*.
The second line contains the string *s* consisting of characters "0" and "1". It is guaranteed that the string *s* is correct. | Print one string — the minimum correct string that you can obtain from the given one. | [
"4\n1001\n",
"1\n1\n"
] | [
"100\n",
"1\n"
] | In the first example you can obtain the answer by the following sequence of operations: "1001" <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/70a0795f45d32287dba0eb83fc4a3f470c6e5537.png" style="max-width: 100.0%;max-height: 100.0%;"/> "1010" <img align="middle" class="tex-formula" src="ht... | 0 | [
{
"input": "4\n1001",
"output": "100"
},
{
"input": "1\n1",
"output": "1"
},
{
"input": "100\n1110111100001111011111111010110011111111011110000111101101011100110110001011000000101010110101011100",
"output": "1000000000000000000000000000000000000000"
},
{
"input": "100\n100000... | 1,526,370,272 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 77 | 6,963,200 | n, k = list(map(int, input().split()))
while k > n % 10:
k -= n%10 + 1
n //= 10
n -= k
print(n)
| Title: Minimum Binary Number
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
String can be called correct if it consists of characters "0" and "1" and there are no redundant leading zeroes. Here are some examples: "0", "10", "1001".
You are given a correct string *s*.
You can perform two... | ```python
n, k = list(map(int, input().split()))
while k > n % 10:
k -= n%10 + 1
n //= 10
n -= k
print(n)
``` | -1 | |
357 | A | Group of Students | PROGRAMMING | 1,000 | [
"brute force",
"greedy",
"implementation"
] | null | null | At the beginning of the school year Berland State University starts two city school programming groups, for beginners and for intermediate coders. The children were tested in order to sort them into groups. According to the results, each student got some score from 1 to *m* points. We know that *c*1 schoolchildren got ... | The first line contains integer *m* (2<=≤<=*m*<=≤<=100). The second line contains *m* integers *c*1, *c*2, ..., *c**m*, separated by single spaces (0<=≤<=*c**i*<=≤<=100). The third line contains two space-separated integers *x* and *y* (1<=≤<=*x*<=≤<=*y*<=≤<=10000). At least one *c**i* is greater than 0. | If it is impossible to pick a passing rate in a way that makes the size of each resulting groups at least *x* and at most *y*, print 0. Otherwise, print an integer from 1 to *m* — the passing rate you'd like to suggest. If there are multiple possible answers, print any of them. | [
"5\n3 4 3 2 1\n6 8\n",
"5\n0 3 3 4 2\n3 10\n",
"2\n2 5\n3 6\n"
] | [
"3\n",
"4\n",
"0\n"
] | In the first sample the beginner group has 7 students, the intermediate group has 6 of them.
In the second sample another correct answer is 3. | 500 | [
{
"input": "5\n3 4 3 2 1\n6 8",
"output": "3"
},
{
"input": "5\n0 3 3 4 2\n3 10",
"output": "4"
},
{
"input": "2\n2 5\n3 6",
"output": "0"
},
{
"input": "3\n0 1 0\n2 10",
"output": "0"
},
{
"input": "5\n2 2 2 2 2\n5 5",
"output": "0"
},
{
"input": "10\... | 1,383,938,983 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 45 | 62 | 307,200 | dumb = input()
l = [int(o) for o in input().split()]
x, y = [int(o) for o in input().split()]
def Valid(l, k, x, y):
s = 0
for i in range(k):
s += l[i]
if s >= x and s <= y and sum(l) - s <= y and s != sum(l) and s != 0:
return True
return False
for i in range(len(l... | Title: Group of Students
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
At the beginning of the school year Berland State University starts two city school programming groups, for beginners and for intermediate coders. The children were tested in order to sort them into groups. According ... | ```python
dumb = input()
l = [int(o) for o in input().split()]
x, y = [int(o) for o in input().split()]
def Valid(l, k, x, y):
s = 0
for i in range(k):
s += l[i]
if s >= x and s <= y and sum(l) - s <= y and s != sum(l) and s != 0:
return True
return False
for i in r... | 0 | |
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,665,099,669 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 92 | 0 | n=input().split()
a=max(n[0],n[1])
b=7-int(a)
if b==2:
print("1/3")
elif b==3:
print("1/2")
elif b==4:
print("2/3")
else:
print(str(b)+"/"+"6") | Title: Die Roll
Time Limit: 1 seconds
Memory Limit: 64 megabytes
Problem Description:
Yakko, Wakko and Dot, world-famous animaniacs, decided to rest from acting in cartoons, and take a leave to travel a bit. Yakko dreamt to go to Pennsylvania, his Motherland and the Motherland of his ancestors. Wakko thought about T... | ```python
n=input().split()
a=max(n[0],n[1])
b=7-int(a)
if b==2:
print("1/3")
elif b==3:
print("1/2")
elif b==4:
print("2/3")
else:
print(str(b)+"/"+"6")
``` | 0 |
818 | A | Diplomas and Certificates | PROGRAMMING | 800 | [
"implementation",
"math"
] | null | null | There are *n* students who have taken part in an olympiad. Now it's time to award the students.
Some of them will receive diplomas, some wiil get certificates, and others won't receive anything. Students with diplomas and certificates are called winners. But there are some rules of counting the number of diplomas and ... | The first (and the only) line of input contains two integers *n* and *k* (1<=≤<=*n*,<=*k*<=≤<=1012), where *n* is the number of students and *k* is the ratio between the number of certificates and the number of diplomas. | Output three numbers: the number of students with diplomas, the number of students with certificates and the number of students who are not winners in case when the number of winners is maximum possible.
It's possible that there are no winners. | [
"18 2\n",
"9 10\n",
"1000000000000 5\n",
"1000000000000 499999999999\n"
] | [
"3 6 9\n",
"0 0 9\n",
"83333333333 416666666665 500000000002\n",
"1 499999999999 500000000000\n"
] | none | 0 | [
{
"input": "18 2",
"output": "3 6 9"
},
{
"input": "9 10",
"output": "0 0 9"
},
{
"input": "1000000000000 5",
"output": "83333333333 416666666665 500000000002"
},
{
"input": "1000000000000 499999999999",
"output": "1 499999999999 500000000000"
},
{
"input": "1 1",... | 1,588,241,410 | 2,147,483,647 | Python 3 | OK | TESTS | 44 | 109 | 0 |
n, k = map(int, input().split())
dips = (n // 2) // (k + 1)
print(dips , dips * k, n - (1 + k) * dips) | Title: Diplomas and Certificates
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
There are *n* students who have taken part in an olympiad. Now it's time to award the students.
Some of them will receive diplomas, some wiil get certificates, and others won't receive anything. Students with... | ```python
n, k = map(int, input().split())
dips = (n // 2) // (k + 1)
print(dips , dips * k, n - (1 + k) * dips)
``` | 3 | |
686 | A | Free Ice Cream | PROGRAMMING | 800 | [
"constructive algorithms",
"implementation"
] | null | null | After their adventure with the magic mirror Kay and Gerda have returned home and sometimes give free ice cream to kids in the summer.
At the start of the day they have *x* ice cream packs. Since the ice cream is free, people start standing in the queue before Kay and Gerda's house even in the night. Each person in the... | The first line contains two space-separated integers *n* and *x* (1<=≤<=*n*<=≤<=1000, 0<=≤<=*x*<=≤<=109).
Each of the next *n* lines contains a character '+' or '-', and an integer *d**i*, separated by a space (1<=≤<=*d**i*<=≤<=109). Record "+ *d**i*" in *i*-th line means that a carrier with *d**i* ice cream packs occ... | Print two space-separated integers — number of ice cream packs left after all operations, and number of kids that left the house in distress. | [
"5 7\n+ 5\n- 10\n- 20\n+ 40\n- 20\n",
"5 17\n- 16\n- 2\n- 98\n+ 100\n- 98\n"
] | [
"22 1\n",
"3 2\n"
] | Consider the first sample.
1. Initially Kay and Gerda have 7 packs of ice cream. 1. Carrier brings 5 more, so now they have 12 packs. 1. A kid asks for 10 packs and receives them. There are only 2 packs remaining. 1. Another kid asks for 20 packs. Kay and Gerda do not have them, so the kid goes away distressed. 1.... | 500 | [
{
"input": "5 7\n+ 5\n- 10\n- 20\n+ 40\n- 20",
"output": "22 1"
},
{
"input": "5 17\n- 16\n- 2\n- 98\n+ 100\n- 98",
"output": "3 2"
},
{
"input": "6 1000000000\n+ 1000000000\n+ 1000000000\n+ 1000000000\n+ 1000000000\n+ 1000000000\n+ 1000000000",
"output": "7000000000 0"
},
{
... | 1,695,995,085 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 34 | 93 | 1,740,800 | n,t = map(int,input().split())
ans=0
for i in range(n):
z, a = input().split()
a = int(a)
if z=='-' and a>t:
ans+=1
elif z=='-' and a<=t:
t-=a
else:
t+=a
print(t, ans)
| Title: Free Ice Cream
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
After their adventure with the magic mirror Kay and Gerda have returned home and sometimes give free ice cream to kids in the summer.
At the start of the day they have *x* ice cream packs. Since the ice cream is free, p... | ```python
n,t = map(int,input().split())
ans=0
for i in range(n):
z, a = input().split()
a = int(a)
if z=='-' and a>t:
ans+=1
elif z=='-' and a<=t:
t-=a
else:
t+=a
print(t, ans)
``` | 3 | |
139 | A | Petr and Book | PROGRAMMING | 1,000 | [
"implementation"
] | null | null | One Sunday Petr went to a bookshop and bought a new book on sports programming. The book had exactly *n* pages.
Petr decided to start reading it starting from the next day, that is, from Monday. Petr's got a very tight schedule and for each day of the week he knows how many pages he will be able to read on that day. S... | The first input line contains the single integer *n* (1<=≤<=*n*<=≤<=1000) — the number of pages in the book.
The second line contains seven non-negative space-separated integers that do not exceed 1000 — those integers represent how many pages Petr can read on Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and... | Print a single number — the number of the day of the week, when Petr will finish reading the book. The days of the week are numbered starting with one in the natural order: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday. | [
"100\n15 20 20 15 10 30 45\n",
"2\n1 0 0 0 0 0 0\n"
] | [
"6\n",
"1\n"
] | Note to the first sample:
By the end of Monday and therefore, by the beginning of Tuesday Petr has 85 pages left. He has 65 pages left by Wednesday, 45 by Thursday, 30 by Friday, 20 by Saturday and on Saturday Petr finishes reading the book (and he also has time to read 10 pages of something else).
Note to the second... | 500 | [
{
"input": "100\n15 20 20 15 10 30 45",
"output": "6"
},
{
"input": "2\n1 0 0 0 0 0 0",
"output": "1"
},
{
"input": "100\n100 200 100 200 300 400 500",
"output": "1"
},
{
"input": "3\n1 1 1 1 1 1 1",
"output": "3"
},
{
"input": "1\n1 1 1 1 1 1 1",
"output": "1... | 1,698,568,192 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 49 | 124 | 1,638,400 | d = 0
n = int(input())
a = list(map(int, input().split()))
if sum(a) > n:
for index, i in enumerate(a):
d += i
if d >= n:
c = index
break
else:
while d < n:
for index, i in enumerate(a):
d += i
if d >= n:
c =... | Title: Petr and Book
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
One Sunday Petr went to a bookshop and bought a new book on sports programming. The book had exactly *n* pages.
Petr decided to start reading it starting from the next day, that is, from Monday. Petr's got a very tight s... | ```python
d = 0
n = int(input())
a = list(map(int, input().split()))
if sum(a) > n:
for index, i in enumerate(a):
d += i
if d >= n:
c = index
break
else:
while d < n:
for index, i in enumerate(a):
d += i
if d >= n:
... | 3 | |
989 | A | A Blend of Springtime | PROGRAMMING | 900 | [
"implementation",
"strings"
] | null | null | "What a pity it's already late spring," sighs Mino with regret, "one more drizzling night and they'd be gone."
"But these blends are at their best, aren't they?" Absorbed in the landscape, Kanno remains optimistic.
The landscape can be expressed as a row of consecutive cells, each of which either contains a flower o... | The first and only line of input contains a non-empty string $s$ consisting of uppercase English letters 'A', 'B', 'C' and characters '.' (dots) only ($\lvert s \rvert \leq 100$) — denoting cells containing an amber flower, a buff one, a canary yellow one, and no flowers, respectively. | Output "Yes" if it's possible that all three colours appear in some cell, and "No" otherwise.
You can print each letter in any case (upper or lower). | [
".BAC.\n",
"AA..CB\n"
] | [
"Yes\n",
"No\n"
] | In the first example, the buff and canary yellow flowers can leave their petals in the central cell, blending all three colours in it.
In the second example, it's impossible to satisfy the requirement because there is no way that amber and buff meet in any cell. | 500 | [
{
"input": ".BAC.",
"output": "Yes"
},
{
"input": "AA..CB",
"output": "No"
},
{
"input": ".",
"output": "No"
},
{
"input": "ACB.AAAAAA",
"output": "Yes"
},
{
"input": "B.BC.BBBCA",
"output": "Yes"
},
{
"input": "BA..CAB..B",
"output": "Yes"
},
... | 1,529,777,393 | 293 | Python 3 | OK | TESTS | 37 | 93 | 0 | s = input()
ans = 'No'
for i in range(1, len(s)-1):
if sorted(s[i-1:i+2]) == ['A','B','C']:
ans = 'Yes'
break
print(ans) | Title: A Blend of Springtime
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
"What a pity it's already late spring," sighs Mino with regret, "one more drizzling night and they'd be gone."
"But these blends are at their best, aren't they?" Absorbed in the landscape, Kanno remains optimisti... | ```python
s = input()
ans = 'No'
for i in range(1, len(s)-1):
if sorted(s[i-1:i+2]) == ['A','B','C']:
ans = 'Yes'
break
print(ans)
``` | 3 | |
1,008 | A | Romaji | PROGRAMMING | 900 | [
"implementation",
"strings"
] | null | null | Vitya has just started learning Berlanese language. It is known that Berlanese uses the Latin alphabet. Vowel letters are "a", "o", "u", "i", and "e". Other letters are consonant.
In Berlanese, there has to be a vowel after every consonant, but there can be any letter after any vowel. The only exception is a consonant... | The first line of the input contains the string $s$ consisting of $|s|$ ($1\leq |s|\leq 100$) lowercase Latin letters. | Print "YES" (without quotes) if there is a vowel after every consonant except "n", otherwise print "NO".
You can print each letter in any case (upper or lower). | [
"sumimasen\n",
"ninja\n",
"codeforces\n"
] | [
"YES\n",
"YES\n",
"NO\n"
] | In the first and second samples, a vowel goes after each consonant except "n", so the word is Berlanese.
In the third sample, the consonant "c" goes after the consonant "r", and the consonant "s" stands on the end, so the word is not Berlanese. | 500 | [
{
"input": "sumimasen",
"output": "YES"
},
{
"input": "ninja",
"output": "YES"
},
{
"input": "codeforces",
"output": "NO"
},
{
"input": "auuaoonntanonnuewannnnpuuinniwoonennyolonnnvienonpoujinndinunnenannmuveoiuuhikucuziuhunnnmunzancenen",
"output": "YES"
},
{
"in... | 1,636,872,863 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 3 | 46 | 4,505,600 | # taking a str input
s = input()
#using len() to find the no of char in s
n = len(s)
# a function to check if char's are vowels or not
def is_vowel(char) :
if char == 'a' or char == 'e' or char == 'i' or char == 'o' or char == 'u' :
return True
else :
return False
#default result
result = "YES"
... | Title: Romaji
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vitya has just started learning Berlanese language. It is known that Berlanese uses the Latin alphabet. Vowel letters are "a", "o", "u", "i", and "e". Other letters are consonant.
In Berlanese, there has to be a vowel after eve... | ```python
# taking a str input
s = input()
#using len() to find the no of char in s
n = len(s)
# a function to check if char's are vowels or not
def is_vowel(char) :
if char == 'a' or char == 'e' or char == 'i' or char == 'o' or char == 'u' :
return True
else :
return False
#default result
result... | 0 | |
80 | A | Panoramix's Prediction | PROGRAMMING | 800 | [
"brute force"
] | A. Panoramix's Prediction | 2 | 256 | A prime number is a number which has exactly two distinct divisors: one and itself. For example, numbers 2, 7, 3 are prime, and 1, 6, 4 are not.
The next prime number after *x* is the smallest prime number greater than *x*. For example, the next prime number after 2 is 3, and the next prime number after 3 is 5. Note t... | The first and only input line contains two positive integers — *n* and *m* (2<=≤<=*n*<=<<=*m*<=≤<=50). It is guaranteed that *n* is prime.
Pretests contain all the cases with restrictions 2<=≤<=*n*<=<<=*m*<=≤<=4. | Print YES, if *m* is the next prime number after *n*, or NO otherwise. | [
"3 5\n",
"7 11\n",
"7 9\n"
] | [
"YES",
"YES",
"NO"
] | none | 500 | [
{
"input": "3 5",
"output": "YES"
},
{
"input": "7 11",
"output": "YES"
},
{
"input": "7 9",
"output": "NO"
},
{
"input": "2 3",
"output": "YES"
},
{
"input": "2 4",
"output": "NO"
},
{
"input": "3 4",
"output": "NO"
},
{
"input": "3 5",
... | 1,659,212,820 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 30 | 0 | from sympy import isprime
n, m = map(int, input().split())
next_prime = 0
c = 0
for i in range(n+1, m):
if isprime(i):
print("NO")
print("YES") | Title: Panoramix's Prediction
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
A prime number is a number which has exactly two distinct divisors: one and itself. For example, numbers 2, 7, 3 are prime, and 1, 6, 4 are not.
The next prime number after *x* is the smallest prime number greater t... | ```python
from sympy import isprime
n, m = map(int, input().split())
next_prime = 0
c = 0
for i in range(n+1, m):
if isprime(i):
print("NO")
print("YES")
``` | -1 |
770 | A | New Password | PROGRAMMING | 800 | [
"*special",
"implementation"
] | null | null | Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help.
Innokentiy decides that new password should satisfy the following conditions:
- the length of the password must be equal to *n*, - the password should cons... | The first line contains two positive integers *n* and *k* (2<=≤<=*n*<=≤<=100, 2<=≤<=*k*<=≤<=*min*(*n*,<=26)) — the length of the password and the number of distinct symbols in it.
Pay attention that a desired new password always exists. | Print any password which satisfies all conditions given by Innokentiy. | [
"4 3\n",
"6 6\n",
"5 2\n"
] | [
"java\n",
"python\n",
"phphp\n"
] | In the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.
In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letter... | 500 | [
{
"input": "4 3",
"output": "abca"
},
{
"input": "6 6",
"output": "abcdef"
},
{
"input": "5 2",
"output": "ababa"
},
{
"input": "3 2",
"output": "aba"
},
{
"input": "10 2",
"output": "ababababab"
},
{
"input": "26 13",
"output": "abcdefghijklmabcde... | 1,626,802,266 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 2 | 140 | 22,323,200 | import string
n,k=map(int,input().split())
l=list(string.ascii_lowercase)
l3=l[:k]+l[:n-k]
print(*l3,sep='') | Title: New Password
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help.
Innokentiy decides that new password should satisfy the foll... | ```python
import string
n,k=map(int,input().split())
l=list(string.ascii_lowercase)
l3=l[:k]+l[:n-k]
print(*l3,sep='')
``` | 0 | |
484 | B | Maximum Value | PROGRAMMING | 2,100 | [
"binary search",
"math",
"sortings",
"two pointers"
] | null | null | You are given a sequence *a* consisting of *n* integers. Find the maximum possible value of (integer remainder of *a**i* divided by *a**j*), where 1<=≤<=*i*,<=*j*<=≤<=*n* and *a**i*<=≥<=*a**j*. | The first line contains integer *n* — the length of the sequence (1<=≤<=*n*<=≤<=2·105).
The second line contains *n* space-separated integers *a**i* (1<=≤<=*a**i*<=≤<=106). | Print the answer to the problem. | [
"3\n3 4 5\n"
] | [
"2\n"
] | none | 1,000 | [
{
"input": "3\n3 4 5",
"output": "2"
},
{
"input": "3\n1 2 4",
"output": "0"
},
{
"input": "1\n1",
"output": "0"
},
{
"input": "1\n1000000",
"output": "0"
},
{
"input": "2\n1000000 999999",
"output": "1"
},
{
"input": "12\n4 4 10 13 28 30 41 43 58 61 7... | 1,490,065,008 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 11 | 1,000 | 18,329,600 | def binary_search_closest_upper(L, key, from_number=0):
lo = from_number
hi = len(L)
if len(L) > 0 and key >= L[0]: # invariants on lo, hi only hold if key >= L[0] and L[0] exists
# Key in [lo, hi)
# L[lo] <= key
# L[hi] > key
while lo < hi - 1:
mid = (lo + hi) ... | Title: Maximum Value
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given a sequence *a* consisting of *n* integers. Find the maximum possible value of (integer remainder of *a**i* divided by *a**j*), where 1<=≤<=*i*,<=*j*<=≤<=*n* and *a**i*<=≥<=*a**j*.
Input Specification:
The ... | ```python
def binary_search_closest_upper(L, key, from_number=0):
lo = from_number
hi = len(L)
if len(L) > 0 and key >= L[0]: # invariants on lo, hi only hold if key >= L[0] and L[0] exists
# Key in [lo, hi)
# L[lo] <= key
# L[hi] > key
while lo < hi - 1:
mid = ... | 0 | |
615 | D | Multipliers | PROGRAMMING | 2,000 | [
"math",
"number theory"
] | null | null | Ayrat has number *n*, represented as it's prime factorization *p**i* of size *m*, i.e. *n*<==<=*p*1·*p*2·...·*p**m*. Ayrat got secret information that that the product of all divisors of *n* taken modulo 109<=+<=7 is the password to the secret data base. Now he wants to calculate this value. | The first line of the input contains a single integer *m* (1<=≤<=*m*<=≤<=200<=000) — the number of primes in factorization of *n*.
The second line contains *m* primes numbers *p**i* (2<=≤<=*p**i*<=≤<=200<=000). | Print one integer — the product of all divisors of *n* modulo 109<=+<=7. | [
"2\n2 3\n",
"3\n2 3 2\n"
] | [
"36\n",
"1728\n"
] | In the first sample *n* = 2·3 = 6. The divisors of 6 are 1, 2, 3 and 6, their product is equal to 1·2·3·6 = 36.
In the second sample 2·3·2 = 12. The divisors of 12 are 1, 2, 3, 4, 6 and 12. 1·2·3·4·6·12 = 1728. | 2,000 | [
{
"input": "2\n2 3",
"output": "36"
},
{
"input": "3\n2 3 2",
"output": "1728"
},
{
"input": "1\n2017",
"output": "2017"
},
{
"input": "2\n63997 63997",
"output": "135893224"
},
{
"input": "5\n11 7 11 7 11",
"output": "750455957"
},
{
"input": "5\n2 2 ... | 1,608,157,398 | 2,147,483,647 | PyPy 3 | RUNTIME_ERROR | TESTS | 11 | 1,029 | 14,745,600 | import collections
import math
m = input()
values = list(map(int, input().split()))
s = {}
for x in values:
s[x] = s.get(x, 0) + 1
n = 1
d = 1
for (x, y) in s.items():
n *= pow(x, y)
d *= (y + 1)
print(pow(n, int(d/2), 1000000007) if d % 2 == 0 else pow(int(math.sqrt(n)), d, 1000000007... | Title: Multipliers
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Ayrat has number *n*, represented as it's prime factorization *p**i* of size *m*, i.e. *n*<==<=*p*1·*p*2·...·*p**m*. Ayrat got secret information that that the product of all divisors of *n* taken modulo 109<=+<=7 is the pa... | ```python
import collections
import math
m = input()
values = list(map(int, input().split()))
s = {}
for x in values:
s[x] = s.get(x, 0) + 1
n = 1
d = 1
for (x, y) in s.items():
n *= pow(x, y)
d *= (y + 1)
print(pow(n, int(d/2), 1000000007) if d % 2 == 0 else pow(int(math.sqrt(n)), d, ... | -1 | |
369 | A | Valera and Plates | PROGRAMMING | 900 | [
"greedy",
"implementation"
] | null | null | Valera is a lazy student. He has *m* clean bowls and *k* clean plates.
Valera has made an eating plan for the next *n* days. As Valera is lazy, he will eat exactly one dish per day. At that, in order to eat a dish, he needs exactly one clean plate or bowl. We know that Valera can cook only two types of dishes. He can... | The first line of the input contains three integers *n*, *m*, *k* (1<=≤<=*n*,<=*m*,<=*k*<=≤<=1000) — the number of the planned days, the number of clean bowls and the number of clean plates.
The second line contains *n* integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=2). If *a**i* equals one, then on day *i* Val... | Print a single integer — the minimum number of times Valera will need to wash a plate/bowl. | [
"3 1 1\n1 2 1\n",
"4 3 1\n1 1 1 1\n",
"3 1 2\n2 2 2\n",
"8 2 2\n1 2 1 2 1 2 1 2\n"
] | [
"1\n",
"1\n",
"0\n",
"4\n"
] | In the first sample Valera will wash a bowl only on the third day, so the answer is one.
In the second sample, Valera will have the first type of the dish during all four days, and since there are only three bowls, he will wash a bowl exactly once.
In the third sample, Valera will have the second type of dish for all... | 500 | [
{
"input": "3 1 1\n1 2 1",
"output": "1"
},
{
"input": "4 3 1\n1 1 1 1",
"output": "1"
},
{
"input": "3 1 2\n2 2 2",
"output": "0"
},
{
"input": "8 2 2\n1 2 1 2 1 2 1 2",
"output": "4"
},
{
"input": "2 100 100\n2 2",
"output": "0"
},
{
"input": "1 1 1\... | 1,668,732,908 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 63 | 62 | 0 | setup = input().split(' ')
days = input().split(' ')
bowls = int(setup[1])
plates = int(setup[2])
d1 = days.count('1')
d2 = days.count('2')
wash = 0
if bowls - d1 >= 0:
bowls -= d1
else:
wash = -1 * (bowls - d1)
bowls = 0
#print(wash)
if d2 - (bowls + plates) > 0:
wash += (d2 -... | Title: Valera and Plates
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Valera is a lazy student. He has *m* clean bowls and *k* clean plates.
Valera has made an eating plan for the next *n* days. As Valera is lazy, he will eat exactly one dish per day. At that, in order to eat a dish, ... | ```python
setup = input().split(' ')
days = input().split(' ')
bowls = int(setup[1])
plates = int(setup[2])
d1 = days.count('1')
d2 = days.count('2')
wash = 0
if bowls - d1 >= 0:
bowls -= d1
else:
wash = -1 * (bowls - d1)
bowls = 0
#print(wash)
if d2 - (bowls + plates) > 0:
was... | 3 | |
638 | A | Home Numbers | PROGRAMMING | 1,100 | [
"*special",
"constructive algorithms",
"math"
] | null | null | The main street of Berland is a straight line with *n* houses built along it (*n* is an even number). The houses are located at both sides of the street. The houses with odd numbers are at one side of the street and are numbered from 1 to *n*<=-<=1 in the order from the beginning of the street to the end (in the pictur... | The first line of the input contains two integers, *n* and *a* (1<=≤<=*a*<=≤<=*n*<=≤<=100<=000) — the number of houses on the street and the number of the house that Vasya needs to reach, correspondingly. It is guaranteed that number *n* is even. | Print a single integer — the minimum time Vasya needs to get from the beginning of the street to house *a*. | [
"4 2\n",
"8 5\n"
] | [
"2\n",
"3\n"
] | In the first sample there are only four houses on the street, two houses at each side. House 2 will be the last at Vasya's right.
The second sample corresponds to picture with *n* = 8. House 5 is the one before last at Vasya's left. | 500 | [
{
"input": "4 2",
"output": "2"
},
{
"input": "8 5",
"output": "3"
},
{
"input": "2 1",
"output": "1"
},
{
"input": "2 2",
"output": "1"
},
{
"input": "10 1",
"output": "1"
},
{
"input": "10 10",
"output": "1"
},
{
"input": "100000 100000",... | 1,679,480,645 | 2,147,483,647 | Python 3 | OK | TESTS | 69 | 62 | 2,457,600 | a = []
b = []
x, y = list(map(int, input().split()))
aux = x
for i in range(int(x/2)):
a.append(1 + i*2)
b.append(aux)
aux -= 2
if y % 2:
print(a.index(y) + 1)
else:
print(b.index(y) + 1) | Title: Home Numbers
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The main street of Berland is a straight line with *n* houses built along it (*n* is an even number). The houses are located at both sides of the street. The houses with odd numbers are at one side of the street and are nu... | ```python
a = []
b = []
x, y = list(map(int, input().split()))
aux = x
for i in range(int(x/2)):
a.append(1 + i*2)
b.append(aux)
aux -= 2
if y % 2:
print(a.index(y) + 1)
else:
print(b.index(y) + 1)
``` | 3 | |
137 | B | Permutation | PROGRAMMING | 1,000 | [
"greedy"
] | null | null | "Hey, it's homework time" — thought Polycarpus and of course he started with his favourite subject, IT. Polycarpus managed to solve all tasks but for the last one in 20 minutes. However, as he failed to solve the last task after some considerable time, the boy asked you to help him.
The sequence of *n* integers is cal... | The first line of the input data contains an integer *n* (1<=≤<=*n*<=≤<=5000) which represents how many numbers are in the sequence. The second line contains a sequence of integers *a**i* (1<=≤<=*a**i*<=≤<=5000,<=1<=≤<=*i*<=≤<=*n*). | Print the only number — the minimum number of changes needed to get the permutation. | [
"3\n3 1 2\n",
"2\n2 2\n",
"5\n5 3 3 3 1\n"
] | [
"0\n",
"1\n",
"2\n"
] | The first sample contains the permutation, which is why no replacements are required.
In the second sample it is enough to replace the first element with the number 1 and that will make the sequence the needed permutation.
In the third sample we can replace the second element with number 4 and the fourth element with... | 1,000 | [
{
"input": "3\n3 1 2",
"output": "0"
},
{
"input": "2\n2 2",
"output": "1"
},
{
"input": "5\n5 3 3 3 1",
"output": "2"
},
{
"input": "5\n6 6 6 6 6",
"output": "5"
},
{
"input": "10\n1 1 2 2 8 8 7 7 9 9",
"output": "5"
},
{
"input": "8\n9 8 7 6 5 4 3 2"... | 1,664,713,519 | 2,147,483,647 | PyPy 3 | OK | TESTS | 48 | 218 | 2,662,400 | from sys import stdin
input=stdin.readline
from collections import Counter
n=int(input()) ; arr=list(map(int,input().split())) ; count=Counter(arr) ; dic=dict() ; c=0
for i in range(1,5001):
dic[i]=0
for i in count:
dic[i]=count[i]
for i in range(1,n+1):
if dic[i]==0:
c+=1
print(c)
| Title: Permutation
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
"Hey, it's homework time" — thought Polycarpus and of course he started with his favourite subject, IT. Polycarpus managed to solve all tasks but for the last one in 20 minutes. However, as he failed to solve the last task ... | ```python
from sys import stdin
input=stdin.readline
from collections import Counter
n=int(input()) ; arr=list(map(int,input().split())) ; count=Counter(arr) ; dic=dict() ; c=0
for i in range(1,5001):
dic[i]=0
for i in count:
dic[i]=count[i]
for i in range(1,n+1):
if dic[i]==0:
c+=1
print... | 3 | |
41 | A | Translation | PROGRAMMING | 800 | [
"implementation",
"strings"
] | A. Translation | 2 | 256 | The translation from the Berland language into the Birland language is not an easy task. Those languages are very similar: a berlandish word differs from a birlandish word with the same meaning a little: it is spelled (and pronounced) reversely. For example, a Berlandish word code corresponds to a Birlandish word edoc.... | The first line contains word *s*, the second line contains word *t*. The words consist of lowercase Latin letters. The input data do not consist unnecessary spaces. The words are not empty and their lengths do not exceed 100 symbols. | If the word *t* is a word *s*, written reversely, print YES, otherwise print NO. | [
"code\nedoc\n",
"abb\naba\n",
"code\ncode\n"
] | [
"YES\n",
"NO\n",
"NO\n"
] | none | 500 | [
{
"input": "code\nedoc",
"output": "YES"
},
{
"input": "abb\naba",
"output": "NO"
},
{
"input": "code\ncode",
"output": "NO"
},
{
"input": "abacaba\nabacaba",
"output": "YES"
},
{
"input": "q\nq",
"output": "YES"
},
{
"input": "asrgdfngfnmfgnhweratgjkk... | 1,631,626,133 | 2,147,483,647 | Python 3 | OK | TESTS | 40 | 154 | 6,758,400 | str=input()
str1=input()
if str[::-1]==str1:
print("YES")
else:
print("NO") | Title: Translation
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
The translation from the Berland language into the Birland language is not an easy task. Those languages are very similar: a berlandish word differs from a birlandish word with the same meaning a little: it is spelled (and pron... | ```python
str=input()
str1=input()
if str[::-1]==str1:
print("YES")
else:
print("NO")
``` | 3.948911 |
221 | B | Little Elephant and Numbers | PROGRAMMING | 1,300 | [
"implementation"
] | null | null | The Little Elephant loves numbers.
He has a positive integer *x*. The Little Elephant wants to find the number of positive integers *d*, such that *d* is the divisor of *x*, and *x* and *d* have at least one common (the same) digit in their decimal representations.
Help the Little Elephant to find the described num... | A single line contains a single integer *x* (1<=≤<=*x*<=≤<=109). | In a single line print an integer — the answer to the problem. | [
"1\n",
"10\n"
] | [
"1\n",
"2\n"
] | none | 1,000 | [
{
"input": "1",
"output": "1"
},
{
"input": "10",
"output": "2"
},
{
"input": "47",
"output": "1"
},
{
"input": "100",
"output": "5"
},
{
"input": "128",
"output": "6"
},
{
"input": "2",
"output": "1"
},
{
"input": "17",
"output": "2"
... | 1,613,583,498 | 2,147,483,647 | PyPy 3 | OK | TESTS | 39 | 216 | 1,536,000 | from sys import stdin ,stdout
from os import path
rd = lambda:stdin.readline().strip()
wr = stdout.write
if(path.exists('input.txt')):
stdin = open("input.txt","r")
import time
#------------------------------------
n = int(rd())
i = 1
def compare(x,y):
flag = False
for i in x :
if i in y :
fl... | Title: Little Elephant and Numbers
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The Little Elephant loves numbers.
He has a positive integer *x*. The Little Elephant wants to find the number of positive integers *d*, such that *d* is the divisor of *x*, and *x* and *d* have at least o... | ```python
from sys import stdin ,stdout
from os import path
rd = lambda:stdin.readline().strip()
wr = stdout.write
if(path.exists('input.txt')):
stdin = open("input.txt","r")
import time
#------------------------------------
n = int(rd())
i = 1
def compare(x,y):
flag = False
for i in x :
if i in ... | 3 | |
946 | B | Weird Subtraction Process | PROGRAMMING | 1,100 | [
"math",
"number theory"
] | null | null | You have two variables *a* and *b*. Consider the following sequence of actions performed with these variables:
1. If *a*<==<=0 or *b*<==<=0, end the process. Otherwise, go to step 2;1. If *a*<=≥<=2·*b*, then set the value of *a* to *a*<=-<=2·*b*, and repeat step 1. Otherwise, go to step 3;1. If *b*<=≥<=2·*a*, then s... | The only line of the input contains two integers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=1018). *n* is the initial value of variable *a*, and *m* is the initial value of variable *b*. | Print two integers — the values of *a* and *b* after the end of the process. | [
"12 5\n",
"31 12\n"
] | [
"0 1\n",
"7 12\n"
] | Explanations to the samples:
1. *a* = 12, *b* = 5 <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/70a0795f45d32287dba0eb83fc4a3f470c6e5537.png" style="max-width: 100.0%;max-height: 100.0%;"/> *a* = 2, *b* = 5 <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/70a0... | 0 | [
{
"input": "12 5",
"output": "0 1"
},
{
"input": "31 12",
"output": "7 12"
},
{
"input": "1000000000000000000 7",
"output": "8 7"
},
{
"input": "31960284556200 8515664064180",
"output": "14928956427840 8515664064180"
},
{
"input": "1000000000000000000 100000000000... | 1,632,028,580 | 2,147,483,647 | Python 3 | OK | TESTS | 81 | 77 | 6,758,400 | a,b=list(map(int,input().split()))
while a>0 and b>0:
if a>=b+b:a%=b+b
elif b>=a+a:b%=a+a
else: break
print(a,b)
| Title: Weird Subtraction Process
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You have two variables *a* and *b*. Consider the following sequence of actions performed with these variables:
1. If *a*<==<=0 or *b*<==<=0, end the process. Otherwise, go to step 2;1. If *a*<=≥<=2·*b*, then... | ```python
a,b=list(map(int,input().split()))
while a>0 and b>0:
if a>=b+b:a%=b+b
elif b>=a+a:b%=a+a
else: break
print(a,b)
``` | 3 | |
254 | C | Anagram | PROGRAMMING | 1,800 | [
"greedy",
"strings"
] | null | null | String *x* is an anagram of string *y*, if we can rearrange the letters in string *x* and get exact string *y*. For example, strings "DOG" and "GOD" are anagrams, so are strings "BABA" and "AABB", but strings "ABBAC" and "CAABA" are not.
You are given two strings *s* and *t* of the same length, consisting of uppercase... | The input consists of two lines. The first line contains string *s*, the second line contains string *t*. The strings have the same length (from 1 to 105 characters) and consist of uppercase English letters. | In the first line print *z* — the minimum number of replacement operations, needed to get an anagram of string *t* from string *s*. In the second line print the lexicographically minimum anagram that could be obtained in *z* operations. | [
"ABA\nCBA\n",
"CDBABC\nADCABD\n"
] | [
"1\nABC\n",
"2\nADBADC\n"
] | The second sample has eight anagrams of string *t*, that can be obtained from string *s* by replacing exactly two letters: "ADBADC", "ADDABC", "CDAABD", "CDBAAD", "CDBADA", "CDDABA", "DDAABC", "DDBAAC". These anagrams are listed in the lexicographical order. The lexicographically minimum anagram is "ADBADC". | 1,500 | [
{
"input": "ABA\nCBA",
"output": "1\nABC"
},
{
"input": "CDBABC\nADCABD",
"output": "2\nADBADC"
},
{
"input": "AABAA\nBBAAA",
"output": "1\nAABAB"
},
{
"input": "OVGHK\nRPGUC",
"output": "4\nCPGRU"
},
{
"input": "CCAACBA\nBBBAACC",
"output": "2\nBCAACBB"
},
... | 1,440,331,009 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 60 | 0 | s=input()
t=input()
alph='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
dic=dict()
for i in range(len(s)):
if s[i] in dic:
dic[s[i]]-=1
else:
dic[s[i]]=-1
if t[i] in dic:
dic[t[i]]+=1
else:
dic[t[i]]=1
result=''
keys=sorted(dic)
changeNum=0
for i in range(len(s)):... | Title: Anagram
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
String *x* is an anagram of string *y*, if we can rearrange the letters in string *x* and get exact string *y*. For example, strings "DOG" and "GOD" are anagrams, so are strings "BABA" and "AABB", but strings "ABBAC" and "CAABA... | ```python
s=input()
t=input()
alph='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
dic=dict()
for i in range(len(s)):
if s[i] in dic:
dic[s[i]]-=1
else:
dic[s[i]]=-1
if t[i] in dic:
dic[t[i]]+=1
else:
dic[t[i]]=1
result=''
keys=sorted(dic)
changeNum=0
for i in rang... | -1 | |
268 | A | Games | PROGRAMMING | 800 | [
"brute force"
] | null | null | Manao works on a sports TV. He's spent much time watching the football games of some country. After a while he began to notice different patterns. For example, each team has two sets of uniforms: home uniform and guest uniform. When a team plays a game at home, the players put on the home uniform. When a team plays as ... | The first line contains an integer *n* (2<=≤<=*n*<=≤<=30). Each of the following *n* lines contains a pair of distinct space-separated integers *h**i*, *a**i* (1<=≤<=*h**i*,<=*a**i*<=≤<=100) — the colors of the *i*-th team's home and guest uniforms, respectively. | In a single line print the number of games where the host team is going to play in the guest uniform. | [
"3\n1 2\n2 4\n3 4\n",
"4\n100 42\n42 100\n5 42\n100 5\n",
"2\n1 2\n1 2\n"
] | [
"1\n",
"5\n",
"0\n"
] | In the first test case the championship consists of 6 games. The only game with the event in question is the game between teams 2 and 1 on the stadium of team 2.
In the second test sample the host team will have to wear guest uniform in the games between teams: 1 and 2, 2 and 1, 2 and 3, 3 and 4, 4 and 2 (the host tea... | 500 | [
{
"input": "3\n1 2\n2 4\n3 4",
"output": "1"
},
{
"input": "4\n100 42\n42 100\n5 42\n100 5",
"output": "5"
},
{
"input": "2\n1 2\n1 2",
"output": "0"
},
{
"input": "7\n4 7\n52 55\n16 4\n55 4\n20 99\n3 4\n7 52",
"output": "6"
},
{
"input": "10\n68 42\n1 35\n25 70\n... | 1,696,895,286 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 30 | 0 | n=int(input())
H=list()
A=list()
res=0
for i in range(n):
l=input().split()
H.append(int(l[0]))
Aappend(int(l[1]))
res+=A.count(H[i])
print(res) | Title: Games
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Manao works on a sports TV. He's spent much time watching the football games of some country. After a while he began to notice different patterns. For example, each team has two sets of uniforms: home uniform and guest uniform. W... | ```python
n=int(input())
H=list()
A=list()
res=0
for i in range(n):
l=input().split()
H.append(int(l[0]))
Aappend(int(l[1]))
res+=A.count(H[i])
print(res)
``` | -1 | |
978 | B | File Name | PROGRAMMING | 800 | [
"greedy",
"strings"
] | null | null | You can not just take the file and send it. When Polycarp trying to send a file in the social network "Codehorses", he encountered an unexpected problem. If the name of the file contains three or more "x" (lowercase Latin letters "x") in a row, the system considers that the file content does not correspond to the socia... | The first line contains integer $n$ $(3 \le n \le 100)$ — the length of the file name.
The second line contains a string of length $n$ consisting of lowercase Latin letters only — the file name. | Print the minimum number of characters to remove from the file name so after that the name does not contain "xxx" as a substring. If initially the file name dost not contain a forbidden substring "xxx", print 0. | [
"6\nxxxiii\n",
"5\nxxoxx\n",
"10\nxxxxxxxxxx\n"
] | [
"1\n",
"0\n",
"8\n"
] | In the first example Polycarp tried to send a file with name contains number $33$, written in Roman numerals. But he can not just send the file, because it name contains three letters "x" in a row. To send the file he needs to remove any one of this letters. | 0 | [
{
"input": "6\nxxxiii",
"output": "1"
},
{
"input": "5\nxxoxx",
"output": "0"
},
{
"input": "10\nxxxxxxxxxx",
"output": "8"
},
{
"input": "100\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"output": "98"
},
{
... | 1,656,399,574 | 2,147,483,647 | Python 3 | OK | TESTS | 13 | 31 | 0 | def func(st , size) :
count = 0
ans = 0
for i in st :
if i == "x" :
count = count + 1
else :
count = 0
if count > 2 :
ans = ans + 1
return ans
x = input()
st = input()
print(func(st , x ) ) | Title: File Name
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You can not just take the file and send it. When Polycarp trying to send a file in the social network "Codehorses", he encountered an unexpected problem. If the name of the file contains three or more "x" (lowercase Latin let... | ```python
def func(st , size) :
count = 0
ans = 0
for i in st :
if i == "x" :
count = count + 1
else :
count = 0
if count > 2 :
ans = ans + 1
return ans
x = input()
st = input()
print(func(st , x ) )
``` | 3 | |
960 | B | Minimize the error | PROGRAMMING | 1,500 | [
"data structures",
"greedy",
"sortings"
] | null | null | You are given two arrays *A* and *B*, each of size *n*. The error, *E*, between these two arrays is defined . You have to perform exactly *k*1 operations on array *A* and exactly *k*2 operations on array *B*. In one operation, you have to choose one element of the array and increase or decrease it by 1.
Output the min... | The first line contains three space-separated integers *n* (1<=≤<=*n*<=≤<=103), *k*1 and *k*2 (0<=≤<=*k*1<=+<=*k*2<=≤<=103, *k*1 and *k*2 are non-negative) — size of arrays and number of operations to perform on *A* and *B* respectively.
Second line contains *n* space separated integers *a*1,<=*a*2,<=...,<=*a**n* (<=-... | Output a single integer — the minimum possible value of after doing exactly *k*1 operations on array *A* and exactly *k*2 operations on array *B*. | [
"2 0 0\n1 2\n2 3\n",
"2 1 0\n1 2\n2 2\n",
"2 5 7\n3 4\n14 4\n"
] | [
"2",
"0",
"1"
] | In the first sample case, we cannot perform any operations on *A* or *B*. Therefore the minimum possible error *E* = (1 - 2)<sup class="upper-index">2</sup> + (2 - 3)<sup class="upper-index">2</sup> = 2.
In the second sample case, we are required to perform exactly one operation on *A*. In order to minimize error, we... | 1,000 | [
{
"input": "2 0 0\n1 2\n2 3",
"output": "2"
},
{
"input": "2 1 0\n1 2\n2 2",
"output": "0"
},
{
"input": "2 5 7\n3 4\n14 4",
"output": "1"
},
{
"input": "2 0 1\n1 2\n2 2",
"output": "0"
},
{
"input": "2 1 1\n0 0\n1 1",
"output": "0"
},
{
"input": "5 5 ... | 1,588,167,152 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 5 | 124 | 921,600 | # -*- coding: utf-8 -*-
"""
Created on Wed Apr 29 08:31:20 2020
@author: Diego
"""
from queue import PriorityQueue
n,k1,k2 = list(map(int, (input().split())))
a = list(map(int, (input().split())))
b = list(map(int, (input().split())))
c = PriorityQueue()
for i in range(n):
dif = a[i] - b[i]
... | Title: Minimize the error
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given two arrays *A* and *B*, each of size *n*. The error, *E*, between these two arrays is defined . You have to perform exactly *k*1 operations on array *A* and exactly *k*2 operations on array *B*. In one ... | ```python
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 29 08:31:20 2020
@author: Diego
"""
from queue import PriorityQueue
n,k1,k2 = list(map(int, (input().split())))
a = list(map(int, (input().split())))
b = list(map(int, (input().split())))
c = PriorityQueue()
for i in range(n):
dif = a[i] - ... | 0 | |
822 | B | Crossword solving | PROGRAMMING | 1,000 | [
"brute force",
"implementation",
"strings"
] | null | null | Erelong Leha was bored by calculating of the greatest common divisor of two factorials. Therefore he decided to solve some crosswords. It's well known that it is a very interesting occupation though it can be very difficult from time to time. In the course of solving one of the crosswords, Leha had to solve a simple ta... | The first line contains two integers *n* and *m* (1<=≤<=*n*<=≤<=*m*<=≤<=1000) — the length of the string *s* and the length of the string *t* correspondingly.
The second line contains *n* lowercase English letters — string *s*.
The third line contains *m* lowercase English letters — string *t*. | In the first line print single integer *k* — the minimal number of symbols that need to be replaced.
In the second line print *k* distinct integers denoting the positions of symbols in the string *s* which need to be replaced. Print the positions in any order. If there are several solutions print any of them. The numb... | [
"3 5\nabc\nxaybz\n",
"4 10\nabcd\nebceabazcd\n"
] | [
"2\n2 3 \n",
"1\n2 \n"
] | none | 750 | [
{
"input": "3 5\nabc\nxaybz",
"output": "2\n2 3 "
},
{
"input": "4 10\nabcd\nebceabazcd",
"output": "1\n2 "
},
{
"input": "1 1\na\na",
"output": "0"
},
{
"input": "1 1\na\nz",
"output": "1\n1 "
},
{
"input": "3 5\naaa\naaaaa",
"output": "0"
},
{
"input... | 1,688,454,964 | 2,147,483,647 | PyPy 3-64 | RUNTIME_ERROR | TESTS | 2 | 77 | 2,867,200 | x,y = map(int , input().split())
ori_x = x
passw = list(input())
hash = list(input())
arr = []
to = len(hash) - len(passw) + 1
i = 0
j = x
for z in range(to):
arr.append(hash[i:j])
i+=1
j+=1
min_count = []
for p in arr:
count = 0
icount = 0
for q in p:
value = passw[icount]
... | Title: Crossword solving
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Erelong Leha was bored by calculating of the greatest common divisor of two factorials. Therefore he decided to solve some crosswords. It's well known that it is a very interesting occupation though it can be very dif... | ```python
x,y = map(int , input().split())
ori_x = x
passw = list(input())
hash = list(input())
arr = []
to = len(hash) - len(passw) + 1
i = 0
j = x
for z in range(to):
arr.append(hash[i:j])
i+=1
j+=1
min_count = []
for p in arr:
count = 0
icount = 0
for q in p:
value = passw[icou... | -1 | |
233 | B | Non-square Equation | PROGRAMMING | 1,400 | [
"binary search",
"brute force",
"math"
] | null | null | Let's consider equation:
where *x*,<=*n* are positive integers, *s*(*x*) is the function, equal to the sum of digits of number *x* in the decimal number system.
You are given an integer *n*, find the smallest positive integer root of equation *x*, or else determine that there are no such roots. | A single line contains integer *n* (1<=≤<=*n*<=≤<=1018) — the equation parameter.
Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specifier. | Print -1, if the equation doesn't have integer positive roots. Otherwise print such smallest integer *x* (*x*<=><=0), that the equation given in the statement holds. | [
"2\n",
"110\n",
"4\n"
] | [
"1\n",
"10\n",
"-1\n"
] | In the first test case *x* = 1 is the minimum root. As *s*(1) = 1 and 1<sup class="upper-index">2</sup> + 1·1 - 2 = 0.
In the second test case *x* = 10 is the minimum root. As *s*(10) = 1 + 0 = 1 and 10<sup class="upper-index">2</sup> + 1·10 - 110 = 0.
In the third test case the equation has no roots. | 1,000 | [
{
"input": "2",
"output": "1"
},
{
"input": "110",
"output": "10"
},
{
"input": "4",
"output": "-1"
},
{
"input": "8",
"output": "2"
},
{
"input": "10000000100000000",
"output": "100000000"
},
{
"input": "10000006999999929",
"output": "99999999"
... | 1,635,786,947 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 62 | 4,608,000 | from collections import defaultdict
n = int(input())
values = list(range(pow(10 , 9)))
smallest = -1
l = 0
r = len(values)-1
while l <= r :
mid = l + (r-l) // 2
temp = pow(values[mid], 2) + sum(int(char) for char in str(values[mid])) * values[mid]
if temp == n:
smallest = values[mid... | Title: Non-square Equation
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Let's consider equation:
where *x*,<=*n* are positive integers, *s*(*x*) is the function, equal to the sum of digits of number *x* in the decimal number system.
You are given an integer *n*, find the smallest posi... | ```python
from collections import defaultdict
n = int(input())
values = list(range(pow(10 , 9)))
smallest = -1
l = 0
r = len(values)-1
while l <= r :
mid = l + (r-l) // 2
temp = pow(values[mid], 2) + sum(int(char) for char in str(values[mid])) * values[mid]
if temp == n:
smallest = ... | -1 | |
22 | B | Bargaining Table | PROGRAMMING | 1,500 | [
"brute force",
"dp"
] | B. Bargaining Table | 2 | 256 | Bob wants to put a new bargaining table in his office. To do so he measured the office room thoroughly and drew its plan: Bob's office room is a rectangular room *n*<=×<=*m* meters. Each square meter of the room is either occupied by some furniture, or free. A bargaining table is rectangular, and should be placed so, t... | The first line contains 2 space-separated numbers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=25) — the office room dimensions. Then there follow *n* lines with *m* characters 0 or 1 each. 0 stands for a free square meter of the office room. 1 stands for an occupied square meter. It's guaranteed that at least one square meter in ... | Output one number — the maximum possible perimeter of a bargaining table for Bob's office room. | [
"3 3\n000\n010\n000\n",
"5 4\n1100\n0000\n0000\n0000\n0000\n"
] | [
"8\n",
"16\n"
] | none | 0 | [
{
"input": "3 3\n000\n010\n000",
"output": "8"
},
{
"input": "5 4\n1100\n0000\n0000\n0000\n0000",
"output": "16"
},
{
"input": "3 3\n000\n110\n000",
"output": "8"
},
{
"input": "4 2\n00\n10\n11\n00",
"output": "6"
},
{
"input": "3 5\n00001\n00000\n10100",
"out... | 1,557,032,988 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 156 | 0 | n, m = map(int, input().split())
n, m = n+1, m+1
dp = [[0 for j in range(m)] for i in range(n)]
for i in range(1,n):
s = input()
for j in range(1, m):
dp[i][j] = dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1]+int(s[j-1])
print (dp[n-1][m-1])
mx = 0
for i in range(1,n):
for j in range(1, m):
f... | Title: Bargaining Table
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Bob wants to put a new bargaining table in his office. To do so he measured the office room thoroughly and drew its plan: Bob's office room is a rectangular room *n*<=×<=*m* meters. Each square meter of the room is either ... | ```python
n, m = map(int, input().split())
n, m = n+1, m+1
dp = [[0 for j in range(m)] for i in range(n)]
for i in range(1,n):
s = input()
for j in range(1, m):
dp[i][j] = dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1]+int(s[j-1])
print (dp[n-1][m-1])
mx = 0
for i in range(1,n):
for j in range(1, m):
... | 0 |
847 | B | Preparing for Merge Sort | PROGRAMMING | 1,600 | [
"binary search",
"data structures"
] | null | null | Ivan has an array consisting of *n* different integers. He decided to reorder all elements in increasing order. Ivan loves merge sort so he decided to represent his array with one or several increasing sequences which he then plans to merge into one sorted array.
Ivan represent his array with increasing sequences with... | The first line contains a single integer *n* (1<=≤<=*n*<=≤<=2·105) — the number of elements in Ivan's array.
The second line contains a sequence consisting of distinct integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=109) — Ivan's array. | Print representation of the given array in the form of one or more increasing sequences in accordance with the algorithm described above. Each sequence must be printed on a new line. | [
"5\n1 3 2 5 4\n",
"4\n4 3 2 1\n",
"4\n10 30 50 101\n"
] | [
"1 3 5 \n2 4 \n",
"4 \n3 \n2 \n1 \n",
"10 30 50 101 \n"
] | none | 0 | [
{
"input": "5\n1 3 2 5 4",
"output": "1 3 5 \n2 4 "
},
{
"input": "4\n4 3 2 1",
"output": "4 \n3 \n2 \n1 "
},
{
"input": "4\n10 30 50 101",
"output": "10 30 50 101 "
},
{
"input": "1\n1",
"output": "1 "
},
{
"input": "1\n200000",
"output": "200000 "
},
{
... | 1,658,805,249 | 2,147,483,647 | PyPy 3-64 | TIME_LIMIT_EXCEEDED | TESTS | 26 | 2,000 | 27,545,600 | # https://codeforces.com/contest/847/problem/B
n = int(input())
A = list(map(int, input().split()))
used = [False] * n
num_used = 0
ans = []
while num_used < n:
seq = []
for i, a in enumerate(A):
if not used[i] and (not seq or seq[-1] < a):
seq.append(a)
used[i] = True
... | Title: Preparing for Merge Sort
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Ivan has an array consisting of *n* different integers. He decided to reorder all elements in increasing order. Ivan loves merge sort so he decided to represent his array with one or several increasing sequence... | ```python
# https://codeforces.com/contest/847/problem/B
n = int(input())
A = list(map(int, input().split()))
used = [False] * n
num_used = 0
ans = []
while num_used < n:
seq = []
for i, a in enumerate(A):
if not used[i] and (not seq or seq[-1] < a):
seq.append(a)
used[i] = T... | 0 | |
96 | A | Football | PROGRAMMING | 900 | [
"implementation",
"strings"
] | A. Football | 2 | 256 | Petya loves football very much. One day, as he was watching a football match, he was writing the players' current positions on a piece of paper. To simplify the situation he depicted it as a string consisting of zeroes and ones. A zero corresponds to players of one team; a one corresponds to players of another team. If... | The first input line contains a non-empty string consisting of characters "0" and "1", which represents players. The length of the string does not exceed 100 characters. There's at least one player from each team present on the field. | Print "YES" if the situation is dangerous. Otherwise, print "NO". | [
"001001\n",
"1000000001\n"
] | [
"NO\n",
"YES\n"
] | none | 500 | [
{
"input": "001001",
"output": "NO"
},
{
"input": "1000000001",
"output": "YES"
},
{
"input": "00100110111111101",
"output": "YES"
},
{
"input": "11110111111111111",
"output": "YES"
},
{
"input": "01",
"output": "NO"
},
{
"input": "10100101",
"outp... | 1,690,909,992 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 60 | 0 | a = input()
zcou = 0
ocou = 0
flag = []
for i in a:
if i == "1":
zcou = 0
ocou += 1
else:
ocou = 0
zcou += 1
print(zcou)
if zcou == 7 or ocou == 7:
flag.append(zcou)
flag.append(ocou)
print(flag)
if 7 in flag:
print("YES")
else:
print("NO")
| Title: Football
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Petya loves football very much. One day, as he was watching a football match, he was writing the players' current positions on a piece of paper. To simplify the situation he depicted it as a string consisting of zeroes and ones. A... | ```python
a = input()
zcou = 0
ocou = 0
flag = []
for i in a:
if i == "1":
zcou = 0
ocou += 1
else:
ocou = 0
zcou += 1
print(zcou)
if zcou == 7 or ocou == 7:
flag.append(zcou)
flag.append(ocou)
print(flag)
if 7 in flag:
print("YES")
else:
print("NO"... | 0 |
488 | B | Candy Boxes | PROGRAMMING | 1,900 | [
"brute force",
"constructive algorithms",
"math"
] | null | null | There is an old tradition of keeping 4 boxes of candies in the house in Cyberland. The numbers of candies are special if their arithmetic mean, their median and their range are all equal. By definition, for a set {*x*1,<=*x*2,<=*x*3,<=*x*4} (*x*1<=≤<=*x*2<=≤<=*x*3<=≤<=*x*4) arithmetic mean is , median is and range is ... | The first line of input contains an only integer *n* (0<=≤<=*n*<=≤<=4).
The next *n* lines contain integers *a**i*, denoting the number of candies in the *i*-th box (1<=≤<=*a**i*<=≤<=500). | In the first output line, print "YES" if a solution exists, or print "NO" if there is no solution.
If a solution exists, you should output 4<=-<=*n* more lines, each line containing an integer *b*, denoting the number of candies in a missing box.
All your numbers *b* must satisfy inequality 1<=≤<=*b*<=≤<=106. It is g... | [
"2\n1\n1\n",
"3\n1\n1\n1\n",
"4\n1\n2\n2\n3\n"
] | [
"YES\n3\n3\n",
"NO\n",
"YES\n"
] | For the first sample, the numbers of candies in 4 boxes can be 1, 1, 3, 3. The arithmetic mean, the median and the range of them are all 2.
For the second sample, it's impossible to find the missing number of candies.
In the third example no box has been lost and numbers satisfy the condition.
You may output *b* in ... | 1,500 | [
{
"input": "2\n1\n1",
"output": "YES\n3\n3"
},
{
"input": "3\n1\n1\n1",
"output": "NO"
},
{
"input": "4\n1\n2\n2\n3",
"output": "YES"
},
{
"input": "0",
"output": "YES\n1\n1\n3\n3"
},
{
"input": "1\n125",
"output": "YES\n125\n375\n375"
},
{
"input": "2... | 1,539,249,437 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 109 | 0 | def check(arr):
arr.sort()
a=sum(arr)/len(arr)
b=(arr[1]+arr[2])/2
c=arr[-1]-arr[0]
return a==b==c
def iftwo(arr):
arr.sort()
a=arr[0]
b=arr[1]
r=b-a
if r&1:
a1=r//2;a2=r//2+1
else:
a1=a2=r//2
arr.append(a1);arr.append(a2)
if chec... | Title: Candy Boxes
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
There is an old tradition of keeping 4 boxes of candies in the house in Cyberland. The numbers of candies are special if their arithmetic mean, their median and their range are all equal. By definition, for a set {*x*1,<=*x... | ```python
def check(arr):
arr.sort()
a=sum(arr)/len(arr)
b=(arr[1]+arr[2])/2
c=arr[-1]-arr[0]
return a==b==c
def iftwo(arr):
arr.sort()
a=arr[0]
b=arr[1]
r=b-a
if r&1:
a1=r//2;a2=r//2+1
else:
a1=a2=r//2
arr.append(a1);arr.append(a2)
... | 0 | |
357 | B | Flag Day | PROGRAMMING | 1,400 | [
"constructive algorithms",
"implementation"
] | null | null | In Berland, there is the national holiday coming — the Flag Day. In the honor of this event the president of the country decided to make a big dance party and asked your agency to organize it. He has several conditions:
- overall, there must be *m* dances;- exactly three people must take part in each dance;- each d... | The first line contains two space-separated integers *n* (3<=≤<=*n*<=≤<=105) and *m* (1<=≤<=*m*<=≤<=105) — the number of dancers and the number of dances, correspondingly. Then *m* lines follow, describing the dances in the order of dancing them. The *i*-th line contains three distinct integers — the numbers of the dan... | Print *n* space-separated integers: the *i*-th number must represent the color of the *i*-th dancer's clothes (1 for white, 2 for red, 3 for blue). If there are multiple valid solutions, print any of them. It is guaranteed that at least one solution exists. | [
"7 3\n1 2 3\n1 4 5\n4 6 7\n",
"9 3\n3 6 9\n2 5 8\n1 4 7\n",
"5 2\n4 1 5\n3 1 2\n"
] | [
"1 2 3 3 2 2 1 \n",
"1 1 1 2 2 2 3 3 3 \n",
"2 3 1 1 3 \n"
] | none | 1,000 | [
{
"input": "7 3\n1 2 3\n1 4 5\n4 6 7",
"output": "1 2 3 3 2 2 1 "
},
{
"input": "9 3\n3 6 9\n2 5 8\n1 4 7",
"output": "1 1 1 2 2 2 3 3 3 "
},
{
"input": "5 2\n4 1 5\n3 1 2",
"output": "2 3 1 1 3 "
},
{
"input": "14 5\n1 5 3\n13 10 11\n6 3 8\n14 9 2\n7 4 12",
"output": "1 ... | 1,684,486,000 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 6 | 1,000 | 1,945,600 | n=input().split()
l=['0']*int(n[0])
x=[]
y=[]
prev_len=0
for i in range (int(n[1])):
t=[1,2,3]
z=[int(j) for j in input().split()]
y=y+[z[j] for j in range (3) if z[j] in x]
x=x+[z[j] for j in range (3) if z[j] not in x]
new_len=len(y)
if new_len-prev_len==0:
l[x[-3]-1]=str(t... | Title: Flag Day
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
In Berland, there is the national holiday coming — the Flag Day. In the honor of this event the president of the country decided to make a big dance party and asked your agency to organize it. He has several conditions:
- ov... | ```python
n=input().split()
l=['0']*int(n[0])
x=[]
y=[]
prev_len=0
for i in range (int(n[1])):
t=[1,2,3]
z=[int(j) for j in input().split()]
y=y+[z[j] for j in range (3) if z[j] in x]
x=x+[z[j] for j in range (3) if z[j] not in x]
new_len=len(y)
if new_len-prev_len==0:
l[x[-3... | 0 | |
266 | A | Stones on the Table | PROGRAMMING | 800 | [
"implementation"
] | null | null | There are *n* stones on the table in a row, each of them can be red, green or blue. Count the minimum number of stones to take from the table so that any two neighboring stones had different colors. Stones in a row are considered neighboring if there are no other stones between them. | The first line contains integer *n* (1<=≤<=*n*<=≤<=50) — the number of stones on the table.
The next line contains string *s*, which represents the colors of the stones. We'll consider the stones in the row numbered from 1 to *n* from left to right. Then the *i*-th character *s* equals "R", if the *i*-th stone is red... | Print a single integer — the answer to the problem. | [
"3\nRRG\n",
"5\nRRRRR\n",
"4\nBRBG\n"
] | [
"1\n",
"4\n",
"0\n"
] | none | 500 | [
{
"input": "3\nRRG",
"output": "1"
},
{
"input": "5\nRRRRR",
"output": "4"
},
{
"input": "4\nBRBG",
"output": "0"
},
{
"input": "1\nB",
"output": "0"
},
{
"input": "2\nBG",
"output": "0"
},
{
"input": "3\nBGB",
"output": "0"
},
{
"input": "... | 1,697,845,435 | 2,147,483,647 | Python 3 | OK | TESTS | 34 | 92 | 0 | t = int(input())
string = input()
i,j = 0,1
count = 0
while j < t:
if string[j] != string[i]:
i = j
j = i + 1
else:
j += 1
count += 1
print(count)
| Title: Stones on the Table
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
There are *n* stones on the table in a row, each of them can be red, green or blue. Count the minimum number of stones to take from the table so that any two neighboring stones had different colors. Stones in a row ... | ```python
t = int(input())
string = input()
i,j = 0,1
count = 0
while j < t:
if string[j] != string[i]:
i = j
j = i + 1
else:
j += 1
count += 1
print(count)
``` | 3 | |
961 | D | Pair Of Lines | PROGRAMMING | 2,000 | [
"geometry"
] | null | null | You are given *n* points on Cartesian plane. Every point is a lattice point (i.<=e. both of its coordinates are integers), and all points are distinct.
You may draw two straight lines (not necessarily distinct). Is it possible to do this in such a way that every point lies on at least one of these lines? | The first line contains one integer *n* (1<=≤<=*n*<=≤<=105) — the number of points you are given.
Then *n* lines follow, each line containing two integers *x**i* and *y**i* (|*x**i*|,<=|*y**i*|<=≤<=109)— coordinates of *i*-th point. All *n* points are distinct. | If it is possible to draw two straight lines in such a way that each of given points belongs to at least one of these lines, print YES. Otherwise, print NO. | [
"5\n0 0\n0 1\n1 1\n1 -1\n2 2\n",
"5\n0 0\n1 0\n2 1\n1 1\n2 3\n"
] | [
"YES\n",
"NO\n"
] | In the first example it is possible to draw two lines, the one containing the points 1, 3 and 5, and another one containing two remaining points. | 0 | [
{
"input": "5\n0 0\n0 1\n1 1\n1 -1\n2 2",
"output": "YES"
},
{
"input": "5\n0 0\n1 0\n2 1\n1 1\n2 3",
"output": "NO"
},
{
"input": "1\n-1000000000 1000000000",
"output": "YES"
},
{
"input": "5\n2 -1\n-4 1\n0 -9\n5 -9\n9 -10",
"output": "NO"
},
{
"input": "5\n6 1\n... | 1,579,839,847 | 2,147,483,647 | Python 3 | OK | TESTS | 121 | 576 | 8,704,000 | def main():
n = int(input())
points = []
for i in range(n):
x, y = map(int, input().split())
points.append((x, y))
if (n < 5):
print("YES")
else:
if test(points[0], points[1], points) or test(points[0], points[2], points) or test(points[1], points[2], points):
print("... | Title: Pair Of Lines
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given *n* points on Cartesian plane. Every point is a lattice point (i.<=e. both of its coordinates are integers), and all points are distinct.
You may draw two straight lines (not necessarily distinct). Is it po... | ```python
def main():
n = int(input())
points = []
for i in range(n):
x, y = map(int, input().split())
points.append((x, y))
if (n < 5):
print("YES")
else:
if test(points[0], points[1], points) or test(points[0], points[2], points) or test(points[1], points[2], points):
... | 3 | |
454 | B | Little Pony and Sort by Shift | PROGRAMMING | 1,200 | [
"implementation"
] | null | null | One day, Twilight Sparkle is interested in how to sort a sequence of integers *a*1,<=*a*2,<=...,<=*a**n* in non-decreasing order. Being a young unicorn, the only operation she can perform is a unit shift. That is, she can move the last element of the sequence to its beginning:
Help Twilight Sparkle to calculate: what ... | The first line contains an integer *n* (2<=≤<=*n*<=≤<=105). The second line contains *n* integer numbers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=105). | If it's impossible to sort the sequence output -1. Otherwise output the minimum number of operations Twilight Sparkle needs to sort it. | [
"2\n2 1\n",
"3\n1 3 2\n",
"2\n1 2\n"
] | [
"1\n",
"-1\n",
"0\n"
] | none | 1,000 | [
{
"input": "2\n2 1",
"output": "1"
},
{
"input": "3\n1 3 2",
"output": "-1"
},
{
"input": "2\n1 2",
"output": "0"
},
{
"input": "6\n3 4 5 6 3 2",
"output": "-1"
},
{
"input": "3\n1 2 1",
"output": "1"
},
{
"input": "5\n1 1 2 1 1",
"output": "2"
}... | 1,653,722,149 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 15 | 186 | 10,752,000 | n=int(input())
ar=list(map(int,input().split()))
a=max(ar)
for x in range(n):
if ar[x]==a:
ind=x
break
x=(ind+1)%n
ans=True
s=k=0
while s<n-1:
#print(x%n,(x+1)%n)
if ar[x%n]>ar[(x+1)%n]:
ans=False
break
x+=1
s+=1
if sorted(ar)==ar:
print(0)
el... | Title: Little Pony and Sort by Shift
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
One day, Twilight Sparkle is interested in how to sort a sequence of integers *a*1,<=*a*2,<=...,<=*a**n* in non-decreasing order. Being a young unicorn, the only operation she can perform is a unit shift. ... | ```python
n=int(input())
ar=list(map(int,input().split()))
a=max(ar)
for x in range(n):
if ar[x]==a:
ind=x
break
x=(ind+1)%n
ans=True
s=k=0
while s<n-1:
#print(x%n,(x+1)%n)
if ar[x%n]>ar[(x+1)%n]:
ans=False
break
x+=1
s+=1
if sorted(ar)==ar:
pr... | 0 | |
412 | B | Network Configuration | PROGRAMMING | 900 | [
"greedy",
"sortings"
] | null | null | The R1 company wants to hold a web search championship. There were *n* computers given for the competition, each of them is connected to the Internet. The organizers believe that the data transfer speed directly affects the result. The higher the speed of the Internet is, the faster the participant will find the necess... | The first line contains two space-separated integers *n* and *k* (1<=≤<=*k*<=≤<=*n*<=≤<=100) — the number of computers and the number of participants, respectively. In the second line you have a space-separated sequence consisting of *n* integers: *a*1,<=*a*2,<=...,<=*a**n* (16<=≤<=*a**i*<=≤<=32768); number *a**i* deno... | Print a single integer — the maximum Internet speed value. It is guaranteed that the answer to the problem is always an integer. | [
"3 2\n40 20 30\n",
"6 4\n100 20 40 20 50 50\n"
] | [
"30\n",
"40\n"
] | In the first test case the organizers can cut the first computer's speed to 30 kilobits. Then two computers (the first and the third one) will have the same speed of 30 kilobits. They should be used as the participants' computers. This answer is optimal. | 1,000 | [
{
"input": "3 2\n40 20 30",
"output": "30"
},
{
"input": "6 4\n100 20 40 20 50 50",
"output": "40"
},
{
"input": "1 1\n16",
"output": "16"
},
{
"input": "2 1\n10000 17",
"output": "10000"
},
{
"input": "2 2\n200 300",
"output": "200"
},
{
"input": "3 1... | 1,397,838,634 | 1,234 | Python 3 | OK | TESTS | 34 | 62 | 0 | n, k = map(int, input().split())
s = list(map(int, input().split()))
s = list(sorted(s))
print(min(s[n - k:])) | Title: Network Configuration
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The R1 company wants to hold a web search championship. There were *n* computers given for the competition, each of them is connected to the Internet. The organizers believe that the data transfer speed directly a... | ```python
n, k = map(int, input().split())
s = list(map(int, input().split()))
s = list(sorted(s))
print(min(s[n - k:]))
``` | 3 | |
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,612,327,155 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 0 | 92 | 2,048,000 | n, k, q = map(int, input().split())
a = [0]*200002
for i in range(n):
i, j = map(int, input().split())
a[i] += 1
a[j + 1] -= 1
for i in range(2, 200001):
a[i] += a[i - 1]
if a[i] >= k:
a[i] = 1
else:
a[i] = 0
for i in range(2, 200001):
a[i] += a[i - 1]
for i in range(q):
l, r = map(int, input().split())
pr... | 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
n, k, q = map(int, input().split())
a = [0]*200002
for i in range(n):
i, j = map(int, input().split())
a[i] += 1
a[j + 1] -= 1
for i in range(2, 200001):
a[i] += a[i - 1]
if a[i] >= k:
a[i] = 1
else:
a[i] = 0
for i in range(2, 200001):
a[i] += a[i - 1]
for i in range(q):
l, r = map(int, input().sp... | 0 | |
94 | A | Restoring Password | PROGRAMMING | 900 | [
"implementation",
"strings"
] | A. Restoring Password | 2 | 256 | Igor K. always used to trust his favorite Kashpirovsky Antivirus. That is why he didn't hesitate to download the link one of his groupmates sent him via QIP Infinium. The link was said to contain "some real funny stuff about swine influenza". The antivirus had no objections and Igor K. run the flash application he had ... | The input data contains 11 lines. The first line represents the binary code 80 characters in length. That is the code written in Igor K.'s ISQ account's info. Next 10 lines contain pairwise distinct binary codes 10 characters in length, corresponding to numbers 0, 1, ..., 9. | Print one line containing 8 characters — The password to Igor K.'s ISQ account. It is guaranteed that the solution exists. | [
"01001100100101100000010110001001011001000101100110010110100001011010100101101100\n0100110000\n0100110010\n0101100000\n0101100010\n0101100100\n0101100110\n0101101000\n0101101010\n0101101100\n0101101110\n",
"10101101111001000010100100011010101101110010110111011000100011011110010110001000\n1001000010\n1101111001\n1... | [
"12345678\n",
"30234919\n"
] | none | 500 | [
{
"input": "01001100100101100000010110001001011001000101100110010110100001011010100101101100\n0100110000\n0100110010\n0101100000\n0101100010\n0101100100\n0101100110\n0101101000\n0101101010\n0101101100\n0101101110",
"output": "12345678"
},
{
"input": "1010110111100100001010010001101010110111001011011... | 1,517,945,678 | 2,147,483,647 | Python 3 | OK | TESTS | 50 | 124 | 5,632,000 | pwd = str(input())
seq = [str(input()),str(input()),str(input()),str(input()),str(input())
,str(input()),str(input()),str(input()),str(input()),str(input())]
for n in range(0 , 8):
for i in range(0 ,len(seq)) :
if pwd[n*10:n*10+10] ==seq[i] :
print(i , end= '') | Title: Restoring Password
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Igor K. always used to trust his favorite Kashpirovsky Antivirus. That is why he didn't hesitate to download the link one of his groupmates sent him via QIP Infinium. The link was said to contain "some real funny stuff a... | ```python
pwd = str(input())
seq = [str(input()),str(input()),str(input()),str(input()),str(input())
,str(input()),str(input()),str(input()),str(input()),str(input())]
for n in range(0 , 8):
for i in range(0 ,len(seq)) :
if pwd[n*10:n*10+10] ==seq[i] :
print(i , end= '')
``` | 3.95851 |
71 | A | Way Too Long Words | PROGRAMMING | 800 | [
"strings"
] | A. Way Too Long Words | 1 | 256 | Sometimes some words like "localization" or "internationalization" are so long that writing them many times in one text is quite tiresome.
Let's consider a word too long, if its length is strictly more than 10 characters. All too long words should be replaced with a special abbreviation.
This abbreviation is made lik... | The first line contains an integer *n* (1<=≤<=*n*<=≤<=100). Each of the following *n* lines contains one word. All the words consist of lowercase Latin letters and possess the lengths of from 1 to 100 characters. | Print *n* lines. The *i*-th line should contain the result of replacing of the *i*-th word from the input data. | [
"4\nword\nlocalization\ninternationalization\npneumonoultramicroscopicsilicovolcanoconiosis\n"
] | [
"word\nl10n\ni18n\np43s\n"
] | none | 500 | [
{
"input": "4\nword\nlocalization\ninternationalization\npneumonoultramicroscopicsilicovolcanoconiosis",
"output": "word\nl10n\ni18n\np43s"
},
{
"input": "5\nabcdefgh\nabcdefghi\nabcdefghij\nabcdefghijk\nabcdefghijklm",
"output": "abcdefgh\nabcdefghi\nabcdefghij\na9k\na11m"
},
{
"input":... | 1,677,466,467 | 2,147,483,647 | Python 3 | OK | TESTS | 20 | 46 | 0 | n = int(input())
for i in range(n):
x = input()
if len(x)>10:
print(x[0],len(x)-2,x[len(x)-1] , sep='')
else:
print(x) | Title: Way Too Long Words
Time Limit: 1 seconds
Memory Limit: 256 megabytes
Problem Description:
Sometimes some words like "localization" or "internationalization" are so long that writing them many times in one text is quite tiresome.
Let's consider a word too long, if its length is strictly more than 10 character... | ```python
n = int(input())
for i in range(n):
x = input()
if len(x)>10:
print(x[0],len(x)-2,x[len(x)-1] , sep='')
else:
print(x)
``` | 3.977 |
0 | none | none | none | 0 | [
"none"
] | null | null | Limak is a little polar bear. He doesn't have many toys and thus he often plays with polynomials.
He considers a polynomial valid if its degree is *n* and its coefficients are integers not exceeding *k* by the absolute value. More formally:
Let *a*0,<=*a*1,<=...,<=*a**n* denote the coefficients, so . Then, a polynomi... | The first line contains two integers *n* and *k* (1<=≤<=*n*<=≤<=200<=000,<=1<=≤<=*k*<=≤<=109) — the degree of the polynomial and the limit for absolute values of coefficients.
The second line contains *n*<=+<=1 integers *a*0,<=*a*1,<=...,<=*a**n* (|*a**i*|<=≤<=*k*,<=*a**n*<=≠<=0) — describing a valid polynomial . It's... | Print the number of ways to change one coefficient to get a valid polynomial *Q* that *Q*(2)<==<=0. | [
"3 1000000000\n10 -9 -3 5\n",
"3 12\n10 -9 -3 5\n",
"2 20\n14 -7 19\n"
] | [
"3\n",
"2\n",
"0\n"
] | In the first sample, we are given a polynomial *P*(*x*) = 10 - 9*x* - 3*x*<sup class="upper-index">2</sup> + 5*x*<sup class="upper-index">3</sup>.
Limak can change one coefficient in three ways:
1. He can set *a*<sub class="lower-index">0</sub> = - 10. Then he would get *Q*(*x*) = - 10 - 9*x* - 3*x*<sup class="upp... | 0 | [
{
"input": "3 1000000000\n10 -9 -3 5",
"output": "3"
},
{
"input": "3 12\n10 -9 -3 5",
"output": "2"
},
{
"input": "2 20\n14 -7 19",
"output": "0"
},
{
"input": "5 5\n0 -4 -2 -2 0 5",
"output": "1"
},
{
"input": "6 10\n-2 -1 7 -3 2 7 -6",
"output": "2"
},
... | 1,574,691,119 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 7 | 2,000 | 58,163,200 | n = input().split(' ')
n, k = int(n[0]), int(n[1])
a = input().split(' ')
for i in range(n+1):
a[i] = int(a[i])
b = [0]*(n+1)
sum = 0
for i in range(n+1):
b[i] = pow(2, i)
sum += a[i]*b[i]
ans = 0
if sum == 0:
print(0)
else:
for i in range(n+1):
if sum%b[i] == 0:
if abs(sum/b[i]-... | Title: none
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Limak is a little polar bear. He doesn't have many toys and thus he often plays with polynomials.
He considers a polynomial valid if its degree is *n* and its coefficients are integers not exceeding *k* by the absolute value. Mor... | ```python
n = input().split(' ')
n, k = int(n[0]), int(n[1])
a = input().split(' ')
for i in range(n+1):
a[i] = int(a[i])
b = [0]*(n+1)
sum = 0
for i in range(n+1):
b[i] = pow(2, i)
sum += a[i]*b[i]
ans = 0
if sum == 0:
print(0)
else:
for i in range(n+1):
if sum%b[i] == 0:
if abs... | 0 | |
448 | A | Rewards | PROGRAMMING | 800 | [
"implementation"
] | null | null | Bizon the Champion is called the Champion for a reason.
Bizon the Champion has recently got a present — a new glass cupboard with *n* shelves and he decided to put all his presents there. All the presents can be divided into two types: medals and cups. Bizon the Champion has *a*1 first prize cups, *a*2 second prize c... | The first line contains integers *a*1, *a*2 and *a*3 (0<=≤<=*a*1,<=*a*2,<=*a*3<=≤<=100). The second line contains integers *b*1, *b*2 and *b*3 (0<=≤<=*b*1,<=*b*2,<=*b*3<=≤<=100). The third line contains integer *n* (1<=≤<=*n*<=≤<=100).
The numbers in the lines are separated by single spaces. | Print "YES" (without the quotes) if all the rewards can be put on the shelves in the described manner. Otherwise, print "NO" (without the quotes). | [
"1 1 1\n1 1 1\n4\n",
"1 1 3\n2 3 4\n2\n",
"1 0 0\n1 0 0\n1\n"
] | [
"YES\n",
"YES\n",
"NO\n"
] | none | 500 | [
{
"input": "1 1 1\n1 1 1\n4",
"output": "YES"
},
{
"input": "1 1 3\n2 3 4\n2",
"output": "YES"
},
{
"input": "1 0 0\n1 0 0\n1",
"output": "NO"
},
{
"input": "0 0 0\n0 0 0\n1",
"output": "YES"
},
{
"input": "100 100 100\n100 100 100\n100",
"output": "YES"
},
... | 1,622,131,197 | 2,147,483,647 | Python 3 | OK | TESTS | 25 | 62 | 0 | a1, a2, a3 = [int(i) for i in input().split()]
b1, b2, b3 = [int(i) for i in input().split()]
n = int(input())
a = a1 + a2 + a3
b = b1 + b2 + b3
n1 = a//5
n2 = b//10
if a % 5 != 0:
n1 = n1 + 1
if b % 10 != 0:
n2 = n2 + 1
n3 = n1 + n2
if n >= n3:
print("YES")
else:... | Title: Rewards
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Bizon the Champion is called the Champion for a reason.
Bizon the Champion has recently got a present — a new glass cupboard with *n* shelves and he decided to put all his presents there. All the presents can be divided into ... | ```python
a1, a2, a3 = [int(i) for i in input().split()]
b1, b2, b3 = [int(i) for i in input().split()]
n = int(input())
a = a1 + a2 + a3
b = b1 + b2 + b3
n1 = a//5
n2 = b//10
if a % 5 != 0:
n1 = n1 + 1
if b % 10 != 0:
n2 = n2 + 1
n3 = n1 + n2
if n >= n3:
print("YES")
... | 3 | |
492 | B | Vanya and Lanterns | PROGRAMMING | 1,200 | [
"binary search",
"implementation",
"math",
"sortings"
] | null | null | Vanya walks late at night along a straight street of length *l*, lit by *n* lanterns. Consider the coordinate system with the beginning of the street corresponding to the point 0, and its end corresponding to the point *l*. Then the *i*-th lantern is at the point *a**i*. The lantern lights all points of the street that... | The first line contains two integers *n*, *l* (1<=≤<=*n*<=≤<=1000, 1<=≤<=*l*<=≤<=109) — the number of lanterns and the length of the street respectively.
The next line contains *n* integers *a**i* (0<=≤<=*a**i*<=≤<=*l*). Multiple lanterns can be located at the same point. The lanterns may be located at the ends of th... | Print the minimum light radius *d*, needed to light the whole street. The answer will be considered correct if its absolute or relative error doesn't exceed 10<=-<=9. | [
"7 15\n15 5 3 7 9 14 0\n",
"2 5\n2 5\n"
] | [
"2.5000000000\n",
"2.0000000000\n"
] | Consider the second sample. At *d* = 2 the first lantern will light the segment [0, 4] of the street, and the second lantern will light segment [3, 5]. Thus, the whole street will be lit. | 1,000 | [
{
"input": "7 15\n15 5 3 7 9 14 0",
"output": "2.5000000000"
},
{
"input": "2 5\n2 5",
"output": "2.0000000000"
},
{
"input": "46 615683844\n431749087 271781274 274974690 324606253 480870261 401650581 13285442 478090364 266585394 425024433 588791449 492057200 391293435 563090494 317950 1... | 1,690,823,294 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 30 | 0 | n, l = map(int, input().split())
a = list(set(map(int, input().split())))
a.sort()
#print(a)
h = list()
for i in range(len(a) - 1):
h.append((a[i + 1] - a[i]) / 2)
print(max(h))
| Title: Vanya and Lanterns
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vanya walks late at night along a straight street of length *l*, lit by *n* lanterns. Consider the coordinate system with the beginning of the street corresponding to the point 0, and its end corresponding to the poi... | ```python
n, l = map(int, input().split())
a = list(set(map(int, input().split())))
a.sort()
#print(a)
h = list()
for i in range(len(a) - 1):
h.append((a[i + 1] - a[i]) / 2)
print(max(h))
``` | 0 | |
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,570,079,946 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 3 | 124 | 409,600 | from collections import Counter
inp = input()
freq = Counter(inp)
print(min(freq[i] for i in 'nineteen'))
| 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
from collections import Counter
inp = input()
freq = Counter(inp)
print(min(freq[i] for i in 'nineteen'))
``` | 0 | |
337 | A | Puzzles | PROGRAMMING | 900 | [
"greedy"
] | null | null | The end of the school year is near and Ms. Manana, the teacher, will soon have to say goodbye to a yet another class. She decided to prepare a goodbye present for her *n* students and give each of them a jigsaw puzzle (which, as wikipedia states, is a tiling puzzle that requires the assembly of numerous small, often od... | The first line contains space-separated integers *n* and *m* (2<=≤<=*n*<=≤<=*m*<=≤<=50). The second line contains *m* space-separated integers *f*1,<=*f*2,<=...,<=*f**m* (4<=≤<=*f**i*<=≤<=1000) — the quantities of pieces in the puzzles sold in the shop. | Print a single integer — the least possible difference the teacher can obtain. | [
"4 6\n10 12 10 7 5 22\n"
] | [
"5\n"
] | Sample 1. The class has 4 students. The shop sells 6 puzzles. If Ms. Manana buys the first four puzzles consisting of 10, 12, 10 and 7 pieces correspondingly, then the difference between the sizes of the largest and the smallest puzzle will be equal to 5. It is impossible to obtain a smaller difference. Note that the t... | 500 | [
{
"input": "4 6\n10 12 10 7 5 22",
"output": "5"
},
{
"input": "2 2\n4 4",
"output": "0"
},
{
"input": "2 10\n4 5 6 7 8 9 10 11 12 12",
"output": "0"
},
{
"input": "4 5\n818 136 713 59 946",
"output": "759"
},
{
"input": "3 20\n446 852 783 313 549 965 40 88 86 617... | 1,682,043,621 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 1 | 62 | 0 | n, m = map(int,input().split())
list1 = list(map(int, input().split()))
list2 = []
for i in range(len(list1)):
if n<=list1[i]<=m:
list2.append(list1[i])
print(min(list2))
| Title: Puzzles
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The end of the school year is near and Ms. Manana, the teacher, will soon have to say goodbye to a yet another class. She decided to prepare a goodbye present for her *n* students and give each of them a jigsaw puzzle (which, a... | ```python
n, m = map(int,input().split())
list1 = list(map(int, input().split()))
list2 = []
for i in range(len(list1)):
if n<=list1[i]<=m:
list2.append(list1[i])
print(min(list2))
``` | -1 | |
0 | none | none | none | 0 | [
"none"
] | null | null | One day student Vasya was sitting on a lecture and mentioned a string *s*1*s*2... *s**n*, consisting of letters "a", "b" and "c" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by composing a graph *G* with the following properties:
- *G* has exactly *n* vertices, numbe... | The first line of the input contains two integers *n* and *m* — the number of vertices and edges in the graph found by Petya, respectively.
Each of the next *m* lines contains two integers *u**i* and *v**i* (1<=≤<=*u**i*,<=*v**i*<=≤<=*n*,<=*u**i*<=≠<=*v**i*) — the edges of the graph *G*. It is guaranteed, that there ... | In the first line print "Yes" (without the quotes), if the string *s* Petya is interested in really exists and "No" (without the quotes) otherwise.
If the string *s* exists, then print it on the second line of the output. The length of *s* must be exactly *n*, it must consist of only letters "a", "b" and "c" only, and... | [
"2 1\n1 2\n",
"4 3\n1 2\n1 3\n1 4\n"
] | [
"Yes\naa\n",
"No\n"
] | In the first sample you are given a graph made of two vertices with an edge between them. So, these vertices can correspond to both the same and adjacent letters. Any of the following strings "aa", "ab", "ba", "bb", "bc", "cb", "cc" meets the graph's conditions.
In the second sample the first vertex is connected to a... | 0 | [
{
"input": "2 1\n1 2",
"output": "Yes\naa"
},
{
"input": "4 3\n1 2\n1 3\n1 4",
"output": "No"
},
{
"input": "4 4\n1 2\n1 3\n1 4\n3 4",
"output": "Yes\nbacc"
},
{
"input": "1 0",
"output": "Yes\na"
},
{
"input": "8 28\n3 2\n4 2\n7 4\n6 3\n3 7\n8 1\n3 4\n5 1\n6 5\n5... | 1,454,611,023 | 5,523 | PyPy 3 | RUNTIME_ERROR | PRETESTS | 0 | 78 | 512,000 |
def dfs(start, color, vis):
vis[start] = 1
for i in g[start]:
if vis[i] == 0:
color[i] = 1 - color[start]
dfs(i, color, vis)
if vis[i] != 0:
if (color[i] == color[start]):
print("No")
quit()
g = {}
... | Title: none
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
One day student Vasya was sitting on a lecture and mentioned a string *s*1*s*2... *s**n*, consisting of letters "a", "b" and "c" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by com... | ```python
def dfs(start, color, vis):
vis[start] = 1
for i in g[start]:
if vis[i] == 0:
color[i] = 1 - color[start]
dfs(i, color, vis)
if vis[i] != 0:
if (color[i] == color[start]):
print("No")
quit()
... | -1 | |
976 | B | Lara Croft and the New Game | PROGRAMMING | 1,300 | [
"implementation",
"math"
] | null | null | You might have heard about the next game in Lara Croft series coming out this year. You also might have watched its trailer. Though you definitely missed the main idea about its plot, so let me lift the veil of secrecy.
Lara is going to explore yet another dangerous dungeon. Game designers decided to use good old 2D e... | The only line contains three integers *n*, *m* and *k* (2<=≤<=*n*,<=*m*<=≤<=109, *n* is always even, 0<=≤<=*k*<=<<=*n*·*m*). Note that *k* doesn't fit into 32-bit integer type! | Print the cell (the row and the column where the cell is situated) where Lara ends up after she moves *k* times. | [
"4 3 0\n",
"4 3 11\n",
"4 3 7\n"
] | [
"1 1\n",
"1 2\n",
"3 2\n"
] | Here is her path on matrix 4 by 3: | 0 | [
{
"input": "4 3 0",
"output": "1 1"
},
{
"input": "4 3 11",
"output": "1 2"
},
{
"input": "4 3 7",
"output": "3 2"
},
{
"input": "1000000000 2 1999999999",
"output": "1 2"
},
{
"input": "1000000000 1000000000 999999999999999999",
"output": "1 2"
},
{
"... | 1,526,047,031 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 3 | 2,000 | 7,065,600 | n,m,k=list(map(int,input().split()))
x=1
y=1
l=n
flag=False
while l>1 and k>1:
l-=1
k-=1
x+=1
while k>0:
flag=True
for i in range(1,m):
if k==0:
break
y+=1
k-=1
x-=1
for i in range(1,m):
if k==0:
break
... | Title: Lara Croft and the New Game
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You might have heard about the next game in Lara Croft series coming out this year. You also might have watched its trailer. Though you definitely missed the main idea about its plot, so let me lift the veil... | ```python
n,m,k=list(map(int,input().split()))
x=1
y=1
l=n
flag=False
while l>1 and k>1:
l-=1
k-=1
x+=1
while k>0:
flag=True
for i in range(1,m):
if k==0:
break
y+=1
k-=1
x-=1
for i in range(1,m):
if k==0:
b... | 0 | |
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,672,824,227 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 46 | 0 | d=['h','e','l','o']
a=list(input())
e=0
a.remove('l')
for j in d:
if j not in a:
e=1
break
if e==0:
if a.index(d[0])<a.index(d[1])<a.index(d[2])<a.index(d[3]):
print("YES")
else:
print("NO")
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
d=['h','e','l','o']
a=list(input())
e=0
a.remove('l')
for j in d:
if j not in a:
e=1
break
if e==0:
if a.index(d[0])<a.index(d[1])<a.index(d[2])<a.index(d[3]):
print("YES")
else:
print("NO")
else:
print("NO")
``` | 0 |
628 | B | New Skateboard | PROGRAMMING | 1,300 | [
"dp"
] | null | null | Max wants to buy a new skateboard. He has calculated the amount of money that is needed to buy a new skateboard. He left a calculator on the floor and went to ask some money from his parents. Meanwhile his little brother Yusuf came and started to press the keys randomly. Unfortunately Max has forgotten the number which... | The only line contains string *s* (1<=≤<=|*s*|<=≤<=3·105). The string *s* contains only digits from 0 to 9. | Print integer *a* — the number of substrings of the string *s* that are divisible by 4.
Note that the answer can be huge, so you should use 64-bit integer type to store it. In C++ you can use the long long integer type and in Java you can use long integer type. | [
"124\n",
"04\n",
"5810438174\n"
] | [
"4\n",
"3\n",
"9\n"
] | none | 0 | [
{
"input": "124",
"output": "4"
},
{
"input": "04",
"output": "3"
},
{
"input": "5810438174",
"output": "9"
},
{
"input": "1",
"output": "0"
},
{
"input": "039",
"output": "1"
},
{
"input": "97247",
"output": "6"
},
{
"input": "5810438174",... | 1,589,805,625 | 2,147,483,647 | PyPy 3 | OK | TESTS | 22 | 202 | 23,756,800 | s = input()
n = len(s)
i = n - 1
ans = 0
while i > 0:
number = int(s[i-1] + s[i])
if s[i] == '4' or s[i] == '8' or s[i] == '0':
ans += 1
if number % 4 == 0:
ans += i
i -= 1
if s[0] == '4' or s[0] == '8' or s[0] == '0':
ans += 1
print(ans) | Title: New Skateboard
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Max wants to buy a new skateboard. He has calculated the amount of money that is needed to buy a new skateboard. He left a calculator on the floor and went to ask some money from his parents. Meanwhile his little brother... | ```python
s = input()
n = len(s)
i = n - 1
ans = 0
while i > 0:
number = int(s[i-1] + s[i])
if s[i] == '4' or s[i] == '8' or s[i] == '0':
ans += 1
if number % 4 == 0:
ans += i
i -= 1
if s[0] == '4' or s[0] == '8' or s[0] == '0':
ans += 1
print(ans)
``` | 3 | |
200 | B | Drinks | PROGRAMMING | 800 | [
"implementation",
"math"
] | null | null | Little Vasya loves orange juice very much. That's why any food and drink in his kitchen necessarily contains orange juice. There are *n* drinks in his fridge, the volume fraction of orange juice in the *i*-th drink equals *p**i* percent.
One day Vasya decided to make himself an orange cocktail. He took equal proportio... | The first input line contains a single integer *n* (1<=≤<=*n*<=≤<=100) — the number of orange-containing drinks in Vasya's fridge. The second line contains *n* integers *p**i* (0<=≤<=*p**i*<=≤<=100) — the volume fraction of orange juice in the *i*-th drink, in percent. The numbers are separated by a space. | Print the volume fraction in percent of orange juice in Vasya's cocktail. The answer will be considered correct if the absolute or relative error does not exceed 10<=<=-<=4. | [
"3\n50 50 100\n",
"4\n0 25 50 75\n"
] | [
"66.666666666667\n",
"37.500000000000\n"
] | Note to the first sample: let's assume that Vasya takes *x* milliliters of each drink from the fridge. Then the volume of pure juice in the cocktail will equal <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/c1fac6e64d3a8ee6a5ac138cbe51e60039b22473.png" style="max-width: 100.0%;max-height: ... | 500 | [
{
"input": "3\n50 50 100",
"output": "66.666666666667"
},
{
"input": "4\n0 25 50 75",
"output": "37.500000000000"
},
{
"input": "3\n0 1 8",
"output": "3.000000000000"
},
{
"input": "5\n96 89 93 95 70",
"output": "88.600000000000"
},
{
"input": "7\n62 41 78 4 38 39... | 1,688,051,662 | 2,147,483,647 | Python 3 | OK | TESTS | 31 | 92 | 0 | n=int(input())
r=list(map(int,input().split()))
print(sum(r)/n)
| Title: Drinks
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Little Vasya loves orange juice very much. That's why any food and drink in his kitchen necessarily contains orange juice. There are *n* drinks in his fridge, the volume fraction of orange juice in the *i*-th drink equals *p**i*... | ```python
n=int(input())
r=list(map(int,input().split()))
print(sum(r)/n)
``` | 3 | |
443 | A | Anton and Letters | PROGRAMMING | 800 | [
"constructive algorithms",
"implementation"
] | null | null | Recently, Anton has found a set. The set consists of small English letters. Anton carefully wrote out all the letters from the set in one line, separated by a comma. He also added an opening curved bracket at the beginning of the line and a closing curved bracket at the end of the line.
Unfortunately, from time to ti... | The first and the single line contains the set of letters. The length of the line doesn't exceed 1000. It is guaranteed that the line starts from an opening curved bracket and ends with a closing curved bracket. Between them, small English letters are listed, separated by a comma. Each comma is followed by a space. | Print a single number — the number of distinct letters in Anton's set. | [
"{a, b, c}\n",
"{b, a, b, a}\n",
"{}\n"
] | [
"3\n",
"2\n",
"0\n"
] | none | 500 | [
{
"input": "{a, b, c}",
"output": "3"
},
{
"input": "{b, a, b, a}",
"output": "2"
},
{
"input": "{}",
"output": "0"
},
{
"input": "{a, a, c, b, b, b, c, c, c, c}",
"output": "3"
},
{
"input": "{a, c, b, b}",
"output": "3"
},
{
"input": "{a, b}",
"o... | 1,693,950,764 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 30 | 0 | print(len(set(input().split()))) | Title: Anton and Letters
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Recently, Anton has found a set. The set consists of small English letters. Anton carefully wrote out all the letters from the set in one line, separated by a comma. He also added an opening curved bracket at the begi... | ```python
print(len(set(input().split())))
``` | 0 | |
385 | A | Bear and Raspberry | PROGRAMMING | 1,000 | [
"brute force",
"greedy",
"implementation"
] | null | null | The bear decided to store some raspberry for the winter. He cunningly found out the price for a barrel of honey in kilos of raspberry for each of the following *n* days. According to the bear's data, on the *i*-th (1<=≤<=*i*<=≤<=*n*) day, the price for one barrel of honey is going to is *x**i* kilos of raspberry.
Unfo... | The first line contains two space-separated integers, *n* and *c* (2<=≤<=*n*<=≤<=100,<=0<=≤<=*c*<=≤<=100), — the number of days and the number of kilos of raspberry that the bear should give for borrowing the barrel.
The second line contains *n* space-separated integers *x*1,<=*x*2,<=...,<=*x**n* (0<=≤<=*x**i*<=≤<=100... | Print a single integer — the answer to the problem. | [
"5 1\n5 10 7 3 20\n",
"6 2\n100 1 10 40 10 40\n",
"3 0\n1 2 3\n"
] | [
"3\n",
"97\n",
"0\n"
] | In the first sample the bear will lend a honey barrel at day 3 and then sell it for 7. Then the bear will buy a barrel for 3 and return it to the friend. So, the profit is (7 - 3 - 1) = 3.
In the second sample bear will lend a honey barrel at day 1 and then sell it for 100. Then the bear buy the barrel for 1 at the da... | 500 | [
{
"input": "5 1\n5 10 7 3 20",
"output": "3"
},
{
"input": "6 2\n100 1 10 40 10 40",
"output": "97"
},
{
"input": "3 0\n1 2 3",
"output": "0"
},
{
"input": "2 0\n2 1",
"output": "1"
},
{
"input": "10 5\n10 1 11 2 12 3 13 4 14 5",
"output": "4"
},
{
"in... | 1,667,529,553 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 32 | 62 | 0 | n,m=map(int,input().split())
l=list(map(int,input().split()))
dif=[]
for i in range(len(l)-1):
dif.append(l[i]-l[i+1])
if max(dif)-m<0:
print(0)
else:
print(max(dif)-m)
| Title: Bear and Raspberry
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The bear decided to store some raspberry for the winter. He cunningly found out the price for a barrel of honey in kilos of raspberry for each of the following *n* days. According to the bear's data, on the *i*-th (1... | ```python
n,m=map(int,input().split())
l=list(map(int,input().split()))
dif=[]
for i in range(len(l)-1):
dif.append(l[i]-l[i+1])
if max(dif)-m<0:
print(0)
else:
print(max(dif)-m)
``` | 3 | |
180 | C | Letter | PROGRAMMING | 1,400 | [
"dp"
] | null | null | Patrick has just finished writing a message to his sweetheart Stacey when he noticed that the message didn't look fancy. Patrick was nervous while writing the message, so some of the letters there were lowercase and some of them were uppercase.
Patrick believes that a message is fancy if any uppercase letter stands to... | The only line of the input contains a non-empty string consisting of uppercase and lowercase letters. The string's length does not exceed 105. | Print a single number — the least number of actions needed to make the message fancy. | [
"PRuvetSTAaYA\n",
"OYPROSTIYAOPECHATALSYAPRIVETSTASYA\n",
"helloworld\n"
] | [
"5\n",
"0\n",
"0\n"
] | none | 0 | [
{
"input": "PRuvetSTAaYA",
"output": "5"
},
{
"input": "OYPROSTIYAOPECHATALSYAPRIVETSTASYA",
"output": "0"
},
{
"input": "helloworld",
"output": "0"
},
{
"input": "P",
"output": "0"
},
{
"input": "t",
"output": "0"
},
{
"input": "XdJ",
"output": "1... | 1,586,097,830 | 2,147,483,647 | PyPy 3 | OK | TESTS | 40 | 310 | 2,457,600 | from sys import stdin,stdout
Pi = lambda x: stdout.write(str(x) + '\n')
Ps = lambda x: stdout.write(str(x))
S = lambda x: x*(x+1) // 2
I = lambda x: 1+(2*x)
R = lambda:stdin.readline()
Ri = lambda x:map(int,x.split())
Rs = lambda x:map(str,x.split())
Rf = lambda x:map(float,x.split())
def main():
# t = i... | Title: Letter
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Patrick has just finished writing a message to his sweetheart Stacey when he noticed that the message didn't look fancy. Patrick was nervous while writing the message, so some of the letters there were lowercase and some of them... | ```python
from sys import stdin,stdout
Pi = lambda x: stdout.write(str(x) + '\n')
Ps = lambda x: stdout.write(str(x))
S = lambda x: x*(x+1) // 2
I = lambda x: 1+(2*x)
R = lambda:stdin.readline()
Ri = lambda x:map(int,x.split())
Rs = lambda x:map(str,x.split())
Rf = lambda x:map(float,x.split())
def main(): ... | 3 | |
527 | A | Playing with Paper | PROGRAMMING | 1,100 | [
"implementation",
"math"
] | null | null | One day Vasya was sitting on a not so interesting Maths lesson and making an origami from a rectangular *a* mm <=×<= *b* mm sheet of paper (*a*<=><=*b*). Usually the first step in making an origami is making a square piece of paper from the rectangular sheet by folding the sheet along the bisector of the right angle... | The first line of the input contains two integers *a*, *b* (1<=≤<=*b*<=<<=*a*<=≤<=1012) — the sizes of the original sheet of paper. | Print a single integer — the number of ships that Vasya will make. | [
"2 1\n",
"10 7\n",
"1000000000000 1\n"
] | [
"2\n",
"6\n",
"1000000000000\n"
] | Pictures to the first and second sample test. | 500 | [
{
"input": "2 1",
"output": "2"
},
{
"input": "10 7",
"output": "6"
},
{
"input": "1000000000000 1",
"output": "1000000000000"
},
{
"input": "3 1",
"output": "3"
},
{
"input": "4 1",
"output": "4"
},
{
"input": "3 2",
"output": "3"
},
{
"in... | 1,658,600,233 | 2,147,483,647 | PyPy 3 | OK | TESTS | 46 | 77 | 0 | def main():
a, b = map(int, input().split())
result = 0
while a != b:
if a >= b:
result += a//b
a = a%b
else:
result += b//a
b = b%a
if a*b == 0:
break
print(result)
main() | Title: Playing with Paper
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
One day Vasya was sitting on a not so interesting Maths lesson and making an origami from a rectangular *a* mm <=×<= *b* mm sheet of paper (*a*<=><=*b*). Usually the first step in making an origami is making a squ... | ```python
def main():
a, b = map(int, input().split())
result = 0
while a != b:
if a >= b:
result += a//b
a = a%b
else:
result += b//a
b = b%a
if a*b == 0:
break
print(result)
main()
``` | 3 | |
31 | B | Sysadmin Bob | PROGRAMMING | 1,500 | [
"greedy",
"implementation",
"strings"
] | B. Sysadmin Bob | 0 | 256 | Email address in Berland is a string of the form *A*@*B*, where *A* and *B* are arbitrary strings consisting of small Latin letters.
Bob is a system administrator in «Bersoft» company. He keeps a list of email addresses of the company's staff. This list is as a large string, where all addresses are written in arbitra... | The first line contains the list of addresses without separators. The length of this string is between 1 and 200, inclusive. The string consists only from small Latin letters and characters «@». | If there is no list of the valid (according to the Berland rules) email addresses such that after removing all commas it coincides with the given string, output No solution. In the other case, output the list. The same address can be written in this list more than once. If there are several solutions, output any of the... | [
"a@aa@a\n",
"a@a@a\n",
"@aa@a\n"
] | [
"a@a,a@a\n",
"No solution\n",
"No solution\n"
] | none | 1,000 | [
{
"input": "a@aa@a",
"output": "a@a,a@a"
},
{
"input": "a@a@a",
"output": "No solution"
},
{
"input": "@aa@a",
"output": "No solution"
},
{
"input": "aba@caba@daba",
"output": "aba@c,aba@daba"
},
{
"input": "asd@qwasd@qwasd@qwasd@qwasd@qw",
"output": "asd@q,wa... | 1,697,009,497 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 44 | 500 | 0 | def valid_email(s):
if s.count('@') != 1:
return False
a, b = s.split('@')
return bool(a) and bool(b)
def split_emails(s):
if not s:
return []
# If s is itself a valid email, return it as the sole solution.
if valid_email(s):
return [s]
# Try to split... | Title: Sysadmin Bob
Time Limit: 0 seconds
Memory Limit: 256 megabytes
Problem Description:
Email address in Berland is a string of the form *A*@*B*, where *A* and *B* are arbitrary strings consisting of small Latin letters.
Bob is a system administrator in «Bersoft» company. He keeps a list of email addresses of t... | ```python
def valid_email(s):
if s.count('@') != 1:
return False
a, b = s.split('@')
return bool(a) and bool(b)
def split_emails(s):
if not s:
return []
# If s is itself a valid email, return it as the sole solution.
if valid_email(s):
return [s]
# Tr... | 0 |
25 | A | IQ test | PROGRAMMING | 1,300 | [
"brute force"
] | A. IQ test | 2 | 256 | Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given *n* numbers differs from the others. Bob observed that one number usually differs from the others in evenness. Help Bob — to check his answers, he needs a program that among the given *n* numbers finds one that i... | The first line contains integer *n* (3<=≤<=*n*<=≤<=100) — amount of numbers in the task. The second line contains *n* space-separated natural numbers, not exceeding 100. It is guaranteed, that exactly one of these numbers differs from the others in evenness. | Output index of number that differs from the others in evenness. Numbers are numbered from 1 in the input order. | [
"5\n2 4 7 8 10\n",
"4\n1 2 1 1\n"
] | [
"3\n",
"2\n"
] | none | 0 | [
{
"input": "5\n2 4 7 8 10",
"output": "3"
},
{
"input": "4\n1 2 1 1",
"output": "2"
},
{
"input": "3\n1 2 2",
"output": "1"
},
{
"input": "3\n100 99 100",
"output": "2"
},
{
"input": "3\n5 3 2",
"output": "3"
},
{
"input": "4\n43 28 1 91",
"output"... | 1,493,573,446 | 2,147,483,647 | Python 3 | OK | TESTS | 32 | 124 | 5,529,600 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 30 10:23:32 2017
@author: lawrenceylong
"""
a = int(input())
b = list(map(int,input().split()))
a = [num%2 for num in b]
print(a.index(0)+1) if a.count(1)>a.count(0) else print(a.index(1)+1)
| Title: IQ test
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given *n* numbers differs from the others. Bob observed that one number usually differs from the others in evenness. Help Bob — t... | ```python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 30 10:23:32 2017
@author: lawrenceylong
"""
a = int(input())
b = list(map(int,input().split()))
a = [num%2 for num in b]
print(a.index(0)+1) if a.count(1)>a.count(0) else print(a.index(1)+1)
``` | 3.9587 |
817 | A | Treasure Hunt | PROGRAMMING | 1,200 | [
"implementation",
"math",
"number theory"
] | null | null | Captain Bill the Hummingbird and his crew recieved an interesting challenge offer. Some stranger gave them a map, potion of teleportation and said that only this potion might help them to reach the treasure.
Bottle with potion has two values *x* and *y* written on it. These values define four moves which can be perfo... | The first line contains four integer numbers *x*1,<=*y*1,<=*x*2,<=*y*2 (<=-<=105<=≤<=*x*1,<=*y*1,<=*x*2,<=*y*2<=≤<=105) — positions of Captain Bill the Hummingbird and treasure respectively.
The second line contains two integer numbers *x*,<=*y* (1<=≤<=*x*,<=*y*<=≤<=105) — values on the potion bottle. | Print "YES" if it is possible for Captain to reach the treasure using the potion, otherwise print "NO" (without quotes). | [
"0 0 0 6\n2 3\n",
"1 1 3 6\n1 5\n"
] | [
"YES\n",
"NO\n"
] | In the first example there exists such sequence of moves:
1. <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/7c939890fb4ed35688177327dac981bfa9216c00.png" style="max-width: 100.0%;max-height: 100.0%;"/> — the first type of move 1. <img align="middle" class="tex-formula" src="https://espr... | 0 | [
{
"input": "0 0 0 6\n2 3",
"output": "YES"
},
{
"input": "1 1 3 6\n1 5",
"output": "NO"
},
{
"input": "5 4 6 -10\n1 1",
"output": "NO"
},
{
"input": "6 -3 -7 -7\n1 2",
"output": "NO"
},
{
"input": "2 -5 -8 8\n2 1",
"output": "YES"
},
{
"input": "70 -81... | 1,575,897,296 | 2,147,483,647 | Python 3 | OK | TESTS | 61 | 109 | 0 | x1, y1, x2, y2 = map(int, input().split())
x, y = map(int, input().split())
if not(abs(x1-x2)%x) and not(abs(y1-y2)%y) and ((abs(y1-y2))//y)%2 == ((abs(x1-x2))//x)%2:
print("YES")
else:
print("NO")
| Title: Treasure Hunt
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Captain Bill the Hummingbird and his crew recieved an interesting challenge offer. Some stranger gave them a map, potion of teleportation and said that only this potion might help them to reach the treasure.
Bottle with... | ```python
x1, y1, x2, y2 = map(int, input().split())
x, y = map(int, input().split())
if not(abs(x1-x2)%x) and not(abs(y1-y2)%y) and ((abs(y1-y2))//y)%2 == ((abs(x1-x2))//x)%2:
print("YES")
else:
print("NO")
``` | 3 | |
629 | B | Far Relative’s Problem | PROGRAMMING | 1,100 | [
"brute force"
] | null | null | Famil Door wants to celebrate his birthday with his friends from Far Far Away. He has *n* friends and each of them can come to the party in a specific range of days of the year from *a**i* to *b**i*. Of course, Famil Door wants to have as many friends celebrating together with him as possible.
Far cars are as weird as... | The first line of the input contains a single integer *n* (1<=≤<=*n*<=≤<=5000) — then number of Famil Door's friends.
Then follow *n* lines, that describe the friends. Each line starts with a capital letter 'F' for female friends and with a capital letter 'M' for male friends. Then follow two integers *a**i* and *b**i... | Print the maximum number of people that may come to Famil Door's party. | [
"4\nM 151 307\nF 343 352\nF 117 145\nM 24 128\n",
"6\nM 128 130\nF 128 131\nF 131 140\nF 131 141\nM 131 200\nM 140 200\n"
] | [
"2\n",
"4\n"
] | In the first sample, friends 3 and 4 can come on any day in range [117, 128].
In the second sample, friends with indices 3, 4, 5 and 6 can come on day 140. | 1,000 | [
{
"input": "4\nM 151 307\nF 343 352\nF 117 145\nM 24 128",
"output": "2"
},
{
"input": "6\nM 128 130\nF 128 131\nF 131 140\nF 131 141\nM 131 200\nM 140 200",
"output": "4"
},
{
"input": "1\nF 68 307",
"output": "0"
},
{
"input": "40\nM 55 363\nF 117 252\nM 157 282\nF 322 345\... | 1,456,001,032 | 2,147,483,647 | Python 3 | OK | TESTS | 76 | 140 | 102,400 |
n=int(input())
m=[0]*366
f=[0]*366
for i in range(n):
g,a,b=input().split()
a,b=int(a),int(b)
if g=='F':
for i in range(a-1,b):
f[i]+=1
elif g=='M':
for i in range(a-1,b):
m[i]+=1
t=0
for i in range(366):
temp=min(f[i],m[i])
t = max(temp,t... | Title: Far Relative’s Problem
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Famil Door wants to celebrate his birthday with his friends from Far Far Away. He has *n* friends and each of them can come to the party in a specific range of days of the year from *a**i* to *b**i*. Of course, F... | ```python
n=int(input())
m=[0]*366
f=[0]*366
for i in range(n):
g,a,b=input().split()
a,b=int(a),int(b)
if g=='F':
for i in range(a-1,b):
f[i]+=1
elif g=='M':
for i in range(a-1,b):
m[i]+=1
t=0
for i in range(366):
temp=min(f[i],m[i])
t = ... | 3 |
Subsets and Splits
Successful Python Submissions
Retrieves all records from the train dataset where the verdict is 'OK', providing basic filtering but limited analytical value.
SQL Console for MatrixStudio/Codeforces-Python-Submissions
Retrieves records of users with a rating of 1600 or higher and a verdict of 'OK', providing basic filtering but limited analytical value.
SQL Console for MatrixStudio/Codeforces-Python-Submissions
Counts the number of entries with a rating above 2000 and a verdict of 'OK', providing basic filtering but limited analytical value.
SQL Console for MatrixStudio/Codeforces-Python-Submissions
Counts the number of entries with a 'OK' verdict, providing a basic overview of a specific category within the dataset.