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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
845 | B | Luba And The Ticket | PROGRAMMING | 1,600 | [
"brute force",
"greedy",
"implementation"
] | null | null | Luba has a ticket consisting of 6 digits. In one move she can choose digit in any position and replace it with arbitrary digit. She wants to know the minimum number of digits she needs to replace in order to make the ticket lucky.
The ticket is considered lucky if the sum of first three digits equals to the sum of las... | You are given a string consisting of 6 characters (all characters are digits from 0 to 9) — this string denotes Luba's ticket. The ticket can start with the digit 0. | Print one number — the minimum possible number of digits Luba needs to replace to make the ticket lucky. | [
"000000\n",
"123456\n",
"111000\n"
] | [
"0\n",
"2\n",
"1\n"
] | In the first example the ticket is already lucky, so the answer is 0.
In the second example Luba can replace 4 and 5 with zeroes, and the ticket will become lucky. It's easy to see that at least two replacements are required.
In the third example Luba can replace any zero with 3. It's easy to see that at least one re... | 0 | [
{
"input": "000000",
"output": "0"
},
{
"input": "123456",
"output": "2"
},
{
"input": "111000",
"output": "1"
},
{
"input": "120111",
"output": "0"
},
{
"input": "999999",
"output": "0"
},
{
"input": "199880",
"output": "1"
},
{
"input": "... | 1,503,332,780 | 4,880 | Python 3 | RUNTIME_ERROR | TESTS | 1 | 46 | 0 | tic = input()
arr = [int(digit) for digit in tic]
arr1 = arr[:3]
arr2 = arr[3:]
sum1 = sum(arr1)
sum2 = sum(arr2)
turns = 0
if sum1>sum2:
arr2.sort()
idx = 0
dis = sum1 - sum2
while (dis>0):
dis = dis - arr2[idx]
turns += 1
idx += 1
print(turns)
elif sum2>sum1:
arr1.sort()
idx = 0
dis =... | Title: Luba And The Ticket
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Luba has a ticket consisting of 6 digits. In one move she can choose digit in any position and replace it with arbitrary digit. She wants to know the minimum number of digits she needs to replace in order to make th... | ```python
tic = input()
arr = [int(digit) for digit in tic]
arr1 = arr[:3]
arr2 = arr[3:]
sum1 = sum(arr1)
sum2 = sum(arr2)
turns = 0
if sum1>sum2:
arr2.sort()
idx = 0
dis = sum1 - sum2
while (dis>0):
dis = dis - arr2[idx]
turns += 1
idx += 1
print(turns)
elif sum2>sum1:
arr1.sort()
idx =... | -1 | |
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,521,562,825 | 2,147,483,647 | Python 3 | OK | TESTS | 32 | 186 | 7,065,600 | n = int(input())
a = input().split()
for i in range(len(a)):
a[i] = int(a[i])
chet = 0
no_chet =0
for i in a:
if i%2==0:
chet+=1
else:
no_chet+=1
if chet>no_chet:
for i in a:
if (i%2):
print(a.index(i)+1)
else:
for i in a:
if i%2==0:
... | Title: IQ test
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given *n* numbers differs from the others. Bob observed that one number usually differs from the others in evenness. Help Bob — t... | ```python
n = int(input())
a = input().split()
for i in range(len(a)):
a[i] = int(a[i])
chet = 0
no_chet =0
for i in a:
if i%2==0:
chet+=1
else:
no_chet+=1
if chet>no_chet:
for i in a:
if (i%2):
print(a.index(i)+1)
else:
for i in a:
if i%2... | 3.940339 |
189 | A | Cut Ribbon | PROGRAMMING | 1,300 | [
"brute force",
"dp"
] | null | null | Polycarpus has a ribbon, its length is *n*. He wants to cut the ribbon in a way that fulfils the following two conditions:
- After the cutting each ribbon piece should have length *a*, *b* or *c*. - After the cutting the number of ribbon pieces should be maximum.
Help Polycarpus and find the number of ribbon piece... | The first line contains four space-separated integers *n*, *a*, *b* and *c* (1<=≤<=*n*,<=*a*,<=*b*,<=*c*<=≤<=4000) — the length of the original ribbon and the acceptable lengths of the ribbon pieces after the cutting, correspondingly. The numbers *a*, *b* and *c* can coincide. | Print a single number — the maximum possible number of ribbon pieces. It is guaranteed that at least one correct ribbon cutting exists. | [
"5 5 3 2\n",
"7 5 5 2\n"
] | [
"2\n",
"2\n"
] | In the first example Polycarpus can cut the ribbon in such way: the first piece has length 2, the second piece has length 3.
In the second example Polycarpus can cut the ribbon in such way: the first piece has length 5, the second piece has length 2. | 500 | [
{
"input": "5 5 3 2",
"output": "2"
},
{
"input": "7 5 5 2",
"output": "2"
},
{
"input": "4 4 4 4",
"output": "1"
},
{
"input": "1 1 1 1",
"output": "1"
},
{
"input": "4000 1 2 3",
"output": "4000"
},
{
"input": "4000 3 4 5",
"output": "1333"
},
... | 1,688,285,137 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 30 | 0 | n,a,b,c = map(int, input().split())
l = [a,b,c]
m = min(l)
dp = dict()
def cut(n):
if n in dp:
return dp[n]
if n < m:
return None
if n == 0:
return 0
ans = 0
for i in l:
remaining = n-i
z = 0
if n-i >= 0:
try:
... | Title: Cut Ribbon
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Polycarpus has a ribbon, its length is *n*. He wants to cut the ribbon in a way that fulfils the following two conditions:
- After the cutting each ribbon piece should have length *a*, *b* or *c*. - After the cutting the... | ```python
n,a,b,c = map(int, input().split())
l = [a,b,c]
m = min(l)
dp = dict()
def cut(n):
if n in dp:
return dp[n]
if n < m:
return None
if n == 0:
return 0
ans = 0
for i in l:
remaining = n-i
z = 0
if n-i >= 0:
try:
... | 0 | |
687 | C | The Values You Can Make | PROGRAMMING | 1,900 | [
"dp"
] | null | null | Pari wants to buy an expensive chocolate from Arya. She has *n* coins, the value of the *i*-th coin is *c**i*. The price of the chocolate is *k*, so Pari will take a subset of her coins with sum equal to *k* and give it to Arya.
Looking at her coins, a question came to her mind: after giving the coins to Arya, what va... | The first line contains two integers *n* and *k* (1<=<=≤<=<=*n*,<=*k*<=<=≤<=<=500) — the number of coins and the price of the chocolate, respectively.
Next line will contain *n* integers *c*1,<=*c*2,<=...,<=*c**n* (1<=≤<=*c**i*<=≤<=500) — the values of Pari's coins.
It's guaranteed that one can make value *k* using t... | First line of the output must contain a single integer *q*— the number of suitable values *x*. Then print *q* integers in ascending order — the values that Arya can make for some subset of coins of Pari that pays for the chocolate. | [
"6 18\n5 6 1 10 12 2\n",
"3 50\n25 25 50\n"
] | [
"16\n0 1 2 3 5 6 7 8 10 11 12 13 15 16 17 18 \n",
"3\n0 25 50 \n"
] | none | 1,500 | [
{
"input": "6 18\n5 6 1 10 12 2",
"output": "16\n0 1 2 3 5 6 7 8 10 11 12 13 15 16 17 18 "
},
{
"input": "3 50\n25 25 50",
"output": "3\n0 25 50 "
},
{
"input": "1 79\n79",
"output": "2\n0 79 "
},
{
"input": "1 114\n114",
"output": "2\n0 114 "
},
{
"input": "5 1\n... | 1,699,250,830 | 2,147,483,647 | PyPy 3-64 | RUNTIME_ERROR | TESTS | 6 | 62 | 2,867,200 | def solve(k, c):
u = {0: []}
for i,ci in enumerate(c):
for v in list(u):
if v+ci <= k:
u.setdefault(v+ci, []).append(i)
vv = [{} for ci in c]
vv.append({k:{0}})
while len(vv) > 1:
vs = vv.pop()
for v, ws in vs.items():
for i ... | Title: The Values You Can Make
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Pari wants to buy an expensive chocolate from Arya. She has *n* coins, the value of the *i*-th coin is *c**i*. The price of the chocolate is *k*, so Pari will take a subset of her coins with sum equal to *k* and... | ```python
def solve(k, c):
u = {0: []}
for i,ci in enumerate(c):
for v in list(u):
if v+ci <= k:
u.setdefault(v+ci, []).append(i)
vv = [{} for ci in c]
vv.append({k:{0}})
while len(vv) > 1:
vs = vv.pop()
for v, ws in vs.items():
... | -1 | |
991 | C | Candies | PROGRAMMING | 1,500 | [
"binary search",
"implementation"
] | null | null | After passing a test, Vasya got himself a box of $n$ candies. He decided to eat an equal amount of candies each morning until there are no more candies. However, Petya also noticed the box and decided to get some candies for himself.
This means the process of eating candies is the following: in the beginning Vasya cho... | The first line contains a single integer $n$ ($1 \leq n \leq 10^{18}$) — the initial amount of candies in the box. | Output a single integer — the minimal amount of $k$ that would allow Vasya to eat at least half of candies he got. | [
"68\n"
] | [
"3\n"
] | In the sample, the amount of candies, with $k=3$, would change in the following way (Vasya eats first):
$68 \to 65 \to 59 \to 56 \to 51 \to 48 \to 44 \to 41 \\ \to 37 \to 34 \to 31 \to 28 \to 26 \to 23 \to 21 \to 18 \to 17 \to 14 \\ \to 13 \to 10 \to 9 \to 6 \to 6 \to 3 \to 3 \to 0$.
In total, Vasya would eat $39$ ca... | 1,250 | [
{
"input": "68",
"output": "3"
},
{
"input": "1",
"output": "1"
},
{
"input": "2",
"output": "1"
},
{
"input": "42",
"output": "1"
},
{
"input": "43",
"output": "2"
},
{
"input": "756",
"output": "29"
},
{
"input": "999999972",
"output"... | 1,668,199,019 | 959 | PyPy 3 | OK | TESTS | 69 | 77 | 1,228,800 | def check(n, k):
S = n
Vasya = 0
Petya = 0
while S > 0:
Vasya+=min(S, k)
S-=min(S, k)
Petya+=(S//10)
S-=(S//10)
return Vasya >= Petya
def process(n):
if check(n, 1):
print(1)
return
s = 1
e = n
while s+1 < e:
... | Title: Candies
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
After passing a test, Vasya got himself a box of $n$ candies. He decided to eat an equal amount of candies each morning until there are no more candies. However, Petya also noticed the box and decided to get some candies for hi... | ```python
def check(n, k):
S = n
Vasya = 0
Petya = 0
while S > 0:
Vasya+=min(S, k)
S-=min(S, k)
Petya+=(S//10)
S-=(S//10)
return Vasya >= Petya
def process(n):
if check(n, 1):
print(1)
return
s = 1
e = n
while s+1 ... | 3 | |
620 | B | Grandfather Dovlet’s calculator | PROGRAMMING | 1,000 | [
"implementation"
] | null | null | Once Max found an electronic calculator from his grandfather Dovlet's chest. He noticed that the numbers were written with seven-segment indicators ([https://en.wikipedia.org/wiki/Seven-segment_display](https://en.wikipedia.org/wiki/Seven-segment_display)).
Max starts to type all the values from *a* to *b*. After typi... | The only line contains two integers *a*,<=*b* (1<=≤<=*a*<=≤<=*b*<=≤<=106) — the first and the last number typed by Max. | Print the only integer *a* — the total number of printed segments. | [
"1 3\n",
"10 15\n"
] | [
"12\n",
"39\n"
] | none | 0 | [
{
"input": "1 3",
"output": "12"
},
{
"input": "10 15",
"output": "39"
},
{
"input": "1 100",
"output": "928"
},
{
"input": "100 10000",
"output": "188446"
},
{
"input": "213 221442",
"output": "5645356"
},
{
"input": "1 1000000",
"output": "287333... | 1,646,302,765 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 5 | 1,000 | 0 | disp = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]
def getSegmentSum(n):
sumD = 0
while(n>0):
sumD += disp[int(n%10)]
n=n//10
return sumD
a, b = list(map(int , input().split()))
sum = 0
for i in range(a, b+1):
sum += getSegmentSum(i)
print(sum)
| Title: Grandfather Dovlet’s calculator
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Once Max found an electronic calculator from his grandfather Dovlet's chest. He noticed that the numbers were written with seven-segment indicators ([https://en.wikipedia.org/wiki/Seven-segment_display](... | ```python
disp = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]
def getSegmentSum(n):
sumD = 0
while(n>0):
sumD += disp[int(n%10)]
n=n//10
return sumD
a, b = list(map(int , input().split()))
sum = 0
for i in range(a, b+1):
sum += getSegmentSum(i)
print(sum)
``` | 0 | |
908 | C | New Year and Curling | PROGRAMMING | 1,500 | [
"brute force",
"geometry",
"implementation",
"math"
] | null | null | Carol is currently curling.
She has *n* disks each with radius *r* on the 2D plane.
Initially she has all these disks above the line *y*<==<=10100.
She then will slide the disks towards the line *y*<==<=0 one by one in order from 1 to *n*.
When she slides the *i*-th disk, she will place its center at the point (*... | The first line will contain two integers *n* and *r* (1<=≤<=*n*,<=*r*<=≤<=1<=000), the number of disks, and the radius of the disks, respectively.
The next line will contain *n* integers *x*1,<=*x*2,<=...,<=*x**n* (1<=≤<=*x**i*<=≤<=1<=000) — the *x*-coordinates of the disks. | Print a single line with *n* numbers. The *i*-th number denotes the *y*-coordinate of the center of the *i*-th disk. The output will be accepted if it has absolute or relative error at most 10<=-<=6.
Namely, let's assume that your answer for a particular value of a coordinate is *a* and the answer of the jury is *b*. ... | [
"6 2\n5 5 6 8 3 12\n"
] | [
"2 6.0 9.87298334621 13.3370849613 12.5187346573 13.3370849613\n"
] | The final positions of the disks will look as follows:
In particular, note the position of the last disk. | 1,000 | [
{
"input": "6 2\n5 5 6 8 3 12",
"output": "2 6.0 9.87298334621 13.3370849613 12.5187346573 13.3370849613"
},
{
"input": "1 1\n5",
"output": "1"
},
{
"input": "5 300\n939 465 129 611 532",
"output": "300 667.864105343 1164.9596696 1522.27745533 2117.05388391"
},
{
"input": "5 ... | 1,606,524,504 | 2,147,483,647 | Python 3 | OK | TESTS | 15 | 717 | 614,400 | # [https://www.dropbox.com/sh/i9cxj44tvv5pqvn/AADey7NNgaV3vJKC8dGet_Kma/C?dl=0&preview=C.py&subfolder_nav_tracking=1 <- https://codeforces.com/blog/entry/56713 <- https://codeforces.com/problemset/problem/908/C <- https://algoprog.ru/material/pc908pC]
import math
(n, r) = map(int, input().split())
x = list(map(int... | Title: New Year and Curling
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Carol is currently curling.
She has *n* disks each with radius *r* on the 2D plane.
Initially she has all these disks above the line *y*<==<=10100.
She then will slide the disks towards the line *y*<==<=0 one b... | ```python
# [https://www.dropbox.com/sh/i9cxj44tvv5pqvn/AADey7NNgaV3vJKC8dGet_Kma/C?dl=0&preview=C.py&subfolder_nav_tracking=1 <- https://codeforces.com/blog/entry/56713 <- https://codeforces.com/problemset/problem/908/C <- https://algoprog.ru/material/pc908pC]
import math
(n, r) = map(int, input().split())
x = li... | 3 | |
31 | A | Worms Evolution | PROGRAMMING | 1,200 | [
"implementation"
] | A. Worms Evolution | 2 | 256 | Professor Vasechkin is studying evolution of worms. Recently he put forward hypotheses that all worms evolve by division. There are *n* forms of worms. Worms of these forms have lengths *a*1, *a*2, ..., *a**n*. To prove his theory, professor needs to find 3 different forms that the length of the first form is equal to ... | The first line contains integer *n* (3<=≤<=*n*<=≤<=100) — amount of worm's forms. The second line contains *n* space-separated integers *a**i* (1<=≤<=*a**i*<=≤<=1000) — lengths of worms of each form. | Output 3 distinct integers *i* *j* *k* (1<=≤<=*i*,<=*j*,<=*k*<=≤<=*n*) — such indexes of worm's forms that *a**i*<==<=*a**j*<=+<=*a**k*. If there is no such triple, output -1. If there are several solutions, output any of them. It possible that *a**j*<==<=*a**k*. | [
"5\n1 2 3 5 7\n",
"5\n1 8 1 5 1\n"
] | [
"3 2 1\n",
"-1\n"
] | none | 500 | [
{
"input": "5\n1 2 3 5 7",
"output": "3 2 1"
},
{
"input": "5\n1 8 1 5 1",
"output": "-1"
},
{
"input": "4\n303 872 764 401",
"output": "-1"
},
{
"input": "6\n86 402 133 524 405 610",
"output": "6 4 1"
},
{
"input": "8\n217 779 418 895 996 473 3 22",
"output":... | 1,593,792,870 | 2,147,483,647 | PyPy 3 | OK | TESTS | 39 | 280 | 0 | n=int(input())
a=list(map(int,input().split()))
for i in range(n):
for j in range(n):
if a[i]+a[j] in a and i!=j!=a.index(a[i]+a[j]):
print(a.index(a[i]+a[j])+1,i+1,j+1)
exit()
print(-1) | Title: Worms Evolution
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Professor Vasechkin is studying evolution of worms. Recently he put forward hypotheses that all worms evolve by division. There are *n* forms of worms. Worms of these forms have lengths *a*1, *a*2, ..., *a**n*. To prove his... | ```python
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
for j in range(n):
if a[i]+a[j] in a and i!=j!=a.index(a[i]+a[j]):
print(a.index(a[i]+a[j])+1,i+1,j+1)
exit()
print(-1)
``` | 3.93 |
313 | B | Ilya and Queries | PROGRAMMING | 1,100 | [
"dp",
"implementation"
] | null | null | Ilya the Lion wants to help all his friends with passing exams. They need to solve the following problem to pass the IT exam.
You've got string *s*<==<=*s*1*s*2... *s**n* (*n* is the length of the string), consisting only of characters "." and "#" and *m* queries. Each query is described by a pair of integers *l**i*,<... | The first line contains string *s* of length *n* (2<=≤<=*n*<=≤<=105). It is guaranteed that the given string only consists of characters "." and "#".
The next line contains integer *m* (1<=≤<=*m*<=≤<=105) — the number of queries. Each of the next *m* lines contains the description of the corresponding query. The *i*-t... | Print *m* integers — the answers to the queries in the order in which they are given in the input. | [
"......\n4\n3 4\n2 3\n1 6\n2 6\n",
"#..###\n5\n1 3\n5 6\n1 5\n3 6\n3 4\n"
] | [
"1\n1\n5\n4\n",
"1\n1\n2\n2\n0\n"
] | none | 1,000 | [
{
"input": "......\n4\n3 4\n2 3\n1 6\n2 6",
"output": "1\n1\n5\n4"
},
{
"input": "#..###\n5\n1 3\n5 6\n1 5\n3 6\n3 4",
"output": "1\n1\n2\n2\n0"
},
{
"input": ".#...#..\n6\n1 5\n2 3\n6 7\n2 4\n2 5\n1 3",
"output": "2\n0\n0\n1\n2\n0"
},
{
"input": "#.#.#..\n5\n3 4\n4 5\n5 7\n5... | 1,688,297,293 | 2,147,483,647 | Python 3 | OK | TESTS | 37 | 1,620 | 5,324,800 | line = input()
pref = [0]
for i in range(1, len(line)):
f = 0
if (line[i] == line[i - 1]):
f += 1
pref.append(pref[i - 1] + f)
n = int(input())
for i in range(n):
x, y = list(map(int, input().split()))
print(pref[y-1] - pref[x-1])
# Sun Jul 02 2023 14:28:12 GMT+0300 (Moscow Standar... | Title: Ilya and Queries
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Ilya the Lion wants to help all his friends with passing exams. They need to solve the following problem to pass the IT exam.
You've got string *s*<==<=*s*1*s*2... *s**n* (*n* is the length of the string), consisting ... | ```python
line = input()
pref = [0]
for i in range(1, len(line)):
f = 0
if (line[i] == line[i - 1]):
f += 1
pref.append(pref[i - 1] + f)
n = int(input())
for i in range(n):
x, y = list(map(int, input().split()))
print(pref[y-1] - pref[x-1])
# Sun Jul 02 2023 14:28:12 GMT+0300 (Mosc... | 3 | |
980 | A | Links and Pearls | PROGRAMMING | 900 | [
"implementation",
"math"
] | null | null | A necklace can be described as a string of links ('-') and pearls ('o'), with the last link or pearl connected to the first one.
You can remove a link or a pearl and insert it between two other existing links or pearls (or between a link and a pearl) on the necklace. This process can be repeated as many times as you l... | The only line of input contains a string $s$ ($3 \leq |s| \leq 100$), representing the necklace, where a dash '-' represents a link and the lowercase English letter 'o' represents a pearl. | Print "YES" if the links and pearls can be rejoined such that the number of links between adjacent pearls is equal. Otherwise print "NO".
You can print each letter in any case (upper or lower). | [
"-o-o--",
"-o---\n",
"-o---o-\n",
"ooo\n"
] | [
"YES",
"YES",
"NO",
"YES\n"
] | none | 500 | [
{
"input": "-o-o--",
"output": "YES"
},
{
"input": "-o---",
"output": "YES"
},
{
"input": "-o---o-",
"output": "NO"
},
{
"input": "ooo",
"output": "YES"
},
{
"input": "---",
"output": "YES"
},
{
"input": "--o-o-----o----o--oo-o-----ooo-oo---o--",
"... | 1,667,034,299 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 69 | 77 | 0 | str=input()
x=str.count('-')
y=len(str)-x
print('YES' if y==0 or x%y==0 else 'NO') | Title: Links and Pearls
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
A necklace can be described as a string of links ('-') and pearls ('o'), with the last link or pearl connected to the first one.
You can remove a link or a pearl and insert it between two other existing links or pearl... | ```python
str=input()
x=str.count('-')
y=len(str)-x
print('YES' if y==0 or x%y==0 else 'NO')
``` | 3 | |
445 | B | DZY Loves Chemistry | PROGRAMMING | 1,400 | [
"dfs and similar",
"dsu",
"greedy"
] | null | null | DZY loves chemistry, and he enjoys mixing chemicals.
DZY has *n* chemicals, and *m* pairs of them will react. He wants to pour these chemicals into a test tube, and he needs to pour them in one by one, in any order.
Let's consider the danger of a test tube. Danger of an empty test tube is 1. And every time when DZY ... | The first line contains two space-separated integers *n* and *m* .
Each of the next *m* lines contains two space-separated integers *x**i* and *y**i* (1<=≤<=*x**i*<=<<=*y**i*<=≤<=*n*). These integers mean that the chemical *x**i* will react with the chemical *y**i*. Each pair of chemicals will appear at most once i... | Print a single integer — the maximum possible danger. | [
"1 0\n",
"2 1\n1 2\n",
"3 2\n1 2\n2 3\n"
] | [
"1\n",
"2\n",
"4\n"
] | In the first sample, there's only one way to pour, and the danger won't increase.
In the second sample, no matter we pour the 1st chemical first, or pour the 2nd chemical first, the answer is always 2.
In the third sample, there are four ways to achieve the maximum possible danger: 2-1-3, 2-3-1, 1-2-3 and 3-2-1 (that... | 1,000 | [
{
"input": "1 0",
"output": "1"
},
{
"input": "2 1\n1 2",
"output": "2"
},
{
"input": "3 2\n1 2\n2 3",
"output": "4"
},
{
"input": "10 10\n1 8\n4 10\n4 6\n5 10\n2 3\n1 7\n3 4\n3 6\n6 9\n3 7",
"output": "512"
},
{
"input": "20 20\n6 8\n13 20\n7 13\n6 17\n5 15\n1 12... | 1,658,993,995 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 3 | 62 | 0 |
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
d = [[] for _ in range(n)]
for i in range(m):
a, b = map(lambda x:int(x)-1, input().split())
d[a].append(b)
d[b].append(a)
x = [[0] for _ in range(n+1)]
c = 1
for i in range(n):
q = [(i, 1)]
x[i] = 1
while ... | Title: DZY Loves Chemistry
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
DZY loves chemistry, and he enjoys mixing chemicals.
DZY has *n* chemicals, and *m* pairs of them will react. He wants to pour these chemicals into a test tube, and he needs to pour them in one by one, in any order... | ```python
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
d = [[] for _ in range(n)]
for i in range(m):
a, b = map(lambda x:int(x)-1, input().split())
d[a].append(b)
d[b].append(a)
x = [[0] for _ in range(n+1)]
c = 1
for i in range(n):
q = [(i, 1)]
x[i] = 1
... | 0 | |
32 | A | Reconnaissance | PROGRAMMING | 800 | [
"brute force"
] | A. Reconnaissance | 2 | 256 | According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most *d* centimeters. Captain Bob has *n* soldiers in his detachment. Their heights are *a*1,<=*a*2,<=...,<=*a**n* centimeters. Som... | The first line contains two integers *n* and *d* (1<=≤<=*n*<=≤<=1000,<=1<=≤<=*d*<=≤<=109) — amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains *n* space-separated integers — heights of all the soldiers in Bob's detachment. These numbers don't exceed 1... | Output one number — amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed *d*. | [
"5 10\n10 20 50 60 65\n",
"5 1\n55 30 29 31 55\n"
] | [
"6\n",
"6\n"
] | none | 500 | [
{
"input": "5 10\n10 20 50 60 65",
"output": "6"
},
{
"input": "5 1\n55 30 29 31 55",
"output": "6"
},
{
"input": "6 10\n4 6 4 1 9 3",
"output": "30"
},
{
"input": "7 100\n19 1694 261 162 1 234 513",
"output": "8"
},
{
"input": "8 42\n37 53 74 187 568 22 5 65",
... | 1,622,441,253 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 124 | 0 | n,d = map(int,input().split())
l = list(map(int,input().split()))
l.sort()
count = 0
for i in range(1,len(l)):
if(l[i]-l[i-1]<=d):
count+=1
print(count*2) | Title: Reconnaissance
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most *d* centimeters. Captain Bob h... | ```python
n,d = map(int,input().split())
l = list(map(int,input().split()))
l.sort()
count = 0
for i in range(1,len(l)):
if(l[i]-l[i-1]<=d):
count+=1
print(count*2)
``` | 0 |
570 | B | Simple Game | PROGRAMMING | 1,300 | [
"constructive algorithms",
"games",
"greedy",
"implementation",
"math"
] | null | null | One day Misha and Andrew were playing a very simple game. First, each player chooses an integer in the range from 1 to *n*. Let's assume that Misha chose number *m*, and Andrew chose number *a*.
Then, by using a random generator they choose a random integer *c* in the range between 1 and *n* (any integer from 1 to *n*... | The first line contains two integers *n* and *m* (1<=≤<=*m*<=≤<=*n*<=≤<=109) — the range of numbers in the game, and the number selected by Misha respectively. | Print a single number — such value *a*, that probability that Andrew wins is the highest. If there are multiple such values, print the minimum of them. | [
"3 1\n",
"4 3\n"
] | [
"2",
"2"
] | In the first sample test: Andrew wins if *c* is equal to 2 or 3. The probability that Andrew wins is 2 / 3. If Andrew chooses *a* = 3, the probability of winning will be 1 / 3. If *a* = 1, the probability of winning is 0.
In the second sample test: Andrew wins if *c* is equal to 1 and 2. The probability that Andrew wi... | 1,000 | [
{
"input": "3 1",
"output": "2"
},
{
"input": "4 3",
"output": "2"
},
{
"input": "5 5",
"output": "4"
},
{
"input": "10 5",
"output": "6"
},
{
"input": "20 13",
"output": "12"
},
{
"input": "51 1",
"output": "2"
},
{
"input": "100 50",
... | 1,655,892,770 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 16 | 62 | 0 | n,m = map(int,input().split())
if m-1 <= n-m:
#1 2 3 4 5
if m != n:
print(m+1)
else:
print(m-1)
else:
if m != 1:
print(m-1)
else:
print(2) | Title: Simple Game
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
One day Misha and Andrew were playing a very simple game. First, each player chooses an integer in the range from 1 to *n*. Let's assume that Misha chose number *m*, and Andrew chose number *a*.
Then, by using a random gen... | ```python
n,m = map(int,input().split())
if m-1 <= n-m:
#1 2 3 4 5
if m != n:
print(m+1)
else:
print(m-1)
else:
if m != 1:
print(m-1)
else:
print(2)
``` | 0 | |
177 | A2 | Good Matrix Elements | PROGRAMMING | 800 | [
"implementation"
] | null | null | The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an *n*<=×<=*n* size matrix, where *n* is odd. The Smart Beaver considers the following matrix elements good:
- Elements of the main diagonal. - Elements of the secondary diagonal. - Elements of the "middle" row — the row which ha... | The first line of input data contains a single odd integer *n*. Each of the next *n* lines contains *n* integers *a**ij* (0<=≤<=*a**ij*<=≤<=100) separated by single spaces — the elements of the given matrix.
The input limitations for getting 30 points are:
- 1<=≤<=*n*<=≤<=5
The input limitations for getting 100 po... | Print a single integer — the sum of good matrix elements. | [
"3\n1 2 3\n4 5 6\n7 8 9\n",
"5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n"
] | [
"45\n",
"17\n"
] | In the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure. | 70 | [
{
"input": "3\n1 2 3\n4 5 6\n7 8 9",
"output": "45"
},
{
"input": "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1",
"output": "17"
},
{
"input": "1\n3",
"output": "3"
},
{
"input": "5\n27 7 3 11 72\n19 49 68 19 59\n41 25 37 64 65\n8 39 96 62 90\n13 37 43 26 33",
... | 1,651,015,201 | 2,147,483,647 | Python 3 | OK | TESTS2 | 33 | 92 | 0 | # cook your dish here
import sys
if __name__ == "__main__":
n = int(sys.stdin.readline().strip())
m = []
for i in range(n):
row = list(map(int, sys.stdin.readline().strip().split()))
m.append(row)
rowSum = sum(m[n//2])
colSum = sum([m[i][n//2] for i in range(n)])
diagSum1 =... | Title: Good Matrix Elements
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an *n*<=×<=*n* size matrix, where *n* is odd. The Smart Beaver considers the following matrix elements good:
- Elements of the ... | ```python
# cook your dish here
import sys
if __name__ == "__main__":
n = int(sys.stdin.readline().strip())
m = []
for i in range(n):
row = list(map(int, sys.stdin.readline().strip().split()))
m.append(row)
rowSum = sum(m[n//2])
colSum = sum([m[i][n//2] for i in range(n)])
... | 3 | |
894 | A | QAQ | PROGRAMMING | 800 | [
"brute force",
"dp"
] | null | null | "QAQ" is a word to denote an expression of crying. Imagine "Q" as eyes with tears and "A" as a mouth.
Now Diamond has given Bort a string consisting of only uppercase English letters of length *n*. There is a great number of "QAQ" in the string (Diamond is so cute!).
Bort wants to know how many subsequences "QAQ" are... | The only line contains a string of length *n* (1<=≤<=*n*<=≤<=100). It's guaranteed that the string only contains uppercase English letters. | Print a single integer — the number of subsequences "QAQ" in the string. | [
"QAQAQYSYIOIWIN\n",
"QAQQQZZYNOIWIN\n"
] | [
"4\n",
"3\n"
] | In the first example there are 4 subsequences "QAQ": "QAQAQYSYIOIWIN", "QAQAQYSYIOIWIN", "QAQAQYSYIOIWIN", "QAQAQYSYIOIWIN". | 500 | [
{
"input": "QAQAQYSYIOIWIN",
"output": "4"
},
{
"input": "QAQQQZZYNOIWIN",
"output": "3"
},
{
"input": "QA",
"output": "0"
},
{
"input": "IAQVAQZLQBQVQFTQQQADAQJA",
"output": "24"
},
{
"input": "QQAAQASGAYAAAAKAKAQIQEAQAIAAIAQQQQQ",
"output": "378"
},
{
... | 1,597,346,739 | 2,147,483,647 | Python 3 | OK | TESTS | 43 | 139 | 0 | s = str(input())
c=0
for i in range(len(s)):
for j in range(i,len(s)):
for k in range(j,len(s)):
if s[i]=="Q" and s[j]=="A" and s[k]=="Q": c+=1
print(c) | Title: QAQ
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
"QAQ" is a word to denote an expression of crying. Imagine "Q" as eyes with tears and "A" as a mouth.
Now Diamond has given Bort a string consisting of only uppercase English letters of length *n*. There is a great number of "QAQ"... | ```python
s = str(input())
c=0
for i in range(len(s)):
for j in range(i,len(s)):
for k in range(j,len(s)):
if s[i]=="Q" and s[j]=="A" and s[k]=="Q": c+=1
print(c)
``` | 3 | |
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,576,572,106 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 218 | 0 | n = int(input())
t = [int(x) for x in input().split()]
m = []
l=[]
for i in range(n-1):
m.append(t[i+1]-t[i])
v = {}
for i in m:
v[i] = v.get(i,0)+1
for i in v:
if v[i] == 1:
l.append(i)
s = [m.index(i) for i in l]
print(min(s) +2)
| Title: IQ test
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given *n* numbers differs from the others. Bob observed that one number usually differs from the others in evenness. Help Bob — t... | ```python
n = int(input())
t = [int(x) for x in input().split()]
m = []
l=[]
for i in range(n-1):
m.append(t[i+1]-t[i])
v = {}
for i in m:
v[i] = v.get(i,0)+1
for i in v:
if v[i] == 1:
l.append(i)
s = [m.index(i) for i in l]
print(min(s) +2)
``` | 0 |
900 | A | Find Extra One | PROGRAMMING | 800 | [
"geometry",
"implementation"
] | null | null | You have *n* distinct points on a plane, none of them lie on *OY* axis. Check that there is a point after removal of which the remaining points are located on one side of the *OY* axis. | The first line contains a single positive integer *n* (2<=≤<=*n*<=≤<=105).
The following *n* lines contain coordinates of the points. The *i*-th of these lines contains two single integers *x**i* and *y**i* (|*x**i*|,<=|*y**i*|<=≤<=109, *x**i*<=≠<=0). No two points coincide. | Print "Yes" if there is such a point, "No" — otherwise.
You can print every letter in any case (upper or lower). | [
"3\n1 1\n-1 -1\n2 -1\n",
"4\n1 1\n2 2\n-1 1\n-2 2\n",
"3\n1 2\n2 1\n4 60\n"
] | [
"Yes",
"No",
"Yes"
] | In the first example the second point can be removed.
In the second example there is no suitable for the condition point.
In the third example any point can be removed. | 500 | [
{
"input": "3\n1 1\n-1 -1\n2 -1",
"output": "Yes"
},
{
"input": "4\n1 1\n2 2\n-1 1\n-2 2",
"output": "No"
},
{
"input": "3\n1 2\n2 1\n4 60",
"output": "Yes"
},
{
"input": "10\n1 1\n2 2\n3 3\n4 4\n5 5\n6 6\n7 7\n8 8\n9 9\n-1 -1",
"output": "Yes"
},
{
"input": "2\n1... | 1,613,733,826 | 2,147,483,647 | PyPy 3 | OK | TESTS | 71 | 842 | 9,625,600 | i=input;n=int(i());x=sum(int(i().split()[0])>0 for _ in[0]*n);print('YNEOS'[1<x<n-1::2]) | Title: Find Extra One
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You have *n* distinct points on a plane, none of them lie on *OY* axis. Check that there is a point after removal of which the remaining points are located on one side of the *OY* axis.
Input Specification:
The first li... | ```python
i=input;n=int(i());x=sum(int(i().split()[0])>0 for _ in[0]*n);print('YNEOS'[1<x<n-1::2])
``` | 3 | |
356 | A | Knight Tournament | PROGRAMMING | 1,500 | [
"data structures",
"dsu"
] | null | null | Hooray! Berl II, the king of Berland is making a knight tournament. The king has already sent the message to all knights in the kingdom and they in turn agreed to participate in this grand event.
As for you, you're just a simple peasant. There's no surprise that you slept in this morning and were late for the tourname... | The first line contains two integers *n*, *m* (2<=≤<=*n*<=≤<=3·105; 1<=≤<=*m*<=≤<=3·105) — the number of knights and the number of fights. Each of the following *m* lines contains three integers *l**i*,<=*r**i*,<=*x**i* (1<=≤<=*l**i*<=<<=*r**i*<=≤<=*n*; *l**i*<=≤<=*x**i*<=≤<=*r**i*) — the description of the *i*-th f... | Print *n* integers. If the *i*-th knight lost, then the *i*-th number should equal the number of the knight that beat the knight number *i*. If the *i*-th knight is the winner, then the *i*-th number must equal 0. | [
"4 3\n1 2 1\n1 3 3\n1 4 4\n",
"8 4\n3 5 4\n3 7 6\n2 8 8\n1 8 1\n"
] | [
"3 1 4 0 ",
"0 8 4 6 4 8 6 1 "
] | Consider the first test case. Knights 1 and 2 fought the first fight and knight 1 won. Knights 1 and 3 fought the second fight and knight 3 won. The last fight was between knights 3 and 4, knight 4 won. | 500 | [
{
"input": "4 3\n1 2 1\n1 3 3\n1 4 4",
"output": "3 1 4 0 "
},
{
"input": "8 4\n3 5 4\n3 7 6\n2 8 8\n1 8 1",
"output": "0 8 4 6 4 8 6 1 "
},
{
"input": "2 1\n1 2 1",
"output": "0 1 "
},
{
"input": "2 1\n1 2 2",
"output": "2 0 "
},
{
"input": "3 1\n1 3 1",
"out... | 1,666,149,256 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 0 | 46 | 0 | n, m = (int(x) for x in input().split(" "))
fights = []
for i in range(m):
fights.append([int(x)-1 for x in input().split(" ")])
knights = [{"alive": True, "killed by": -1, "next": None} for i in range(n)]
for t in range(m):
lt = fights[t][0]
rt = fights[t][1]
xt = fights[t][2]
for j in range(lt, rt+1):
... | Title: Knight Tournament
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Hooray! Berl II, the king of Berland is making a knight tournament. The king has already sent the message to all knights in the kingdom and they in turn agreed to participate in this grand event.
As for you, you're j... | ```python
n, m = (int(x) for x in input().split(" "))
fights = []
for i in range(m):
fights.append([int(x)-1 for x in input().split(" ")])
knights = [{"alive": True, "killed by": -1, "next": None} for i in range(n)]
for t in range(m):
lt = fights[t][0]
rt = fights[t][1]
xt = fights[t][2]
for j in range(lt,... | 0 | |
61 | A | Ultra-Fast Mathematician | PROGRAMMING | 800 | [
"implementation"
] | A. Ultra-Fast Mathematician | 2 | 256 | Shapur was an extremely gifted student. He was great at everything including Combinatorics, Algebra, Number Theory, Geometry, Calculus, etc. He was not only smart but extraordinarily fast! He could manage to sum 1018 numbers in a single second.
One day in 230 AD Shapur was trying to find out if any one can possibly do... | There are two lines in each input. Each of them contains a single number. It is guaranteed that the numbers are made from 0 and 1 only and that their length is same. The numbers may start with 0. The length of each number doesn't exceed 100. | Write one line — the corresponding answer. Do not omit the leading 0s. | [
"1010100\n0100101\n",
"000\n111\n",
"1110\n1010\n",
"01110\n01100\n"
] | [
"1110001\n",
"111\n",
"0100\n",
"00010\n"
] | none | 500 | [
{
"input": "1010100\n0100101",
"output": "1110001"
},
{
"input": "000\n111",
"output": "111"
},
{
"input": "1110\n1010",
"output": "0100"
},
{
"input": "01110\n01100",
"output": "00010"
},
{
"input": "011101\n000001",
"output": "011100"
},
{
"input": "... | 1,590,592,730 | 2,147,483,647 | Python 3 | OK | TESTS | 102 | 109 | 0 | s = input()
s1 = input()
ans= ""
l = len(s)
for i in range(l):
if(s[i]!=s1[i]):
ans+='1'
else:
ans+='0'
print(ans)
| Title: Ultra-Fast Mathematician
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Shapur was an extremely gifted student. He was great at everything including Combinatorics, Algebra, Number Theory, Geometry, Calculus, etc. He was not only smart but extraordinarily fast! He could manage to sum 10... | ```python
s = input()
s1 = input()
ans= ""
l = len(s)
for i in range(l):
if(s[i]!=s1[i]):
ans+='1'
else:
ans+='0'
print(ans)
``` | 3.97275 |
159 | B | Matchmaker | PROGRAMMING | 1,100 | [
"*special",
"greedy",
"sortings"
] | null | null | Polycarpus has *n* markers and *m* marker caps. Each marker is described by two numbers: *x**i* is the color and *y**i* is the diameter. Correspondingly, each cap is described by two numbers: *a**j* is the color and *b**j* is the diameter. Cap (*a**j*,<=*b**j*) can close marker (*x**i*,<=*y**i*) only if their diameters... | The first input line contains two space-separated integers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=105) — the number of markers and the number of caps, correspondingly.
Next *n* lines describe the markers. The *i*-th line contains two space-separated integers *x**i*, *y**i* (1<=≤<=*x**i*,<=*y**i*<=≤<=1000) — the *i*-th mark... | Print two space-separated integers *u*,<=*v*, where *u* is the number of closed markers and *v* is the number of beautifully closed markers in the sought optimal way. Remember that you have to find the way to close the maximum number of markers, and if there are several such ways, you should choose the one where the nu... | [
"3 4\n1 2\n3 4\n2 4\n5 4\n2 4\n1 1\n1 2\n",
"2 2\n1 2\n2 1\n3 4\n5 1\n"
] | [
"3 2\n",
"1 0\n"
] | In the first test sample the first marker should be closed by the fourth cap, the second marker should be closed by the first cap and the third marker should be closed by the second cap. Thus, three markers will be closed, and two of them will be beautifully closed — the first and the third markers. | 1,000 | [
{
"input": "3 4\n1 2\n3 4\n2 4\n5 4\n2 4\n1 1\n1 2",
"output": "3 2"
},
{
"input": "2 2\n1 2\n2 1\n3 4\n5 1",
"output": "1 0"
},
{
"input": "6 7\n2 1\n2 2\n2 1\n1 1\n2 1\n1 2\n2 2\n2 2\n2 2\n1 2\n2 2\n1 1\n1 2",
"output": "3 3"
},
{
"input": "6 7\n2 1\n1 1\n2 2\n1 2\n1 1\n1 2... | 1,428,397,762 | 2,147,483,647 | Python 3 | OK | TESTS | 37 | 1,590 | 4,608,000 | import sys
import math
n, m = list(map(int, input().split()))
c = []
z = [0] * 1000
k = [0] * 1000
for i in range(1000):
c.append([0] * 1000)
for i in range(n):
x, y = list(map(int, input().split()))
c[x - 1][y - 1] += 1
z[y - 1] += 1
ca = 0
cb = 0
for i in range(m):
... | Title: Matchmaker
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Polycarpus has *n* markers and *m* marker caps. Each marker is described by two numbers: *x**i* is the color and *y**i* is the diameter. Correspondingly, each cap is described by two numbers: *a**j* is the color and *b**j* i... | ```python
import sys
import math
n, m = list(map(int, input().split()))
c = []
z = [0] * 1000
k = [0] * 1000
for i in range(1000):
c.append([0] * 1000)
for i in range(n):
x, y = list(map(int, input().split()))
c[x - 1][y - 1] += 1
z[y - 1] += 1
ca = 0
cb = 0
for i in ra... | 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,687,972,598 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 31 | 0 | a, b, c = map(int, input().split())
sr = (a + b + c) // 3
total = 0
total += abs(a - sr)
total += abs(b - sr)
total += abs(c - sr)
print(total) | 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
a, b, c = map(int, input().split())
sr = (a + b + c) // 3
total = 0
total += abs(a - sr)
total += abs(b - sr)
total += abs(c - sr)
print(total)
``` | 0 | |
912 | A | Tricky Alchemy | PROGRAMMING | 800 | [
"implementation"
] | null | null | During the winter holidays, the demand for Christmas balls is exceptionally high. Since it's already 2018, the advances in alchemy allow easy and efficient ball creation by utilizing magic crystals.
Grisha needs to obtain some yellow, green and blue balls. It's known that to produce a yellow ball one needs two yellow ... | The first line features two integers *A* and *B* (0<=≤<=*A*,<=*B*<=≤<=109), denoting the number of yellow and blue crystals respectively at Grisha's disposal.
The next line contains three integers *x*, *y* and *z* (0<=≤<=*x*,<=*y*,<=*z*<=≤<=109) — the respective amounts of yellow, green and blue balls to be obtained. | Print a single integer — the minimum number of crystals that Grisha should acquire in addition. | [
"4 3\n2 1 1\n",
"3 9\n1 1 3\n",
"12345678 87654321\n43043751 1000000000 53798715\n"
] | [
"2\n",
"1\n",
"2147483648\n"
] | In the first sample case, Grisha needs five yellow and four blue crystals to create two yellow balls, one green ball, and one blue ball. To do that, Grisha needs to obtain two additional crystals: one yellow and one blue. | 500 | [
{
"input": "4 3\n2 1 1",
"output": "2"
},
{
"input": "3 9\n1 1 3",
"output": "1"
},
{
"input": "12345678 87654321\n43043751 1000000000 53798715",
"output": "2147483648"
},
{
"input": "12 12\n3 5 2",
"output": "0"
},
{
"input": "770 1390\n170 442 311",
"output"... | 1,616,393,394 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 3 | 46 | 0 |
a,c=map(int,input().split())
y,g,b=map(int,input().split())
yellow = (2*y)+g
blue=(3*b)+g
x=yellow-a
y=blue-c
if x>=0 and y>=0:
print(x+y)
| Title: Tricky Alchemy
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
During the winter holidays, the demand for Christmas balls is exceptionally high. Since it's already 2018, the advances in alchemy allow easy and efficient ball creation by utilizing magic crystals.
Grisha needs to obta... | ```python
a,c=map(int,input().split())
y,g,b=map(int,input().split())
yellow = (2*y)+g
blue=(3*b)+g
x=yellow-a
y=blue-c
if x>=0 and y>=0:
print(x+y)
``` | 0 | |
36 | A | Extra-terrestrial Intelligence | PROGRAMMING | 1,300 | [
"implementation"
] | A. Extra-terrestrial Intelligence | 2 | 64 | Recently Vasya got interested in finding extra-terrestrial intelligence. He made a simple extra-terrestrial signals’ receiver and was keeping a record of the signals for *n* days in a row. Each of those *n* days Vasya wrote a 1 in his notebook if he had received a signal that day and a 0 if he hadn’t. Vasya thinks that... | The first line contains integer *n* (3<=≤<=*n*<=≤<=100) — amount of days during which Vasya checked if there were any signals. The second line contains *n* characters 1 or 0 — the record Vasya kept each of those *n* days. It’s guaranteed that the given record sequence contains at least three 1s. | If Vasya has found extra-terrestrial intelligence, output YES, otherwise output NO. | [
"8\n00111000\n",
"7\n1001011\n",
"7\n1010100\n"
] | [
"YES\n",
"NO\n",
"YES\n"
] | none | 500 | [
{
"input": "8\n00111000",
"output": "YES"
},
{
"input": "7\n1001011",
"output": "NO"
},
{
"input": "7\n1010100",
"output": "YES"
},
{
"input": "5\n10101",
"output": "YES"
},
{
"input": "3\n111",
"output": "YES"
},
{
"input": "10\n0011111011",
"outp... | 1,546,660,211 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 186 | 0 | n=int(input());ans=0;s=input();pd=0;p=0;z=0;x=0
for i in range(0,n):
if pd==0:
if s[i]=='1':
pd=1
else:
if s[i]=='1':
pd=0
if x==1:
if z==p:
pass
else:
print('NO')
pd=1... | Title: Extra-terrestrial Intelligence
Time Limit: 2 seconds
Memory Limit: 64 megabytes
Problem Description:
Recently Vasya got interested in finding extra-terrestrial intelligence. He made a simple extra-terrestrial signals’ receiver and was keeping a record of the signals for *n* days in a row. Each of those *n* da... | ```python
n=int(input());ans=0;s=input();pd=0;p=0;z=0;x=0
for i in range(0,n):
if pd==0:
if s[i]=='1':
pd=1
else:
if s[i]=='1':
pd=0
if x==1:
if z==p:
pass
else:
print('NO')
... | -1 |
948 | A | Protect Sheep | PROGRAMMING | 900 | [
"brute force",
"dfs and similar",
"graphs",
"implementation"
] | null | null | Bob is a farmer. He has a large pasture with many sheep. Recently, he has lost some of them due to wolf attacks. He thus decided to place some shepherd dogs in such a way that all his sheep are protected.
The pasture is a rectangle consisting of *R*<=×<=*C* cells. Each cell is either empty, contains a sheep, a wolf or... | First line contains two integers *R* (1<=≤<=*R*<=≤<=500) and *C* (1<=≤<=*C*<=≤<=500), denoting the number of rows and the numbers of columns respectively.
Each of the following *R* lines is a string consisting of exactly *C* characters, representing one row of the pasture. Here, 'S' means a sheep, 'W' a wolf and '.' a... | If it is impossible to protect all sheep, output a single line with the word "No".
Otherwise, output a line with the word "Yes". Then print *R* lines, representing the pasture after placing dogs. Again, 'S' means a sheep, 'W' a wolf, 'D' is a dog and '.' an empty space. You are not allowed to move, remove or add a she... | [
"6 6\n..S...\n..S.W.\n.S....\n..W...\n...W..\n......\n",
"1 2\nSW\n",
"5 5\n.S...\n...S.\nS....\n...S.\n.S...\n"
] | [
"Yes\n..SD..\n..SDW.\n.SD...\n.DW...\nDD.W..\n......\n",
"No\n",
"Yes\n.S...\n...S.\nS.D..\n...S.\n.S...\n"
] | In the first example, we can split the pasture into two halves, one containing wolves and one containing sheep. Note that the sheep at (2,1) is safe, as wolves cannot move diagonally.
In the second example, there are no empty spots to put dogs that would guard the lone sheep.
In the third example, there are no wolves... | 500 | [
{
"input": "1 2\nSW",
"output": "No"
},
{
"input": "10 10\n....W.W.W.\n.........S\n.S.S...S..\nW.......SS\n.W..W.....\n.W...W....\nS..S...S.S\n....W...S.\n..S..S.S.S\nSS.......S",
"output": "Yes\nDDDDWDWDWD\nDDDDDDDDDS\nDSDSDDDSDD\nWDDDDDDDSS\nDWDDWDDDDD\nDWDDDWDDDD\nSDDSDDDSDS\nDDDDWDDDSD\nDDSD... | 1,588,053,031 | 2,147,483,647 | PyPy 3 | RUNTIME_ERROR | TESTS | 1 | 186 | 2,048,000 | r, c = map(int, input().split())
s = [''] * c
for i in range(r):
s[i] = input()
possible = True
for i in range(r):
for j in range(c):
if s[i][j] == 'W':
if s[i+1][j] == 'S' and s[i-1][j] == 'S' and s[i][j-1] == 'S' and s[i][j+1] == 'S':
possible = False
if possible ... | Title: Protect Sheep
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Bob is a farmer. He has a large pasture with many sheep. Recently, he has lost some of them due to wolf attacks. He thus decided to place some shepherd dogs in such a way that all his sheep are protected.
The pasture is ... | ```python
r, c = map(int, input().split())
s = [''] * c
for i in range(r):
s[i] = input()
possible = True
for i in range(r):
for j in range(c):
if s[i][j] == 'W':
if s[i+1][j] == 'S' and s[i-1][j] == 'S' and s[i][j-1] == 'S' and s[i][j+1] == 'S':
possible = False
if... | -1 | |
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,561,184,676 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 93 | 0 | def gcd(a, b):
if b == 0:
return a
if a > b:
return gcd(a % b, b)
else:
return gcd(a, b % a)
a, b, c = map(int, input().split())
print(len([i for i in range(gcd(a, b), c + 1, gcd(a, b))]))
| 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
def gcd(a, b):
if b == 0:
return a
if a > b:
return gcd(a % b, b)
else:
return gcd(a, b % a)
a, b, c = map(int, input().split())
print(len([i for i in range(gcd(a, b), c + 1, gcd(a, b))]))
``` | 0 | |
731 | C | Socks | PROGRAMMING | 1,600 | [
"dfs and similar",
"dsu",
"graphs",
"greedy"
] | null | null | Arseniy is already grown-up and independent. His mother decided to leave him alone for *m* days and left on a vacation. She have prepared a lot of food, left some money and washed all Arseniy's clothes.
Ten minutes before her leave she realized that it would be also useful to prepare instruction of which particular c... | The first line of input contains three integers *n*, *m* and *k* (2<=≤<=*n*<=≤<=200<=000, 0<=≤<=*m*<=≤<=200<=000, 1<=≤<=*k*<=≤<=200<=000) — the number of socks, the number of days and the number of available colors respectively.
The second line contain *n* integers *c*1, *c*2, ..., *c**n* (1<=≤<=*c**i*<=≤<=*k*) — curr... | Print one integer — the minimum number of socks that should have their colors changed in order to be able to obey the instructions and not make people laugh from watching the socks of different colors. | [
"3 2 3\n1 2 3\n1 2\n2 3\n",
"3 2 2\n1 1 2\n1 2\n2 1\n"
] | [
"2\n",
"0\n"
] | In the first sample, Arseniy can repaint the first and the third socks to the second color.
In the second sample, there is no need to change any colors. | 1,500 | [
{
"input": "3 2 3\n1 2 3\n1 2\n2 3",
"output": "2"
},
{
"input": "3 2 2\n1 1 2\n1 2\n2 1",
"output": "0"
},
{
"input": "3 3 3\n1 2 3\n1 2\n2 3\n3 1",
"output": "2"
},
{
"input": "4 2 4\n1 2 3 4\n1 2\n3 4",
"output": "2"
},
{
"input": "10 3 2\n2 1 1 2 1 1 2 1 2 2\n... | 1,697,246,778 | 2,147,483,647 | PyPy 3-64 | TIME_LIMIT_EXCEEDED | TESTS | 5 | 2,000 | 89,907,200 | from collections import defaultdict
from collections import deque
class Graph:
def __init__(self,vertices):
self.graph = defaultdict(list)
self.V = vertices
def addEdge(self, u, v):
self.graph[u].append(v)
self.graph[v].append(u)
def dfs(self,u,visited):
s = deque(... | Title: Socks
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Arseniy is already grown-up and independent. His mother decided to leave him alone for *m* days and left on a vacation. She have prepared a lot of food, left some money and washed all Arseniy's clothes.
Ten minutes before her l... | ```python
from collections import defaultdict
from collections import deque
class Graph:
def __init__(self,vertices):
self.graph = defaultdict(list)
self.V = vertices
def addEdge(self, u, v):
self.graph[u].append(v)
self.graph[v].append(u)
def dfs(self,u,visited):
... | 0 | |
740 | A | Alyona and copybooks | PROGRAMMING | 1,300 | [
"brute force",
"implementation"
] | null | null | Little girl Alyona is in a shop to buy some copybooks for school. She study four subjects so she wants to have equal number of copybooks for each of the subjects. There are three types of copybook's packs in the shop: it is possible to buy one copybook for *a* rubles, a pack of two copybooks for *b* rubles, and a pack ... | The only line contains 4 integers *n*, *a*, *b*, *c* (1<=≤<=*n*,<=*a*,<=*b*,<=*c*<=≤<=109). | Print the minimum amount of rubles she should pay to buy such number of copybooks *k* that *n*<=+<=*k* is divisible by 4. | [
"1 1 3 4\n",
"6 2 1 1\n",
"4 4 4 4\n",
"999999999 1000000000 1000000000 1000000000\n"
] | [
"3\n",
"1\n",
"0\n",
"1000000000\n"
] | In the first example Alyona can buy 3 packs of 1 copybook for 3*a* = 3 rubles in total. After that she will have 4 copybooks which she can split between the subjects equally.
In the second example Alyuna can buy a pack of 2 copybooks for *b* = 1 ruble. She will have 8 copybooks in total.
In the third example Alyona ... | 500 | [
{
"input": "1 1 3 4",
"output": "3"
},
{
"input": "6 2 1 1",
"output": "1"
},
{
"input": "4 4 4 4",
"output": "0"
},
{
"input": "999999999 1000000000 1000000000 1000000000",
"output": "1000000000"
},
{
"input": "1016 3 2 1",
"output": "0"
},
{
"input":... | 1,479,921,232 | 2,332 | Python 3 | WRONG_ANSWER | PRETESTS | 11 | 61 | 0 | n, a, b, c = map(int, input().split())
k = (n // 4 + 1) * 4 - n
if n % 4 == 0:
ans = 0
elif a <= b / 2 and a <= c / 3:
ans = a * k
elif b / 2 <= a and b / 2 <= c / 3:
ans = k // 2 * b + (k % 2) * min(a, b, c)
elif c / 3 <= a and c / 3 <= b / 2:
ans = k // 3 * c + min(k % 3 * a, c, b)
print(ans) | Title: Alyona and copybooks
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Little girl Alyona is in a shop to buy some copybooks for school. She study four subjects so she wants to have equal number of copybooks for each of the subjects. There are three types of copybook's packs in the sh... | ```python
n, a, b, c = map(int, input().split())
k = (n // 4 + 1) * 4 - n
if n % 4 == 0:
ans = 0
elif a <= b / 2 and a <= c / 3:
ans = a * k
elif b / 2 <= a and b / 2 <= c / 3:
ans = k // 2 * b + (k % 2) * min(a, b, c)
elif c / 3 <= a and c / 3 <= b / 2:
ans = k // 3 * c + min(k % 3 * a, c, b)
print(a... | 0 | |
433 | A | Kitahara Haruki's Gift | PROGRAMMING | 1,100 | [
"brute force",
"implementation"
] | null | null | Kitahara Haruki has bought *n* apples for Touma Kazusa and Ogiso Setsuna. Now he wants to divide all the apples between the friends.
Each apple weights 100 grams or 200 grams. Of course Kitahara Haruki doesn't want to offend any of his friend. Therefore the total weight of the apples given to Touma Kazusa must be equa... | The first line contains an integer *n* (1<=≤<=*n*<=≤<=100) — the number of apples. The second line contains *n* integers *w*1,<=*w*2,<=...,<=*w**n* (*w**i*<==<=100 or *w**i*<==<=200), where *w**i* is the weight of the *i*-th apple. | In a single line print "YES" (without the quotes) if it is possible to divide all the apples between his friends. Otherwise print "NO" (without the quotes). | [
"3\n100 200 100\n",
"4\n100 100 100 200\n"
] | [
"YES\n",
"NO\n"
] | In the first test sample Kitahara Haruki can give the first and the last apple to Ogiso Setsuna and the middle apple to Touma Kazusa. | 500 | [
{
"input": "3\n100 200 100",
"output": "YES"
},
{
"input": "4\n100 100 100 200",
"output": "NO"
},
{
"input": "1\n100",
"output": "NO"
},
{
"input": "1\n200",
"output": "NO"
},
{
"input": "2\n100 100",
"output": "YES"
},
{
"input": "2\n200 200",
"o... | 1,646,240,965 | 2,147,483,647 | Python 3 | OK | TESTS | 50 | 46 | 0 | n=int(input())
A=list(map(int,input().split()))
a = A.count(100)
b= A.count(200)
k=b%2
a-=k*2
if(a>=0 and a%2==0):print("YES")
else: print("NO") | Title: Kitahara Haruki's Gift
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Kitahara Haruki has bought *n* apples for Touma Kazusa and Ogiso Setsuna. Now he wants to divide all the apples between the friends.
Each apple weights 100 grams or 200 grams. Of course Kitahara Haruki doesn't w... | ```python
n=int(input())
A=list(map(int,input().split()))
a = A.count(100)
b= A.count(200)
k=b%2
a-=k*2
if(a>=0 and a%2==0):print("YES")
else: print("NO")
``` | 3 | |
706 | B | Interesting drink | PROGRAMMING | 1,100 | [
"binary search",
"dp",
"implementation"
] | null | null | Vasiliy likes to rest after a hard work, so you may often meet him in some bar nearby. As all programmers do, he loves the famous drink "Beecola", which can be bought in *n* different shops in the city. It's known that the price of one bottle in the shop *i* is equal to *x**i* coins.
Vasiliy plans to buy his favorite ... | The first line of the input contains a single integer *n* (1<=≤<=*n*<=≤<=100<=000) — the number of shops in the city that sell Vasiliy's favourite drink.
The second line contains *n* integers *x**i* (1<=≤<=*x**i*<=≤<=100<=000) — prices of the bottles of the drink in the *i*-th shop.
The third line contains a single i... | Print *q* integers. The *i*-th of them should be equal to the number of shops where Vasiliy will be able to buy a bottle of the drink on the *i*-th day. | [
"5\n3 10 8 6 11\n4\n1\n10\n3\n11\n"
] | [
"0\n4\n1\n5\n"
] | On the first day, Vasiliy won't be able to buy a drink in any of the shops.
On the second day, Vasiliy can buy a drink in the shops 1, 2, 3 and 4.
On the third day, Vasiliy can buy a drink only in the shop number 1.
Finally, on the last day Vasiliy can buy a drink in any shop. | 1,000 | [
{
"input": "5\n3 10 8 6 11\n4\n1\n10\n3\n11",
"output": "0\n4\n1\n5"
},
{
"input": "5\n868 987 714 168 123\n10\n424\n192\n795\n873\n117\n914\n735\n158\n631\n471",
"output": "2\n2\n3\n4\n0\n4\n3\n1\n2\n2"
},
{
"input": "3\n435 482 309\n7\n245\n241\n909\n745\n980\n29\n521",
"output": "... | 1,699,973,986 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 10 | 2,000 | 12,390,400 | n = int(input())
xtuple = tuple(sorted(map(int, input().split())))
q = int(input())
for i in range(q):
mi = int(input())
print(len([x for x in xtuple if x <= mi])) | Title: Interesting drink
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vasiliy likes to rest after a hard work, so you may often meet him in some bar nearby. As all programmers do, he loves the famous drink "Beecola", which can be bought in *n* different shops in the city. It's known tha... | ```python
n = int(input())
xtuple = tuple(sorted(map(int, input().split())))
q = int(input())
for i in range(q):
mi = int(input())
print(len([x for x in xtuple if x <= mi]))
``` | 0 | |
421 | A | Pasha and Hamsters | PROGRAMMING | 800 | [
"constructive algorithms",
"implementation"
] | null | null | Pasha has two hamsters: Arthur and Alexander. Pasha put *n* apples in front of them. Pasha knows which apples Arthur likes. Similarly, Pasha knows which apples Alexander likes. Pasha doesn't want any conflict between the hamsters (as they may like the same apple), so he decided to distribute the apples between the hams... | The first line contains integers *n*, *a*, *b* (1<=≤<=*n*<=≤<=100; 1<=≤<=*a*,<=*b*<=≤<=*n*) — the number of apples Pasha has, the number of apples Arthur likes and the number of apples Alexander likes, correspondingly.
The next line contains *a* distinct integers — the numbers of the apples Arthur likes. The next line... | Print *n* characters, each of them equals either 1 or 2. If the *i*-h character equals 1, then the *i*-th apple should be given to Arthur, otherwise it should be given to Alexander. If there are multiple correct answers, you are allowed to print any of them. | [
"4 2 3\n1 2\n2 3 4\n",
"5 5 2\n3 4 1 2 5\n2 3\n"
] | [
"1 1 2 2\n",
"1 1 1 1 1\n"
] | none | 500 | [
{
"input": "4 2 3\n1 2\n2 3 4",
"output": "1 1 2 2"
},
{
"input": "5 5 2\n3 4 1 2 5\n2 3",
"output": "1 1 1 1 1"
},
{
"input": "100 69 31\n1 3 4 5 6 7 8 9 10 11 12 14 15 16 17 18 19 20 21 24 26 27 29 31 37 38 39 40 44 46 48 49 50 51 53 55 56 57 58 59 60 61 63 64 65 66 67 68 69 70 71 72 7... | 1,661,868,757 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 2 | 61 | 0 | n, a, b = map(int, input().split())
ma = set(map(int, input().split()))
mb = list(map(int, input().split()))
for i in range(a):
print(1, end=" ")
for i in range(b):
if mb[i] not in ma:
print(2, end=" ") | Title: Pasha and Hamsters
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Pasha has two hamsters: Arthur and Alexander. Pasha put *n* apples in front of them. Pasha knows which apples Arthur likes. Similarly, Pasha knows which apples Alexander likes. Pasha doesn't want any conflict between... | ```python
n, a, b = map(int, input().split())
ma = set(map(int, input().split()))
mb = list(map(int, input().split()))
for i in range(a):
print(1, end=" ")
for i in range(b):
if mb[i] not in ma:
print(2, end=" ")
``` | 0 | |
99 | A | Help Far Away Kingdom | PROGRAMMING | 800 | [
"strings"
] | A. Help Far Away Kingdom | 2 | 256 | In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there.
Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Ki... | The first line contains a single number to round up — the integer part (a non-empty set of decimal digits that do not start with 0 — with the exception of a case when the set consists of a single digit — in this case 0 can go first), then follows character «.» (a dot), and then follows the fractional part (any non-empt... | If the last number of the integer part is not equal to 9, print the rounded-up number without leading zeroes. Otherwise, print the message "GOTO Vasilisa." (without the quotes). | [
"0.0\n",
"1.49\n",
"1.50\n",
"2.71828182845904523536\n",
"3.14159265358979323846\n",
"12345678901234567890.1\n",
"123456789123456789.999\n"
] | [
"0",
"1",
"2",
"3",
"3",
"12345678901234567890",
"GOTO Vasilisa."
] | none | 500 | [
{
"input": "0.0",
"output": "0"
},
{
"input": "1.49",
"output": "1"
},
{
"input": "1.50",
"output": "2"
},
{
"input": "2.71828182845904523536",
"output": "3"
},
{
"input": "3.14159265358979323846",
"output": "3"
},
{
"input": "12345678901234567890.1",
... | 1,698,632,879 | 2,147,483,647 | Python 3 | OK | TESTS | 150 | 92 | 0 | a,b = input().split('.')
if a[-1] != '9' and int(b[0])<5:
print(a)
elif a[-1] != '9' and int(b[0]) >= 5:
print(int(a)+1)
elif a[-1] == '9':
print("GOTO Vasilisa.") | Title: Help Far Away Kingdom
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there.
Most damage those stran... | ```python
a,b = input().split('.')
if a[-1] != '9' and int(b[0])<5:
print(a)
elif a[-1] != '9' and int(b[0]) >= 5:
print(int(a)+1)
elif a[-1] == '9':
print("GOTO Vasilisa.")
``` | 3.977 |
279 | B | Books | PROGRAMMING | 1,400 | [
"binary search",
"brute force",
"implementation",
"two pointers"
] | null | null | When Valera has got some free time, he goes to the library to read some books. Today he's got *t* free minutes to read. That's why Valera took *n* books in the library and for each book he estimated the time he is going to need to read it. Let's number the books by integers from 1 to *n*. Valera needs *a**i* minutes to... | The first line contains two integers *n* and *t* (1<=≤<=*n*<=≤<=105; 1<=≤<=*t*<=≤<=109) — the number of books and the number of free minutes Valera's got. The second line contains a sequence of *n* integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=104), where number *a**i* shows the number of minutes that the boy n... | Print a single integer — the maximum number of books Valera can read. | [
"4 5\n3 1 2 1\n",
"3 3\n2 2 3\n"
] | [
"3\n",
"1\n"
] | none | 1,000 | [
{
"input": "4 5\n3 1 2 1",
"output": "3"
},
{
"input": "3 3\n2 2 3",
"output": "1"
},
{
"input": "1 3\n5",
"output": "0"
},
{
"input": "1 10\n4",
"output": "1"
},
{
"input": "2 10\n6 4",
"output": "2"
},
{
"input": "6 10\n2 3 4 2 1 1",
"output": "4... | 1,698,590,401 | 2,147,483,647 | PyPy 3 | TIME_LIMIT_EXCEEDED | TESTS | 8 | 2,000 | 6,451,200 | #amount, time = input().split()
data = input().split()
amount = int(data[0])
time = int(data[1])
def Solution():
books = list(input().split())
maxReadenBooksAmount = 0
for bookIndex in range(0, amount):
allTime = time
currentReadenBooksAmount = 0
for subBookIndex in ra... | Title: Books
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
When Valera has got some free time, he goes to the library to read some books. Today he's got *t* free minutes to read. That's why Valera took *n* books in the library and for each book he estimated the time he is going to need t... | ```python
#amount, time = input().split()
data = input().split()
amount = int(data[0])
time = int(data[1])
def Solution():
books = list(input().split())
maxReadenBooksAmount = 0
for bookIndex in range(0, amount):
allTime = time
currentReadenBooksAmount = 0
for subBookI... | 0 | |
0 | none | none | none | 0 | [
"none"
] | null | null | You've got a string $a_1, a_2, \dots, a_n$, consisting of zeros and ones.
Let's call a sequence of consecutive elements $a_i, a_{i<=+<=1}, \ldots,<=a_j$ ($1\leq<=i\leq<=j\leq<=n$) a substring of string $a$.
You can apply the following operations any number of times:
- Choose some substring of string $a$ (for examp... | The first line of input contains integers $n$, $x$ and $y$ ($1<=\leq<=n<=\leq<=300\,000, 0 \leq x, y \leq 10^9$) — length of the string, cost of the first operation (substring reverse) and cost of the second operation (inverting all elements of substring).
The second line contains the string $a$ of length $n$, consist... | Print a single integer — the minimum total cost of operations you need to spend to get a string consisting only of ones. Print $0$, if you do not need to perform any operations. | [
"5 1 10\n01000\n",
"5 10 1\n01000\n",
"7 2 3\n1111111\n"
] | [
"11\n",
"2\n",
"0\n"
] | In the first sample, at first you need to reverse substring $[1 \dots 2]$, and then you need to invert substring $[2 \dots 5]$.
Then the string was changed as follows:
«01000» $\to$ «10000» $\to$ «11111».
The total cost of operations is $1 + 10 = 11$.
In the second sample, at first you need to invert substring $[1... | 0 | [
{
"input": "5 1 10\n01000",
"output": "11"
},
{
"input": "5 10 1\n01000",
"output": "2"
},
{
"input": "7 2 3\n1111111",
"output": "0"
},
{
"input": "1 60754033 959739508\n0",
"output": "959739508"
},
{
"input": "1 431963980 493041212\n1",
"output": "0"
},
... | 1,530,517,270 | 2,147,483,647 | PyPy 3 | OK | TESTS | 115 | 155 | 4,198,400 | n,x,y=map(int, input().split())
a=input()
k=0
i=0
if a[i]=='0':
k+=1
while i<n and a[i]=='0':
i+=1
for j in range(i,n-1):
if a[j]=='1' and a[j+1]=='0':
k+=1
if k==0:
print(0)
elif x<y:
print((k-1)*x+y)
else:
print(k*y) | Title: none
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You've got a string $a_1, a_2, \dots, a_n$, consisting of zeros and ones.
Let's call a sequence of consecutive elements $a_i, a_{i<=+<=1}, \ldots,<=a_j$ ($1\leq<=i\leq<=j\leq<=n$) a substring of string $a$.
You can apply the fo... | ```python
n,x,y=map(int, input().split())
a=input()
k=0
i=0
if a[i]=='0':
k+=1
while i<n and a[i]=='0':
i+=1
for j in range(i,n-1):
if a[j]=='1' and a[j+1]=='0':
k+=1
if k==0:
print(0)
elif x<y:
print((k-1)*x+y)
else:
print(k*y)
``` | 3 | |
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,562,878,252 | 2,147,483,647 | Python 3 | OK | TESTS | 33 | 342 | 0 | n,m=list(map(int,input().split()))
L=list(map(int,input().split()))
P=list(map(int,L))
mi=0
ma=0
for i in range(n):
x=max(L)
ma+=x
L[L.index(x)]-=1
#print(P)
for i in range(n):
x=min(P)
if x==0:
P.remove(x)
x=min(P)
mi+=x
P[P.index(x)]-=1
print(ma,m... | 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=list(map(int,input().split()))
L=list(map(int,input().split()))
P=list(map(int,L))
mi=0
ma=0
for i in range(n):
x=max(L)
ma+=x
L[L.index(x)]-=1
#print(P)
for i in range(n):
x=min(P)
if x==0:
P.remove(x)
x=min(P)
mi+=x
P[P.index(x)]-=1
... | 3 | |
818 | B | Permutation Game | PROGRAMMING | 1,600 | [
"implementation"
] | null | null | *n* children are standing in a circle and playing a game. Children's numbers in clockwise order form a permutation *a*1,<=*a*2,<=...,<=*a**n* of length *n*. It is an integer sequence such that each integer from 1 to *n* appears exactly once in it.
The game consists of *m* steps. On each step the current leader with in... | The first line contains two integer numbers *n*, *m* (1<=≤<=*n*,<=*m*<=≤<=100).
The second line contains *m* integer numbers *l*1,<=*l*2,<=...,<=*l**m* (1<=≤<=*l**i*<=≤<=*n*) — indices of leaders in the beginning of each step. | Print such permutation of *n* numbers *a*1,<=*a*2,<=...,<=*a**n* that leaders in the game will be exactly *l*1,<=*l*2,<=...,<=*l**m* if all the rules are followed. If there are multiple solutions print any of them.
If there is no permutation which satisfies all described conditions print -1. | [
"4 5\n2 3 1 4 4\n",
"3 3\n3 1 2\n"
] | [
"3 1 2 4 \n",
"-1\n"
] | Let's follow leadership in the first example:
- Child 2 starts. - Leadership goes from 2 to 2 + *a*<sub class="lower-index">2</sub> = 3. - Leadership goes from 3 to 3 + *a*<sub class="lower-index">3</sub> = 5. As it's greater than 4, it's going in a circle to 1. - Leadership goes from 1 to 1 + *a*<sub class="lowe... | 0 | [
{
"input": "4 5\n2 3 1 4 4",
"output": "3 1 2 4 "
},
{
"input": "3 3\n3 1 2",
"output": "-1"
},
{
"input": "1 100\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 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 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,498,752,845 | 4,145 | Python 3 | WRONG_ANSWER | TESTS | 3 | 46 | 5,529,600 | read = lambda: map(int, input().split())
n, m = read()
l = list(read())
a = [0] * (n + 1)
def fail():
print(-1)
exit()
for i in range(min(n, m - 1)):
if a[l[i]]: fail()
a[l[i]] = (l[i + 1] - l[i]) % n
if a[l[i]] == 0: a[l[i]] = n
s = set(a)
mex = 0
for i in range(1, n + 1):
if not ... | Title: Permutation Game
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
*n* children are standing in a circle and playing a game. Children's numbers in clockwise order form a permutation *a*1,<=*a*2,<=...,<=*a**n* of length *n*. It is an integer sequence such that each integer from 1 to *n... | ```python
read = lambda: map(int, input().split())
n, m = read()
l = list(read())
a = [0] * (n + 1)
def fail():
print(-1)
exit()
for i in range(min(n, m - 1)):
if a[l[i]]: fail()
a[l[i]] = (l[i + 1] - l[i]) % n
if a[l[i]] == 0: a[l[i]] = n
s = set(a)
mex = 0
for i in range(1, n + 1):
... | 0 | |
673 | A | Bear and Game | PROGRAMMING | 800 | [
"implementation"
] | null | null | Bear Limak likes watching sports on TV. He is going to watch a game today. The game lasts 90 minutes and there are no breaks.
Each minute can be either interesting or boring. If 15 consecutive minutes are boring then Limak immediately turns TV off.
You know that there will be *n* interesting minutes *t*1,<=*t*2,<=...... | The first line of the input contains one integer *n* (1<=≤<=*n*<=≤<=90) — the number of interesting minutes.
The second line contains *n* integers *t*1,<=*t*2,<=...,<=*t**n* (1<=≤<=*t*1<=<<=*t*2<=<<=... *t**n*<=≤<=90), given in the increasing order. | Print the number of minutes Limak will watch the game. | [
"3\n7 20 88\n",
"9\n16 20 30 40 50 60 70 80 90\n",
"9\n15 20 30 40 50 60 70 80 90\n"
] | [
"35\n",
"15\n",
"90\n"
] | In the first sample, minutes 21, 22, ..., 35 are all boring and thus Limak will turn TV off immediately after the 35-th minute. So, he would watch the game for 35 minutes.
In the second sample, the first 15 minutes are boring.
In the third sample, there are no consecutive 15 boring minutes. So, Limak will watch the w... | 500 | [
{
"input": "3\n7 20 88",
"output": "35"
},
{
"input": "9\n16 20 30 40 50 60 70 80 90",
"output": "15"
},
{
"input": "9\n15 20 30 40 50 60 70 80 90",
"output": "90"
},
{
"input": "30\n6 11 12 15 22 24 30 31 32 33 34 35 40 42 44 45 47 50 53 54 57 58 63 67 75 77 79 81 83 88",
... | 1,590,322,571 | 2,147,483,647 | Python 3 | OK | TESTS | 34 | 108 | 0 | n = int(input())
ans = 0
l = list(map(int , input().split()))
j = 0
for i in range(n):
if l[i]-j >15:
print(j+15)
ans = 1
break
j = l[i]
if ans == 0:
if j+15 >90 :
print(90)
else:
print(j+15)
| Title: Bear and Game
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Bear Limak likes watching sports on TV. He is going to watch a game today. The game lasts 90 minutes and there are no breaks.
Each minute can be either interesting or boring. If 15 consecutive minutes are boring then Lim... | ```python
n = int(input())
ans = 0
l = list(map(int , input().split()))
j = 0
for i in range(n):
if l[i]-j >15:
print(j+15)
ans = 1
break
j = l[i]
if ans == 0:
if j+15 >90 :
print(90)
else:
print(j+15)
``` | 3 | |
599 | A | Patrick and Shopping | PROGRAMMING | 800 | [
"implementation"
] | null | null | Today Patrick waits for a visit from his friend Spongebob. To prepare for the visit, Patrick needs to buy some goodies in two stores located near his house. There is a *d*1 meter long road between his house and the first shop and a *d*2 meter long road between his house and the second shop. Also, there is a road of len... | The first line of the input contains three integers *d*1, *d*2, *d*3 (1<=≤<=*d*1,<=*d*2,<=*d*3<=≤<=108) — the lengths of the paths.
- *d*1 is the length of the path connecting Patrick's house and the first shop; - *d*2 is the length of the path connecting Patrick's house and the second shop; - *d*3 is the length o... | Print the minimum distance that Patrick will have to walk in order to visit both shops and return to his house. | [
"10 20 30\n",
"1 1 5\n"
] | [
"60\n",
"4\n"
] | The first sample is shown on the picture in the problem statement. One of the optimal routes is: house <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/70a0795f45d32287dba0eb83fc4a3f470c6e5537.png" style="max-width: 100.0%;max-height: 100.0%;"/> first shop <img align="middle" class="tex-form... | 500 | [
{
"input": "10 20 30",
"output": "60"
},
{
"input": "1 1 5",
"output": "4"
},
{
"input": "100 33 34",
"output": "134"
},
{
"input": "777 777 777",
"output": "2331"
},
{
"input": "2 2 8",
"output": "8"
},
{
"input": "12 34 56",
"output": "92"
},
... | 1,591,183,410 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 78 | 0 | x,y,z=map(int,input().split())
min1=z+z
min2=(x+x+y+y)
print(min(min1,min2)) | Title: Patrick and Shopping
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Today Patrick waits for a visit from his friend Spongebob. To prepare for the visit, Patrick needs to buy some goodies in two stores located near his house. There is a *d*1 meter long road between his house and the... | ```python
x,y,z=map(int,input().split())
min1=z+z
min2=(x+x+y+y)
print(min(min1,min2))
``` | 0 | |
616 | B | Dinner with Emma | PROGRAMMING | 1,000 | [
"games",
"greedy"
] | null | null | Jack decides to invite Emma out for a dinner. Jack is a modest student, he doesn't want to go to an expensive restaurant. Emma is a girl with high taste, she prefers elite places.
Munhattan consists of *n* streets and *m* avenues. There is exactly one restaurant on the intersection of each street and avenue. The stree... | The first line contains two integers *n*,<=*m* (1<=≤<=*n*,<=*m*<=≤<=100) — the number of streets and avenues in Munhattan.
Each of the next *n* lines contains *m* integers *c**ij* (1<=≤<=*c**ij*<=≤<=109) — the cost of the dinner in the restaurant on the intersection of the *i*-th street and the *j*-th avenue. | Print the only integer *a* — the cost of the dinner for Jack and Emma. | [
"3 4\n4 1 3 5\n2 2 2 2\n5 4 5 1\n",
"3 3\n1 2 3\n2 3 1\n3 1 2\n"
] | [
"2\n",
"1\n"
] | In the first example if Emma chooses the first or the third streets Jack can choose an avenue with the cost of the dinner 1. So she chooses the second street and Jack chooses any avenue. The cost of the dinner is 2.
In the second example regardless of Emma's choice Jack can choose a restaurant with the cost of the din... | 0 | [
{
"input": "3 4\n4 1 3 5\n2 2 2 2\n5 4 5 1",
"output": "2"
},
{
"input": "3 3\n1 2 3\n2 3 1\n3 1 2",
"output": "1"
},
{
"input": "1 1\n1",
"output": "1"
},
{
"input": "1 10\n74 35 82 39 1 84 29 41 70 12",
"output": "1"
},
{
"input": "10 1\n44\n23\n65\n17\n48\n29\n... | 1,607,755,198 | 2,147,483,647 | Python 3 | OK | TESTS | 16 | 93 | 512,000 | def dinner (n,m,seq) :
cheapest = 0
for x in range(n) :
smallest = min(seq[x])
if smallest > cheapest :
cheapest = smallest
return cheapest
n,m = list(map(int,input().split()))
seq = []
for y in range(n) :
seq.append(list(map(int,input().sp... | Title: Dinner with Emma
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Jack decides to invite Emma out for a dinner. Jack is a modest student, he doesn't want to go to an expensive restaurant. Emma is a girl with high taste, she prefers elite places.
Munhattan consists of *n* streets and... | ```python
def dinner (n,m,seq) :
cheapest = 0
for x in range(n) :
smallest = min(seq[x])
if smallest > cheapest :
cheapest = smallest
return cheapest
n,m = list(map(int,input().split()))
seq = []
for y in range(n) :
seq.append(list(map(int,... | 3 | |
122 | A | Lucky Division | PROGRAMMING | 1,000 | [
"brute force",
"number theory"
] | null | null | Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya calls a number almost lucky if it could be evenly divided by some lucky number. Help him find ... | The single line contains an integer *n* (1<=≤<=*n*<=≤<=1000) — the number that needs to be checked. | In the only line print "YES" (without the quotes), if number *n* is almost lucky. Otherwise, print "NO" (without the quotes). | [
"47\n",
"16\n",
"78\n"
] | [
"YES\n",
"YES\n",
"NO\n"
] | Note that all lucky numbers are almost lucky as any number is evenly divisible by itself.
In the first sample 47 is a lucky number. In the second sample 16 is divisible by 4. | 500 | [
{
"input": "47",
"output": "YES"
},
{
"input": "16",
"output": "YES"
},
{
"input": "78",
"output": "NO"
},
{
"input": "48",
"output": "YES"
},
{
"input": "100",
"output": "YES"
},
{
"input": "107",
"output": "NO"
},
{
"input": "77",
"ou... | 1,690,626,933 | 2,147,483,647 | Python 3 | OK | TESTS | 36 | 92 | 0 | n = int(input())
lst = [4,7,47,74,44,77,444,447,474,744,777,774,747,477]
out = [0 if n%i==0 else 1 for i in lst]
if 0 in out:
print('YES')
else:
print('NO') | Title: Lucky Division
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
... | ```python
n = int(input())
lst = [4,7,47,74,44,77,444,447,474,744,777,774,747,477]
out = [0 if n%i==0 else 1 for i in lst]
if 0 in out:
print('YES')
else:
print('NO')
``` | 3 | |
572 | A | Arrays | PROGRAMMING | 900 | [
"sortings"
] | null | null | You are given two arrays *A* and *B* consisting of integers, sorted in non-decreasing order. Check whether it is possible to choose *k* numbers in array *A* and choose *m* numbers in array *B* so that any number chosen in the first array is strictly less than any number chosen in the second array. | The first line contains two integers *n**A*,<=*n**B* (1<=≤<=*n**A*,<=*n**B*<=≤<=105), separated by a space — the sizes of arrays *A* and *B*, correspondingly.
The second line contains two integers *k* and *m* (1<=≤<=*k*<=≤<=*n**A*,<=1<=≤<=*m*<=≤<=*n**B*), separated by a space.
The third line contains *n**A* numbers *... | Print "YES" (without the quotes), if you can choose *k* numbers in array *A* and *m* numbers in array *B* so that any number chosen in array *A* was strictly less than any number chosen in array *B*. Otherwise, print "NO" (without the quotes). | [
"3 3\n2 1\n1 2 3\n3 4 5\n",
"3 3\n3 3\n1 2 3\n3 4 5\n",
"5 2\n3 1\n1 1 1 1 1\n2 2\n"
] | [
"YES\n",
"NO\n",
"YES\n"
] | In the first sample test you can, for example, choose numbers 1 and 2 from array *A* and number 3 from array *B* (1 < 3 and 2 < 3).
In the second sample test the only way to choose *k* elements in the first array and *m* elements in the second one is to choose all numbers in both arrays, but then not all the num... | 500 | [
{
"input": "3 3\n2 1\n1 2 3\n3 4 5",
"output": "YES"
},
{
"input": "3 3\n3 3\n1 2 3\n3 4 5",
"output": "NO"
},
{
"input": "5 2\n3 1\n1 1 1 1 1\n2 2",
"output": "YES"
},
{
"input": "3 5\n1 1\n5 5 5\n5 5 5 5 5",
"output": "NO"
},
{
"input": "1 1\n1 1\n1\n1",
"ou... | 1,679,340,826 | 2,147,483,647 | PyPy 3 | OK | TESTS | 52 | 280 | 14,028,800 | n,m = map(int, input().split())
a,b = map(int, input().split())
N = list(map(int, input().split()))
M = list(map(int, input().split()))
if N[a-1] >= M[-b]:
print('NO')
else:
print('YES') | Title: Arrays
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given two arrays *A* and *B* consisting of integers, sorted in non-decreasing order. Check whether it is possible to choose *k* numbers in array *A* and choose *m* numbers in array *B* so that any number chosen in the fi... | ```python
n,m = map(int, input().split())
a,b = map(int, input().split())
N = list(map(int, input().split()))
M = list(map(int, input().split()))
if N[a-1] >= M[-b]:
print('NO')
else:
print('YES')
``` | 3 | |
1,011 | B | Planning The Expedition | PROGRAMMING | 1,200 | [
"binary search",
"brute force",
"implementation"
] | null | null | Natasha is planning an expedition to Mars for $n$ people. One of the important tasks is to provide food for each participant.
The warehouse has $m$ daily food packages. Each package has some food type $a_i$.
Each participant must eat exactly one food package each day. Due to extreme loads, each participant must eat t... | The first line contains two integers $n$ and $m$ ($1 \le n \le 100$, $1 \le m \le 100$) — the number of the expedition participants and the number of the daily food packages available.
The second line contains sequence of integers $a_1, a_2, \dots, a_m$ ($1 \le a_i \le 100$), where $a_i$ is the type of $i$-th food pac... | Print the single integer — the number of days the expedition can last. If it is not possible to plan the expedition for even one day, print 0. | [
"4 10\n1 5 2 1 1 1 2 5 7 2\n",
"100 1\n1\n",
"2 5\n5 4 3 2 1\n",
"3 9\n42 42 42 42 42 42 42 42 42\n"
] | [
"2\n",
"0\n",
"1\n",
"3\n"
] | In the first example, Natasha can assign type $1$ food to the first participant, the same type $1$ to the second, type $5$ to the third and type $2$ to the fourth. In this case, the expedition can last for $2$ days, since each participant can get two food packages of his food type (there will be used $4$ packages of ty... | 1,000 | [
{
"input": "4 10\n1 5 2 1 1 1 2 5 7 2",
"output": "2"
},
{
"input": "100 1\n1",
"output": "0"
},
{
"input": "2 5\n5 4 3 2 1",
"output": "1"
},
{
"input": "3 9\n42 42 42 42 42 42 42 42 42",
"output": "3"
},
{
"input": "1 1\n100",
"output": "1"
},
{
"inp... | 1,667,220,331 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 14 | 46 | 102,400 |
from collections import defaultdict, deque, Counter
from functools import lru_cache
from heapq import heappush, heappop
from bisect import bisect_right, bisect_left
def inpNum():
return int(input())
def inpStr():
return input()
def inpSepNum():
return map(int, input().split())
def inpNumList()... | Title: Planning The Expedition
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Natasha is planning an expedition to Mars for $n$ people. One of the important tasks is to provide food for each participant.
The warehouse has $m$ daily food packages. Each package has some food type $a_i$.
E... | ```python
from collections import defaultdict, deque, Counter
from functools import lru_cache
from heapq import heappush, heappop
from bisect import bisect_right, bisect_left
def inpNum():
return int(input())
def inpStr():
return input()
def inpSepNum():
return map(int, input().split())
def in... | 0 | |
961 | A | Tetris | PROGRAMMING | 900 | [
"implementation"
] | null | null | You are given a following process.
There is a platform with $n$ columns. $1 \times 1$ squares are appearing one after another in some columns on this platform. If there are no squares in the column, a square will occupy the bottom row. Otherwise a square will appear at the top of the highest square of this column.
... | The first line of input contain 2 integer numbers $n$ and $m$ ($1 \le n, m \le 1000$) — the length of the platform and the number of the squares.
The next line contain $m$ integer numbers $c_1, c_2, \dots, c_m$ ($1 \le c_i \le n$) — column in which $i$-th square will appear. | Print one integer — the amount of points you will receive. | [
"3 9\n1 1 2 2 2 3 1 2 3\n"
] | [
"2\n"
] | In the sample case the answer will be equal to $2$ because after the appearing of $6$-th square will be removed one row (counts of the squares on the platform will look like $[2~ 3~ 1]$, and after removing one row will be $[1~ 2~ 0]$).
After the appearing of $9$-th square counts will be $[2~ 3~ 1]$, and after removing... | 0 | [
{
"input": "3 9\n1 1 2 2 2 3 1 2 3",
"output": "2"
},
{
"input": "1 7\n1 1 1 1 1 1 1",
"output": "7"
},
{
"input": "1 1\n1",
"output": "1"
},
{
"input": "3 5\n1 1 1 2 3",
"output": "1"
},
{
"input": "4 6\n4 4 4 4 4 4",
"output": "0"
},
{
"input": "4 6\... | 1,564,397,612 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 109 | 409,600 | from collections import Counter as c
n,m = map(int,input().split())
l = input().replace(' ','')
print(list(c(l).values())[-1]) | Title: Tetris
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given a following process.
There is a platform with $n$ columns. $1 \times 1$ squares are appearing one after another in some columns on this platform. If there are no squares in the column, a square will occupy the bo... | ```python
from collections import Counter as c
n,m = map(int,input().split())
l = input().replace(' ','')
print(list(c(l).values())[-1])
``` | 0 | |
0 | none | none | none | 0 | [
"none"
] | null | null | For a given positive integer *n* denote its *k*-rounding as the minimum positive integer *x*, such that *x* ends with *k* or more zeros in base 10 and is divisible by *n*.
For example, 4-rounding of 375 is 375·80<==<=30000. 30000 is the minimum integer such that it ends with 4 or more zeros and is divisible by 375.
W... | The only line contains two integers *n* and *k* (1<=≤<=*n*<=≤<=109, 0<=≤<=*k*<=≤<=8). | Print the *k*-rounding of *n*. | [
"375 4\n",
"10000 1\n",
"38101 0\n",
"123456789 8\n"
] | [
"30000\n",
"10000\n",
"38101\n",
"12345678900000000\n"
] | none | 0 | [
{
"input": "375 4",
"output": "30000"
},
{
"input": "10000 1",
"output": "10000"
},
{
"input": "38101 0",
"output": "38101"
},
{
"input": "123456789 8",
"output": "12345678900000000"
},
{
"input": "1 0",
"output": "1"
},
{
"input": "2 0",
"output":... | 1,505,654,278 | 778 | Python 3 | WRONG_ANSWER | PRETESTS | 8 | 62 | 0 | n,k=map(int,input().split())
m=n
i=0
j=0
while not n%2:
n//=2
i+=1
while not n%5:
n//=5
j+=1
print(max((n*10**k),m))
| Title: none
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
For a given positive integer *n* denote its *k*-rounding as the minimum positive integer *x*, such that *x* ends with *k* or more zeros in base 10 and is divisible by *n*.
For example, 4-rounding of 375 is 375·80<==<=30000. 30000... | ```python
n,k=map(int,input().split())
m=n
i=0
j=0
while not n%2:
n//=2
i+=1
while not n%5:
n//=5
j+=1
print(max((n*10**k),m))
``` | 0 | |
37 | A | Towers | PROGRAMMING | 1,000 | [
"sortings"
] | A. Towers | 2 | 256 | Little Vasya has received a young builder’s kit. The kit consists of several wooden bars, the lengths of all of them are known. The bars can be put one on the top of the other if their lengths are the same.
Vasya wants to construct the minimal number of towers from the bars. Help Vasya to use the bars in the best way ... | The first line contains an integer *N* (1<=≤<=*N*<=≤<=1000) — the number of bars at Vasya’s disposal. The second line contains *N* space-separated integers *l**i* — the lengths of the bars. All the lengths are natural numbers not exceeding 1000. | In one line output two numbers — the height of the largest tower and their total number. Remember that Vasya should use all the bars. | [
"3\n1 2 3\n",
"4\n6 5 6 7\n"
] | [
"1 3\n",
"2 3\n"
] | none | 500 | [
{
"input": "3\n1 2 3",
"output": "1 3"
},
{
"input": "4\n6 5 6 7",
"output": "2 3"
},
{
"input": "4\n3 2 1 1",
"output": "2 3"
},
{
"input": "4\n1 2 3 3",
"output": "2 3"
},
{
"input": "3\n20 22 36",
"output": "1 3"
},
{
"input": "25\n47 30 94 41 45 20... | 1,599,485,041 | 2,147,483,647 | PyPy 3 | OK | TESTS | 61 | 342 | 307,200 | import sys
from collections import Counter
n = sys.stdin.readline()
bars = Counter(list(map(int, sys.stdin.readline().strip().split())))
print(bars.most_common()[0][1], len(bars.keys()))
| Title: Towers
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Little Vasya has received a young builder’s kit. The kit consists of several wooden bars, the lengths of all of them are known. The bars can be put one on the top of the other if their lengths are the same.
Vasya wants to construct... | ```python
import sys
from collections import Counter
n = sys.stdin.readline()
bars = Counter(list(map(int, sys.stdin.readline().strip().split())))
print(bars.most_common()[0][1], len(bars.keys()))
``` | 3.913928 |
285 | C | Building Permutation | PROGRAMMING | 1,200 | [
"greedy",
"implementation",
"sortings"
] | null | null | Permutation *p* is an ordered set of integers *p*1,<=<=*p*2,<=<=...,<=<=*p**n*, consisting of *n* distinct positive integers, each of them doesn't exceed *n*. We'll denote the *i*-th element of permutation *p* as *p**i*. We'll call number *n* the size or the length of permutation *p*1,<=<=*p*2,<=<=...,<=<=*p**n*.
You ... | The first line contains integer *n* (1<=≤<=*n*<=≤<=3·105) — the size of the sought permutation. The second line contains *n* integers *a*1,<=*a*2,<=...,<=*a**n* (<=-<=109<=≤<=*a**i*<=≤<=109). | Print a single number — the minimum number of moves.
Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier. | [
"2\n3 0\n",
"3\n-1 -1 2\n"
] | [
"2\n",
"6\n"
] | In the first sample you should decrease the first number by one and then increase the second number by one. The resulting permutation is (2, 1).
In the second sample you need 6 moves to build permutation (1, 3, 2). | 1,500 | [
{
"input": "2\n3 0",
"output": "2"
},
{
"input": "3\n-1 -1 2",
"output": "6"
},
{
"input": "5\n-3 5 -3 3 3",
"output": "10"
},
{
"input": "10\n9 6 -2 4 1 1 1 9 6 2",
"output": "18"
},
{
"input": "9\n2 0 0 6 5 4 1 9 3",
"output": "15"
},
{
"input": "100... | 1,660,920,364 | 2,147,483,647 | Python 3 | OK | TESTS | 33 | 421 | 24,883,200 | n = int(input())
a = [int(i) for i in input().split()]
a.sort()
ans = 0
for i in range(1,n+1):
ans+= abs(a[i-1]-i)
print(ans)
| Title: Building Permutation
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Permutation *p* is an ordered set of integers *p*1,<=<=*p*2,<=<=...,<=<=*p**n*, consisting of *n* distinct positive integers, each of them doesn't exceed *n*. We'll denote the *i*-th element of permutation *p* as *... | ```python
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
ans = 0
for i in range(1,n+1):
ans+= abs(a[i-1]-i)
print(ans)
``` | 3 | |
3 | A | Shortest path of the king | PROGRAMMING | 1,000 | [
"greedy",
"shortest paths"
] | A. Shortest path of the king | 1 | 64 | The king is left alone on the chessboard. In spite of this loneliness, he doesn't lose heart, because he has business of national importance. For example, he has to pay an official visit to square *t*. As the king is not in habit of wasting his time, he wants to get from his current position *s* to square *t* in the le... | The first line contains the chessboard coordinates of square *s*, the second line — of square *t*.
Chessboard coordinates consist of two characters, the first one is a lowercase Latin letter (from a to h), the second one is a digit from 1 to 8. | In the first line print *n* — minimum number of the king's moves. Then in *n* lines print the moves themselves. Each move is described with one of the 8: L, R, U, D, LU, LD, RU or RD.
L, R, U, D stand respectively for moves left, right, up and down (according to the picture), and 2-letter combinations stand for diago... | [
"a8\nh1\n"
] | [
"7\nRD\nRD\nRD\nRD\nRD\nRD\nRD\n"
] | none | 0 | [
{
"input": "a8\nh1",
"output": "7\nRD\nRD\nRD\nRD\nRD\nRD\nRD"
},
{
"input": "b2\nb4",
"output": "2\nU\nU"
},
{
"input": "a5\na5",
"output": "0"
},
{
"input": "h1\nb2",
"output": "6\nLU\nL\nL\nL\nL\nL"
},
{
"input": "c5\nh2",
"output": "5\nRD\nRD\nRD\nR\nR"
... | 1,589,540,869 | 2,147,483,647 | PyPy 3 | TIME_LIMIT_EXCEEDED | TESTS | 1 | 1,000 | 29,696,000 | def fun(x1,y1,x2,y2):
if abs(x2-x1)==abs(y2-y1):
print(abs(x2-x1))
else:
print(abs(x2-x1)+abs(y2-y1))
while x1-x2!=0 or y1-y2!=0:
if x1-x2<0 and y1-y2==0:
x1=x1+1
print("D")
if x1-x2>0 and y1-y2==0:
x1=x1-1
print("U")... | Title: Shortest path of the king
Time Limit: 1 seconds
Memory Limit: 64 megabytes
Problem Description:
The king is left alone on the chessboard. In spite of this loneliness, he doesn't lose heart, because he has business of national importance. For example, he has to pay an official visit to square *t*. As the king ... | ```python
def fun(x1,y1,x2,y2):
if abs(x2-x1)==abs(y2-y1):
print(abs(x2-x1))
else:
print(abs(x2-x1)+abs(y2-y1))
while x1-x2!=0 or y1-y2!=0:
if x1-x2<0 and y1-y2==0:
x1=x1+1
print("D")
if x1-x2>0 and y1-y2==0:
x1=x1-1
... | 0 |
1,009 | B | Minimum Ternary String | PROGRAMMING | 1,400 | [
"greedy",
"implementation"
] | null | null | You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace "12" with "21" or vice versa).
For e... | The first line of the input contains the string $s$ consisting only of characters '0', '1' and '2', its length is between $1$ and $10^5$ (inclusive). | Print a single string — the minimum possible (lexicographically) string you can obtain by using the swaps described above arbitrary number of times (possibly, zero). | [
"100210\n",
"11222121\n",
"20\n"
] | [
"001120\n",
"11112222\n",
"20\n"
] | none | 0 | [
{
"input": "100210",
"output": "001120"
},
{
"input": "11222121",
"output": "11112222"
},
{
"input": "20",
"output": "20"
},
{
"input": "1002",
"output": "0012"
},
{
"input": "10",
"output": "01"
},
{
"input": "000021",
"output": "000012"
},
{
... | 1,531,637,860 | 2,147,483,647 | Python 3 | OK | TESTS | 30 | 140 | 819,200 | # -*- coding: utf - 8 -*-
"""""""""""""""""""""""""""""""""""""""""""""
| author: mr.math - Hakimov Rahimjon |
| e-mail: [email protected] |
"""""""""""""""""""""""""""""""""""""""""""""
# inp = open("input.txt", "r"); input = inp.readline; out = open("output.txt", "w"); print = out.write
TN = ... | Title: Minimum Ternary String
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) ... | ```python
# -*- coding: utf - 8 -*-
"""""""""""""""""""""""""""""""""""""""""""""
| author: mr.math - Hakimov Rahimjon |
| e-mail: [email protected] |
"""""""""""""""""""""""""""""""""""""""""""""
# inp = open("input.txt", "r"); input = inp.readline; out = open("output.txt", "w"); print = out.wr... | 3 | |
931 | A | Friends Meeting | PROGRAMMING | 800 | [
"brute force",
"greedy",
"implementation",
"math"
] | null | null | Two friends are on the coordinate axis *Ox* in points with integer coordinates. One of them is in the point *x*1<==<=*a*, another one is in the point *x*2<==<=*b*.
Each of the friends can move by one along the line in any direction unlimited number of times. When a friend moves, the tiredness of a friend changes acco... | The first line contains a single integer *a* (1<=≤<=*a*<=≤<=1000) — the initial position of the first friend.
The second line contains a single integer *b* (1<=≤<=*b*<=≤<=1000) — the initial position of the second friend.
It is guaranteed that *a*<=≠<=*b*. | Print the minimum possible total tiredness if the friends meet in the same point. | [
"3\n4\n",
"101\n99\n",
"5\n10\n"
] | [
"1\n",
"2\n",
"9\n"
] | In the first example the first friend should move by one to the right (then the meeting happens at point 4), or the second friend should move by one to the left (then the meeting happens at point 3). In both cases, the total tiredness becomes 1.
In the second example the first friend should move by one to the left, an... | 500 | [
{
"input": "3\n4",
"output": "1"
},
{
"input": "101\n99",
"output": "2"
},
{
"input": "5\n10",
"output": "9"
},
{
"input": "1\n2",
"output": "1"
},
{
"input": "1\n1000",
"output": "250000"
},
{
"input": "999\n1000",
"output": "1"
},
{
"inpu... | 1,529,012,182 | 2,147,483,647 | PyPy 3 | OK | TESTS | 40 | 109 | 0 | a, b = int(input()), int(input())
c = abs(a - b)
if c % 2 == 1:
print((c + 1) // 2 + (c // 2) * (c // 2 + 1))
else:
print((c // 2) * (c // 2 + 1))
| Title: Friends Meeting
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Two friends are on the coordinate axis *Ox* in points with integer coordinates. One of them is in the point *x*1<==<=*a*, another one is in the point *x*2<==<=*b*.
Each of the friends can move by one along the line in... | ```python
a, b = int(input()), int(input())
c = abs(a - b)
if c % 2 == 1:
print((c + 1) // 2 + (c // 2) * (c // 2 + 1))
else:
print((c // 2) * (c // 2 + 1))
``` | 3 | |
996 | A | Hit the Lottery | PROGRAMMING | 800 | [
"dp",
"greedy"
] | null | null | Allen has a LOT of money. He has $n$ dollars in the bank. For security reasons, he wants to withdraw it in cash (we will not disclose the reasons here). The denominations for dollar bills are $1$, $5$, $10$, $20$, $100$. What is the minimum number of bills Allen could receive after withdrawing his entire balance? | The first and only line of input contains a single integer $n$ ($1 \le n \le 10^9$). | Output the minimum number of bills that Allen could receive. | [
"125\n",
"43\n",
"1000000000\n"
] | [
"3\n",
"5\n",
"10000000\n"
] | In the first sample case, Allen can withdraw this with a $100$ dollar bill, a $20$ dollar bill, and a $5$ dollar bill. There is no way for Allen to receive $125$ dollars in one or two bills.
In the second sample case, Allen can withdraw two $20$ dollar bills and three $1$ dollar bills.
In the third sample case, Allen... | 500 | [
{
"input": "125",
"output": "3"
},
{
"input": "43",
"output": "5"
},
{
"input": "1000000000",
"output": "10000000"
},
{
"input": "4",
"output": "4"
},
{
"input": "5",
"output": "1"
},
{
"input": "1",
"output": "1"
},
{
"input": "74",
"o... | 1,688,929,323 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 31 | 0 | n=input()
n=int(n)
res=n-122
print(res)
| Title: Hit the Lottery
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Allen has a LOT of money. He has $n$ dollars in the bank. For security reasons, he wants to withdraw it in cash (we will not disclose the reasons here). The denominations for dollar bills are $1$, $5$, $10$, $20$, $100$... | ```python
n=input()
n=int(n)
res=n-122
print(res)
``` | 0 | |
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,679,999,570 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 10 | 31 | 0 | x = input()
ptr = 0
while x[ptr] == '0':
ptr += 1
print("yes" if x.count('0', ptr) >= 6 or x == '0' else "no")
#########################################
## ##
## Implemented by brownfox2k6 ##
## ##
#########################... | 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
x = input()
ptr = 0
while x[ptr] == '0':
ptr += 1
print("yes" if x.count('0', ptr) >= 6 or x == '0' else "no")
#########################################
## ##
## Implemented by brownfox2k6 ##
## ##
###############... | -1 | |
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,645,495,957 | 2,147,483,647 | Python 3 | OK | TESTS | 45 | 92 | 0 | import math
x = input().split()
a = int(x[0])
b = int(x[1])
n = int(x[-1])
while True:
x = math.gcd(a,n)
n-=x
if n==0 or n<x:
print("0")
break
y = math.gcd(b,n)
n -= y
if n==0 or n<y:
print("1")
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
import math
x = input().split()
a = int(x[0])
b = int(x[1])
n = int(x[-1])
while True:
x = math.gcd(a,n)
n-=x
if n==0 or n<x:
print("0")
break
y = math.gcd(b,n)
n -= y
if n==0 or n<y:
print("1")
break
``` | 3 | |
518 | B | Tanya and Postcard | PROGRAMMING | 1,400 | [
"greedy",
"implementation",
"strings"
] | null | null | Little Tanya decided to present her dad a postcard on his Birthday. She has already created a message — string *s* of length *n*, consisting of uppercase and lowercase English letters. Tanya can't write yet, so she found a newspaper and decided to cut out the letters and glue them into the postcard to achieve string *s... | The first line contains line *s* (1<=≤<=|*s*|<=≤<=2·105), consisting of uppercase and lowercase English letters — the text of Tanya's message.
The second line contains line *t* (|*s*|<=≤<=|*t*|<=≤<=2·105), consisting of uppercase and lowercase English letters — the text written in the newspaper.
Here |*a*| means the ... | Print two integers separated by a space:
- the first number is the number of times Tanya shouts "YAY!" while making the message, - the second number is the number of times Tanya says "WHOOPS" while making the message. | [
"AbC\nDCbA\n",
"ABC\nabc\n",
"abacaba\nAbaCaBA\n"
] | [
"3 0\n",
"0 3\n",
"3 4\n"
] | none | 1,000 | [
{
"input": "AbC\nDCbA",
"output": "3 0"
},
{
"input": "ABC\nabc",
"output": "0 3"
},
{
"input": "abacaba\nAbaCaBA",
"output": "3 4"
},
{
"input": "zzzzz\nZZZZZ",
"output": "0 5"
},
{
"input": "zzzZZZ\nZZZzzZ",
"output": "5 1"
},
{
"input": "abcdefghijk... | 1,612,181,965 | 2,147,483,647 | PyPy 3 | TIME_LIMIT_EXCEEDED | TESTS | 7 | 2,000 | 11,161,600 | s = input()
t = input()
n = len(s)
y = w = 0
for i in s:
indx = t.find(i)
if(indx != -1):
t = t[:indx] + "_" + t[indx + 1:]
y += 1
else:
w += 1
print(str(y) + " " + str(w))
| Title: Tanya and Postcard
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Little Tanya decided to present her dad a postcard on his Birthday. She has already created a message — string *s* of length *n*, consisting of uppercase and lowercase English letters. Tanya can't write yet, so she f... | ```python
s = input()
t = input()
n = len(s)
y = w = 0
for i in s:
indx = t.find(i)
if(indx != -1):
t = t[:indx] + "_" + t[indx + 1:]
y += 1
else:
w += 1
print(str(y) + " " + str(w))
``` | 0 | |
116 | A | Tram | PROGRAMMING | 800 | [
"implementation"
] | null | null | Linear Kingdom has exactly one tram line. It has *n* stops, numbered from 1 to *n* in the order of tram's movement. At the *i*-th stop *a**i* passengers exit the tram, while *b**i* passengers enter it. The tram is empty before it arrives at the first stop. Also, when the tram arrives at the last stop, all passengers ex... | The first line contains a single number *n* (2<=≤<=*n*<=≤<=1000) — the number of the tram's stops.
Then *n* lines follow, each contains two integers *a**i* and *b**i* (0<=≤<=*a**i*,<=*b**i*<=≤<=1000) — the number of passengers that exits the tram at the *i*-th stop, and the number of passengers that enter the tram at... | Print a single integer denoting the minimum possible capacity of the tram (0 is allowed). | [
"4\n0 3\n2 5\n4 2\n4 0\n"
] | [
"6\n"
] | For the first example, a capacity of 6 is sufficient:
- At the first stop, the number of passengers inside the tram before arriving is 0. Then, 3 passengers enter the tram, and the number of passengers inside the tram becomes 3. - At the second stop, 2 passengers exit the tram (1 passenger remains inside). Then, 5 ... | 500 | [
{
"input": "4\n0 3\n2 5\n4 2\n4 0",
"output": "6"
},
{
"input": "5\n0 4\n4 6\n6 5\n5 4\n4 0",
"output": "6"
},
{
"input": "10\n0 5\n1 7\n10 8\n5 3\n0 5\n3 3\n8 8\n0 6\n10 1\n9 0",
"output": "18"
},
{
"input": "3\n0 1\n1 1\n1 0",
"output": "1"
},
{
"input": "4\n0 1... | 1,695,132,998 | 2,147,483,647 | Python 3 | OK | TESTS | 71 | 92 | 0 | # 4
# 0 3
# 2 5
# 4 2
# 4 0
c = 0
m = 0
for _ in range(int(input())):
a = [int(x) for x in input().split()]
c -= a[0]
c += a[1]
if(c>m):
m=c
print(m) | Title: Tram
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Linear Kingdom has exactly one tram line. It has *n* stops, numbered from 1 to *n* in the order of tram's movement. At the *i*-th stop *a**i* passengers exit the tram, while *b**i* passengers enter it. The tram is empty before it ... | ```python
# 4
# 0 3
# 2 5
# 4 2
# 4 0
c = 0
m = 0
for _ in range(int(input())):
a = [int(x) for x in input().split()]
c -= a[0]
c += a[1]
if(c>m):
m=c
print(m)
``` | 3 | |
813 | B | The Golden Age | PROGRAMMING | 1,800 | [
"brute force",
"math"
] | null | null | Unlucky year in Berland is such a year that its number *n* can be represented as *n*<==<=*x**a*<=+<=*y**b*, where *a* and *b* are non-negative integer numbers.
For example, if *x*<==<=2 and *y*<==<=3 then the years 4 and 17 are unlucky (4<==<=20<=+<=31, 17<==<=23<=+<=32<==<=24<=+<=30) and year 18 isn't unlucky as the... | The first line contains four integer numbers *x*, *y*, *l* and *r* (2<=≤<=*x*,<=*y*<=≤<=1018, 1<=≤<=*l*<=≤<=*r*<=≤<=1018). | Print the maximum length of The Golden Age within the interval [*l*,<=*r*].
If all years in the interval [*l*,<=*r*] are unlucky then print 0. | [
"2 3 1 10\n",
"3 5 10 22\n",
"2 3 3 5\n"
] | [
"1\n",
"8\n",
"0\n"
] | In the first example the unlucky years are 2, 3, 4, 5, 7, 9 and 10. So maximum length of The Golden Age is achived in the intervals [1, 1], [6, 6] and [8, 8].
In the second example the longest Golden Age is the interval [15, 22]. | 0 | [
{
"input": "2 3 1 10",
"output": "1"
},
{
"input": "3 5 10 22",
"output": "8"
},
{
"input": "2 3 3 5",
"output": "0"
},
{
"input": "2 2 1 10",
"output": "1"
},
{
"input": "2 2 1 1000000",
"output": "213568"
},
{
"input": "2 2 1 1000000000000000000",
... | 1,496,679,491 | 4,391 | Python 3 | OK | TESTS | 85 | 62 | 307,200 |
x,y,l,r=map(int,input().split())
lst = []
pwdX = 1
pwdY = 1
for i in range(0,65):
pwdY = 1
for j in range(0,65):
if pwdX + pwdY > r:
lst.append(pwdX + pwdY)
break
toAdd = pwdX + pwdY
lst.append(toAdd)
pwdY*=y
pwdX*=x
lst.append(r+1)
lst.append(l-... | Title: The Golden Age
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Unlucky year in Berland is such a year that its number *n* can be represented as *n*<==<=*x**a*<=+<=*y**b*, where *a* and *b* are non-negative integer numbers.
For example, if *x*<==<=2 and *y*<==<=3 then the years 4 a... | ```python
x,y,l,r=map(int,input().split())
lst = []
pwdX = 1
pwdY = 1
for i in range(0,65):
pwdY = 1
for j in range(0,65):
if pwdX + pwdY > r:
lst.append(pwdX + pwdY)
break
toAdd = pwdX + pwdY
lst.append(toAdd)
pwdY*=y
pwdX*=x
lst.append(r+1)
lst... | 3 | |
748 | B | Santa Claus and Keyboard Check | PROGRAMMING | 1,500 | [
"implementation",
"strings"
] | null | null | Santa Claus decided to disassemble his keyboard to clean it. After he returned all the keys back, he suddenly realized that some pairs of keys took each other's place! That is, Santa suspects that each key is either on its place, or on the place of another key, which is located exactly where the first key should be.
... | The input consists of only two strings *s* and *t* denoting the favorite Santa's patter and the resulting string. *s* and *t* are not empty and have the same length, which is at most 1000. Both strings consist only of lowercase English letters. | If Santa is wrong, and there is no way to divide some of keys into pairs and swap keys in each pair so that the keyboard will be fixed, print «-1» (without quotes).
Otherwise, the first line of output should contain the only integer *k* (*k*<=≥<=0) — the number of pairs of keys that should be swapped. The following *k... | [
"helloworld\nehoolwlroz\n",
"hastalavistababy\nhastalavistababy\n",
"merrychristmas\nchristmasmerry\n"
] | [
"3\nh e\nl o\nd z\n",
"0\n",
"-1\n"
] | none | 1,000 | [
{
"input": "helloworld\nehoolwlroz",
"output": "3\nh e\nl o\nd z"
},
{
"input": "hastalavistababy\nhastalavistababy",
"output": "0"
},
{
"input": "merrychristmas\nchristmasmerry",
"output": "-1"
},
{
"input": "kusyvdgccw\nkusyvdgccw",
"output": "0"
},
{
"input": "... | 1,505,425,955 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 13 | 77 | 204,800 | a = input()
b = input()
slov = {}
i = 0
kek = 0
while i <= len(a)-1:
if a[i] != b[i]:
for ii in slov.items():
if a[i] == ii[0] and b[i] == ii[1] or a[i] == ii[1] and b[i] == ii[0]:
break
elif a[i] != ii[0] and b[i] == ii[1] or a[i] == ii[0] and b[i] != ii[1] or a[i] != ii[1] and b[i] == ii[0] or... | Title: Santa Claus and Keyboard Check
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Santa Claus decided to disassemble his keyboard to clean it. After he returned all the keys back, he suddenly realized that some pairs of keys took each other's place! That is, Santa suspects that each ke... | ```python
a = input()
b = input()
slov = {}
i = 0
kek = 0
while i <= len(a)-1:
if a[i] != b[i]:
for ii in slov.items():
if a[i] == ii[0] and b[i] == ii[1] or a[i] == ii[1] and b[i] == ii[0]:
break
elif a[i] != ii[0] and b[i] == ii[1] or a[i] == ii[0] and b[i] != ii[1] or a[i] != ii[1] and b[i] =... | 0 | |
183 | B | Zoo | PROGRAMMING | 1,700 | [
"brute force",
"geometry"
] | null | null | The Zoo in the Grid Kingdom is represented by an infinite grid. The Zoo has *n* observation binoculars located at the *OX* axis. For each *i* between 1 and *n*, inclusive, there exists a single binocular located at the point with coordinates (*i*,<=0). There are *m* flamingos in the Zoo, located at points with positive... | The first line contains two space-separated integers *n* and *m* (1<=≤<=*n*<=≤<=106,<=1<=≤<=*m*<=≤<=250), denoting the number of binoculars and the number of flamingos, respectively.
Then *m* lines follow, the *i*-th line will contain two space-separated integers *x**i* and *y**i* (1<=≤<=*x**i*,<=*y**i*<=≤<=109), whic... | Print a single integer denoting the maximum total number of flamingos that can be seen by all the binoculars. | [
"5 5\n2 1\n4 1\n3 2\n4 3\n4 4\n"
] | [
"11\n"
] | This picture shows the answer to the example test case. | 1,000 | [
{
"input": "5 5\n2 1\n4 1\n3 2\n4 3\n4 4",
"output": "11"
},
{
"input": "3 3\n1 1\n2 10\n3 100",
"output": "3"
},
{
"input": "1 2\n450000001 500000000\n900000001 1000000000",
"output": "2"
},
{
"input": "3 6\n1 1\n1 2\n1 3\n2 1\n2 2\n3 1",
"output": "7"
},
{
"inpu... | 1,384,005,970 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 3 | 92 | 307,200 | from sys import *
l = stdin.readline()
(n,m) = (int(tkn) for tkn in l.split())
xs = [0] * m; ys = [0] * m
maxhits = [1] * (n + 1)
maxhits[0] = 0
for i in range(m):
l = stdin.readline()
(x,y) = (int(tkn) for tkn in l.split())
xs[i] = x; ys[i] = y
for i in range(m):
for j in range(m):
... | Title: Zoo
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The Zoo in the Grid Kingdom is represented by an infinite grid. The Zoo has *n* observation binoculars located at the *OX* axis. For each *i* between 1 and *n*, inclusive, there exists a single binocular located at the point with c... | ```python
from sys import *
l = stdin.readline()
(n,m) = (int(tkn) for tkn in l.split())
xs = [0] * m; ys = [0] * m
maxhits = [1] * (n + 1)
maxhits[0] = 0
for i in range(m):
l = stdin.readline()
(x,y) = (int(tkn) for tkn in l.split())
xs[i] = x; ys[i] = y
for i in range(m):
for j in range(m):... | 0 | |
864 | B | Polycarp and Letters | PROGRAMMING | 1,000 | [
"brute force",
"implementation",
"strings"
] | null | null | Polycarp loves lowercase letters and dislikes uppercase ones. Once he got a string *s* consisting only of lowercase and uppercase Latin letters.
Let *A* be a set of positions in the string. Let's call it pretty if following conditions are met:
- letters on positions from *A* in the string are all distinct and lowerc... | The first line contains a single integer *n* (1<=≤<=*n*<=≤<=200) — length of string *s*.
The second line contains a string *s* consisting of lowercase and uppercase Latin letters. | Print maximum number of elements in pretty set of positions for string *s*. | [
"11\naaaaBaabAbA\n",
"12\nzACaAbbaazzC\n",
"3\nABC\n"
] | [
"2\n",
"3\n",
"0\n"
] | In the first example the desired positions might be 6 and 8 or 7 and 8. Positions 6 and 7 contain letters 'a', position 8 contains letter 'b'. The pair of positions 1 and 8 is not suitable because there is an uppercase letter 'B' between these position.
In the second example desired positions can be 7, 8 and 11. There... | 1,000 | [
{
"input": "11\naaaaBaabAbA",
"output": "2"
},
{
"input": "12\nzACaAbbaazzC",
"output": "3"
},
{
"input": "3\nABC",
"output": "0"
},
{
"input": "1\na",
"output": "1"
},
{
"input": "2\naz",
"output": "2"
},
{
"input": "200\nXbTJZqcbpYuZQEoUrbxlPXAPCtVLr... | 1,643,360,232 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 3 | 31 | 0 | n=int(input())
s=input()
d={}
ans=-float('inf')
for each in s:
if each.islower():
if each not in d:
d[each]=0
d[each]+=1
else:
ans=max(ans,len(d))
d.clear()
print(ans) | Title: Polycarp and Letters
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Polycarp loves lowercase letters and dislikes uppercase ones. Once he got a string *s* consisting only of lowercase and uppercase Latin letters.
Let *A* be a set of positions in the string. Let's call it pretty if... | ```python
n=int(input())
s=input()
d={}
ans=-float('inf')
for each in s:
if each.islower():
if each not in d:
d[each]=0
d[each]+=1
else:
ans=max(ans,len(d))
d.clear()
print(ans)
``` | 0 | |
651 | B | Beautiful Paintings | PROGRAMMING | 1,200 | [
"greedy",
"sortings"
] | null | null | There are *n* pictures delivered for the new exhibition. The *i*-th painting has beauty *a**i*. We know that a visitor becomes happy every time he passes from a painting to a more beautiful one.
We are allowed to arranged pictures in any order. What is the maximum possible number of times the visitor may become happy ... | The first line of the input contains integer *n* (1<=≤<=*n*<=≤<=1000) — the number of painting.
The second line contains the sequence *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=1000), where *a**i* means the beauty of the *i*-th painting. | Print one integer — the maximum possible number of neighbouring pairs, such that *a**i*<=+<=1<=><=*a**i*, after the optimal rearrangement. | [
"5\n20 30 10 50 40\n",
"4\n200 100 100 200\n"
] | [
"4\n",
"2\n"
] | In the first sample, the optimal order is: 10, 20, 30, 40, 50.
In the second sample, the optimal order is: 100, 200, 100, 200. | 1,000 | [
{
"input": "5\n20 30 10 50 40",
"output": "4"
},
{
"input": "4\n200 100 100 200",
"output": "2"
},
{
"input": "10\n2 2 2 2 2 2 2 2 2 2",
"output": "0"
},
{
"input": "1\n1000",
"output": "0"
},
{
"input": "2\n444 333",
"output": "1"
},
{
"input": "100\n... | 1,634,314,473 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 30 | 0 | # your code goes here
n = int(input())
l = list(map(int, input().split().strip()))
sorted(l)
for i in range(0,n):
if (l[i+1]> l[i]):
count = 1 + count
print(count)
| Title: Beautiful Paintings
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
There are *n* pictures delivered for the new exhibition. The *i*-th painting has beauty *a**i*. We know that a visitor becomes happy every time he passes from a painting to a more beautiful one.
We are allowed to a... | ```python
# your code goes here
n = int(input())
l = list(map(int, input().split().strip()))
sorted(l)
for i in range(0,n):
if (l[i+1]> l[i]):
count = 1 + count
print(count)
``` | -1 | |
831 | B | Keyboard Layouts | PROGRAMMING | 800 | [
"implementation",
"strings"
] | null | null | There are two popular keyboard layouts in Berland, they differ only in letters positions. All the other keys are the same. In Berland they use alphabet with 26 letters which coincides with English alphabet.
You are given two strings consisting of 26 distinct letters each: all keys of the first and the second layouts i... | The first line contains a string of length 26 consisting of distinct lowercase English letters. This is the first layout.
The second line contains a string of length 26 consisting of distinct lowercase English letters. This is the second layout.
The third line contains a non-empty string *s* consisting of lowercase a... | Print the text if the same keys were pressed in the second layout. | [
"qwertyuiopasdfghjklzxcvbnm\nveamhjsgqocnrbfxdtwkylupzi\nTwccpQZAvb2017\n",
"mnbvcxzlkjhgfdsapoiuytrewq\nasdfghjklqwertyuiopzxcvbnm\n7abaCABAABAcaba7\n"
] | [
"HelloVKCup2017\n",
"7uduGUDUUDUgudu7\n"
] | none | 750 | [
{
"input": "qwertyuiopasdfghjklzxcvbnm\nveamhjsgqocnrbfxdtwkylupzi\nTwccpQZAvb2017",
"output": "HelloVKCup2017"
},
{
"input": "mnbvcxzlkjhgfdsapoiuytrewq\nasdfghjklqwertyuiopzxcvbnm\n7abaCABAABAcaba7",
"output": "7uduGUDUUDUgudu7"
},
{
"input": "ayvguplhjsoiencbkxdrfwmqtz\nkhzvtbspcndier... | 1,653,979,072 | 2,147,483,647 | Python 3 | OK | TESTS | 19 | 46 | 0 | first_layout = input()
second_layout = input()
text =input()
output=""
for i in text:
if(i.isdigit()==False):
second_layout_index = first_layout.index(i.lower())
if(i.isupper()):
output+=second_layout[second_layout_index].upper()
else:
output+=second_layout[... | Title: Keyboard Layouts
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
There are two popular keyboard layouts in Berland, they differ only in letters positions. All the other keys are the same. In Berland they use alphabet with 26 letters which coincides with English alphabet.
You are gi... | ```python
first_layout = input()
second_layout = input()
text =input()
output=""
for i in text:
if(i.isdigit()==False):
second_layout_index = first_layout.index(i.lower())
if(i.isupper()):
output+=second_layout[second_layout_index].upper()
else:
output+=seco... | 3 | |
0 | none | none | none | 0 | [
"none"
] | null | null | A very brave explorer Petya once decided to explore Paris catacombs. Since Petya is not really experienced, his exploration is just walking through the catacombs.
Catacombs consist of several rooms and bidirectional passages between some pairs of them. Some passages can connect a room to itself and since the passages ... | The first line contains a single integer *n* (1<=≤<=*n*<=≤<=2·105) — then number of notes in Petya's logbook.
The second line contains *n* non-negative integers *t*1,<=*t*2,<=...,<=*t**n* (0<=≤<=*t**i*<=<<=*i*) — notes in the logbook. | In the only line print a single integer — the minimum possible number of rooms in Paris catacombs. | [
"2\n0 0\n",
"5\n0 1 0 1 3\n"
] | [
"2\n",
"3\n"
] | In the first sample, sequence of rooms Petya visited could be, for example 1 → 1 → 2, 1 → 2 → 1 or 1 → 2 → 3. The minimum possible number of rooms is 2.
In the second sample, the sequence could be 1 → 2 → 3 → 1 → 2 → 1. | 0 | [
{
"input": "2\n0 0",
"output": "2"
},
{
"input": "5\n0 1 0 1 3",
"output": "3"
},
{
"input": "7\n0 1 0 0 0 0 0",
"output": "6"
},
{
"input": "100\n0 0 0 0 0 0 1 4 4 0 2 2 4 1 7 1 11 0 8 4 12 12 3 0 3 2 2 4 3 9 1 5 4 6 9 14 6 2 4 18 7 7 19 11 20 13 17 16 0 34 2 6 12 27 9 4 29 ... | 1,510,519,699 | 2,147,483,647 | Python 3 | OK | TESTS | 31 | 155 | 15,974,400 | n = int( input() )
a = list( map( int, input().split() ) )
memo = {}
ans = 1
for i in a:
if i not in memo:
memo[i] = 1
else:
ans += 1
print( ans ) | Title: none
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
A very brave explorer Petya once decided to explore Paris catacombs. Since Petya is not really experienced, his exploration is just walking through the catacombs.
Catacombs consist of several rooms and bidirectional passages betw... | ```python
n = int( input() )
a = list( map( int, input().split() ) )
memo = {}
ans = 1
for i in a:
if i not in memo:
memo[i] = 1
else:
ans += 1
print( ans )
``` | 3 | |
750 | A | New Year and Hurry | PROGRAMMING | 800 | [
"binary search",
"brute force",
"implementation",
"math"
] | null | null | Limak is going to participate in a contest on the last day of the 2016. The contest will start at 20:00 and will last four hours, exactly until midnight. There will be *n* problems, sorted by difficulty, i.e. problem 1 is the easiest and problem *n* is the hardest. Limak knows it will take him 5·*i* minutes to solve th... | The only line of the input contains two integers *n* and *k* (1<=≤<=*n*<=≤<=10, 1<=≤<=*k*<=≤<=240) — the number of the problems in the contest and the number of minutes Limak needs to get to the party from his house. | Print one integer, denoting the maximum possible number of problems Limak can solve so that he could get to the party at midnight or earlier. | [
"3 222\n",
"4 190\n",
"7 1\n"
] | [
"2\n",
"4\n",
"7\n"
] | In the first sample, there are 3 problems and Limak needs 222 minutes to get to the party. The three problems require 5, 10 and 15 minutes respectively. Limak can spend 5 + 10 = 15 minutes to solve first two problems. Then, at 20:15 he can leave his house to get to the party at 23:57 (after 222 minutes). In this scenar... | 500 | [
{
"input": "3 222",
"output": "2"
},
{
"input": "4 190",
"output": "4"
},
{
"input": "7 1",
"output": "7"
},
{
"input": "10 135",
"output": "6"
},
{
"input": "10 136",
"output": "5"
},
{
"input": "1 1",
"output": "1"
},
{
"input": "1 240",
... | 1,683,624,389 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 52 | 62 | 0 | a , n = map(int , input().split())
count_problems = 0
count_min = 20 * 60 + n
for i in range(a):
s = (i+1) * 5
if(count_min + s > 24 * 60):
break
else:
count_min += s
count_problems += 1
print(count_problems) | Title: New Year and Hurry
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Limak is going to participate in a contest on the last day of the 2016. The contest will start at 20:00 and will last four hours, exactly until midnight. There will be *n* problems, sorted by difficulty, i.e. problem... | ```python
a , n = map(int , input().split())
count_problems = 0
count_min = 20 * 60 + n
for i in range(a):
s = (i+1) * 5
if(count_min + s > 24 * 60):
break
else:
count_min += s
count_problems += 1
print(count_problems)
``` | 3 | |
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,673,121,265 | 2,147,483,647 | Python 3 | OK | TESTS | 44 | 92 | 0 | n = input()
a = n[0]
j = 1
dangerous = False
for i in range(1, len(n)):
if n[i] == a:
j += 1
if j == 7:
dangerous = True
break
else:
a = n[i]
j = 1
print("YES" if dangerous else "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
n = input()
a = n[0]
j = 1
dangerous = False
for i in range(1, len(n)):
if n[i] == a:
j += 1
if j == 7:
dangerous = True
break
else:
a = n[i]
j = 1
print("YES" if dangerous else "NO")
``` | 3.977 |
295 | A | Greg and Array | PROGRAMMING | 1,400 | [
"data structures",
"implementation"
] | null | null | Greg has an array *a*<==<=*a*1,<=*a*2,<=...,<=*a**n* and *m* operations. Each operation looks as: *l**i*, *r**i*, *d**i*, (1<=≤<=*l**i*<=≤<=*r**i*<=≤<=*n*). To apply operation *i* to the array means to increase all array elements with numbers *l**i*,<=*l**i*<=+<=1,<=...,<=*r**i* by value *d**i*.
Greg wrote down *k* qu... | The first line contains integers *n*, *m*, *k* (1<=≤<=*n*,<=*m*,<=*k*<=≤<=105). The second line contains *n* integers: *a*1,<=*a*2,<=...,<=*a**n* (0<=≤<=*a**i*<=≤<=105) — the initial array.
Next *m* lines contain operations, the operation number *i* is written as three integers: *l**i*, *r**i*, *d**i*, (1<=≤<=*l**i*<=... | On a single line print *n* integers *a*1,<=*a*2,<=...,<=*a**n* — the array after executing all the queries. Separate the printed numbers by spaces.
Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier. | [
"3 3 3\n1 2 3\n1 2 1\n1 3 2\n2 3 4\n1 2\n1 3\n2 3\n",
"1 1 1\n1\n1 1 1\n1 1\n",
"4 3 6\n1 2 3 4\n1 2 1\n2 3 2\n3 4 4\n1 2\n1 3\n2 3\n1 2\n1 3\n2 3\n"
] | [
"9 18 17\n",
"2\n",
"5 18 31 20\n"
] | none | 500 | [
{
"input": "3 3 3\n1 2 3\n1 2 1\n1 3 2\n2 3 4\n1 2\n1 3\n2 3",
"output": "9 18 17"
},
{
"input": "1 1 1\n1\n1 1 1\n1 1",
"output": "2"
},
{
"input": "4 3 6\n1 2 3 4\n1 2 1\n2 3 2\n3 4 4\n1 2\n1 3\n2 3\n1 2\n1 3\n2 3",
"output": "5 18 31 20"
},
{
"input": "1 1 1\n0\n1 1 0\n1 1... | 1,680,459,261 | 2,147,483,647 | PyPy 3-64 | TIME_LIMIT_EXCEEDED | TESTS | 10 | 1,500 | 19,251,200 | n,m,k = (input()).split(" ")
n = int(n)
m = int(m)
k = int(k)
a = input().split(" ")
for i in range(0,n):
a[i] = int(a[i])
o = []
for i in range(0,m):
l,r,d = input().split(" ")
l = int(l)
r = int(r)
d = int(d)
o.append([l,r,d])
q = []
dic = {}
for i in range(0,k):
x,y = input().split(" ")... | Title: Greg and Array
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Greg has an array *a*<==<=*a*1,<=*a*2,<=...,<=*a**n* and *m* operations. Each operation looks as: *l**i*, *r**i*, *d**i*, (1<=≤<=*l**i*<=≤<=*r**i*<=≤<=*n*). To apply operation *i* to the array means to increase all array... | ```python
n,m,k = (input()).split(" ")
n = int(n)
m = int(m)
k = int(k)
a = input().split(" ")
for i in range(0,n):
a[i] = int(a[i])
o = []
for i in range(0,m):
l,r,d = input().split(" ")
l = int(l)
r = int(r)
d = int(d)
o.append([l,r,d])
q = []
dic = {}
for i in range(0,k):
x,y = input().... | 0 | |
417 | C | Football | PROGRAMMING | 1,400 | [
"constructive algorithms",
"graphs",
"implementation"
] | null | null | One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided into *n* teams and played several matches, two teams could not play against each other more than once.
The appointed Judge was the most experienced member — Pavel. But since he was the ... | The first line contains two integers — *n* and *k* (1<=≤<=*n*,<=*k*<=≤<=1000). | In the first line print an integer *m* — number of the played games. The following *m* lines should contain the information about all the matches, one match per line. The *i*-th line should contain two integers *a**i* and *b**i* (1<=≤<=*a**i*,<=*b**i*<=≤<=*n*; *a**i*<=≠<=*b**i*). The numbers *a**i* and *b**i* mean, tha... | [
"3 1\n"
] | [
"3\n1 2\n2 3\n3 1\n"
] | none | 1,500 | [
{
"input": "3 1",
"output": "3\n1 2\n2 3\n3 1"
},
{
"input": "7 3",
"output": "21\n1 2\n1 3\n1 4\n2 3\n2 4\n2 5\n3 4\n3 5\n3 6\n4 5\n4 6\n4 7\n5 6\n5 7\n5 1\n6 7\n6 1\n6 2\n7 1\n7 2\n7 3"
},
{
"input": "4 1",
"output": "4\n1 2\n2 3\n3 4\n4 1"
},
{
"input": "5 2",
"output"... | 1,397,752,394 | 3,194 | Python 3 | WRONG_ANSWER | PRETESTS | 0 | 46 | 0 | n, k = map(int, input().split())
if n-1 < 2*k:
print(-1)
else:
for i in range(n):
for j in range(k):
print(i+1, (i+j+1)%n+1)
| Title: Football
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided into *n* teams and played several matches, two teams could not play against each other more ... | ```python
n, k = map(int, input().split())
if n-1 < 2*k:
print(-1)
else:
for i in range(n):
for j in range(k):
print(i+1, (i+j+1)%n+1)
``` | 0 | |
343 | D | Water Tree | PROGRAMMING | 2,100 | [
"data structures",
"dfs and similar",
"graphs",
"trees"
] | null | null | Mad scientist Mike has constructed a rooted tree, which consists of *n* vertices. Each vertex is a reservoir which can be either empty or filled with water.
The vertices of the tree are numbered from 1 to *n* with the root at vertex 1. For each vertex, the reservoirs of its children are located below the reservoir of ... | The first line of the input contains an integer *n* (1<=≤<=*n*<=≤<=500000) — the number of vertices in the tree. Each of the following *n*<=-<=1 lines contains two space-separated numbers *a**i*, *b**i* (1<=≤<=*a**i*,<=*b**i*<=≤<=*n*, *a**i*<=≠<=*b**i*) — the edges of the tree.
The next line contains a number *q* (1<=... | For each type 3 operation print 1 on a separate line if the vertex is full, and 0 if the vertex is empty. Print the answers to queries in the order in which the queries are given in the input. | [
"5\n1 2\n5 1\n2 3\n4 2\n12\n1 1\n2 3\n3 1\n3 2\n3 3\n3 4\n1 2\n2 4\n3 1\n3 3\n3 4\n3 5\n"
] | [
"0\n0\n0\n1\n0\n1\n0\n1\n"
] | none | 2,000 | [
{
"input": "5\n1 2\n5 1\n2 3\n4 2\n12\n1 1\n2 3\n3 1\n3 2\n3 3\n3 4\n1 2\n2 4\n3 1\n3 3\n3 4\n3 5",
"output": "0\n0\n0\n1\n0\n1\n0\n1"
},
{
"input": "1\n1\n3 1",
"output": "0"
},
{
"input": "2\n1 2\n13\n1 1\n3 1\n3 2\n2 1\n3 1\n3 2\n2 2\n3 1\n3 2\n1 1\n2 2\n3 1\n3 2",
"output": "1\n1... | 1,691,640,100 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 6 | 3,244 | 95,539,200 | class IntervalTree:
def __init__(self, n):
self.n = n
self.st = [0] * ((n << 2) + 7)
self.lazy = [0] * ((n << 2) + 7)
def fix(self, id, l, r):
if self.lazy[id] == 0:
return
if self.lazy[id] > self.st[id]:
self.st[id] = self.lazy[id]
... | Title: Water Tree
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Mad scientist Mike has constructed a rooted tree, which consists of *n* vertices. Each vertex is a reservoir which can be either empty or filled with water.
The vertices of the tree are numbered from 1 to *n* with the root ... | ```python
class IntervalTree:
def __init__(self, n):
self.n = n
self.st = [0] * ((n << 2) + 7)
self.lazy = [0] * ((n << 2) + 7)
def fix(self, id, l, r):
if self.lazy[id] == 0:
return
if self.lazy[id] > self.st[id]:
self.st[id] = self... | -1 | |
136 | A | Presents | PROGRAMMING | 800 | [
"implementation"
] | null | null | Little Petya very much likes gifts. Recently he has received a new laptop as a New Year gift from his mother. He immediately decided to give it to somebody else as what can be more pleasant than giving somebody gifts. And on this occasion he organized a New Year party at his place and invited *n* his friends there.
If... | The first line contains one integer *n* (1<=≤<=*n*<=≤<=100) — the quantity of friends Petya invited to the party. The second line contains *n* space-separated integers: the *i*-th number is *p**i* — the number of a friend who gave a gift to friend number *i*. It is guaranteed that each friend received exactly one gift.... | Print *n* space-separated integers: the *i*-th number should equal the number of the friend who gave a gift to friend number *i*. | [
"4\n2 3 4 1\n",
"3\n1 3 2\n",
"2\n1 2\n"
] | [
"4 1 2 3\n",
"1 3 2\n",
"1 2\n"
] | none | 500 | [
{
"input": "4\n2 3 4 1",
"output": "4 1 2 3"
},
{
"input": "3\n1 3 2",
"output": "1 3 2"
},
{
"input": "2\n1 2",
"output": "1 2"
},
{
"input": "1\n1",
"output": "1"
},
{
"input": "10\n1 3 2 6 4 5 7 9 8 10",
"output": "1 3 2 5 6 4 7 9 8 10"
},
{
"input"... | 1,699,536,693 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 101 | 154 | 0 | # Input
n = int(input())
gifts = list(map(int, input().split()))
# Output
for i in range(1, n + 1):
print(gifts.index(i) + 1, end=" ") | Title: Presents
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Little Petya very much likes gifts. Recently he has received a new laptop as a New Year gift from his mother. He immediately decided to give it to somebody else as what can be more pleasant than giving somebody gifts. And on t... | ```python
# Input
n = int(input())
gifts = list(map(int, input().split()))
# Output
for i in range(1, n + 1):
print(gifts.index(i) + 1, end=" ")
``` | 3 | |
758 | B | Blown Garland | PROGRAMMING | 1,100 | [
"brute force",
"implementation",
"number theory"
] | null | null | Nothing is eternal in the world, Kostya understood it on the 7-th of January when he saw partially dead four-color garland.
Now he has a goal to replace dead light bulbs, however he doesn't know how many light bulbs for each color are required. It is guaranteed that for each of four colors at least one light is workin... | The first and the only line contains the string *s* (4<=≤<=|*s*|<=≤<=100), which describes the garland, the *i*-th symbol of which describes the color of the *i*-th light bulb in the order from the beginning of garland:
- 'R' — the light bulb is red, - 'B' — the light bulb is blue, - 'Y' — the light bulb is yellow... | In the only line print four integers *k**r*,<=*k**b*,<=*k**y*,<=*k**g* — the number of dead light bulbs of red, blue, yellow and green colors accordingly. | [
"RYBGRYBGR\n",
"!RGYB\n",
"!!!!YGRB\n",
"!GB!RG!Y!\n"
] | [
"0 0 0 0",
"0 1 0 0",
"1 1 1 1",
"2 1 1 0"
] | In the first example there are no dead light bulbs.
In the second example it is obvious that one blue bulb is blown, because it could not be light bulbs of other colors on its place according to the statements. | 1,000 | [
{
"input": "RYBGRYBGR",
"output": "0 0 0 0"
},
{
"input": "!RGYB",
"output": "0 1 0 0"
},
{
"input": "!!!!YGRB",
"output": "1 1 1 1"
},
{
"input": "!GB!RG!Y!",
"output": "2 1 1 0"
},
{
"input": "RYBG",
"output": "0 0 0 0"
},
{
"input": "!Y!!!Y!!G!!!G!!... | 1,656,249,861 | 2,147,483,647 | Python 3 | OK | TESTS | 65 | 46 | 4,505,600 | # / *
#
# / \ | | / \ | | | |
# / __\ | | / __\ |--| | |
# / \ |__ | __ / \ | | \__ /
#
# __ __
# / \ | / | ) / \ | )
# / __\ |< |-< / __\ |-<
# / \ | \ |__) / \ | \
#
# * /
# Function to count frequency of each e... | Title: Blown Garland
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Nothing is eternal in the world, Kostya understood it on the 7-th of January when he saw partially dead four-color garland.
Now he has a goal to replace dead light bulbs, however he doesn't know how many light bulbs for ... | ```python
# / *
#
# / \ | | / \ | | | |
# / __\ | | / __\ |--| | |
# / \ |__ | __ / \ | | \__ /
#
# __ __
# / \ | / | ) / \ | )
# / __\ |< |-< / __\ |-<
# / \ | \ |__) / \ | \
#
# * /
# Function to count frequency... | 3 | |
552 | D | Vanya and Triangles | PROGRAMMING | 1,900 | [
"brute force",
"combinatorics",
"data structures",
"geometry",
"math",
"sortings"
] | null | null | Vanya got bored and he painted *n* distinct points on the plane. After that he connected all the points pairwise and saw that as a result many triangles were formed with vertices in the painted points. He asks you to count the number of the formed triangles with the non-zero area. | The first line contains integer *n* (1<=≤<=*n*<=≤<=2000) — the number of the points painted on the plane.
Next *n* lines contain two integers each *x**i*,<=*y**i* (<=-<=100<=≤<=*x**i*,<=*y**i*<=≤<=100) — the coordinates of the *i*-th point. It is guaranteed that no two given points coincide. | In the first line print an integer — the number of triangles with the non-zero area among the painted points. | [
"4\n0 0\n1 1\n2 0\n2 2\n",
"3\n0 0\n1 1\n2 0\n",
"1\n1 1\n"
] | [
"3\n",
"1\n",
"0\n"
] | Note to the first sample test. There are 3 triangles formed: (0, 0) - (1, 1) - (2, 0); (0, 0) - (2, 2) - (2, 0); (1, 1) - (2, 2) - (2, 0).
Note to the second sample test. There is 1 triangle formed: (0, 0) - (1, 1) - (2, 0).
Note to the third sample test. A single point doesn't form a single triangle. | 2,000 | [
{
"input": "4\n0 0\n1 1\n2 0\n2 2",
"output": "3"
},
{
"input": "3\n0 0\n1 1\n2 0",
"output": "1"
},
{
"input": "1\n1 1",
"output": "0"
},
{
"input": "5\n0 0\n1 1\n2 2\n3 3\n4 4",
"output": "0"
},
{
"input": "5\n0 0\n1 1\n2 3\n3 6\n4 10",
"output": "10"
},
... | 1,538,023,361 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 109 | 0 |
def gcd(a, b):
if b == 0:
return a
else:
return gcd(b, a % b)
n, m, k = [int(x) for x in input().split()]
x=gcd(n,k)
k/=x
x=n/x;
y=gcd(m,k)
k/=y
y=m/y;
if k != 1 and k != 2:
print("NO")
exit()
if k == 1:
if x*2<=n:
x*=2
elif y*2<=m:
y*=2
else:
print("NO")
exit()
print("YES")
pr... | Title: Vanya and Triangles
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vanya got bored and he painted *n* distinct points on the plane. After that he connected all the points pairwise and saw that as a result many triangles were formed with vertices in the painted points. He asks you t... | ```python
def gcd(a, b):
if b == 0:
return a
else:
return gcd(b, a % b)
n, m, k = [int(x) for x in input().split()]
x=gcd(n,k)
k/=x
x=n/x;
y=gcd(m,k)
k/=y
y=m/y;
if k != 1 and k != 2:
print("NO")
exit()
if k == 1:
if x*2<=n:
x*=2
elif y*2<=m:
y*=2
else:
print("NO")
exit()
print(... | -1 | |
102 | B | Sum of Digits | PROGRAMMING | 1,000 | [
"implementation"
] | B. Sum of Digits | 2 | 265 | Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number *n*. How many times can Gerald put a spell on it until the number becomes one-... | The first line contains the only integer *n* (0<=≤<=*n*<=≤<=10100000). It is guaranteed that *n* doesn't contain any leading zeroes. | Print the number of times a number can be replaced by the sum of its digits until it only contains one digit. | [
"0\n",
"10\n",
"991\n"
] | [
"0\n",
"1\n",
"3\n"
] | In the first sample the number already is one-digit — Herald can't cast a spell.
The second test contains number 10. After one casting of a spell it becomes 1, and here the process is completed. Thus, Gerald can only cast the spell once.
The third test contains number 991. As one casts a spell the following transform... | 1,000 | [
{
"input": "0",
"output": "0"
},
{
"input": "10",
"output": "1"
},
{
"input": "991",
"output": "3"
},
{
"input": "99",
"output": "2"
},
{
"input": "100",
"output": "1"
},
{
"input": "123456789",
"output": "2"
},
{
"input": "32",
"output... | 1,691,352,655 | 2,147,483,647 | PyPy 3 | OK | TESTS | 51 | 218 | 1,945,600 | n = input()
counter = 0
summ = 0
if len(n) > 1:
for i in n:
summ += int(i)
counter += 1
while summ > 9:
newSum = 0
while summ > 0:
newSum += summ % 10
summ //= 10
summ = newSum
counter += 1
print(counter)
else:
print... | Title: Sum of Digits
Time Limit: 2 seconds
Memory Limit: 265 megabytes
Problem Description:
Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came... | ```python
n = input()
counter = 0
summ = 0
if len(n) > 1:
for i in n:
summ += int(i)
counter += 1
while summ > 9:
newSum = 0
while summ > 0:
newSum += summ % 10
summ //= 10
summ = newSum
counter += 1
print(counter)
else:
... | 3.941999 |
34 | B | Sale | PROGRAMMING | 900 | [
"greedy",
"sortings"
] | B. Sale | 2 | 256 | Once Bob got to a sale of old TV sets. There were *n* TV sets at that sale. TV set with index *i* costs *a**i* bellars. Some TV sets have a negative price — their owners are ready to pay Bob if he buys their useless apparatus. Bob can «buy» any TV sets he wants. Though he's very strong, Bob can carry at most *m* TV set... | The first line contains two space-separated integers *n* and *m* (1<=≤<=*m*<=≤<=*n*<=≤<=100) — amount of TV sets at the sale, and amount of TV sets that Bob can carry. The following line contains *n* space-separated integers *a**i* (<=-<=1000<=≤<=*a**i*<=≤<=1000) — prices of the TV sets. | Output the only number — the maximum sum of money that Bob can earn, given that he can carry at most *m* TV sets. | [
"5 3\n-6 0 35 -2 4\n",
"4 2\n7 0 0 -7\n"
] | [
"8\n",
"7\n"
] | none | 1,000 | [
{
"input": "5 3\n-6 0 35 -2 4",
"output": "8"
},
{
"input": "4 2\n7 0 0 -7",
"output": "7"
},
{
"input": "6 6\n756 -611 251 -66 572 -818",
"output": "1495"
},
{
"input": "5 5\n976 437 937 788 518",
"output": "0"
},
{
"input": "5 3\n-2 -2 -2 -2 -2",
"output": "... | 1,596,265,879 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 2 | 248 | 20,172,800 | n,m = map(int, input().split())
ar = sorted([int(i) for i in input().split(' ')])
p = 0
for i in range(m):
if i==0:
p+=ar[i]
else:
if p<p+ar[i]:
print(p)
break
else:
p+=ar[i]
print(abs(p)) | Title: Sale
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Once Bob got to a sale of old TV sets. There were *n* TV sets at that sale. TV set with index *i* costs *a**i* bellars. Some TV sets have a negative price — their owners are ready to pay Bob if he buys their useless apparatus. Bob can... | ```python
n,m = map(int, input().split())
ar = sorted([int(i) for i in input().split(' ')])
p = 0
for i in range(m):
if i==0:
p+=ar[i]
else:
if p<p+ar[i]:
print(p)
break
else:
p+=ar[i]
print(abs(p))
``` | 0 |
59 | A | Word | PROGRAMMING | 800 | [
"implementation",
"strings"
] | A. Word | 2 | 256 | Vasya is very upset that many people on the Net mix uppercase and lowercase letters in one word. That's why he decided to invent an extension for his favorite browser that would change the letters' register in every word so that it either only consisted of lowercase letters or, vice versa, only of uppercase ones. At th... | The first line contains a word *s* — it consists of uppercase and lowercase Latin letters and possesses the length from 1 to 100. | Print the corrected word *s*. If the given word *s* has strictly more uppercase letters, make the word written in the uppercase register, otherwise - in the lowercase one. | [
"HoUse\n",
"ViP\n",
"maTRIx\n"
] | [
"house\n",
"VIP\n",
"matrix\n"
] | none | 500 | [
{
"input": "HoUse",
"output": "house"
},
{
"input": "ViP",
"output": "VIP"
},
{
"input": "maTRIx",
"output": "matrix"
},
{
"input": "BNHWpnpawg",
"output": "bnhwpnpawg"
},
{
"input": "VTYGP",
"output": "VTYGP"
},
{
"input": "CHNenu",
"output": "chn... | 1,593,155,232 | 2,147,483,647 | Python 3 | OK | TESTS | 30 | 218 | 6,656,000 | word = str(input())
low, up = 0, 0
for w in word:
if w.isupper():
up += 1
else:
low += 1
if low == up:
print(word.lower())
elif low < up:
print(word.upper())
else:
print(word.lower()) | Title: Word
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Vasya is very upset that many people on the Net mix uppercase and lowercase letters in one word. That's why he decided to invent an extension for his favorite browser that would change the letters' register in every word so that it ei... | ```python
word = str(input())
low, up = 0, 0
for w in word:
if w.isupper():
up += 1
else:
low += 1
if low == up:
print(word.lower())
elif low < up:
print(word.upper())
else:
print(word.lower())
``` | 3.933102 |
732 | A | Buy a Shovel | PROGRAMMING | 800 | [
"brute force",
"constructive algorithms",
"implementation",
"math"
] | null | null | Polycarp urgently needs a shovel! He comes to the shop and chooses an appropriate one. The shovel that Policarp chooses is sold for *k* burles. Assume that there is an unlimited number of such shovels in the shop.
In his pocket Polycarp has an unlimited number of "10-burle coins" and exactly one coin of *r* burles (1<... | The single line of input contains two integers *k* and *r* (1<=≤<=*k*<=≤<=1000, 1<=≤<=*r*<=≤<=9) — the price of one shovel and the denomination of the coin in Polycarp's pocket that is different from "10-burle coins".
Remember that he has an unlimited number of coins in the denomination of 10, that is, Polycarp has e... | Print the required minimum number of shovels Polycarp has to buy so that he can pay for them without any change. | [
"117 3\n",
"237 7\n",
"15 2\n"
] | [
"9\n",
"1\n",
"2\n"
] | In the first example Polycarp can buy 9 shovels and pay 9·117 = 1053 burles. Indeed, he can pay this sum by using 10-burle coins and one 3-burle coin. He can't buy fewer shovels without any change.
In the second example it is enough for Polycarp to buy one shovel.
In the third example Polycarp should buy two shovels ... | 500 | [
{
"input": "117 3",
"output": "9"
},
{
"input": "237 7",
"output": "1"
},
{
"input": "15 2",
"output": "2"
},
{
"input": "1 1",
"output": "1"
},
{
"input": "1 9",
"output": "9"
},
{
"input": "1000 3",
"output": "1"
},
{
"input": "1000 1",
... | 1,673,929,913 | 2,147,483,647 | Python 3 | OK | TESTS | 54 | 46 | 0 | c,r=map(int,input().split())
i=1
while 1:
if ((i*c)-r)%10==0 or (i*c)%10==0:
print(i)
break
else:
i+=1 | Title: Buy a Shovel
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Polycarp urgently needs a shovel! He comes to the shop and chooses an appropriate one. The shovel that Policarp chooses is sold for *k* burles. Assume that there is an unlimited number of such shovels in the shop.
In his ... | ```python
c,r=map(int,input().split())
i=1
while 1:
if ((i*c)-r)%10==0 or (i*c)%10==0:
print(i)
break
else:
i+=1
``` | 3 | |
189 | A | Cut Ribbon | PROGRAMMING | 1,300 | [
"brute force",
"dp"
] | null | null | Polycarpus has a ribbon, its length is *n*. He wants to cut the ribbon in a way that fulfils the following two conditions:
- After the cutting each ribbon piece should have length *a*, *b* or *c*. - After the cutting the number of ribbon pieces should be maximum.
Help Polycarpus and find the number of ribbon piece... | The first line contains four space-separated integers *n*, *a*, *b* and *c* (1<=≤<=*n*,<=*a*,<=*b*,<=*c*<=≤<=4000) — the length of the original ribbon and the acceptable lengths of the ribbon pieces after the cutting, correspondingly. The numbers *a*, *b* and *c* can coincide. | Print a single number — the maximum possible number of ribbon pieces. It is guaranteed that at least one correct ribbon cutting exists. | [
"5 5 3 2\n",
"7 5 5 2\n"
] | [
"2\n",
"2\n"
] | In the first example Polycarpus can cut the ribbon in such way: the first piece has length 2, the second piece has length 3.
In the second example Polycarpus can cut the ribbon in such way: the first piece has length 5, the second piece has length 2. | 500 | [
{
"input": "5 5 3 2",
"output": "2"
},
{
"input": "7 5 5 2",
"output": "2"
},
{
"input": "4 4 4 4",
"output": "1"
},
{
"input": "1 1 1 1",
"output": "1"
},
{
"input": "4000 1 2 3",
"output": "4000"
},
{
"input": "4000 3 4 5",
"output": "1333"
},
... | 1,694,778,012 | 2,147,483,647 | PyPy 3-64 | TIME_LIMIT_EXCEEDED | TESTS | 4 | 1,000 | 2,252,800 | n, a, b, c = map(int, input().split())
res = 0
for cnt_a in range(n+1):
for cnt_b in range(n+1):
for cnt_c in range(n+1):
if a*cnt_a + b*cnt_b + c*cnt_c == n:
res = max(res, cnt_a + cnt_b + cnt_c)
print(res) | Title: Cut Ribbon
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Polycarpus has a ribbon, its length is *n*. He wants to cut the ribbon in a way that fulfils the following two conditions:
- After the cutting each ribbon piece should have length *a*, *b* or *c*. - After the cutting the... | ```python
n, a, b, c = map(int, input().split())
res = 0
for cnt_a in range(n+1):
for cnt_b in range(n+1):
for cnt_c in range(n+1):
if a*cnt_a + b*cnt_b + c*cnt_c == n:
res = max(res, cnt_a + cnt_b + cnt_c)
print(res)
``` | 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,595,307,455 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 77 | 6,656,000 | #!/usr/bin/env python
# coding: utf-8
# In[5]:
x = input()
y = "hello"
# In[6]:
j = 0
# In[7]:
for i in range(len(x)):
if x[i] == x[j]:
j += 1
if j == 5:
print("YES")
break
# In[8]:
if j<5:
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
#!/usr/bin/env python
# coding: utf-8
# In[5]:
x = input()
y = "hello"
# In[6]:
j = 0
# In[7]:
for i in range(len(x)):
if x[i] == x[j]:
j += 1
if j == 5:
print("YES")
break
# In[8]:
if j<5:
print("NO")
``` | 0 |
460 | A | Vasya and Socks | PROGRAMMING | 900 | [
"brute force",
"implementation",
"math"
] | null | null | Vasya has *n* pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When he comes home in the evening, Vasya takes off the used socks and throws them away. Every *m*-th day (at days with numbers *m*,<=2*m*,<=3*m*,<=...) mom buys a pair of socks to Vasya. She does it la... | The single line contains two integers *n* and *m* (1<=≤<=*n*<=≤<=100; 2<=≤<=*m*<=≤<=100), separated by a space. | Print a single integer — the answer to the problem. | [
"2 2\n",
"9 3\n"
] | [
"3\n",
"13\n"
] | In the first sample Vasya spends the first two days wearing the socks that he had initially. Then on day three he puts on the socks that were bought on day two.
In the second sample Vasya spends the first nine days wearing the socks that he had initially. Then he spends three days wearing the socks that were bought on... | 500 | [
{
"input": "2 2",
"output": "3"
},
{
"input": "9 3",
"output": "13"
},
{
"input": "1 2",
"output": "1"
},
{
"input": "2 3",
"output": "2"
},
{
"input": "1 99",
"output": "1"
},
{
"input": "4 4",
"output": "5"
},
{
"input": "10 2",
"outp... | 1,651,810,245 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 26 | 62 | 0 | info = input().split()
socknum = int(info[0])
buyinterval = int(info[1])
counter = 0
while socknum != 0:
counter += 1
socknum -= 1
if counter % buyinterval == 0:
socknum += 1
print(counter) | Title: Vasya and Socks
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vasya has *n* pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When he comes home in the evening, Vasya takes off the used socks and throws them away. Every *m*-th... | ```python
info = input().split()
socknum = int(info[0])
buyinterval = int(info[1])
counter = 0
while socknum != 0:
counter += 1
socknum -= 1
if counter % buyinterval == 0:
socknum += 1
print(counter)
``` | 3 | |
61 | A | Ultra-Fast Mathematician | PROGRAMMING | 800 | [
"implementation"
] | A. Ultra-Fast Mathematician | 2 | 256 | Shapur was an extremely gifted student. He was great at everything including Combinatorics, Algebra, Number Theory, Geometry, Calculus, etc. He was not only smart but extraordinarily fast! He could manage to sum 1018 numbers in a single second.
One day in 230 AD Shapur was trying to find out if any one can possibly do... | There are two lines in each input. Each of them contains a single number. It is guaranteed that the numbers are made from 0 and 1 only and that their length is same. The numbers may start with 0. The length of each number doesn't exceed 100. | Write one line — the corresponding answer. Do not omit the leading 0s. | [
"1010100\n0100101\n",
"000\n111\n",
"1110\n1010\n",
"01110\n01100\n"
] | [
"1110001\n",
"111\n",
"0100\n",
"00010\n"
] | none | 500 | [
{
"input": "1010100\n0100101",
"output": "1110001"
},
{
"input": "000\n111",
"output": "111"
},
{
"input": "1110\n1010",
"output": "0100"
},
{
"input": "01110\n01100",
"output": "00010"
},
{
"input": "011101\n000001",
"output": "011100"
},
{
"input": "... | 1,696,407,203 | 2,147,483,647 | Python 3 | OK | TESTS | 102 | 46 | 0 | no1 = input()
no2 = input()
ans = ""
for idx in range(len(no1)):
ans += str(int(no1[idx]) ^ int(no2[idx]))
print(ans) | Title: Ultra-Fast Mathematician
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Shapur was an extremely gifted student. He was great at everything including Combinatorics, Algebra, Number Theory, Geometry, Calculus, etc. He was not only smart but extraordinarily fast! He could manage to sum 10... | ```python
no1 = input()
no2 = input()
ans = ""
for idx in range(len(no1)):
ans += str(int(no1[idx]) ^ int(no2[idx]))
print(ans)
``` | 3.9885 |
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,621,371,371 | 2,147,483,647 | PyPy 3 | OK | TESTS | 40 | 216 | 2,150,400 | import sys
s=input()
n=len(s)
l=0
u=0
for i in range(n):
if(ord(s[i])>=97):
l=min(l,u)
u+=1
else:
l=min(u,l)+1
print(min(u,l)) | 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
import sys
s=input()
n=len(s)
l=0
u=0
for i in range(n):
if(ord(s[i])>=97):
l=min(l,u)
u+=1
else:
l=min(u,l)+1
print(min(u,l))
``` | 3 | |
102 | B | Sum of Digits | PROGRAMMING | 1,000 | [
"implementation"
] | B. Sum of Digits | 2 | 265 | Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number *n*. How many times can Gerald put a spell on it until the number becomes one-... | The first line contains the only integer *n* (0<=≤<=*n*<=≤<=10100000). It is guaranteed that *n* doesn't contain any leading zeroes. | Print the number of times a number can be replaced by the sum of its digits until it only contains one digit. | [
"0\n",
"10\n",
"991\n"
] | [
"0\n",
"1\n",
"3\n"
] | In the first sample the number already is one-digit — Herald can't cast a spell.
The second test contains number 10. After one casting of a spell it becomes 1, and here the process is completed. Thus, Gerald can only cast the spell once.
The third test contains number 991. As one casts a spell the following transform... | 1,000 | [
{
"input": "0",
"output": "0"
},
{
"input": "10",
"output": "1"
},
{
"input": "991",
"output": "3"
},
{
"input": "99",
"output": "2"
},
{
"input": "100",
"output": "1"
},
{
"input": "123456789",
"output": "2"
},
{
"input": "32",
"output... | 1,621,843,315 | 2,147,483,647 | Python 3 | OK | TESTS | 51 | 592 | 0 | n = input()
c = 0
while int(n) > 9:
temp = 0
c += 1
for i in n :
temp += int(i)
n = str(temp)
# print(temp)
print(c) | Title: Sum of Digits
Time Limit: 2 seconds
Memory Limit: 265 megabytes
Problem Description:
Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came... | ```python
n = input()
c = 0
while int(n) > 9:
temp = 0
c += 1
for i in n :
temp += int(i)
n = str(temp)
# print(temp)
print(c)
``` | 3.852 |
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,937,643 | 6,943 | PyPy 3 | COMPILATION_ERROR | PRETESTS | 0 | 0 | 0 | #include<bits/stdc++.h>
using namespace std;
typedef int LL;
int main()
{
/*freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);*/
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
LL i,j,n,s=0,m=0,f[10000],temp[1000];
string a,b;
cin>>n;
cin>>a>>b;
for(i=0... | 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
#include<bits/stdc++.h>
using namespace std;
typedef int LL;
int main()
{
/*freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);*/
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
LL i,j,n,s=0,m=0,f[10000],temp[1000];
string a,b;
cin>>n;
cin>>a>>b;
... | -1 | |
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,516,857,301 | 661 | Python 3 | OK | TESTS | 44 | 62 | 5,632,000 | n, k = map(int, input().split())
l = 0
r = 10 ** 12 + 1
while r - l > 1:
d = (r + l) // 2
if n // (d*k + d) >= 2:
l = d
else:
r = d
d = l
g = d * k
sh = n - g - d
print(d, g, sh) | 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())
l = 0
r = 10 ** 12 + 1
while r - l > 1:
d = (r + l) // 2
if n // (d*k + d) >= 2:
l = d
else:
r = d
d = l
g = d * k
sh = n - g - d
print(d, g, sh)
``` | 3 | |
433 | B | Kuriyama Mirai's Stones | PROGRAMMING | 1,200 | [
"dp",
"implementation",
"sortings"
] | null | null | Kuriyama Mirai has killed many monsters and got many (namely *n*) stones. She numbers the stones from 1 to *n*. The cost of the *i*-th stone is *v**i*. Kuriyama Mirai wants to know something about these stones so she will ask you two kinds of questions:
1. She will tell you two numbers, *l* and *r* (1<=≤<=*l*<=≤<=*r*... | The first line contains an integer *n* (1<=≤<=*n*<=≤<=105). The second line contains *n* integers: *v*1,<=*v*2,<=...,<=*v**n* (1<=≤<=*v**i*<=≤<=109) — costs of the stones.
The third line contains an integer *m* (1<=≤<=*m*<=≤<=105) — the number of Kuriyama Mirai's questions. Then follow *m* lines, each line contains t... | Print *m* lines. Each line must contain an integer — the answer to Kuriyama Mirai's question. Print the answers to the questions in the order of input. | [
"6\n6 4 2 7 2 7\n3\n2 3 6\n1 3 4\n1 1 6\n",
"4\n5 5 2 3\n10\n1 2 4\n2 1 4\n1 1 1\n2 1 4\n2 1 2\n1 1 1\n1 3 3\n1 1 3\n1 4 4\n1 2 2\n"
] | [
"24\n9\n28\n",
"10\n15\n5\n15\n5\n5\n2\n12\n3\n5\n"
] | Please note that the answers to the questions may overflow 32-bit integer type. | 1,500 | [
{
"input": "6\n6 4 2 7 2 7\n3\n2 3 6\n1 3 4\n1 1 6",
"output": "24\n9\n28"
},
{
"input": "4\n5 5 2 3\n10\n1 2 4\n2 1 4\n1 1 1\n2 1 4\n2 1 2\n1 1 1\n1 3 3\n1 1 3\n1 4 4\n1 2 2",
"output": "10\n15\n5\n15\n5\n5\n2\n12\n3\n5"
},
{
"input": "4\n2 2 3 6\n9\n2 2 3\n1 1 3\n2 2 3\n2 2 3\n2 2 2\n1... | 1,696,096,034 | 2,147,483,647 | Python 3 | OK | TESTS | 46 | 904 | 17,510,400 | x = int(input())
totals = [0]
stones = list(map(int, input().split()))
for i in range(len(stones)):
totals.append(stones[i] + totals[i])
stones.sort()
others = [0]
for i in range(len(stones)):
others.append(stones[i] + others[i])
for i in range(int(input())):
a, b, c = map(int, input().split())
if a == ... | Title: Kuriyama Mirai's Stones
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Kuriyama Mirai has killed many monsters and got many (namely *n*) stones. She numbers the stones from 1 to *n*. The cost of the *i*-th stone is *v**i*. Kuriyama Mirai wants to know something about these stones s... | ```python
x = int(input())
totals = [0]
stones = list(map(int, input().split()))
for i in range(len(stones)):
totals.append(stones[i] + totals[i])
stones.sort()
others = [0]
for i in range(len(stones)):
others.append(stones[i] + others[i])
for i in range(int(input())):
a, b, c = map(int, input().split())
... | 3 | |
265 | A | Colorful Stones (Simplified Edition) | PROGRAMMING | 800 | [
"implementation"
] | null | null | There is a sequence of colorful stones. The color of each stone is one of red, green, or blue. You are given a string *s*. The *i*-th (1-based) character of *s* represents the color of the *i*-th stone. If the character is "R", "G", or "B", the color of the corresponding stone is red, green, or blue, respectively.
Ini... | The input contains two lines. The first line contains the string *s* (1<=≤<=|*s*|<=≤<=50). The second line contains the string *t* (1<=≤<=|*t*|<=≤<=50). The characters of each string will be one of "R", "G", or "B". It is guaranteed that Liss don't move out of the sequence. | Print the final 1-based position of Liss in a single line. | [
"RGB\nRRR\n",
"RRRBGBRBBB\nBBBRR\n",
"BRRBGBRGRBGRGRRGGBGBGBRGBRGRGGGRBRRRBRBBBGRRRGGBBB\nBBRBGGRGRGBBBRBGRBRBBBBRBRRRBGBBGBBRRBBGGRBRRBRGRB\n"
] | [
"2\n",
"3\n",
"15\n"
] | none | 500 | [
{
"input": "RGB\nRRR",
"output": "2"
},
{
"input": "RRRBGBRBBB\nBBBRR",
"output": "3"
},
{
"input": "BRRBGBRGRBGRGRRGGBGBGBRGBRGRGGGRBRRRBRBBBGRRRGGBBB\nBBRBGGRGRGBBBRBGRBRBBBBRBRRRBGBBGBBRRBBGGRBRRBRGRB",
"output": "15"
},
{
"input": "G\nRRBBRBRRBR",
"output": "1"
},
... | 1,657,893,480 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 19 | 122 | 0 | # 122 ms, 0KB
s = input()
t = input()
pos = 0
for i in range(len(t)):
if t[i] == s[pos]:
pos += 1
print(pos + 1)
# 124 ms, 0KB
"""
import sys
lst1, lst2 = [], []
pos = 0
string = sys.stdin.readline().strip()
instructions = sys.stdin.readline().strip()
for instruction in instructions:
... | Title: Colorful Stones (Simplified Edition)
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
There is a sequence of colorful stones. The color of each stone is one of red, green, or blue. You are given a string *s*. The *i*-th (1-based) character of *s* represents the color of the *i*-th st... | ```python
# 122 ms, 0KB
s = input()
t = input()
pos = 0
for i in range(len(t)):
if t[i] == s[pos]:
pos += 1
print(pos + 1)
# 124 ms, 0KB
"""
import sys
lst1, lst2 = [], []
pos = 0
string = sys.stdin.readline().strip()
instructions = sys.stdin.readline().strip()
for instruction in instru... | 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,646,868,837 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 30 | 0 | def somme(m,x,y,z):
a,b,c = 0,0,0
if m[0][0] == '-':
a=-int(m[0][1:])
else:
a=int(m[0])
if m[1][0] == '-':
b=-int(m[1][1:])
else:
b=int(m[1])
if m[2][0] == '-':
c=-int(m[2][1:])
else:
c=int(m[2])
print(m,a,b,c)
... | 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
def somme(m,x,y,z):
a,b,c = 0,0,0
if m[0][0] == '-':
a=-int(m[0][1:])
else:
a=int(m[0])
if m[1][0] == '-':
b=-int(m[1][1:])
else:
b=int(m[1])
if m[2][0] == '-':
c=-int(m[2][1:])
else:
c=int(m[2])
print(m,... | 0 |
283 | A | Cows and Sequence | PROGRAMMING | 1,600 | [
"constructive algorithms",
"data structures",
"implementation"
] | null | null | Bessie and the cows are playing with sequences and need your help. They start with a sequence, initially containing just the number 0, and perform *n* operations. Each operation is one of the following:
1. Add the integer *x**i* to the first *a**i* elements of the sequence. 1. Append an integer *k**i* to the end of ... | The first line contains a single integer *n* (1<=≤<=*n*<=≤<=2·105) — the number of operations. The next *n* lines describe the operations. Each line will start with an integer *t**i* (1<=≤<=*t**i*<=≤<=3), denoting the type of the operation (see above). If *t**i*<==<=1, it will be followed by two integers *a**i*,<=*x**i... | Output *n* lines each containing the average of the numbers in the sequence after the corresponding operation.
The answer will be considered correct if its absolute or relative error doesn't exceed 10<=-<=6. | [
"5\n2 1\n3\n2 3\n2 1\n3\n",
"6\n2 1\n1 2 20\n2 2\n1 2 -3\n3\n3\n"
] | [
"0.500000\n0.000000\n1.500000\n1.333333\n1.500000\n",
"0.500000\n20.500000\n14.333333\n12.333333\n17.500000\n17.000000\n"
] | In the second sample, the sequence becomes <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/fb5aaaa5dc516fe540cef52fd153768bfdb941c8.png" style="max-width: 100.0%;max-height: 100.0%;"/> | 1,000 | [
{
"input": "5\n2 1\n3\n2 3\n2 1\n3",
"output": "0.500000\n0.000000\n1.500000\n1.333333\n1.500000"
},
{
"input": "6\n2 1\n1 2 20\n2 2\n1 2 -3\n3\n3",
"output": "0.500000\n20.500000\n14.333333\n12.333333\n17.500000\n17.000000"
},
{
"input": "1\n1 1 1",
"output": "1.000000"
},
{
... | 1,417,864,397 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 8 | 3,000 | 307,200 | import sys
import math
n = int(sys.stdin.readline())
k = [0]
c = 1
for i in range(n):
t = [int(x) for x in (sys.stdin.readline()).split()]
if(t[0] == 1):
for i in range(t[1]):
k[i] += t[2]
elif(t[0] == 2):
k.append(t[1])
c += 1
elif(t[0] == 3 and c >=... | Title: Cows and Sequence
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Bessie and the cows are playing with sequences and need your help. They start with a sequence, initially containing just the number 0, and perform *n* operations. Each operation is one of the following:
1. Add the i... | ```python
import sys
import math
n = int(sys.stdin.readline())
k = [0]
c = 1
for i in range(n):
t = [int(x) for x in (sys.stdin.readline()).split()]
if(t[0] == 1):
for i in range(t[1]):
k[i] += t[2]
elif(t[0] == 2):
k.append(t[1])
c += 1
elif(t[0] == ... | 0 | |
659 | A | Round House | PROGRAMMING | 1,000 | [
"implementation",
"math"
] | null | null | Vasya lives in a round building, whose entrances are numbered sequentially by integers from 1 to *n*. Entrance *n* and entrance 1 are adjacent.
Today Vasya got bored and decided to take a walk in the yard. Vasya lives in entrance *a* and he decided that during his walk he will move around the house *b* entrances in th... | The single line of the input contains three space-separated integers *n*, *a* and *b* (1<=≤<=*n*<=≤<=100,<=1<=≤<=*a*<=≤<=*n*,<=<=-<=100<=≤<=*b*<=≤<=100) — the number of entrances at Vasya's place, the number of his entrance and the length of his walk, respectively. | Print a single integer *k* (1<=≤<=*k*<=≤<=*n*) — the number of the entrance where Vasya will be at the end of his walk. | [
"6 2 -5\n",
"5 1 3\n",
"3 2 7\n"
] | [
"3\n",
"4\n",
"3\n"
] | The first example is illustrated by the picture in the statements. | 500 | [
{
"input": "6 2 -5",
"output": "3"
},
{
"input": "5 1 3",
"output": "4"
},
{
"input": "3 2 7",
"output": "3"
},
{
"input": "1 1 0",
"output": "1"
},
{
"input": "1 1 -1",
"output": "1"
},
{
"input": "1 1 1",
"output": "1"
},
{
"input": "100 ... | 1,559,092,134 | 2,147,483,647 | Python 3 | OK | TESTS | 50 | 108 | 0 | def go_to(starts,ends,numbers):
return ((starts%numbers)+(ends%numbers))%numbers
n = input().split()
k = go_to(int(n[1]),int(n[2]),int(n[0]))
if k == 0:
print(int(n[0]))
else:
print(k) | Title: Round House
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vasya lives in a round building, whose entrances are numbered sequentially by integers from 1 to *n*. Entrance *n* and entrance 1 are adjacent.
Today Vasya got bored and decided to take a walk in the yard. Vasya lives in e... | ```python
def go_to(starts,ends,numbers):
return ((starts%numbers)+(ends%numbers))%numbers
n = input().split()
k = go_to(int(n[1]),int(n[2]),int(n[0]))
if k == 0:
print(int(n[0]))
else:
print(k)
``` | 3 | |
1 | A | Theatre Square | PROGRAMMING | 1,000 | [
"math"
] | A. Theatre Square | 1 | 256 | Theatre Square in the capital city of Berland has a rectangular shape with the size *n*<=×<=*m* meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the size *a*<=×<=*a*.
What is the least number of flagstones needed to pave the... | The input contains three positive integer numbers in the first line: *n*,<=<=*m* and *a* (1<=≤<=<=*n*,<=*m*,<=*a*<=≤<=109). | Write the needed number of flagstones. | [
"6 6 4\n"
] | [
"4\n"
] | none | 0 | [
{
"input": "6 6 4",
"output": "4"
},
{
"input": "1 1 1",
"output": "1"
},
{
"input": "2 1 1",
"output": "2"
},
{
"input": "1 2 1",
"output": "2"
},
{
"input": "2 2 1",
"output": "4"
},
{
"input": "2 1 2",
"output": "1"
},
{
"input": "1 1 3"... | 1,694,432,600 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 31 | 0 | lista = list(map(int, input().split()))
n = lista[0]
m = lista[1]
a = lista[2]
if n*m > 1:
cal = (n*m)/(a*a)
number = int(cal * 2)
else:
number = 1
print(number)
| Title: Theatre Square
Time Limit: 1 seconds
Memory Limit: 256 megabytes
Problem Description:
Theatre Square in the capital city of Berland has a rectangular shape with the size *n*<=×<=*m* meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each ... | ```python
lista = list(map(int, input().split()))
n = lista[0]
m = lista[1]
a = lista[2]
if n*m > 1:
cal = (n*m)/(a*a)
number = int(cal * 2)
else:
number = 1
print(number)
``` | 0 |
35 | A | Shell Game | PROGRAMMING | 1,000 | [
"implementation"
] | A. Shell Game | 2 | 64 | Today the «Z» city residents enjoy a shell game competition. The residents are gathered on the main square to watch the breath-taking performance. The performer puts 3 non-transparent cups upside down in a row. Then he openly puts a small ball under one of the cups and starts to shuffle the cups around very quickly so ... | The first input line contains an integer from 1 to 3 — index of the cup which covers the ball before the shuffles. The following three lines describe the shuffles. Each description of a shuffle contains two distinct integers from 1 to 3 — indexes of the cups which the performer shuffled this time. The cups are numbered... | In the first line output an integer from 1 to 3 — index of the cup which will have the ball after all the shuffles. | [
"1\n1 2\n2 1\n2 1\n",
"1\n2 1\n3 1\n1 3\n"
] | [
"2\n",
"2\n"
] | none | 500 | [
{
"input": "1\n1 2\n2 1\n2 1",
"output": "2"
},
{
"input": "1\n2 1\n3 1\n1 3",
"output": "2"
},
{
"input": "3\n3 1\n2 1\n1 2",
"output": "1"
},
{
"input": "1\n1 3\n1 2\n2 3",
"output": "2"
},
{
"input": "3\n3 2\n3 1\n3 1",
"output": "2"
},
{
"input": "... | 1,590,935,640 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 186 | 0 | n=int(input(""))
l=[0]*3
l[n-1]=1
for i in range(3):
a,b=map(int,input().split())
if(a==n):
l[b-1]==1
l[n-1]==0
n=b
elif(b==n):
l[a-1]==1
l[n-1]==0
n=a
print(n) | Title: Shell Game
Time Limit: 2 seconds
Memory Limit: 64 megabytes
Problem Description:
Today the «Z» city residents enjoy a shell game competition. The residents are gathered on the main square to watch the breath-taking performance. The performer puts 3 non-transparent cups upside down in a row. Then he openly put... | ```python
n=int(input(""))
l=[0]*3
l[n-1]=1
for i in range(3):
a,b=map(int,input().split())
if(a==n):
l[b-1]==1
l[n-1]==0
n=b
elif(b==n):
l[a-1]==1
l[n-1]==0
n=a
print(n)
``` | -1 |
577 | A | Multiplication Table | PROGRAMMING | 1,000 | [
"implementation",
"number theory"
] | null | null | Let's consider a table consisting of *n* rows and *n* columns. The cell located at the intersection of *i*-th row and *j*-th column contains number *i*<=×<=*j*. The rows and columns are numbered starting from 1.
You are given a positive integer *x*. Your task is to count the number of cells in a table that contain num... | The single line contains numbers *n* and *x* (1<=≤<=*n*<=≤<=105, 1<=≤<=*x*<=≤<=109) — the size of the table and the number that we are looking for in the table. | Print a single number: the number of times *x* occurs in the table. | [
"10 5\n",
"6 12\n",
"5 13\n"
] | [
"2\n",
"4\n",
"0\n"
] | A table for the second sample test is given below. The occurrences of number 12 are marked bold. | 500 | [
{
"input": "10 5",
"output": "2"
},
{
"input": "6 12",
"output": "4"
},
{
"input": "5 13",
"output": "0"
},
{
"input": "1 1",
"output": "1"
},
{
"input": "2 1",
"output": "1"
},
{
"input": "100000 1",
"output": "1"
},
{
"input": "1 10000000... | 1,687,780,665 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 47 | 77 | 1,638,400 | import bisect
left = lambda l,a : bisect.bisect_left(l,a) #returns index of value>=a
right = lambda l,a : bisect.bisect_right(l,a) #returns index of value >a
import sys
def input(): return sys.stdin.readline().strip()
def getints(): return map(int,sys.stdin.readline().strip().split())
n,x = getints()
ans = 0... | Title: Multiplication Table
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Let's consider a table consisting of *n* rows and *n* columns. The cell located at the intersection of *i*-th row and *j*-th column contains number *i*<=×<=*j*. The rows and columns are numbered starting from 1.
Y... | ```python
import bisect
left = lambda l,a : bisect.bisect_left(l,a) #returns index of value>=a
right = lambda l,a : bisect.bisect_right(l,a) #returns index of value >a
import sys
def input(): return sys.stdin.readline().strip()
def getints(): return map(int,sys.stdin.readline().strip().split())
n,x = getints(... | 3 | |
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,673,618,416 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 19 | 92 | 0 | def is_prime(n):
if n <= 1:
return False
for i in range(2, int(n ** 0.5) + 1):
if n % i == 0:
return False
return True
def next_prime():
f, s = map(int, input().split())
if not is_prime(s):
return 'NO'
included = list(range(f+1, s))
if len(included) == 0 a... | Title: Panoramix's Prediction
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
A prime number is a number which has exactly two distinct divisors: one and itself. For example, numbers 2, 7, 3 are prime, and 1, 6, 4 are not.
The next prime number after *x* is the smallest prime number greater t... | ```python
def is_prime(n):
if n <= 1:
return False
for i in range(2, int(n ** 0.5) + 1):
if n % i == 0:
return False
return True
def next_prime():
f, s = map(int, input().split())
if not is_prime(s):
return 'NO'
included = list(range(f+1, s))
if len(includ... | 0 |
814 | A | An abandoned sentiment from past | PROGRAMMING | 900 | [
"constructive algorithms",
"greedy",
"implementation",
"sortings"
] | null | null | A few years ago, Hitagi encountered a giant crab, who stole the whole of her body weight. Ever since, she tried to avoid contact with others, for fear that this secret might be noticed.
To get rid of the oddity and recover her weight, a special integer sequence is needed. Hitagi's sequence has been broken for a long t... | The first line of input contains two space-separated positive integers *n* (2<=≤<=*n*<=≤<=100) and *k* (1<=≤<=*k*<=≤<=*n*) — the lengths of sequence *a* and *b* respectively.
The second line contains *n* space-separated integers *a*1,<=*a*2,<=...,<=*a**n* (0<=≤<=*a**i*<=≤<=200) — Hitagi's broken sequence with exactly ... | Output "Yes" if it's possible to replace zeros in *a* with elements in *b* and make the resulting sequence not increasing, and "No" otherwise. | [
"4 2\n11 0 0 14\n5 4\n",
"6 1\n2 3 0 8 9 10\n5\n",
"4 1\n8 94 0 4\n89\n",
"7 7\n0 0 0 0 0 0 0\n1 2 3 4 5 6 7\n"
] | [
"Yes\n",
"No\n",
"Yes\n",
"Yes\n"
] | In the first sample:
- Sequence *a* is 11, 0, 0, 14. - Two of the elements are lost, and the candidates in *b* are 5 and 4. - There are two possible resulting sequences: 11, 5, 4, 14 and 11, 4, 5, 14, both of which fulfill the requirements. Thus the answer is "Yes".
In the second sample, the only possible resulti... | 500 | [
{
"input": "4 2\n11 0 0 14\n5 4",
"output": "Yes"
},
{
"input": "6 1\n2 3 0 8 9 10\n5",
"output": "No"
},
{
"input": "4 1\n8 94 0 4\n89",
"output": "Yes"
},
{
"input": "7 7\n0 0 0 0 0 0 0\n1 2 3 4 5 6 7",
"output": "Yes"
},
{
"input": "40 1\n23 26 27 28 31 35 38 4... | 1,595,367,116 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 93 | 6,963,200 |
n , m = map(int,input().split())
l1 = list(map(int,input().split()))
l2 = list(map(int,input().split()))
l2.sort(reverse= True)
if n == m and len(set(l2)) == n :
print('Yes')
exit()
elif m == 1 :
for i in range(n):
if l1[i] == 0 :
l1[i] = l2[0]
if sorted(l1) == ... | Title: An abandoned sentiment from past
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
A few years ago, Hitagi encountered a giant crab, who stole the whole of her body weight. Ever since, she tried to avoid contact with others, for fear that this secret might be noticed.
To get rid of t... | ```python
n , m = map(int,input().split())
l1 = list(map(int,input().split()))
l2 = list(map(int,input().split()))
l2.sort(reverse= True)
if n == m and len(set(l2)) == n :
print('Yes')
exit()
elif m == 1 :
for i in range(n):
if l1[i] == 0 :
l1[i] = l2[0]
if sort... | -1 | |
602 | A | Two Bases | PROGRAMMING | 1,100 | [
"brute force",
"implementation"
] | null | null | After seeing the "ALL YOUR BASE ARE BELONG TO US" meme for the first time, numbers *X* and *Y* realised that they have different bases, which complicated their relations.
You're given a number *X* represented in base *b**x* and a number *Y* represented in base *b**y*. Compare those two numbers. | The first line of the input contains two space-separated integers *n* and *b**x* (1<=≤<=*n*<=≤<=10, 2<=≤<=*b**x*<=≤<=40), where *n* is the number of digits in the *b**x*-based representation of *X*.
The second line contains *n* space-separated integers *x*1,<=*x*2,<=...,<=*x**n* (0<=≤<=*x**i*<=<<=*b**x*) — the dig... | Output a single character (quotes for clarity):
- '<' if *X*<=<<=*Y* - '>' if *X*<=><=*Y* - '=' if *X*<==<=*Y* | [
"6 2\n1 0 1 1 1 1\n2 10\n4 7\n",
"3 3\n1 0 2\n2 5\n2 4\n",
"7 16\n15 15 4 0 0 7 10\n7 9\n4 8 0 3 1 5 0\n"
] | [
"=\n",
"<\n",
">\n"
] | In the first sample, *X* = 101111<sub class="lower-index">2</sub> = 47<sub class="lower-index">10</sub> = *Y*.
In the second sample, *X* = 102<sub class="lower-index">3</sub> = 21<sub class="lower-index">5</sub> and *Y* = 24<sub class="lower-index">5</sub> = 112<sub class="lower-index">3</sub>, thus *X* < *Y*.
In ... | 500 | [
{
"input": "6 2\n1 0 1 1 1 1\n2 10\n4 7",
"output": "="
},
{
"input": "3 3\n1 0 2\n2 5\n2 4",
"output": "<"
},
{
"input": "7 16\n15 15 4 0 0 7 10\n7 9\n4 8 0 3 1 5 0",
"output": ">"
},
{
"input": "2 2\n1 0\n2 3\n1 0",
"output": "<"
},
{
"input": "2 2\n1 0\n1 3\n1"... | 1,612,434,999 | 2,147,483,647 | Python 3 | OK | TESTS | 118 | 77 | 307,200 | n,b1=map(int,input().split())
x=list(map(int,input().split()))
m,b2=map(int,input().split())
y=list(map(int,input().split()))
x=x[::-1]
y=y[::-1]
ans1 = 0
for i in range(n):
ans1+=(b1**i)*x[i]
ans2 = 0
for i in range(m):
ans2+=(b2**i)*y[i]
if ans1==ans2:
print("=")
elif ans1<ans2:
print("<")
else:
... | Title: Two Bases
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
After seeing the "ALL YOUR BASE ARE BELONG TO US" meme for the first time, numbers *X* and *Y* realised that they have different bases, which complicated their relations.
You're given a number *X* represented in base *b**x* ... | ```python
n,b1=map(int,input().split())
x=list(map(int,input().split()))
m,b2=map(int,input().split())
y=list(map(int,input().split()))
x=x[::-1]
y=y[::-1]
ans1 = 0
for i in range(n):
ans1+=(b1**i)*x[i]
ans2 = 0
for i in range(m):
ans2+=(b2**i)*y[i]
if ans1==ans2:
print("=")
elif ans1<ans2:
print("<... | 3 | |
189 | A | Cut Ribbon | PROGRAMMING | 1,300 | [
"brute force",
"dp"
] | null | null | Polycarpus has a ribbon, its length is *n*. He wants to cut the ribbon in a way that fulfils the following two conditions:
- After the cutting each ribbon piece should have length *a*, *b* or *c*. - After the cutting the number of ribbon pieces should be maximum.
Help Polycarpus and find the number of ribbon piece... | The first line contains four space-separated integers *n*, *a*, *b* and *c* (1<=≤<=*n*,<=*a*,<=*b*,<=*c*<=≤<=4000) — the length of the original ribbon and the acceptable lengths of the ribbon pieces after the cutting, correspondingly. The numbers *a*, *b* and *c* can coincide. | Print a single number — the maximum possible number of ribbon pieces. It is guaranteed that at least one correct ribbon cutting exists. | [
"5 5 3 2\n",
"7 5 5 2\n"
] | [
"2\n",
"2\n"
] | In the first example Polycarpus can cut the ribbon in such way: the first piece has length 2, the second piece has length 3.
In the second example Polycarpus can cut the ribbon in such way: the first piece has length 5, the second piece has length 2. | 500 | [
{
"input": "5 5 3 2",
"output": "2"
},
{
"input": "7 5 5 2",
"output": "2"
},
{
"input": "4 4 4 4",
"output": "1"
},
{
"input": "1 1 1 1",
"output": "1"
},
{
"input": "4000 1 2 3",
"output": "4000"
},
{
"input": "4000 3 4 5",
"output": "1333"
},
... | 1,681,138,318 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 4 | 61 | 0 | n,a,b,c=map(int,input().split())
s=[a,b,c]
s.sort()
cnt=0
for i in range(len(s)):
if(n>0):
n=n-s[i]
cnt+=1
print(cnt)
| Title: Cut Ribbon
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Polycarpus has a ribbon, its length is *n*. He wants to cut the ribbon in a way that fulfils the following two conditions:
- After the cutting each ribbon piece should have length *a*, *b* or *c*. - After the cutting the... | ```python
n,a,b,c=map(int,input().split())
s=[a,b,c]
s.sort()
cnt=0
for i in range(len(s)):
if(n>0):
n=n-s[i]
cnt+=1
print(cnt)
``` | 0 | |
519 | B | A and B and Compilation Errors | PROGRAMMING | 1,100 | [
"data structures",
"implementation",
"sortings"
] | null | null | A and B are preparing themselves for programming contests.
B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code.
Initially, the compiler displayed *n* compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix... | The first line of the input contains integer *n* (3<=≤<=*n*<=≤<=105) — the initial number of compilation errors.
The second line contains *n* space-separated integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=109) — the errors the compiler displayed for the first time.
The third line contains *n*<=-<=1 space-sepa... | Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively. | [
"5\n1 5 8 123 7\n123 7 5 1\n5 1 7\n",
"6\n1 4 3 3 5 7\n3 7 5 4 3\n4 3 7 5\n"
] | [
"8\n123\n",
"1\n3\n"
] | In the first test sample B first corrects the error number 8, then the error number 123.
In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. | 1,000 | [
{
"input": "5\n1 5 8 123 7\n123 7 5 1\n5 1 7",
"output": "8\n123"
},
{
"input": "6\n1 4 3 3 5 7\n3 7 5 4 3\n4 3 7 5",
"output": "1\n3"
},
{
"input": "3\n1 2 3\n3 2\n2",
"output": "1\n3"
},
{
"input": "10\n460626451 802090732 277246428 661369649 388684428 784303821 376287098 6... | 1,681,160,071 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 33 | 124 | 22,118,400 | n = int(input())
arr = list(map(int, input().split()))
arr2 = list(map(int, input().split()))
arr3 = list(map(int, input().split()))
print(sum(arr) - sum(arr2))
print(sum(arr2) - sum(arr3)) | Title: A and B and Compilation Errors
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
A and B are preparing themselves for programming contests.
B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code.
Initially, the compiler disp... | ```python
n = int(input())
arr = list(map(int, input().split()))
arr2 = list(map(int, input().split()))
arr3 = list(map(int, input().split()))
print(sum(arr) - sum(arr2))
print(sum(arr2) - sum(arr3))
``` | 3 | |
361 | A | Levko and Table | PROGRAMMING | 800 | [
"constructive algorithms",
"implementation"
] | null | null | Levko loves tables that consist of *n* rows and *n* columns very much. He especially loves beautiful tables. A table is beautiful to Levko if the sum of elements in each row and column of the table equals *k*.
Unfortunately, he doesn't know any such table. Your task is to help him to find at least one of them. | The single line contains two integers, *n* and *k* (1<=≤<=*n*<=≤<=100, 1<=≤<=*k*<=≤<=1000). | Print any beautiful table. Levko doesn't like too big numbers, so all elements of the table mustn't exceed 1000 in their absolute value.
If there are multiple suitable tables, you are allowed to print any of them. | [
"2 4\n",
"4 7\n"
] | [
"1 3\n3 1\n",
"2 1 0 4\n4 0 2 1\n1 3 3 0\n0 3 2 2\n"
] | In the first sample the sum in the first row is 1 + 3 = 4, in the second row — 3 + 1 = 4, in the first column — 1 + 3 = 4 and in the second column — 3 + 1 = 4. There are other beautiful tables for this sample.
In the second sample the sum of elements in each row and each column equals 7. Besides, there are other table... | 500 | [
{
"input": "2 4",
"output": "4 0 \n0 4 "
},
{
"input": "4 7",
"output": "7 0 0 0 \n0 7 0 0 \n0 0 7 0 \n0 0 0 7 "
},
{
"input": "1 8",
"output": "8 "
},
{
"input": "9 3",
"output": "3 0 0 0 0 0 0 0 0 \n0 3 0 0 0 0 0 0 0 \n0 0 3 0 0 0 0 0 0 \n0 0 0 3 0 0 0 0 0 \n0 0 0 0 3 0... | 1,691,064,037 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 22 | 109 | 3,276,800 | # Wadea #
n,k = map(int,input().split());arr = [0] * n
for i in range(n):m = arr.copy() ;m[i] = k;print(*m) | Title: Levko and Table
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Levko loves tables that consist of *n* rows and *n* columns very much. He especially loves beautiful tables. A table is beautiful to Levko if the sum of elements in each row and column of the table equals *k*.
Unfortun... | ```python
# Wadea #
n,k = map(int,input().split());arr = [0] * n
for i in range(n):m = arr.copy() ;m[i] = k;print(*m)
``` | 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,696,749,795 | 2,147,483,647 | PyPy 3-64 | RUNTIME_ERROR | TESTS | 0 | 154 | 2,969,600 | t=int(input())
L={}
for i in range(t):
L.add(t/i)
flag=1
for i in L:
if i%2==0:
flag=1
else:
flag=0
break
if flag==0:
print('NO')
else:
print('YES') | 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
t=int(input())
L={}
for i in range(t):
L.add(t/i)
flag=1
for i in L:
if i%2==0:
flag=1
else:
flag=0
break
if flag==0:
print('NO')
else:
print('YES')
``` | -1 |
109 | A | Lucky Sum of Digits | PROGRAMMING | 1,000 | [
"brute force",
"implementation"
] | A. Lucky Sum of Digits | 2 | 256 | Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya wonders eagerly what minimum lucky number has the sum of digits equal to *n*. Help him cope wi... | The single line contains an integer *n* (1<=≤<=*n*<=≤<=106) — the sum of digits of the required lucky number. | Print on the single line the result — the minimum lucky number, whose sum of digits equals *n*. If such number does not exist, print -1. | [
"11\n",
"10\n"
] | [
"47\n",
"-1\n"
] | none | 500 | [
{
"input": "11",
"output": "47"
},
{
"input": "10",
"output": "-1"
},
{
"input": "64",
"output": "4477777777"
},
{
"input": "1",
"output": "-1"
},
{
"input": "4",
"output": "4"
},
{
"input": "7",
"output": "7"
},
{
"input": "12",
"outpu... | 1,556,594,654 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 2 | 278 | 0 | n = int(input())
a = 1
b = 1
b_inc_list = list()
while(1):
if((a*4+b*7) > n):
print(-1)
exit()
a = (n-(b*7))/4
if(a.is_integer()):
for i in range(int(a)):
b_inc_list.append(4)
for i in range(b):
b_inc_list.append(7)
break
else:
... | Title: Lucky Sum of Digits
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
... | ```python
n = int(input())
a = 1
b = 1
b_inc_list = list()
while(1):
if((a*4+b*7) > n):
print(-1)
exit()
a = (n-(b*7))/4
if(a.is_integer()):
for i in range(int(a)):
b_inc_list.append(4)
for i in range(b):
b_inc_list.append(7)
break
el... | 0 |
381 | A | Sereja and Dima | PROGRAMMING | 800 | [
"greedy",
"implementation",
"two pointers"
] | null | null | Sereja and Dima play a game. The rules of the game are very simple. The players have *n* cards in a row. Each card contains a number, all numbers on the cards are distinct. The players take turns, Sereja moves first. During his turn a player can take one card: either the leftmost card in a row, or the rightmost one. Th... | The first line contains integer *n* (1<=≤<=*n*<=≤<=1000) — the number of cards on the table. The second line contains space-separated numbers on the cards from left to right. The numbers on the cards are distinct integers from 1 to 1000. | On a single line, print two integers. The first number is the number of Sereja's points at the end of the game, the second number is the number of Dima's points at the end of the game. | [
"4\n4 1 2 10\n",
"7\n1 2 3 4 5 6 7\n"
] | [
"12 5\n",
"16 12\n"
] | In the first sample Sereja will take cards with numbers 10 and 2, so Sereja's sum is 12. Dima will take cards with numbers 4 and 1, so Dima's sum is 5. | 500 | [
{
"input": "4\n4 1 2 10",
"output": "12 5"
},
{
"input": "7\n1 2 3 4 5 6 7",
"output": "16 12"
},
{
"input": "42\n15 29 37 22 16 5 26 31 6 32 19 3 45 36 33 14 25 20 48 7 42 11 24 28 9 18 8 21 47 17 38 40 44 4 35 1 43 39 41 27 12 13",
"output": "613 418"
},
{
"input": "43\n32 ... | 1,688,413,851 | 2,147,483,647 | Python 3 | COMPILATION_ERROR | TESTS | 0 | 0 | 0 | #include <iostream>
using namespace std;
int main()
{
int n;cin>>n;
int v[n];
for(int i=0;i<n;i++){
cin>>v[i];
}
int Ser=0,Dima=0;
bool Sereja=1;
int i=0,j=n-1;
while(i<=j){
int x;
if (v[i]>v[j]){
x=v[i];
i++;
}... | Title: Sereja and Dima
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Sereja and Dima play a game. The rules of the game are very simple. The players have *n* cards in a row. Each card contains a number, all numbers on the cards are distinct. The players take turns, Sereja moves first. Du... | ```python
#include <iostream>
using namespace std;
int main()
{
int n;cin>>n;
int v[n];
for(int i=0;i<n;i++){
cin>>v[i];
}
int Ser=0,Dima=0;
bool Sereja=1;
int i=0,j=n-1;
while(i<=j){
int x;
if (v[i]>v[j]){
x=v[i];
i++;
... | -1 | |
50 | A | Domino piling | PROGRAMMING | 800 | [
"greedy",
"math"
] | A. Domino piling | 2 | 256 | You are given a rectangular board of *M*<=×<=*N* squares. Also you are given an unlimited number of standard domino pieces of 2<=×<=1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as possible on the board so as to meet the following conditions:
1. Each domino completely covers ... | In a single line you are given two integers *M* and *N* — board sizes in squares (1<=≤<=*M*<=≤<=*N*<=≤<=16). | Output one number — the maximal number of dominoes, which can be placed. | [
"2 4\n",
"3 3\n"
] | [
"4\n",
"4\n"
] | none | 500 | [
{
"input": "2 4",
"output": "4"
},
{
"input": "3 3",
"output": "4"
},
{
"input": "1 5",
"output": "2"
},
{
"input": "1 6",
"output": "3"
},
{
"input": "1 15",
"output": "7"
},
{
"input": "1 16",
"output": "8"
},
{
"input": "2 5",
"outpu... | 1,640,026,972 | 2,147,483,647 | Python 3 | OK | TESTS | 35 | 92 | 0 | inp = input()
inp2 = inp.split(" ")
k = int(inp2[0]) * int(inp2[1])
if k % 2 == 0:
j = k/2
else:
j = (k - 1)/2
print(int(j))
| Title: Domino piling
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
You are given a rectangular board of *M*<=×<=*N* squares. Also you are given an unlimited number of standard domino pieces of 2<=×<=1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as p... | ```python
inp = input()
inp2 = inp.split(" ")
k = int(inp2[0]) * int(inp2[1])
if k % 2 == 0:
j = k/2
else:
j = (k - 1)/2
print(int(j))
``` | 3.977 |
620 | B | Grandfather Dovlet’s calculator | PROGRAMMING | 1,000 | [
"implementation"
] | null | null | Once Max found an electronic calculator from his grandfather Dovlet's chest. He noticed that the numbers were written with seven-segment indicators ([https://en.wikipedia.org/wiki/Seven-segment_display](https://en.wikipedia.org/wiki/Seven-segment_display)).
Max starts to type all the values from *a* to *b*. After typi... | The only line contains two integers *a*,<=*b* (1<=≤<=*a*<=≤<=*b*<=≤<=106) — the first and the last number typed by Max. | Print the only integer *a* — the total number of printed segments. | [
"1 3\n",
"10 15\n"
] | [
"12\n",
"39\n"
] | none | 0 | [
{
"input": "1 3",
"output": "12"
},
{
"input": "10 15",
"output": "39"
},
{
"input": "1 100",
"output": "928"
},
{
"input": "100 10000",
"output": "188446"
},
{
"input": "213 221442",
"output": "5645356"
},
{
"input": "1 1000000",
"output": "287333... | 1,670,298,199 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 5 | 1,000 | 0 | a,b=map(int,input().split())
cnt=0
for i in range(a,b+1):
while i>0:
if i%10==0 or i%10==6 or i%10==9:
cnt+=6
i=i//10
elif i%10==1:
cnt+=2
i=i//10
elif i%10==2 or i%10==3 or i%10==5:
cnt+=5
i=i//10
e... | Title: Grandfather Dovlet’s calculator
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Once Max found an electronic calculator from his grandfather Dovlet's chest. He noticed that the numbers were written with seven-segment indicators ([https://en.wikipedia.org/wiki/Seven-segment_display](... | ```python
a,b=map(int,input().split())
cnt=0
for i in range(a,b+1):
while i>0:
if i%10==0 or i%10==6 or i%10==9:
cnt+=6
i=i//10
elif i%10==1:
cnt+=2
i=i//10
elif i%10==2 or i%10==3 or i%10==5:
cnt+=5
i=i//10
... | 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,038,896 | 996 | Python 3 | WRONG_ANSWER | PRETESTS | 3 | 46 | 5,529,600 | v = list( map( int, input().split() ) )
ans = []
for i in range( 0, 3 ):
for b in range( 1, 101 ):
if v[i] <= b and v[-1] <= b and 2*v[i] >= b:
if i == 2:
if 2*v[-1] >= b:
ans.append( b )
break
else:
... | 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
v = list( map( int, input().split() ) )
ans = []
for i in range( 0, 3 ):
for b in range( 1, 101 ):
if v[i] <= b and v[-1] <= b and 2*v[i] >= b:
if i == 2:
if 2*v[-1] >= b:
ans.append( b )
break
else:
... | 0 |
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.