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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
296 | A | Yaroslav and Permutations | PROGRAMMING | 1,100 | [
"greedy",
"math"
] | null | null | Yaroslav has an array that consists of *n* integers. In one second Yaroslav can swap two neighboring array elements. Now Yaroslav is wondering if he can obtain an array where any two neighboring elements would be distinct in a finite time.
Help Yaroslav. | The first line contains integer *n* (1<=≤<=*n*<=≤<=100) — the number of elements in the array. The second line contains *n* integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=1000) — the array elements. | In the single line print "YES" (without the quotes) if Yaroslav can obtain the array he needs, and "NO" (without the quotes) otherwise. | [
"1\n1\n",
"3\n1 1 2\n",
"4\n7 7 7 7\n"
] | [
"YES\n",
"YES\n",
"NO\n"
] | In the first sample the initial array fits well.
In the second sample Yaroslav can get array: 1, 2, 1. He can swap the last and the second last elements to obtain it.
In the third sample Yarosav can't get the array he needs. | 500 | [
{
"input": "1\n1",
"output": "YES"
},
{
"input": "3\n1 1 2",
"output": "YES"
},
{
"input": "4\n7 7 7 7",
"output": "NO"
},
{
"input": "4\n479 170 465 146",
"output": "YES"
},
{
"input": "5\n996 437 605 996 293",
"output": "YES"
},
{
"input": "6\n727 53... | 1,675,708,921 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 24 | 92 | 0 | '''
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.
'''
n = input()
x = [int(i... | Title: Yaroslav and Permutations
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Yaroslav has an array that consists of *n* integers. In one second Yaroslav can swap two neighboring array elements. Now Yaroslav is wondering if he can obtain an array where any two neighboring elements would... | ```python
'''
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.
'''
n = input()
... | 0 | |
677 | A | Vanya and Fence | PROGRAMMING | 800 | [
"implementation"
] | null | null | Vanya and his friends are walking along the fence of height *h* and they do not want the guard to notice them. In order to achieve this the height of each of the friends should not exceed *h*. If the height of some person is greater than *h* he can bend down and then he surely won't be noticed by the guard. The height ... | The first line of the input contains two integers *n* and *h* (1<=≤<=*n*<=≤<=1000, 1<=≤<=*h*<=≤<=1000) — the number of friends and the height of the fence, respectively.
The second line contains *n* integers *a**i* (1<=≤<=*a**i*<=≤<=2*h*), the *i*-th of them is equal to the height of the *i*-th person. | Print a single integer — the minimum possible valid width of the road. | [
"3 7\n4 5 14\n",
"6 1\n1 1 1 1 1 1\n",
"6 5\n7 6 8 9 10 5\n"
] | [
"4\n",
"6\n",
"11\n"
] | In the first sample, only person number 3 must bend down, so the required width is equal to 1 + 1 + 2 = 4.
In the second sample, all friends are short enough and no one has to bend, so the width 1 + 1 + 1 + 1 + 1 + 1 = 6 is enough.
In the third sample, all the persons have to bend, except the last one. The required m... | 500 | [
{
"input": "3 7\n4 5 14",
"output": "4"
},
{
"input": "6 1\n1 1 1 1 1 1",
"output": "6"
},
{
"input": "6 5\n7 6 8 9 10 5",
"output": "11"
},
{
"input": "10 420\n214 614 297 675 82 740 174 23 255 15",
"output": "13"
},
{
"input": "10 561\n657 23 1096 487 785 66 481... | 1,698,023,896 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 29 | 61 | 0 | n, h = map(int, input().split())
friend_heights = list(map(int, input().split()))
minimum_width = 0
for height in friend_heights:
if height > h:
minimum_width += 2 # If the person is taller than the fence, they need 2 units of width.
else:
minimum_width += 1 # If the person is short... | Title: Vanya and Fence
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vanya and his friends are walking along the fence of height *h* and they do not want the guard to notice them. In order to achieve this the height of each of the friends should not exceed *h*. If the height of some pers... | ```python
n, h = map(int, input().split())
friend_heights = list(map(int, input().split()))
minimum_width = 0
for height in friend_heights:
if height > h:
minimum_width += 2 # If the person is taller than the fence, they need 2 units of width.
else:
minimum_width += 1 # If the perso... | 3 | |
884 | A | Book Reading | PROGRAMMING | 800 | [
"implementation"
] | null | null | Recently Luba bought a very interesting book. She knows that it will take *t* seconds to read the book. Luba wants to finish reading as fast as she can.
But she has some work to do in each of *n* next days. The number of seconds that Luba has to spend working during *i*-th day is *a**i*. If some free time remains, she... | The first line contains two integers *n* and *t* (1<=≤<=*n*<=≤<=100, 1<=≤<=*t*<=≤<=106) — the number of days and the time required to read the book.
The second line contains *n* integers *a**i* (0<=≤<=*a**i*<=≤<=86400) — the time Luba has to spend on her work during *i*-th day. | Print the minimum day Luba can finish reading the book.
It is guaranteed that answer doesn't exceed *n*. | [
"2 2\n86400 86398\n",
"2 86400\n0 86400\n"
] | [
"2\n",
"1\n"
] | none | 0 | [
{
"input": "2 2\n86400 86398",
"output": "2"
},
{
"input": "2 86400\n0 86400",
"output": "1"
},
{
"input": "2 86400\n1 86399",
"output": "2"
},
{
"input": "100 1000000\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0... | 1,509,206,917 | 2,147,483,647 | Python 3 | OK | TESTS | 16 | 62 | 0 | n,t=[int(x) for x in input().split()]
arr=[int(x) for x in input().split()]
cnt=0
for x in arr:
if 86400-x>=0:
t-=(86400-x)
cnt+=1
if t<=0:
break
print(cnt) | Title: Book Reading
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Recently Luba bought a very interesting book. She knows that it will take *t* seconds to read the book. Luba wants to finish reading as fast as she can.
But she has some work to do in each of *n* next days. The number of ... | ```python
n,t=[int(x) for x in input().split()]
arr=[int(x) for x in input().split()]
cnt=0
for x in arr:
if 86400-x>=0:
t-=(86400-x)
cnt+=1
if t<=0:
break
print(cnt)
``` | 3 | |
58 | A | Chat room | PROGRAMMING | 1,000 | [
"greedy",
"strings"
] | A. Chat room | 1 | 256 | Vasya has recently learned to type and log on to the Internet. He immediately entered a chat room and decided to say hello to everybody. Vasya typed the word *s*. It is considered that Vasya managed to say hello if several letters can be deleted from the typed word so that it resulted in the word "hello". For example, ... | The first and only line contains the word *s*, which Vasya typed. This word consisits of small Latin letters, its length is no less that 1 and no more than 100 letters. | If Vasya managed to say hello, print "YES", otherwise print "NO". | [
"ahhellllloou\n",
"hlelo\n"
] | [
"YES\n",
"NO\n"
] | none | 500 | [
{
"input": "ahhellllloou",
"output": "YES"
},
{
"input": "hlelo",
"output": "NO"
},
{
"input": "helhcludoo",
"output": "YES"
},
{
"input": "hehwelloho",
"output": "YES"
},
{
"input": "pnnepelqomhhheollvlo",
"output": "YES"
},
{
"input": "tymbzjyqhymeda... | 1,683,657,512 | 2,147,483,647 | Python 3 | OK | TESTS | 40 | 31 | 0 | # line = input()
# lCounter = 0
# pattern = 'hello'
# ind1 = 0
# indOfH = line.find('h')
# indOfO = line.find('o')
# if indOfH == -1 or indOfO == -1: print('NO')
#
#
# else:
# ans = 'YES'
# helloline = line[int(indOfH):int(indOfO) + 1]
# #print(helloline)
# if helloline.find('e') == -1 or hel... | 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
# line = input()
# lCounter = 0
# pattern = 'hello'
# ind1 = 0
# indOfH = line.find('h')
# indOfO = line.find('o')
# if indOfH == -1 or indOfO == -1: print('NO')
#
#
# else:
# ans = 'YES'
# helloline = line[int(indOfH):int(indOfO) + 1]
# #print(helloline)
# if helloline.find('e') ==... | 3.9845 |
701 | C | They Are Everywhere | PROGRAMMING | 1,500 | [
"binary search",
"strings",
"two pointers"
] | null | null | Sergei B., the young coach of Pokemons, has found the big house which consists of *n* flats ordered in a row from left to right. It is possible to enter each flat from the street. It is possible to go out from each flat. Also, each flat is connected with the flat to the left and the flat to the right. Flat number 1 is ... | The first line contains the integer *n* (1<=≤<=*n*<=≤<=100<=000) — the number of flats in the house.
The second line contains the row *s* with the length *n*, it consists of uppercase and lowercase letters of English alphabet, the *i*-th letter equals the type of Pokemon, which is in the flat number *i*. | Print the minimum number of flats which Sergei B. should visit in order to catch Pokemons of all types which there are in the house. | [
"3\nAaA\n",
"7\nbcAAcbc\n",
"6\naaBCCe\n"
] | [
"2\n",
"3\n",
"5\n"
] | In the first test Sergei B. can begin, for example, from the flat number 1 and end in the flat number 2.
In the second test Sergei B. can begin, for example, from the flat number 4 and end in the flat number 6.
In the third test Sergei B. must begin from the flat number 2 and end in the flat number 6. | 1,000 | [
{
"input": "3\nAaA",
"output": "2"
},
{
"input": "7\nbcAAcbc",
"output": "3"
},
{
"input": "6\naaBCCe",
"output": "5"
},
{
"input": "1\nA",
"output": "1"
},
{
"input": "1\ng",
"output": "1"
},
{
"input": "52\nabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQ... | 1,698,169,853 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 3 | 46 | 0 | # love thy neighbour
from sys import stdin,stdout
def ArrayIn():return list(map(int,input().split()))
def print(x):stdout.write(f'{x}\n')
n=int(input())
flats=input()
target=set(flats)
l, r=0, n-1
while l<r:
if set(flats[l:r])==target:
r-=1
elif set(flats[l+1:r+1])==target:
l+=1
else:
... | Title: They Are Everywhere
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Sergei B., the young coach of Pokemons, has found the big house which consists of *n* flats ordered in a row from left to right. It is possible to enter each flat from the street. It is possible to go out from each ... | ```python
# love thy neighbour
from sys import stdin,stdout
def ArrayIn():return list(map(int,input().split()))
def print(x):stdout.write(f'{x}\n')
n=int(input())
flats=input()
target=set(flats)
l, r=0, n-1
while l<r:
if set(flats[l:r])==target:
r-=1
elif set(flats[l+1:r+1])==target:
l+=1
... | 0 | |
158 | A | Next Round | PROGRAMMING | 800 | [
"*special",
"implementation"
] | null | null | "Contestant who earns a score equal to or greater than the *k*-th place finisher's score will advance to the next round, as long as the contestant earns a positive score..." — an excerpt from contest rules.
A total of *n* participants took part in the contest (*n*<=≥<=*k*), and you already know their scores. Calculate... | The first line of the input contains two integers *n* and *k* (1<=≤<=*k*<=≤<=*n*<=≤<=50) separated by a single space.
The second line contains *n* space-separated integers *a*1,<=*a*2,<=...,<=*a**n* (0<=≤<=*a**i*<=≤<=100), where *a**i* is the score earned by the participant who got the *i*-th place. The given sequence... | Output the number of participants who advance to the next round. | [
"8 5\n10 9 8 7 7 7 5 5\n",
"4 2\n0 0 0 0\n"
] | [
"6\n",
"0\n"
] | In the first example the participant on the 5th place earned 7 points. As the participant on the 6th place also earned 7 points, there are 6 advancers.
In the second example nobody got a positive score. | 500 | [
{
"input": "8 5\n10 9 8 7 7 7 5 5",
"output": "6"
},
{
"input": "4 2\n0 0 0 0",
"output": "0"
},
{
"input": "5 1\n1 1 1 1 1",
"output": "5"
},
{
"input": "5 5\n1 1 1 1 1",
"output": "5"
},
{
"input": "1 1\n10",
"output": "1"
},
{
"input": "17 14\n16 15... | 1,698,906,062 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 2 | 92 | 0 | n, k = map(int, input().split())
l = list(map(int, input().split()))
for i in range(n):
if not (l[i] >= l[k-1] and l[i] != 0):
break
print(i) | Title: Next Round
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
"Contestant who earns a score equal to or greater than the *k*-th place finisher's score will advance to the next round, as long as the contestant earns a positive score..." — an excerpt from contest rules.
A total of *n* p... | ```python
n, k = map(int, input().split())
l = list(map(int, input().split()))
for i in range(n):
if not (l[i] >= l[k-1] and l[i] != 0):
break
print(i)
``` | 0 | |
435 | A | Queue on Bus Stop | PROGRAMMING | 1,000 | [
"implementation"
] | null | null | It's that time of the year when the Russians flood their countryside summer cottages (dachas) and the bus stop has a lot of people. People rarely go to the dacha on their own, it's usually a group, so the people stand in queue by groups.
The bus stop queue has *n* groups of people. The *i*-th group from the beginning ... | The first line contains two integers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=100). The next line contains *n* integers: *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=*m*). | Print a single integer — the number of buses that is needed to transport all *n* groups to the dacha countryside. | [
"4 3\n2 3 2 1\n",
"3 4\n1 2 1\n"
] | [
"3\n",
"1\n"
] | none | 500 | [
{
"input": "4 3\n2 3 2 1",
"output": "3"
},
{
"input": "3 4\n1 2 1",
"output": "1"
},
{
"input": "1 5\n4",
"output": "1"
},
{
"input": "5 1\n1 1 1 1 1",
"output": "5"
},
{
"input": "6 4\n1 3 2 3 4 1",
"output": "5"
},
{
"input": "6 8\n6 1 1 1 4 5",
... | 1,585,216,298 | 2,147,483,647 | Python 3 | OK | TESTS | 34 | 109 | 0 | '''
ID: essi
LANG: PYTHON3
TASK: self-contest.py
'''
n, m = map(int,input().split())
a = list(map(int,input().split()))
res = 1
su = 0
for i in range(n):
su+= a[i]
if su > m:
res+=1
su = a[i]
print(res) | Title: Queue on Bus Stop
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
It's that time of the year when the Russians flood their countryside summer cottages (dachas) and the bus stop has a lot of people. People rarely go to the dacha on their own, it's usually a group, so the people stand... | ```python
'''
ID: essi
LANG: PYTHON3
TASK: self-contest.py
'''
n, m = map(int,input().split())
a = list(map(int,input().split()))
res = 1
su = 0
for i in range(n):
su+= a[i]
if su > m:
res+=1
su = a[i]
print(res)
``` | 3 | |
202 | A | LLPS | PROGRAMMING | 800 | [
"binary search",
"bitmasks",
"brute force",
"greedy",
"implementation",
"strings"
] | null | null | This problem's actual name, "Lexicographically Largest Palindromic Subsequence" is too long to fit into the page headline.
You are given string *s* consisting of lowercase English letters only. Find its lexicographically largest palindromic subsequence.
We'll call a non-empty string *s*[*p*1*p*2... *p**k*] = *s**p*1*... | The only input line contains a non-empty string *s* consisting of lowercase English letters only. Its length does not exceed 10. | Print the lexicographically largest palindromic subsequence of string *s*. | [
"radar\n",
"bowwowwow\n",
"codeforces\n",
"mississipp\n"
] | [
"rr\n",
"wwwww\n",
"s\n",
"ssss\n"
] | Among all distinct subsequences of string "radar" the following ones are palindromes: "a", "d", "r", "aa", "rr", "ada", "rar", "rdr", "raar" and "radar". The lexicographically largest of them is "rr". | 500 | [
{
"input": "radar",
"output": "rr"
},
{
"input": "bowwowwow",
"output": "wwwww"
},
{
"input": "codeforces",
"output": "s"
},
{
"input": "mississipp",
"output": "ssss"
},
{
"input": "tourist",
"output": "u"
},
{
"input": "romka",
"output": "r"
},
... | 1,644,505,586 | 2,147,483,647 | Python 3 | OK | TESTS | 54 | 62 | 0 | s=str(input())
k=max(s)
g=s.count(k)
print(k*g) | Title: LLPS
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
This problem's actual name, "Lexicographically Largest Palindromic Subsequence" is too long to fit into the page headline.
You are given string *s* consisting of lowercase English letters only. Find its lexicographically largest ... | ```python
s=str(input())
k=max(s)
g=s.count(k)
print(k*g)
``` | 3 | |
975 | B | Mancala | PROGRAMMING | 1,100 | [
"brute force",
"implementation"
] | null | null | Mancala is a game famous in the Middle East. It is played on a board that consists of 14 holes.
Initially, each hole has $a_i$ stones. When a player makes a move, he chooses a hole which contains a positive number of stones. He takes all the stones inside it and then redistributes these stones one by one in the next ... | The only line contains 14 integers $a_1, a_2, \ldots, a_{14}$ ($0 \leq a_i \leq 10^9$) — the number of stones in each hole.
It is guaranteed that for any $i$ ($1\leq i \leq 14$) $a_i$ is either zero or odd, and there is at least one stone in the board. | Output one integer, the maximum possible score after one move. | [
"0 1 1 0 0 0 0 0 0 7 0 0 0 0\n",
"5 1 1 1 1 0 0 0 0 0 0 0 0 0\n"
] | [
"4\n",
"8\n"
] | In the first test case the board after the move from the hole with $7$ stones will look like 1 2 2 0 0 0 0 0 0 0 1 1 1 1. Then the player collects the even numbers and ends up with a score equal to $4$. | 1,000 | [
{
"input": "0 1 1 0 0 0 0 0 0 7 0 0 0 0",
"output": "4"
},
{
"input": "5 1 1 1 1 0 0 0 0 0 0 0 0 0",
"output": "8"
},
{
"input": "10001 10001 10001 10001 10001 10001 10001 10001 10001 10001 10001 10001 10001 1",
"output": "54294"
},
{
"input": "0 0 0 0 0 0 0 0 0 0 0 0 0 15",
... | 1,525,186,900 | 3,400 | Python 3 | WRONG_ANSWER | PRETESTS | 6 | 92 | 7,065,600 | holes = [int(x) for x in input().split()]
Max = max(holes)
ind = holes.index(Max)
holes[ind] = 0
zero = holes.count(0)
_1 = 14 - zero
n = Max//14
ex = Max - (n*14)
if n == 0 :
for i in range(Max) :
if ind ==13 :
ind = 0
holes[ind] += 1
else :
ind += ... | Title: Mancala
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Mancala is a game famous in the Middle East. It is played on a board that consists of 14 holes.
Initially, each hole has $a_i$ stones. When a player makes a move, he chooses a hole which contains a positive number of stones. ... | ```python
holes = [int(x) for x in input().split()]
Max = max(holes)
ind = holes.index(Max)
holes[ind] = 0
zero = holes.count(0)
_1 = 14 - zero
n = Max//14
ex = Max - (n*14)
if n == 0 :
for i in range(Max) :
if ind ==13 :
ind = 0
holes[ind] += 1
else :
... | 0 | |
17 | A | Noldbach problem | PROGRAMMING | 1,000 | [
"brute force",
"math",
"number theory"
] | A. Noldbach problem | 2 | 64 | Nick is interested in prime numbers. Once he read about Goldbach problem. It states that every even integer greater than 2 can be expressed as the sum of two primes. That got Nick's attention and he decided to invent a problem of his own and call it Noldbach problem. Since Nick is interested only in prime numbers, Nold... | The first line of the input contains two integers *n* (2<=≤<=*n*<=≤<=1000) and *k* (0<=≤<=*k*<=≤<=1000). | Output YES if at least *k* prime numbers from 2 to *n* inclusively can be expressed as it was described above. Otherwise output NO. | [
"27 2\n",
"45 7\n"
] | [
"YES",
"NO"
] | In the first sample the answer is YES since at least two numbers can be expressed as it was described (for example, 13 and 19). In the second sample the answer is NO since it is impossible to express 7 prime numbers from 2 to 45 in the desired form. | 0 | [
{
"input": "27 2",
"output": "YES"
},
{
"input": "45 7",
"output": "NO"
},
{
"input": "2 0",
"output": "YES"
},
{
"input": "15 1",
"output": "YES"
},
{
"input": "17 1",
"output": "YES"
},
{
"input": "34 5",
"output": "NO"
},
{
"input": "37 ... | 1,674,380,464 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 35 | 154 | 1,945,600 | n,k = map(int,input().split())
l = []
ct = 0
for i in range(2,2*n+1):
b = True
for j in range(2,i):
if j*j > i:
break;
if(i%j == 0):
b = False
break;
if(b):
l.append(i)
for i in range(0,len(l)-1):
if l[i]+l[i+1]+1 > n:
br... | Title: Noldbach problem
Time Limit: 2 seconds
Memory Limit: 64 megabytes
Problem Description:
Nick is interested in prime numbers. Once he read about Goldbach problem. It states that every even integer greater than 2 can be expressed as the sum of two primes. That got Nick's attention and he decided to invent a prob... | ```python
n,k = map(int,input().split())
l = []
ct = 0
for i in range(2,2*n+1):
b = True
for j in range(2,i):
if j*j > i:
break;
if(i%j == 0):
b = False
break;
if(b):
l.append(i)
for i in range(0,len(l)-1):
if l[i]+l[i+1]+1 > n:
... | 3.947004 |
2 | B | The least round way | PROGRAMMING | 2,000 | [
"dp",
"math"
] | B. The least round way | 2 | 64 | There is a square matrix *n*<=×<=*n*, consisting of non-negative integer numbers. You should find such a way on it that
- starts in the upper left cell of the matrix; - each following cell is to the right or down from the current cell; - the way ends in the bottom right cell.
Moreover, if we multiply together all... | The first line contains an integer number *n* (2<=≤<=*n*<=≤<=1000), *n* is the size of the matrix. Then follow *n* lines containing the matrix elements (non-negative integer numbers not exceeding 109). | In the first line print the least number of trailing zeros. In the second line print the correspondent way itself. | [
"3\n1 2 3\n4 5 6\n7 8 9\n"
] | [
"0\nDDRR\n"
] | none | 0 | [
{
"input": "3\n1 2 3\n4 5 6\n7 8 9",
"output": "0\nDDRR"
},
{
"input": "2\n7 6\n3 8",
"output": "0\nDR"
},
{
"input": "3\n4 10 5\n10 9 4\n6 5 3",
"output": "1\nDRRD"
},
{
"input": "4\n1 1 9 9\n3 4 7 3\n7 9 1 7\n1 7 1 5",
"output": "0\nDDDRRR"
},
{
"input": "5\n8 3... | 1,673,144,508 | 2,147,483,647 | PyPy 3-64 | MEMORY_LIMIT_EXCEEDED | TESTS | 15 | 248 | 67,072,000 | n = int(input())
grid = [[0] * n for _ in range(n)]
c2 = [[0] * n for _ in range(n)]
c5 = [[0] * n for _ in range(n)]
m2 = [[(3200,3200)] * (n+1) for _ in range(n+1)]
m5 = [[(3200,3200)] * (n+1) for _ in range(n+1)]
dm2 = [[''] * (n+1) for _ in range(n+1)]
dm5 = [[''] * (n+1) for _ in range(n+1)]
m2[0][1] = (0,... | Title: The least round way
Time Limit: 2 seconds
Memory Limit: 64 megabytes
Problem Description:
There is a square matrix *n*<=×<=*n*, consisting of non-negative integer numbers. You should find such a way on it that
- starts in the upper left cell of the matrix; - each following cell is to the right or down fro... | ```python
n = int(input())
grid = [[0] * n for _ in range(n)]
c2 = [[0] * n for _ in range(n)]
c5 = [[0] * n for _ in range(n)]
m2 = [[(3200,3200)] * (n+1) for _ in range(n+1)]
m5 = [[(3200,3200)] * (n+1) for _ in range(n+1)]
dm2 = [[''] * (n+1) for _ in range(n+1)]
dm5 = [[''] * (n+1) for _ in range(n+1)]
m2[0... | 0 |
835 | A | Key races | PROGRAMMING | 800 | [
"math"
] | null | null | Two boys decided to compete in text typing on the site "Key races". During the competition, they have to type a text consisting of *s* characters. The first participant types one character in *v*1 milliseconds and has ping *t*1 milliseconds. The second participant types one character in *v*2 milliseconds and has ping *... | The first line contains five integers *s*, *v*1, *v*2, *t*1, *t*2 (1<=≤<=*s*,<=*v*1,<=*v*2,<=*t*1,<=*t*2<=≤<=1000) — the number of characters in the text, the time of typing one character for the first participant, the time of typing one character for the the second participant, the ping of the first participant and th... | If the first participant wins, print "First". If the second participant wins, print "Second". In case of a draw print "Friendship". | [
"5 1 2 1 2\n",
"3 3 1 1 1\n",
"4 5 3 1 5\n"
] | [
"First\n",
"Second\n",
"Friendship\n"
] | In the first example, information on the success of the first participant comes in 7 milliseconds, of the second participant — in 14 milliseconds. So, the first wins.
In the second example, information on the success of the first participant comes in 11 milliseconds, of the second participant — in 5 milliseconds. So, ... | 500 | [
{
"input": "5 1 2 1 2",
"output": "First"
},
{
"input": "3 3 1 1 1",
"output": "Second"
},
{
"input": "4 5 3 1 5",
"output": "Friendship"
},
{
"input": "1000 1000 1000 1000 1000",
"output": "Friendship"
},
{
"input": "1 1 1 1 1",
"output": "Friendship"
},
... | 1,577,939,024 | 2,147,483,647 | PyPy 3 | OK | TESTS | 32 | 155 | 0 | s, v1, v2, t1, t2 = map(int, input().split())
f1 = 2 * t1 + (s * v1)
f2 = 2 * t2 + (s * v2)
if f1 < f2:
print("First")
elif f1 > f2:
print("Second")
else:
print("Friendship")
| Title: Key races
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Two boys decided to compete in text typing on the site "Key races". During the competition, they have to type a text consisting of *s* characters. The first participant types one character in *v*1 milliseconds and has ping *t... | ```python
s, v1, v2, t1, t2 = map(int, input().split())
f1 = 2 * t1 + (s * v1)
f2 = 2 * t2 + (s * v2)
if f1 < f2:
print("First")
elif f1 > f2:
print("Second")
else:
print("Friendship")
``` | 3 | |
617 | A | Elephant | PROGRAMMING | 800 | [
"math"
] | null | null | An elephant decided to visit his friend. It turned out that the elephant's house is located at point 0 and his friend's house is located at point *x*(*x*<=><=0) of the coordinate line. In one step the elephant can move 1, 2, 3, 4 or 5 positions forward. Determine, what is the minimum number of steps he need to make ... | The first line of the input contains an integer *x* (1<=≤<=*x*<=≤<=1<=000<=000) — The coordinate of the friend's house. | Print the minimum number of steps that elephant needs to make to get from point 0 to point *x*. | [
"5\n",
"12\n"
] | [
"1\n",
"3\n"
] | In the first sample the elephant needs to make one step of length 5 to reach the point *x*.
In the second sample the elephant can get to point *x* if he moves by 3, 5 and 4. There are other ways to get the optimal answer but the elephant cannot reach *x* in less than three moves. | 500 | [
{
"input": "5",
"output": "1"
},
{
"input": "12",
"output": "3"
},
{
"input": "999999",
"output": "200000"
},
{
"input": "41",
"output": "9"
},
{
"input": "1000000",
"output": "200000"
},
{
"input": "1",
"output": "1"
},
{
"input": "2",
... | 1,696,261,317 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 31 | 0 | a = int(input())
b = a // 5
r = a % 5
if r < 4:
c = 1
else:
c = 0
if r == 0:
print(b)
else:
total = b + c
print(total)
| Title: Elephant
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
An elephant decided to visit his friend. It turned out that the elephant's house is located at point 0 and his friend's house is located at point *x*(*x*<=><=0) of the coordinate line. In one step the elephant can move 1, 2... | ```python
a = int(input())
b = a // 5
r = a % 5
if r < 4:
c = 1
else:
c = 0
if r == 0:
print(b)
else:
total = b + c
print(total)
``` | 0 | |
365 | A | Good Number | PROGRAMMING | 1,100 | [
"implementation"
] | null | null | Let's call a number *k*-good if it contains all digits not exceeding *k* (0,<=...,<=*k*). You've got a number *k* and an array *a* containing *n* numbers. Find out how many *k*-good numbers are in *a* (count each number every time it occurs in array *a*). | The first line contains integers *n* and *k* (1<=≤<=*n*<=≤<=100, 0<=≤<=*k*<=≤<=9). The *i*-th of the following *n* lines contains integer *a**i* without leading zeroes (1<=≤<=*a**i*<=≤<=109). | Print a single integer — the number of *k*-good numbers in *a*. | [
"10 6\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n",
"2 1\n1\n10\n"
] | [
"10\n",
"1\n"
] | none | 500 | [
{
"input": "10 6\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560",
"output": "10"
},
{
"input": "2 1\n1\n10",
"output": "1"
},
{
"input": "1 0\n1000000000",
"output": "1"
},
{
"input": "1 1\n1000000000",
"output": "1"
},
{
... | 1,669,491,432 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 31 | 0 | data = list(map(int, input().split()))
num_count = 0
for i in range(data[0]):
arr = list(map(int, input()))
if len(arr) > data[1]:
num_count += arr.count(data[1])
print(num_count) | Title: Good Number
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Let's call a number *k*-good if it contains all digits not exceeding *k* (0,<=...,<=*k*). You've got a number *k* and an array *a* containing *n* numbers. Find out how many *k*-good numbers are in *a* (count each number eve... | ```python
data = list(map(int, input().split()))
num_count = 0
for i in range(data[0]):
arr = list(map(int, input()))
if len(arr) > data[1]:
num_count += arr.count(data[1])
print(num_count)
``` | 0 | |
48 | A | Rock-paper-scissors | PROGRAMMING | 900 | [
"implementation",
"schedules"
] | A. Rock-paper-scissors | 2 | 256 | Uncle Fyodor, Matroskin the Cat and Sharic the Dog live their simple but happy lives in Prostokvashino. Sometimes they receive parcels from Uncle Fyodor’s parents and sometimes from anonymous benefactors, in which case it is hard to determine to which one of them the package has been sent. A photographic rifle is obvio... | The first input line contains the name of the gesture that Uncle Fyodor showed, the second line shows which gesture Matroskin showed and the third line shows Sharic’s gesture. | Print "F" (without quotes) if Uncle Fyodor wins. Print "M" if Matroskin wins and "S" if Sharic wins. If it is impossible to find the winner, print "?". | [
"rock\nrock\nrock\n",
"paper\nrock\nrock\n",
"scissors\nrock\nrock\n",
"scissors\npaper\nrock\n"
] | [
"?\n",
"F\n",
"?\n",
"?\n"
] | none | 0 | [
{
"input": "rock\nrock\nrock",
"output": "?"
},
{
"input": "paper\nrock\nrock",
"output": "F"
},
{
"input": "scissors\nrock\nrock",
"output": "?"
},
{
"input": "scissors\npaper\nrock",
"output": "?"
},
{
"input": "paper\npaper\nrock",
"output": "?"
},
{
... | 1,584,378,766 | 2,147,483,647 | PyPy 3 | OK | TESTS | 27 | 310 | 0 | l=[]
for i in range(3):
l.append(str(input( )))
x=l[:]
x= set(x)
if len(x)!=2:
print("?")
else:
if l[1]==l[2] and l[0]!=l[1]:
if l[1]== 'rock' and l[0]=='paper' or l[1]=='paper' and l[0]=='scissors' or l[1]=='scissors' and l[0]=='rock':
print("F")
else:
... | Title: Rock-paper-scissors
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Uncle Fyodor, Matroskin the Cat and Sharic the Dog live their simple but happy lives in Prostokvashino. Sometimes they receive parcels from Uncle Fyodor’s parents and sometimes from anonymous benefactors, in which case ... | ```python
l=[]
for i in range(3):
l.append(str(input( )))
x=l[:]
x= set(x)
if len(x)!=2:
print("?")
else:
if l[1]==l[2] and l[0]!=l[1]:
if l[1]== 'rock' and l[0]=='paper' or l[1]=='paper' and l[0]=='scissors' or l[1]=='scissors' and l[0]=='rock':
print("F")
else:
... | 3.9225 |
234 | C | Weather | PROGRAMMING | 1,300 | [
"dp",
"implementation"
] | null | null | Scientists say a lot about the problems of global warming and cooling of the Earth. Indeed, such natural phenomena strongly influence all life on our planet.
Our hero Vasya is quite concerned about the problems. He decided to try a little experiment and observe how outside daily temperature changes. He hung out a ther... | The first line contains a single integer *n* (2<=≤<=*n*<=≤<=105) — the number of days for which Vasya has been measuring the temperature.
The second line contains a sequence of *n* integers *t*1,<=*t*2,<=...,<=*t**n* (|*t**i*|<=≤<=109) — the sequence of temperature values. Numbers *t**i* are separated by single space... | Print a single integer — the answer to the given task. | [
"4\n-1 1 -2 1\n",
"5\n0 -1 1 2 -5\n"
] | [
"1\n",
"2\n"
] | Note to the first sample: there are two ways to change exactly one number so that the sequence met Vasya's condition. You can either replace the first number 1 by any negative number or replace the number -2 by any positive number. | 0 | [
{
"input": "4\n-1 1 -2 1",
"output": "1"
},
{
"input": "5\n0 -1 1 2 -5",
"output": "2"
},
{
"input": "6\n0 0 0 0 0 0",
"output": "6"
},
{
"input": "6\n-1 -2 -3 -4 5 6",
"output": "0"
},
{
"input": "8\n1 2 -1 0 10 2 12 13",
"output": "3"
},
{
"input": "... | 1,620,606,149 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 92 | 6,656,000 | banana = open("input.txt","r")
n = banana.readlines()
n = int(n)
listTemps = list(banana.readline().split())
mango = open("output.txt", "w")
mango.write("3")
banana.close
mango.close
| Title: Weather
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Scientists say a lot about the problems of global warming and cooling of the Earth. Indeed, such natural phenomena strongly influence all life on our planet.
Our hero Vasya is quite concerned about the problems. He decided to ... | ```python
banana = open("input.txt","r")
n = banana.readlines()
n = int(n)
listTemps = list(banana.readline().split())
mango = open("output.txt", "w")
mango.write("3")
banana.close
mango.close
``` | -1 | |
262 | B | Roma and Changing Signs | PROGRAMMING | 1,200 | [
"greedy"
] | null | null | Roma works in a company that sells TVs. Now he has to prepare a report for the last year.
Roma has got a list of the company's incomes. The list is a sequence that consists of *n* integers. The total income of the company is the sum of all integers in sequence. Roma decided to perform exactly *k* changes of signs of s... | The first line contains two integers *n* and *k* (1<=≤<=*n*,<=*k*<=≤<=105), showing, how many numbers are in the sequence and how many swaps are to be made.
The second line contains a non-decreasing sequence, consisting of *n* integers *a**i* (|*a**i*|<=≤<=104).
The numbers in the lines are separated by single spaces... | In the single line print the answer to the problem — the maximum total income that we can obtain after exactly *k* changes. | [
"3 2\n-1 -1 1\n",
"3 1\n-1 -1 1\n"
] | [
"3\n",
"1\n"
] | In the first sample we can get sequence [1, 1, 1], thus the total income equals 3.
In the second test, the optimal strategy is to get sequence [-1, 1, 1], thus the total income equals 1. | 1,000 | [
{
"input": "3 2\n-1 -1 1",
"output": "3"
},
{
"input": "3 1\n-1 -1 1",
"output": "1"
},
{
"input": "17 27\n257 320 676 1136 2068 2505 2639 4225 4951 5786 7677 7697 7851 8337 8429 8469 9343",
"output": "81852"
},
{
"input": "69 28\n-9822 -9264 -9253 -9221 -9139 -9126 -9096 -89... | 1,689,443,703 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 0 | 92 | 0 | print("_RANDOM_GUESS_1689443703.6148257")# 1689443703.6148458 | Title: Roma and Changing Signs
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Roma works in a company that sells TVs. Now he has to prepare a report for the last year.
Roma has got a list of the company's incomes. The list is a sequence that consists of *n* integers. The total income of ... | ```python
print("_RANDOM_GUESS_1689443703.6148257")# 1689443703.6148458
``` | 0 | |
39 | D | Cubical Planet | PROGRAMMING | 1,100 | [
"math"
] | D. Cubical Planet | 2 | 64 | You can find anything whatsoever in our Galaxy! A cubical planet goes round an icosahedral star. Let us introduce a system of axes so that the edges of the cubical planet are parallel to the coordinate axes and two opposite vertices lay in the points (0,<=0,<=0) and (1,<=1,<=1). Two flies live on the planet. At the mom... | The first line contains three space-separated integers (0 or 1) — the coordinates of the first fly, the second line analogously contains the coordinates of the second fly. | Output "YES" (without quotes) if the flies see each other. Otherwise, output "NO". | [
"0 0 0\n0 1 0\n",
"1 1 0\n0 1 0\n",
"0 0 0\n1 1 1\n"
] | [
"YES\n",
"YES\n",
"NO\n"
] | none | 0 | [
{
"input": "0 0 0\n0 1 0",
"output": "YES"
},
{
"input": "1 1 0\n0 1 0",
"output": "YES"
},
{
"input": "0 0 0\n1 1 1",
"output": "NO"
},
{
"input": "0 0 0\n1 0 0",
"output": "YES"
},
{
"input": "0 0 0\n0 1 0",
"output": "YES"
},
{
"input": "0 0 0\n1 1 ... | 1,675,016,673 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 0 | 92 | 0 | n = input().split()
m=input().split()
a=[]
b=[]
s=0
s1=0
s2=0
s3=0
for i in n:
a.append(int(i))
for i in m:
b.append(int(i))
for i in range (len(a)):
if a[i] == 0:
s+=1
elif a[i] == 1:
s2+=1
if b[i] == 1:
s1+=1
elif b[i] == 0:
s3+=1
if (s==3 and s1 == s1) or (s2== 3 and s3 ==3):
print('NO')
else:
print(... | Title: Cubical Planet
Time Limit: 2 seconds
Memory Limit: 64 megabytes
Problem Description:
You can find anything whatsoever in our Galaxy! A cubical planet goes round an icosahedral star. Let us introduce a system of axes so that the edges of the cubical planet are parallel to the coordinate axes and two opposite v... | ```python
n = input().split()
m=input().split()
a=[]
b=[]
s=0
s1=0
s2=0
s3=0
for i in n:
a.append(int(i))
for i in m:
b.append(int(i))
for i in range (len(a)):
if a[i] == 0:
s+=1
elif a[i] == 1:
s2+=1
if b[i] == 1:
s1+=1
elif b[i] == 0:
s3+=1
if (s==3 and s1 == s1) or (s2== 3 and s3 ==3):
print('NO')
els... | 0 |
837 | D | Round Subset | PROGRAMMING | 2,100 | [
"dp",
"math"
] | null | null | Let's call the roundness of the number the number of zeros to which it ends.
You have an array of *n* numbers. You need to choose a subset of exactly *k* numbers so that the roundness of the product of the selected numbers will be maximum possible. | The first line contains two integer numbers *n* and *k* (1<=≤<=*n*<=≤<=200,<=1<=≤<=*k*<=≤<=*n*).
The second line contains *n* space-separated integer numbers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=1018). | Print maximal roundness of product of the chosen subset of length *k*. | [
"3 2\n50 4 20\n",
"5 3\n15 16 3 25 9\n",
"3 3\n9 77 13\n"
] | [
"3\n",
"3\n",
"0\n"
] | In the first example there are 3 subsets of 2 numbers. [50, 4] has product 200 with roundness 2, [4, 20] — product 80, roundness 1, [50, 20] — product 1000, roundness 3.
In the second example subset [15, 16, 25] has product 6000, roundness 3.
In the third example all subsets has product with roundness 0. | 0 | [
{
"input": "3 2\n50 4 20",
"output": "3"
},
{
"input": "5 3\n15 16 3 25 9",
"output": "3"
},
{
"input": "3 3\n9 77 13",
"output": "0"
},
{
"input": "1 1\n200000000",
"output": "8"
},
{
"input": "1 1\n3",
"output": "0"
},
{
"input": "3 1\n10000000000000... | 1,525,305,911 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 3 | 2,000 | 7,475,200 | import random
#begin
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = []
for i in a:
l = r = 0
while not i % 2**(l+1): l += 1
while not i % 5**(r+1): r += 1
b.append((l, r))
#genetic
obj_max, years, shufle_year, tick = 128, 1000, 50, 0
key = [i for i in ran... | Title: Round Subset
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Let's call the roundness of the number the number of zeros to which it ends.
You have an array of *n* numbers. You need to choose a subset of exactly *k* numbers so that the roundness of the product of the selected number... | ```python
import random
#begin
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = []
for i in a:
l = r = 0
while not i % 2**(l+1): l += 1
while not i % 5**(r+1): r += 1
b.append((l, r))
#genetic
obj_max, years, shufle_year, tick = 128, 1000, 50, 0
key = [i fo... | 0 | |
149 | A | Business trip | PROGRAMMING | 900 | [
"greedy",
"implementation",
"sortings"
] | null | null | What joy! Petya's parents went on a business trip for the whole year and the playful kid is left all by himself. Petya got absolutely happy. He jumped on the bed and threw pillows all day long, until...
Today Petya opened the cupboard and found a scary note there. His parents had left him with duties: he should water... | The first line contains exactly one integer *k* (0<=≤<=*k*<=≤<=100). The next line contains twelve space-separated integers: the *i*-th (1<=≤<=*i*<=≤<=12) number in the line represents *a**i* (0<=≤<=*a**i*<=≤<=100). | Print the only integer — the minimum number of months when Petya has to water the flower so that the flower grows no less than by *k* centimeters. If the flower can't grow by *k* centimeters in a year, print -1. | [
"5\n1 1 1 1 2 2 3 2 2 1 1 1\n",
"0\n0 0 0 0 0 0 0 1 1 2 3 0\n",
"11\n1 1 4 1 1 5 1 1 4 1 1 1\n"
] | [
"2\n",
"0\n",
"3\n"
] | Let's consider the first sample test. There it is enough to water the flower during the seventh and the ninth month. Then the flower grows by exactly five centimeters.
In the second sample Petya's parents will believe him even if the flower doesn't grow at all (*k* = 0). So, it is possible for Petya not to water the f... | 500 | [
{
"input": "5\n1 1 1 1 2 2 3 2 2 1 1 1",
"output": "2"
},
{
"input": "0\n0 0 0 0 0 0 0 1 1 2 3 0",
"output": "0"
},
{
"input": "11\n1 1 4 1 1 5 1 1 4 1 1 1",
"output": "3"
},
{
"input": "15\n20 1 1 1 1 2 2 1 2 2 1 1",
"output": "1"
},
{
"input": "7\n8 9 100 12 14 ... | 1,644,085,227 | 2,147,483,647 | Python 3 | OK | TESTS | 39 | 92 | 0 | #****************************************
#** Solution by BAZOOKA **
#** Sponsored by RED BULL**
#** I love ❤Kateryna Gret❤ **
#****************************************/
k=int(input())
m=sorted(map(int,input().split()))[::-1]
for i in range(13):
if sum(m[:i])>=k:
print(i)
exit(0)
p... | Title: Business trip
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
What joy! Petya's parents went on a business trip for the whole year and the playful kid is left all by himself. Petya got absolutely happy. He jumped on the bed and threw pillows all day long, until...
Today Petya open... | ```python
#****************************************
#** Solution by BAZOOKA **
#** Sponsored by RED BULL**
#** I love ❤Kateryna Gret❤ **
#****************************************/
k=int(input())
m=sorted(map(int,input().split()))[::-1]
for i in range(13):
if sum(m[:i])>=k:
print(i)
ex... | 3 | |
199 | A | Hexadecimal's theorem | PROGRAMMING | 900 | [
"brute force",
"constructive algorithms",
"implementation",
"number theory"
] | null | null | Recently, a chaotic virus Hexadecimal advanced a new theorem which will shake the Universe. She thinks that each Fibonacci number can be represented as sum of three not necessary different Fibonacci numbers.
Let's remember how Fibonacci numbers can be calculated. *F*0<==<=0, *F*1<==<=1, and all the next numbers are *F... | The input contains of a single integer *n* (0<=≤<=*n*<=<<=109) — the number that should be represented by the rules described above. It is guaranteed that *n* is a Fibonacci number. | Output three required numbers: *a*, *b* and *c*. If there is no answer for the test you have to print "I'm too stupid to solve this problem" without the quotes.
If there are multiple answers, print any of them. | [
"3\n",
"13\n"
] | [
"1 1 1\n",
"2 3 8\n"
] | none | 500 | [
{
"input": "3",
"output": "1 1 1"
},
{
"input": "13",
"output": "2 3 8"
},
{
"input": "0",
"output": "0 0 0"
},
{
"input": "1",
"output": "1 0 0"
},
{
"input": "2",
"output": "1 1 0"
},
{
"input": "1597",
"output": "233 377 987"
},
{
"input... | 1,591,873,503 | 2,147,483,647 | Python 3 | OK | TESTS | 54 | 218 | 0 | k=int(input())
print("0 0 "+str(k)) | Title: Hexadecimal's theorem
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Recently, a chaotic virus Hexadecimal advanced a new theorem which will shake the Universe. She thinks that each Fibonacci number can be represented as sum of three not necessary different Fibonacci numbers.
Let'... | ```python
k=int(input())
print("0 0 "+str(k))
``` | 3 | |
287 | B | Pipeline | PROGRAMMING | 1,700 | [
"binary search",
"math"
] | null | null | Vova, the Ultimate Thule new shaman, wants to build a pipeline. As there are exactly *n* houses in Ultimate Thule, Vova wants the city to have exactly *n* pipes, each such pipe should be connected to the water supply. A pipe can be connected to the water supply if there's water flowing out of it. Initially Vova has onl... | The first line contains two space-separated integers *n* and *k* (1<=≤<=*n*<=≤<=1018, 2<=≤<=*k*<=≤<=109).
Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. | Print a single integer — the minimum number of splitters needed to build the pipeline. If it is impossible to build a pipeline with the given splitters, print -1. | [
"4 3\n",
"5 5\n",
"8 4\n"
] | [
"2\n",
"1\n",
"-1\n"
] | none | 1,500 | [
{
"input": "4 3",
"output": "2"
},
{
"input": "5 5",
"output": "1"
},
{
"input": "8 4",
"output": "-1"
},
{
"input": "1000000000000000000 1000000000",
"output": "-1"
},
{
"input": "499999998500000001 1000000000",
"output": "999955279"
},
{
"input": "49... | 1,695,492,363 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 0 | 46 | 0 | def main():
n, k = map(int, input().split())
count = 0
while n > 0:
if k == 1:
return -1
if k <= n:
n -=k
count += 1
k -= 1
return count
print(main()) | Title: Pipeline
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vova, the Ultimate Thule new shaman, wants to build a pipeline. As there are exactly *n* houses in Ultimate Thule, Vova wants the city to have exactly *n* pipes, each such pipe should be connected to the water supply. A pipe c... | ```python
def main():
n, k = map(int, input().split())
count = 0
while n > 0:
if k == 1:
return -1
if k <= n:
n -=k
count += 1
k -= 1
return count
print(main())
``` | 0 | |
584 | A | Olesya and Rodion | PROGRAMMING | 1,000 | [
"math"
] | null | null | Olesya loves numbers consisting of *n* digits, and Rodion only likes numbers that are divisible by *t*. Find some number that satisfies both of them.
Your task is: given the *n* and *t* print an integer strictly larger than zero consisting of *n* digits that is divisible by *t*. If such number doesn't exist, print <=-... | The single line contains two numbers, *n* and *t* (1<=≤<=*n*<=≤<=100, 2<=≤<=*t*<=≤<=10) — the length of the number and the number it should be divisible by. | Print one such positive number without leading zeroes, — the answer to the problem, or <=-<=1, if such number doesn't exist. If there are multiple possible answers, you are allowed to print any of them. | [
"3 2\n"
] | [
"712"
] | none | 500 | [
{
"input": "3 2",
"output": "222"
},
{
"input": "2 2",
"output": "22"
},
{
"input": "4 3",
"output": "3333"
},
{
"input": "5 3",
"output": "33333"
},
{
"input": "10 7",
"output": "7777777777"
},
{
"input": "2 9",
"output": "99"
},
{
"input"... | 1,667,339,992 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 31 | 0 | n=int(input())
m=int(input())
l=[]
f=[]
for i in range(n):
l.append(n)
if(m%2==0 and l[len(l)-1]%2!=0):
l[len(l)-1]+=1
elif(m%2!=0 and l[len(l)-1]%2==0):
l[len(l)-1]-=1;
for i in range(len(l)):
f.append(str(l[i]))
k=''.join(f)
print(k) | Title: Olesya and Rodion
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Olesya loves numbers consisting of *n* digits, and Rodion only likes numbers that are divisible by *t*. Find some number that satisfies both of them.
Your task is: given the *n* and *t* print an integer strictly larg... | ```python
n=int(input())
m=int(input())
l=[]
f=[]
for i in range(n):
l.append(n)
if(m%2==0 and l[len(l)-1]%2!=0):
l[len(l)-1]+=1
elif(m%2!=0 and l[len(l)-1]%2==0):
l[len(l)-1]-=1;
for i in range(len(l)):
f.append(str(l[i]))
k=''.join(f)
print(k)
``` | -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,610,096,218 | 2,147,483,647 | Python 3 | OK | TESTS | 45 | 218 | 0 | def gcd(x, y):
while(y):x, y = y, x % y
return x
a, b, c = map(int, input().split())
while 1:
if gcd(a, c) > c:
print(1)
break
c -= gcd(a, c)
if gcd(b, c) > c:
print(0)
break
c -= gcd(b, c) | Title: Epic Game
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Simon and Antisimon play a game. Initially each player receives one fixed positive integer that doesn't change throughout the game. Simon receives number *a* and Antisimon receives number *b*. They also have a heap of *n* sto... | ```python
def gcd(x, y):
while(y):x, y = y, x % y
return x
a, b, c = map(int, input().split())
while 1:
if gcd(a, c) > c:
print(1)
break
c -= gcd(a, c)
if gcd(b, c) > c:
print(0)
break
c -= gcd(b, c)
``` | 3 | |
139 | A | Petr and Book | PROGRAMMING | 1,000 | [
"implementation"
] | null | null | One Sunday Petr went to a bookshop and bought a new book on sports programming. The book had exactly *n* pages.
Petr decided to start reading it starting from the next day, that is, from Monday. Petr's got a very tight schedule and for each day of the week he knows how many pages he will be able to read on that day. S... | The first input line contains the single integer *n* (1<=≤<=*n*<=≤<=1000) — the number of pages in the book.
The second line contains seven non-negative space-separated integers that do not exceed 1000 — those integers represent how many pages Petr can read on Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and... | Print a single number — the number of the day of the week, when Petr will finish reading the book. The days of the week are numbered starting with one in the natural order: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday. | [
"100\n15 20 20 15 10 30 45\n",
"2\n1 0 0 0 0 0 0\n"
] | [
"6\n",
"1\n"
] | Note to the first sample:
By the end of Monday and therefore, by the beginning of Tuesday Petr has 85 pages left. He has 65 pages left by Wednesday, 45 by Thursday, 30 by Friday, 20 by Saturday and on Saturday Petr finishes reading the book (and he also has time to read 10 pages of something else).
Note to the second... | 500 | [
{
"input": "100\n15 20 20 15 10 30 45",
"output": "6"
},
{
"input": "2\n1 0 0 0 0 0 0",
"output": "1"
},
{
"input": "100\n100 200 100 200 300 400 500",
"output": "1"
},
{
"input": "3\n1 1 1 1 1 1 1",
"output": "3"
},
{
"input": "1\n1 1 1 1 1 1 1",
"output": "1... | 1,660,820,529 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 62 | 0 | book = int(input())
sps = list(map(int, input().split()))
for_week = sum(strnc)
if for_week >= book:
strnc = 0
for j in range (7):
strnc += sps[j]
if strnc >= book:
print (j + 1)
break
else:
amn_week = book // for_week
for_week *= amn_week
for j... | Title: Petr and Book
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
One Sunday Petr went to a bookshop and bought a new book on sports programming. The book had exactly *n* pages.
Petr decided to start reading it starting from the next day, that is, from Monday. Petr's got a very tight s... | ```python
book = int(input())
sps = list(map(int, input().split()))
for_week = sum(strnc)
if for_week >= book:
strnc = 0
for j in range (7):
strnc += sps[j]
if strnc >= book:
print (j + 1)
break
else:
amn_week = book // for_week
for_week *= amn_week
... | -1 | |
958 | E1 | Guard Duty (easy) | PROGRAMMING | 1,600 | [
"brute force",
"geometry",
"greedy",
"math"
] | null | null | The Rebel fleet is afraid that the Empire might want to strike back again. Princess Heidi needs to know if it is possible to assign *R* Rebel spaceships to guard *B* bases so that every base has exactly one guardian and each spaceship has exactly one assigned base (in other words, the assignment is a perfect matching).... | The first line contains two space-separated integers *R*,<=*B*(1<=≤<=*R*,<=*B*<=≤<=10). For 1<=≤<=*i*<=≤<=*R*, the *i*<=+<=1-th line contains two space-separated integers *x**i* and *y**i* (|*x**i*|,<=|*y**i*|<=≤<=10000) denoting the coordinates of the *i*-th Rebel spaceship. The following *B* lines have the same forma... | If it is possible to connect Rebel spaceships and bases so as satisfy the constraint, output Yes, otherwise output No (without quote). | [
"3 3\n0 0\n2 0\n3 1\n-2 1\n0 3\n2 2\n",
"2 1\n1 0\n2 2\n3 1\n"
] | [
"Yes\n",
"No\n"
] | For the first example, one possible way is to connect the Rebels and bases in order.
For the second example, there is no perfect matching between Rebels and bases. | 0 | [
{
"input": "3 3\n0 0\n2 0\n3 1\n-2 1\n0 3\n2 2",
"output": "Yes"
},
{
"input": "2 1\n1 0\n2 2\n3 1",
"output": "No"
},
{
"input": "1 1\n3686 4362\n-7485 5112",
"output": "Yes"
},
{
"input": "1 2\n1152 -7324\n-5137 -35\n-6045 -5271",
"output": "No"
},
{
"input": "1... | 1,577,119,717 | 2,147,483,647 | PyPy 3 | OK | TESTS | 51 | 140 | 0 | l = input().split(' ')
print("Yes" if int(l[0]) == int(l[1]) else "No") | Title: Guard Duty (easy)
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The Rebel fleet is afraid that the Empire might want to strike back again. Princess Heidi needs to know if it is possible to assign *R* Rebel spaceships to guard *B* bases so that every base has exactly one guardian a... | ```python
l = input().split(' ')
print("Yes" if int(l[0]) == int(l[1]) else "No")
``` | 3 | |
999 | A | Mishka and Contest | PROGRAMMING | 800 | [
"brute force",
"implementation"
] | null | null | Mishka started participating in a programming contest. There are $n$ problems in the contest. Mishka's problem-solving skill is equal to $k$.
Mishka arranges all problems from the contest into a list. Because of his weird principles, Mishka only solves problems from one of the ends of the list. Every time, he chooses ... | The first line of input contains two integers $n$ and $k$ ($1 \le n, k \le 100$) — the number of problems in the contest and Mishka's problem-solving skill.
The second line of input contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 100$), where $a_i$ is the difficulty of the $i$-th problem. The problems are... | Print one integer — the maximum number of problems Mishka can solve. | [
"8 4\n4 2 3 1 5 1 6 4\n",
"5 2\n3 1 2 1 3\n",
"5 100\n12 34 55 43 21\n"
] | [
"5\n",
"0\n",
"5\n"
] | In the first example, Mishka can solve problems in the following order: $[4, 2, 3, 1, 5, 1, 6, 4] \rightarrow [2, 3, 1, 5, 1, 6, 4] \rightarrow [2, 3, 1, 5, 1, 6] \rightarrow [3, 1, 5, 1, 6] \rightarrow [1, 5, 1, 6] \rightarrow [5, 1, 6]$, so the number of solved problems will be equal to $5$.
In the second example, M... | 0 | [
{
"input": "8 4\n4 2 3 1 5 1 6 4",
"output": "5"
},
{
"input": "5 2\n3 1 2 1 3",
"output": "0"
},
{
"input": "5 100\n12 34 55 43 21",
"output": "5"
},
{
"input": "100 100\n44 47 36 83 76 94 86 69 31 2 22 77 37 51 10 19 25 78 53 25 1 29 48 95 35 53 22 72 49 86 60 38 13 91 89 1... | 1,641,219,810 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 2 | 31 | 0 | n , k = input().split()
n = int(n)
k = int(k)
lst = list(map(int,input().split()))
count = 0
while lst[0]<=k or lst[len(lst)-1]<=k:
if lst[0]<=k:
lst.remove(lst[0])
count+=1
elif lst[len(lst)-1]<=k:
lst.remove(lst[len(lst)-1])
count+=1
print(count)
| Title: Mishka and Contest
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Mishka started participating in a programming contest. There are $n$ problems in the contest. Mishka's problem-solving skill is equal to $k$.
Mishka arranges all problems from the contest into a list. Because of his... | ```python
n , k = input().split()
n = int(n)
k = int(k)
lst = list(map(int,input().split()))
count = 0
while lst[0]<=k or lst[len(lst)-1]<=k:
if lst[0]<=k:
lst.remove(lst[0])
count+=1
elif lst[len(lst)-1]<=k:
lst.remove(lst[len(lst)-1])
count+=1
print(count)
``` | -1 | |
490 | A | Team Olympiad | PROGRAMMING | 800 | [
"greedy",
"implementation",
"sortings"
] | null | null | The School №0 of the capital of Berland has *n* children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each child we know value *t**i*:
- *t**i*<==<=1, if the *i*-th child is good at prog... | The first line contains integer *n* (1<=≤<=*n*<=≤<=5000) — the number of children in the school. The second line contains *n* integers *t*1,<=*t*2,<=...,<=*t**n* (1<=≤<=*t**i*<=≤<=3), where *t**i* describes the skill of the *i*-th child. | In the first line output integer *w* — the largest possible number of teams.
Then print *w* lines, containing three numbers in each line. Each triple represents the indexes of the children forming the team. You can print both the teams, and the numbers in the triplets in any order. The children are numbered from 1 to... | [
"7\n1 3 1 3 2 1 2\n",
"4\n2 1 1 2\n"
] | [
"2\n3 5 2\n6 7 4\n",
"0\n"
] | none | 500 | [
{
"input": "7\n1 3 1 3 2 1 2",
"output": "2\n3 5 2\n6 7 4"
},
{
"input": "4\n2 1 1 2",
"output": "0"
},
{
"input": "1\n2",
"output": "0"
},
{
"input": "2\n3 1",
"output": "0"
},
{
"input": "3\n2 1 2",
"output": "0"
},
{
"input": "3\n1 2 3",
"output... | 1,682,414,769 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 6 | 31 | 0 | n = int(input())
arr = [int(i) for i in input().split()]
num = [ 0 for _ in range(3)]
t = 0
for i in arr :
num[i-1]+=1
t+=1
while t%3 != 0 and t > 0 :
t-=1
d = t // 3
g = {"1":[],"2":[],"3":[]}
for i,ele in enumerate(arr):
g[str(ele)].append(i+1)
vv = []
v1 = g['1']
v2 = g['2... | Title: Team Olympiad
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The School №0 of the capital of Berland has *n* children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education)... | ```python
n = int(input())
arr = [int(i) for i in input().split()]
num = [ 0 for _ in range(3)]
t = 0
for i in arr :
num[i-1]+=1
t+=1
while t%3 != 0 and t > 0 :
t-=1
d = t // 3
g = {"1":[],"2":[],"3":[]}
for i,ele in enumerate(arr):
g[str(ele)].append(i+1)
vv = []
v1 = g['1']
... | -1 | |
802 | A | Heidi and Library (easy) | PROGRAMMING | 1,800 | [
"greedy"
] | null | null | Your search for Heidi is over – you finally found her at a library, dressed up as a human. In fact, she has spent so much time there that she now runs the place! Her job is to buy books and keep them at the library so that people can borrow and read them. There are *n* different books, numbered 1 through *n*.
We will ... | The first line of input will contain two integers *n* and *k* (1<=≤<=*n*,<=*k*<=≤<=80). The second line will contain *n* integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=*n*) – the sequence of book requests. | On a single line print the minimum cost of buying books at the store so as to satisfy all requests. | [
"4 80\n1 2 2 1\n",
"4 1\n1 2 2 1\n",
"4 2\n1 2 3 1\n"
] | [
"2\n",
"3\n",
"3\n"
] | In the first test case, Heidi is able to keep all books forever. Therefore, she only needs to buy the book 1 before the first day and the book 2 before the second day.
In the second test case, she can only keep one book at a time. Therefore she will need to buy new books on the first, second and fourth day.
In the th... | 0 | [
{
"input": "4 80\n1 2 2 1",
"output": "2"
},
{
"input": "4 1\n1 2 2 1",
"output": "3"
},
{
"input": "4 2\n1 2 3 1",
"output": "3"
},
{
"input": "11 1\n1 2 3 5 1 10 10 1 1 3 5",
"output": "9"
},
{
"input": "5 2\n1 2 3 1 2",
"output": "4"
},
{
"input": "... | 1,613,161,581 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 46 | 0 | x = input().lower()
for a in x:
if a== "h" or a == "i" or a == "e" or a == "d" or a == "i":
print("NO")
else:
print("YES")
break
| Title: Heidi and Library (easy)
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Your search for Heidi is over – you finally found her at a library, dressed up as a human. In fact, she has spent so much time there that she now runs the place! Her job is to buy books and keep them at the lib... | ```python
x = input().lower()
for a in x:
if a== "h" or a == "i" or a == "e" or a == "d" or a == "i":
print("NO")
else:
print("YES")
break
``` | 0 | |
0 | none | none | none | 0 | [
"none"
] | null | null | Today Sonya learned about long integers and invited all her friends to share the fun. Sonya has an initially empty multiset with integers. Friends give her *t* queries, each of one of the following type:
1. <=+<= *a**i* — add non-negative integer *a**i* to the multiset. Note, that she has a multiset, thus there may b... | The first line of the input contains an integer *t* (1<=≤<=*t*<=≤<=100<=000) — the number of operation Sonya has to perform.
Next *t* lines provide the descriptions of the queries in order they appear in the input file. The *i*-th row starts with a character *c**i* — the type of the corresponding operation. If *c**i* ... | For each query of the third type print the number of integers matching the given pattern. Each integer is counted as many times, as it appears in the multiset at this moment of time. | [
"12\n+ 1\n+ 241\n? 1\n+ 361\n- 241\n? 0101\n+ 101\n? 101\n- 101\n? 101\n+ 4000\n? 0\n",
"4\n+ 200\n+ 200\n- 200\n? 0\n"
] | [
"2\n1\n2\n1\n1\n",
"1\n"
] | Consider the integers matching the patterns from the queries of the third type. Queries are numbered in the order they appear in the input.
1. 1 and 241. 1. 361. 1. 101 and 361. 1. 361. 1. 4000. | 0 | [
{
"input": "12\n+ 1\n+ 241\n? 1\n+ 361\n- 241\n? 0101\n+ 101\n? 101\n- 101\n? 101\n+ 4000\n? 0",
"output": "2\n1\n2\n1\n1"
},
{
"input": "4\n+ 200\n+ 200\n- 200\n? 0",
"output": "1"
},
{
"input": "20\n+ 61\n+ 99\n+ 51\n+ 70\n+ 7\n+ 34\n+ 71\n+ 86\n+ 68\n+ 39\n+ 78\n+ 81\n+ 89\n? 10\n? 00... | 1,547,275,436 | 2,147,483,647 | PyPy 3 | RUNTIME_ERROR | TESTS | 4 | 186 | 1,024,000 | N=int(input())
M=[0]*N
for i in range(N):
S = input()
pat = 0
for t in range(2,len(S)):
pat = (pat+(ord(S[t])&1))<<1
if S[0]=='?':
print(M[pat])
else:
exec('M[pat]'+S[0]+'=1') | Title: none
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Today Sonya learned about long integers and invited all her friends to share the fun. Sonya has an initially empty multiset with integers. Friends give her *t* queries, each of one of the following type:
1. <=+<= *a**i* — add no... | ```python
N=int(input())
M=[0]*N
for i in range(N):
S = input()
pat = 0
for t in range(2,len(S)):
pat = (pat+(ord(S[t])&1))<<1
if S[0]=='?':
print(M[pat])
else:
exec('M[pat]'+S[0]+'=1')
``` | -1 | |
499 | B | Lecture | PROGRAMMING | 1,000 | [
"implementation",
"strings"
] | null | null | You have a new professor of graph theory and he speaks very quickly. You come up with the following plan to keep up with his lecture and make notes.
You know two languages, and the professor is giving the lecture in the first one. The words in both languages consist of lowercase English characters, each language consi... | The first line contains two integers, *n* and *m* (1<=≤<=*n*<=≤<=3000, 1<=≤<=*m*<=≤<=3000) — the number of words in the professor's lecture and the number of words in each of these languages.
The following *m* lines contain the words. The *i*-th line contains two strings *a**i*, *b**i* meaning that the word *a**i* bel... | Output exactly *n* words: how you will record the lecture in your notebook. Output the words of the lecture in the same order as in the input. | [
"4 3\ncodeforces codesecrof\ncontest round\nletter message\ncodeforces contest letter contest\n",
"5 3\njoll wuqrd\neuzf un\nhbnyiyc rsoqqveh\nhbnyiyc joll joll euzf joll\n"
] | [
"codeforces round letter round\n",
"hbnyiyc joll joll un joll\n"
] | none | 500 | [
{
"input": "4 3\ncodeforces codesecrof\ncontest round\nletter message\ncodeforces contest letter contest",
"output": "codeforces round letter round"
},
{
"input": "5 3\njoll wuqrd\neuzf un\nhbnyiyc rsoqqveh\nhbnyiyc joll joll euzf joll",
"output": "hbnyiyc joll joll un joll"
},
{
"input"... | 1,601,091,974 | 2,147,483,647 | Python 3 | OK | TESTS | 37 | 109 | 716,800 | # Aditya Morankar
# lsta = list(map(int,input().split()))
def main():
lst={}
n,m = list(map(int,input().split()))
for i in range(m):
a,b = list(input().split(' '))
lst[a] = b
sentence = list(input().split(' '))
for i in range(n):
if senten... | Title: Lecture
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You have a new professor of graph theory and he speaks very quickly. You come up with the following plan to keep up with his lecture and make notes.
You know two languages, and the professor is giving the lecture in the first ... | ```python
# Aditya Morankar
# lsta = list(map(int,input().split()))
def main():
lst={}
n,m = list(map(int,input().split()))
for i in range(m):
a,b = list(input().split(' '))
lst[a] = b
sentence = list(input().split(' '))
for i in range(n):
... | 3 | |
148 | C | Terse princess | PROGRAMMING | 1,700 | [
"constructive algorithms",
"greedy"
] | null | null | «Next please», — the princess called and cast an estimating glance at the next groom.
The princess intends to choose the most worthy groom, this is, the richest one. Whenever she sees a groom who is more rich than each of the previous ones, she says a measured «Oh...». Whenever the groom is richer than all previous on... | The only line of input data contains three integer numbers *n*,<=*a* and *b* (1<=≤<=*n*<=≤<=100,<=0<=≤<=*a*,<=*b*<=≤<=15,<=*n*<=><=*a*<=+<=*b*), separated with single spaces. | Output any sequence of integers *t*1,<=*t*2,<=...,<=*t**n*, where *t**i* (1<=≤<=*t**i*<=≤<=50000) is the fortune of *i*-th groom, that satisfies the given constraints. If no sequence exists that would satisfy all the requirements, output a single number -1. | [
"10 2 3\n",
"5 0 0\n"
] | [
"5 1 3 6 16 35 46 4 200 99",
"10 10 6 6 5"
] | Let's have a closer look at the answer for the first sample test.
- The princess said «Oh...» (highlighted in bold): 5 1 3 6 16 35 46 4 200 99. - The princess exclaimed «Wow!» (highlighted in bold): 5 1 3 6 16 35 46 4 200 99. | 1,000 | [
{
"input": "10 2 3",
"output": "1 2 4 8 9 10 10 10 10 10 "
},
{
"input": "5 0 0",
"output": "1 1 1 1 1 "
},
{
"input": "5 2 2",
"output": "1 2 4 5 6 "
},
{
"input": "6 2 2",
"output": "1 2 4 5 6 6 "
},
{
"input": "10 9 0",
"output": "-1"
},
{
"input": ... | 1,688,039,963 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 4 | 46 | 0 | a, c, b = map(int, input().split())
C = [a - c - b]
at = a - b - c
t = True
for i in range(a):
if at > 0:
C.append(1)
at -= 1
elif b > 0:
C.append(sum(C) + 1)
b -= 1
elif c > 0:
C.append(max(C) + 1)
c -= 1
if C[i] > 50000:
t = False
... | Title: Terse princess
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
«Next please», — the princess called and cast an estimating glance at the next groom.
The princess intends to choose the most worthy groom, this is, the richest one. Whenever she sees a groom who is more rich than each ... | ```python
a, c, b = map(int, input().split())
C = [a - c - b]
at = a - b - c
t = True
for i in range(a):
if at > 0:
C.append(1)
at -= 1
elif b > 0:
C.append(sum(C) + 1)
b -= 1
elif c > 0:
C.append(max(C) + 1)
c -= 1
if C[i] > 50000:
... | 0 | |
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,422,334 | 2,147,483,647 | PyPy 3-64 | RUNTIME_ERROR | TESTS | 0 | 216 | 4,505,600 | {
"cells": [
{
"cell_type": "code",
"execution_count": 20,
"id": "a3e88404",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"I: 8\n",
"the: 8\n"
]
}
],
"source": [
"def cl(i):\n",
" count=0\n",
" with ... | 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
{
"cells": [
{
"cell_type": "code",
"execution_count": 20,
"id": "a3e88404",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"I: 8\n",
"the: 8\n"
]
}
],
"source": [
"def cl(i):\n",
" count=0\n",
... | -1 |
275 | A | Lights Out | PROGRAMMING | 900 | [
"implementation"
] | null | null | Lenny is playing a game on a 3<=×<=3 grid of lights. In the beginning of the game all lights are switched on. Pressing any of the lights will toggle it and all side-adjacent lights. The goal of the game is to switch all the lights off. We consider the toggling as follows: if the light was switched on then it will be sw... | The input consists of three rows. Each row contains three integers each between 0 to 100 inclusive. The *j*-th number in the *i*-th row is the number of times the *j*-th light of the *i*-th row of the grid is pressed. | Print three lines, each containing three characters. The *j*-th character of the *i*-th line is "1" if and only if the corresponding light is switched on, otherwise it's "0". | [
"1 0 0\n0 0 0\n0 0 1\n",
"1 0 1\n8 8 8\n2 0 3\n"
] | [
"001\n010\n100\n",
"010\n011\n100\n"
] | none | 500 | [
{
"input": "1 0 0\n0 0 0\n0 0 1",
"output": "001\n010\n100"
},
{
"input": "1 0 1\n8 8 8\n2 0 3",
"output": "010\n011\n100"
},
{
"input": "13 85 77\n25 50 45\n65 79 9",
"output": "000\n010\n000"
},
{
"input": "96 95 5\n8 84 74\n67 31 61",
"output": "011\n011\n101"
},
{... | 1,652,271,745 | 2,147,483,647 | Python 3 | OK | TESTS | 33 | 46 | 0 | g = [[0] + list(map(int, input().split())) + [0] for i in range(3)]
w = [[0]*5] + g + [[0]*5]
for i in range(1,4):
print("".join(map(str, [1 - (w[i][j-1] + w[i][j+1] + w[i][j] + w[i-1][j] + w[i+1][j]) %2 for j in range(1,4)])))
| Title: Lights Out
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Lenny is playing a game on a 3<=×<=3 grid of lights. In the beginning of the game all lights are switched on. Pressing any of the lights will toggle it and all side-adjacent lights. The goal of the game is to switch all the ... | ```python
g = [[0] + list(map(int, input().split())) + [0] for i in range(3)]
w = [[0]*5] + g + [[0]*5]
for i in range(1,4):
print("".join(map(str, [1 - (w[i][j-1] + w[i][j+1] + w[i][j] + w[i-1][j] + w[i+1][j]) %2 for j in range(1,4)])))
``` | 3 | |
71 | A | Way Too Long Words | PROGRAMMING | 800 | [
"strings"
] | A. Way Too Long Words | 1 | 256 | Sometimes some words like "localization" or "internationalization" are so long that writing them many times in one text is quite tiresome.
Let's consider a word too long, if its length is strictly more than 10 characters. All too long words should be replaced with a special abbreviation.
This abbreviation is made lik... | The first line contains an integer *n* (1<=≤<=*n*<=≤<=100). Each of the following *n* lines contains one word. All the words consist of lowercase Latin letters and possess the lengths of from 1 to 100 characters. | Print *n* lines. The *i*-th line should contain the result of replacing of the *i*-th word from the input data. | [
"4\nword\nlocalization\ninternationalization\npneumonoultramicroscopicsilicovolcanoconiosis\n"
] | [
"word\nl10n\ni18n\np43s\n"
] | none | 500 | [
{
"input": "4\nword\nlocalization\ninternationalization\npneumonoultramicroscopicsilicovolcanoconiosis",
"output": "word\nl10n\ni18n\np43s"
},
{
"input": "5\nabcdefgh\nabcdefghi\nabcdefghij\nabcdefghijk\nabcdefghijklm",
"output": "abcdefgh\nabcdefghi\nabcdefghij\na9k\na11m"
},
{
"input":... | 1,696,891,018 | 2,147,483,647 | Python 3 | OK | TESTS | 20 | 46 | 0 | n = int(input(""))
i = 1
while i < n + 1:
a = str(input(""))
if len(a) > 10:
print(a[0], (len(a) - 2), a[-1], sep="")
else:
print(a)
i = i + 1
| Title: Way Too Long Words
Time Limit: 1 seconds
Memory Limit: 256 megabytes
Problem Description:
Sometimes some words like "localization" or "internationalization" are so long that writing them many times in one text is quite tiresome.
Let's consider a word too long, if its length is strictly more than 10 character... | ```python
n = int(input(""))
i = 1
while i < n + 1:
a = str(input(""))
if len(a) > 10:
print(a[0], (len(a) - 2), a[-1], sep="")
else:
print(a)
i = i + 1
``` | 3.977 |
94 | A | Restoring Password | PROGRAMMING | 900 | [
"implementation",
"strings"
] | A. Restoring Password | 2 | 256 | Igor K. always used to trust his favorite Kashpirovsky Antivirus. That is why he didn't hesitate to download the link one of his groupmates sent him via QIP Infinium. The link was said to contain "some real funny stuff about swine influenza". The antivirus had no objections and Igor K. run the flash application he had ... | The input data contains 11 lines. The first line represents the binary code 80 characters in length. That is the code written in Igor K.'s ISQ account's info. Next 10 lines contain pairwise distinct binary codes 10 characters in length, corresponding to numbers 0, 1, ..., 9. | Print one line containing 8 characters — The password to Igor K.'s ISQ account. It is guaranteed that the solution exists. | [
"01001100100101100000010110001001011001000101100110010110100001011010100101101100\n0100110000\n0100110010\n0101100000\n0101100010\n0101100100\n0101100110\n0101101000\n0101101010\n0101101100\n0101101110\n",
"10101101111001000010100100011010101101110010110111011000100011011110010110001000\n1001000010\n1101111001\n1... | [
"12345678\n",
"30234919\n"
] | none | 500 | [
{
"input": "01001100100101100000010110001001011001000101100110010110100001011010100101101100\n0100110000\n0100110010\n0101100000\n0101100010\n0101100100\n0101100110\n0101101000\n0101101010\n0101101100\n0101101110",
"output": "12345678"
},
{
"input": "1010110111100100001010010001101010110111001011011... | 1,560,350,309 | 2,147,483,647 | Python 3 | OK | TESTS | 50 | 248 | 0 | n = input()
d = dict()
for i in range(10):
s = input()
d[s] = i
for i in range(8):
s = n[i * 10:i * 10 + 10]
print(d[s], end="") | Title: Restoring Password
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Igor K. always used to trust his favorite Kashpirovsky Antivirus. That is why he didn't hesitate to download the link one of his groupmates sent him via QIP Infinium. The link was said to contain "some real funny stuff a... | ```python
n = input()
d = dict()
for i in range(10):
s = input()
d[s] = i
for i in range(8):
s = n[i * 10:i * 10 + 10]
print(d[s], end="")
``` | 3.938 |
456 | A | Laptops | PROGRAMMING | 1,100 | [
"sortings"
] | null | null | One day Dima and Alex had an argument about the price and quality of laptops. Dima thinks that the more expensive a laptop is, the better it is. Alex disagrees. Alex thinks that there are two laptops, such that the price of the first laptop is less (strictly smaller) than the price of the second laptop but the quality ... | The first line contains an integer *n* (1<=≤<=*n*<=≤<=105) — the number of laptops.
Next *n* lines contain two integers each, *a**i* and *b**i* (1<=≤<=*a**i*,<=*b**i*<=≤<=*n*), where *a**i* is the price of the *i*-th laptop, and *b**i* is the number that represents the quality of the *i*-th laptop (the larger the numb... | If Alex is correct, print "Happy Alex", otherwise print "Poor Alex" (without the quotes). | [
"2\n1 2\n2 1\n"
] | [
"Happy Alex\n"
] | none | 500 | [
{
"input": "2\n1 2\n2 1",
"output": "Happy Alex"
},
{
"input": "2\n1 1\n2 2",
"output": "Poor Alex"
},
{
"input": "3\n2 2\n3 3\n1 1",
"output": "Poor Alex"
},
{
"input": "3\n3 3\n1 2\n2 1",
"output": "Happy Alex"
},
{
"input": "1\n1 1",
"output": "Poor Alex"
... | 1,681,589,750 | 2,147,483,647 | Python 3 | OK | TESTS | 46 | 280 | 5,017,600 | #Keshika Patwari
#Indian Institute Of Technology, Jodhpur
# 2022
import sys
input=sys.stdin.readline
def exe():
for i in range(len(x)):
if(x[i]!=y[i]):
return 'Happy Alex'
return 'Poor Alex'
x=[]
y=[]
for i in range(int(input())):
a,b=map(int,input().split())
x.append(... | Title: Laptops
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
One day Dima and Alex had an argument about the price and quality of laptops. Dima thinks that the more expensive a laptop is, the better it is. Alex disagrees. Alex thinks that there are two laptops, such that the price of the... | ```python
#Keshika Patwari
#Indian Institute Of Technology, Jodhpur
# 2022
import sys
input=sys.stdin.readline
def exe():
for i in range(len(x)):
if(x[i]!=y[i]):
return 'Happy Alex'
return 'Poor Alex'
x=[]
y=[]
for i in range(int(input())):
a,b=map(int,input().split())
... | 3 | |
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,694,694,781 | 2,147,483,647 | Python 3 | OK | TESTS | 101 | 92 | 0 | n = int(input())
s = input().split()
mydict = {int(s[i]): i + 1 for i in range(n)}
mydict = dict(sorted(mydict.items()))
count = []
for items in mydict.values():
count.append(items)
print(*count) | 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
n = int(input())
s = input().split()
mydict = {int(s[i]): i + 1 for i in range(n)}
mydict = dict(sorted(mydict.items()))
count = []
for items in mydict.values():
count.append(items)
print(*count)
``` | 3 | |
785 | B | Anton and Classes | PROGRAMMING | 1,100 | [
"greedy",
"sortings"
] | null | null | Anton likes to play chess. Also he likes to do programming. No wonder that he decided to attend chess classes and programming classes.
Anton has *n* variants when he will attend chess classes, *i*-th variant is given by a period of time (*l*1,<=*i*,<=*r*1,<=*i*). Also he has *m* variants when he will attend programmin... | The first line of the input contains a single integer *n* (1<=≤<=*n*<=≤<=200<=000) — the number of time periods when Anton can attend chess classes.
Each of the following *n* lines of the input contains two integers *l*1,<=*i* and *r*1,<=*i* (1<=≤<=*l*1,<=*i*<=≤<=*r*1,<=*i*<=≤<=109) — the *i*-th variant of a period of... | Output one integer — the maximal possible distance between time periods. | [
"3\n1 5\n2 6\n2 3\n2\n2 4\n6 8\n",
"3\n1 5\n2 6\n3 7\n2\n2 4\n1 4\n"
] | [
"3\n",
"0\n"
] | In the first sample Anton can attend chess classes in the period (2, 3) and attend programming classes in the period (6, 8). It's not hard to see that in this case the distance between the periods will be equal to 3.
In the second sample if he chooses any pair of periods, they will intersect. So the answer is 0. | 1,000 | [
{
"input": "3\n1 5\n2 6\n2 3\n2\n2 4\n6 8",
"output": "3"
},
{
"input": "3\n1 5\n2 6\n3 7\n2\n2 4\n1 4",
"output": "0"
},
{
"input": "20\n13 141\n57 144\n82 124\n16 23\n18 44\n64 65\n117 133\n84 117\n77 142\n40 119\n105 120\n71 92\n5 142\n48 132\n106 121\n5 80\n45 92\n66 81\n7 93\n27 71\... | 1,687,068,586 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 25 | 2,308 | 32,768,000 | n = int(input())
chess = []
mnr = 1e9
mnl = 1e9
mxl = -1
mxr = -1
for i in range(n):
chess.append([int(e) for e in input().split()])
if chess[i][0] > mxl:
mxl = chess[i][0]
if chess[i][1] < mnr:
mnr = chess[i][1]
if chess[i][0] < mnl:
mnl = chess[i][0]
if chess[... | Title: Anton and Classes
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Anton likes to play chess. Also he likes to do programming. No wonder that he decided to attend chess classes and programming classes.
Anton has *n* variants when he will attend chess classes, *i*-th variant is given... | ```python
n = int(input())
chess = []
mnr = 1e9
mnl = 1e9
mxl = -1
mxr = -1
for i in range(n):
chess.append([int(e) for e in input().split()])
if chess[i][0] > mxl:
mxl = chess[i][0]
if chess[i][1] < mnr:
mnr = chess[i][1]
if chess[i][0] < mnl:
mnl = chess[i][0]
... | 0 | |
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,687,709,485 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 0 | 92 | 0 | n = int(input())
no_of_4s = n // 4
no_of_7s = 0
remainder = n % 4
if remainder == 1:
no_of_4s -= 5
no_of_7s = 3
elif remainder == 2:
no_of_4s -= 3
no_of_7s = 2
elif remainder == 3:
no_of_4s -= 1
no_of_7s = 1
print(no_of_4s, no_of_7s)
if no_of_4s < 0:
print(-1)
else:
while no_of_4s - 7... | 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())
no_of_4s = n // 4
no_of_7s = 0
remainder = n % 4
if remainder == 1:
no_of_4s -= 5
no_of_7s = 3
elif remainder == 2:
no_of_4s -= 3
no_of_7s = 2
elif remainder == 3:
no_of_4s -= 1
no_of_7s = 1
print(no_of_4s, no_of_7s)
if no_of_4s < 0:
print(-1)
else:
while no... | 0 |
2 | A | Winner | PROGRAMMING | 1,500 | [
"hashing",
"implementation"
] | A. Winner | 1 | 64 | The winner of the card game popular in Berland "Berlogging" is determined according to the following rules. If at the end of the game there is only one player with the maximum number of points, he is the winner. The situation becomes more difficult if the number of such players is more than one. During each round a pla... | The first line contains an integer number *n* (1<=<=≤<=<=*n*<=<=≤<=<=1000), *n* is the number of rounds played. Then follow *n* lines, containing the information about the rounds in "name score" format in chronological order, where name is a string of lower-case Latin letters with the length from 1 to 32, and score is ... | Print the name of the winner. | [
"3\nmike 3\nandrew 5\nmike 2\n",
"3\nandrew 3\nandrew 2\nmike 5\n"
] | [
"andrew\n",
"andrew\n"
] | none | 0 | [
{
"input": "3\nmike 3\nandrew 5\nmike 2",
"output": "andrew"
},
{
"input": "3\nandrew 3\nandrew 2\nmike 5",
"output": "andrew"
},
{
"input": "5\nkaxqybeultn -352\nmgochgrmeyieyskhuourfg -910\nkaxqybeultn 691\nmgochgrmeyieyskhuourfg -76\nkaxqybeultn -303",
"output": "kaxqybeultn"
},... | 1,520,622,172 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 9 | 124 | 5,632,000 | n = int(input())
res = {}
max_name = ""
max_score = -1E16
for k in range(n):
a = input().split(' ')
name, score = a[0], int(a[1])
res[name] = res.get(name, 0) + score
if (max_score < res[name]):
max_score = res[name]
max_name = name
print(max_name)
| Title: Winner
Time Limit: 1 seconds
Memory Limit: 64 megabytes
Problem Description:
The winner of the card game popular in Berland "Berlogging" is determined according to the following rules. If at the end of the game there is only one player with the maximum number of points, he is the winner. The situation becomes... | ```python
n = int(input())
res = {}
max_name = ""
max_score = -1E16
for k in range(n):
a = input().split(' ')
name, score = a[0], int(a[1])
res[name] = res.get(name, 0) + score
if (max_score < res[name]):
max_score = res[name]
max_name = name
print(max_name)
``` | 0 |
999 | C | Alphabetic Removals | PROGRAMMING | 1,200 | [
"implementation"
] | null | null | You are given a string $s$ consisting of $n$ lowercase Latin letters. Polycarp wants to remove exactly $k$ characters ($k \le n$) from the string $s$. Polycarp uses the following algorithm $k$ times:
- if there is at least one letter 'a', remove the leftmost occurrence and stop the algorithm, otherwise go to next ite... | The first line of input contains two integers $n$ and $k$ ($1 \le k \le n \le 4 \cdot 10^5$) — the length of the string and the number of letters Polycarp will remove.
The second line contains the string $s$ consisting of $n$ lowercase Latin letters. | Print the string that will be obtained from $s$ after Polycarp removes exactly $k$ letters using the above algorithm $k$ times.
If the resulting string is empty, print nothing. It is allowed to print nothing or an empty line (line break). | [
"15 3\ncccaabababaccbc\n",
"15 9\ncccaabababaccbc\n",
"1 1\nu\n"
] | [
"cccbbabaccbc\n",
"cccccc\n",
""
] | none | 0 | [
{
"input": "15 3\ncccaabababaccbc",
"output": "cccbbabaccbc"
},
{
"input": "15 9\ncccaabababaccbc",
"output": "cccccc"
},
{
"input": "5 2\nzyzyx",
"output": "zzy"
},
{
"input": "4 3\nhack",
"output": "k"
},
{
"input": "4 3\nzzzz",
"output": "z"
},
{
"i... | 1,653,136,998 | 2,147,483,647 | PyPy 3-64 | TIME_LIMIT_EXCEEDED | TESTS | 4 | 2,000 | 14,131,200 | n, k = map(int, input().split())
s = input()
if(n == k):
print()
exit()
d = {chr(i + ord('a')) : 0 for i in range(26)}
for i in range(n):
d[s[i]] += 1
c = 'a'
for i in d.keys():
if(d[i] <= k):
k -= d[i]
else:
d[i] -= k
c = i
break
ans ... | Title: Alphabetic Removals
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given a string $s$ consisting of $n$ lowercase Latin letters. Polycarp wants to remove exactly $k$ characters ($k \le n$) from the string $s$. Polycarp uses the following algorithm $k$ times:
- if there is... | ```python
n, k = map(int, input().split())
s = input()
if(n == k):
print()
exit()
d = {chr(i + ord('a')) : 0 for i in range(26)}
for i in range(n):
d[s[i]] += 1
c = 'a'
for i in d.keys():
if(d[i] <= k):
k -= d[i]
else:
d[i] -= k
c = i
break... | 0 | |
637 | B | Chat Order | PROGRAMMING | 1,200 | [
"*special",
"binary search",
"constructive algorithms",
"data structures",
"sortings"
] | null | null | Polycarp is a big lover of killing time in social networks. A page with a chatlist in his favourite network is made so that when a message is sent to some friend, his friend's chat rises to the very top of the page. The relative order of the other chats doesn't change. If there was no chat with this friend before, then... | The first line contains integer *n* (1<=≤<=*n*<=≤<=200<=000) — the number of Polycarpus' messages. Next *n* lines enlist the message recipients in the order in which the messages were sent. The name of each participant is a non-empty sequence of lowercase English letters of length at most 10. | Print all the recipients to who Polycarp talked to in the order of chats with them, from top to bottom. | [
"4\nalex\nivan\nroman\nivan\n",
"8\nalina\nmaria\nekaterina\ndarya\ndarya\nekaterina\nmaria\nalina\n"
] | [
"ivan\nroman\nalex\n",
"alina\nmaria\nekaterina\ndarya\n"
] | In the first test case Polycarpus first writes to friend by name "alex", and the list looks as follows:
1. alex
Then Polycarpus writes to friend by name "ivan" and the list looks as follows:
1. ivan 1. alex
Polycarpus writes the third message to friend by name "roman" and the list looks as follows:
1. roman 1... | 1,000 | [
{
"input": "4\nalex\nivan\nroman\nivan",
"output": "ivan\nroman\nalex"
},
{
"input": "8\nalina\nmaria\nekaterina\ndarya\ndarya\nekaterina\nmaria\nalina",
"output": "alina\nmaria\nekaterina\ndarya"
},
{
"input": "1\nwdi",
"output": "wdi"
},
{
"input": "2\nypg\nypg",
"outpu... | 1,625,866,748 | 2,147,483,647 | PyPy 3 | TIME_LIMIT_EXCEEDED | TESTS | 46 | 3,000 | 24,576,000 | from queue import LifoQueue
names1 = set()
names2 = set()
q = LifoQueue()
n = int(input())
for i in range(n):
name = input()
q.put(name)
names1.add(name)
while names1:
name = q.get()
if name not in names2:
names2.add(name)
names1.remove(name)
print(name)
... | Title: Chat Order
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Polycarp is a big lover of killing time in social networks. A page with a chatlist in his favourite network is made so that when a message is sent to some friend, his friend's chat rises to the very top of the page. The rela... | ```python
from queue import LifoQueue
names1 = set()
names2 = set()
q = LifoQueue()
n = int(input())
for i in range(n):
name = input()
q.put(name)
names1.add(name)
while names1:
name = q.get()
if name not in names2:
names2.add(name)
names1.remove(name)
print(name)
... | 0 | |
384 | A | Coder | PROGRAMMING | 800 | [
"implementation"
] | null | null | Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (*x*,<=*y*), he can move to (or attack) positions (*x*<=+<=1,<=*y*), (*x*–1,<=*y*), (*x*,<=*y*<=+<=1) and (*x*,<=*y*–1).
... | The first line contains an integer *n* (1<=≤<=*n*<=≤<=1000). | On the first line print an integer, the maximum number of Coders that can be placed on the chessboard.
On each of the next *n* lines print *n* characters, describing the configuration of the Coders. For an empty cell print an '.', and for a Coder print a 'C'.
If there are multiple correct answers, you can print any. | [
"2\n"
] | [
"2\nC.\n.C\n"
] | none | 500 | [
{
"input": "2",
"output": "2\nC.\n.C"
},
{
"input": "3",
"output": "5\nC.C\n.C.\nC.C"
},
{
"input": "4",
"output": "8\nC.C.\n.C.C\nC.C.\n.C.C"
},
{
"input": "10",
"output": "50\nC.C.C.C.C.\n.C.C.C.C.C\nC.C.C.C.C.\n.C.C.C.C.C\nC.C.C.C.C.\n.C.C.C.C.C\nC.C.C.C.C.\n.C.C.C.C.C... | 1,592,487,362 | 2,147,483,647 | PyPy 3 | OK | TESTS | 15 | 265 | 7,577,600 | from collections import *
from math import *
n = int(input())
a = [['.' for i in range(n)] for j in range(n)]
ans = 0
for i in range(n):
for j in range(n):
if (i+j)%2 == 0:
a[i][j] = 'C'
ans += 1
print(ans)
for i in range(n):
print("".join(a[i]))
| Title: Coder
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (*x*,<=*y*), he can move to (or... | ```python
from collections import *
from math import *
n = int(input())
a = [['.' for i in range(n)] for j in range(n)]
ans = 0
for i in range(n):
for j in range(n):
if (i+j)%2 == 0:
a[i][j] = 'C'
ans += 1
print(ans)
for i in range(n):
print("".join(a[i]))
``` | 3 | |
58 | A | Chat room | PROGRAMMING | 1,000 | [
"greedy",
"strings"
] | A. Chat room | 1 | 256 | Vasya has recently learned to type and log on to the Internet. He immediately entered a chat room and decided to say hello to everybody. Vasya typed the word *s*. It is considered that Vasya managed to say hello if several letters can be deleted from the typed word so that it resulted in the word "hello". For example, ... | The first and only line contains the word *s*, which Vasya typed. This word consisits of small Latin letters, its length is no less that 1 and no more than 100 letters. | If Vasya managed to say hello, print "YES", otherwise print "NO". | [
"ahhellllloou\n",
"hlelo\n"
] | [
"YES\n",
"NO\n"
] | none | 500 | [
{
"input": "ahhellllloou",
"output": "YES"
},
{
"input": "hlelo",
"output": "NO"
},
{
"input": "helhcludoo",
"output": "YES"
},
{
"input": "hehwelloho",
"output": "YES"
},
{
"input": "pnnepelqomhhheollvlo",
"output": "YES"
},
{
"input": "tymbzjyqhymeda... | 1,488,881,227 | 2,147,483,647 | PyPy 3 | OK | TESTS | 40 | 93 | 23,142,400 | st = list(input())
w = "hello"
i = 0
for char in w:
while i < len(st):
if st[i] != char:
del st[i]
else:
i += 1
break
s = ''.join(st)
if s[:5] == 'hello':
print ("YES")
else:
print ("NO")
| Title: Chat room
Time Limit: 1 seconds
Memory Limit: 256 megabytes
Problem Description:
Vasya has recently learned to type and log on to the Internet. He immediately entered a chat room and decided to say hello to everybody. Vasya typed the word *s*. It is considered that Vasya managed to say hello if several letter... | ```python
st = list(input())
w = "hello"
i = 0
for char in w:
while i < len(st):
if st[i] != char:
del st[i]
else:
i += 1
break
s = ''.join(st)
if s[:5] == 'hello':
print ("YES")
else:
print ("NO")
``` | 3.910394 |
237 | A | Free Cash | PROGRAMMING | 1,000 | [
"implementation"
] | null | null | Valera runs a 24/7 fast food cafe. He magically learned that next day *n* people will visit his cafe. For each person we know the arrival time: the *i*-th person comes exactly at *h**i* hours *m**i* minutes. The cafe spends less than a minute to serve each client, but if a client comes in and sees that there is no free... | The first line contains a single integer *n* (1<=≤<=*n*<=≤<=105), that is the number of cafe visitors.
Each of the following *n* lines has two space-separated integers *h**i* and *m**i* (0<=≤<=*h**i*<=≤<=23; 0<=≤<=*m**i*<=≤<=59), representing the time when the *i*-th person comes into the cafe.
Note that the time is... | Print a single integer — the minimum number of cashes, needed to serve all clients next day. | [
"4\n8 0\n8 10\n8 10\n8 45\n",
"3\n0 12\n10 11\n22 22\n"
] | [
"2\n",
"1\n"
] | In the first sample it is not enough one cash to serve all clients, because two visitors will come into cafe in 8:10. Therefore, if there will be one cash in cafe, then one customer will be served by it, and another one will not wait and will go away.
In the second sample all visitors will come in different times, so ... | 500 | [
{
"input": "4\n8 0\n8 10\n8 10\n8 45",
"output": "2"
},
{
"input": "3\n0 12\n10 11\n22 22",
"output": "1"
},
{
"input": "5\n12 8\n15 27\n15 27\n16 2\n19 52",
"output": "2"
},
{
"input": "7\n5 6\n7 34\n7 34\n7 34\n12 29\n15 19\n20 23",
"output": "3"
},
{
"input": "... | 1,692,624,594 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 8 | 2,000 | 307,200 | t=int(input())
mas=[]
for i in range(t):
n,m=map(int,input().split())
m=n*60+m
mas.append(m)
a=[]
for i in mas:
a.append(mas.count(i))
print(max(a)) | Title: Free Cash
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Valera runs a 24/7 fast food cafe. He magically learned that next day *n* people will visit his cafe. For each person we know the arrival time: the *i*-th person comes exactly at *h**i* hours *m**i* minutes. The cafe spends l... | ```python
t=int(input())
mas=[]
for i in range(t):
n,m=map(int,input().split())
m=n*60+m
mas.append(m)
a=[]
for i in mas:
a.append(mas.count(i))
print(max(a))
``` | 0 | |
667 | A | Pouring Rain | PROGRAMMING | 1,100 | [
"geometry",
"math"
] | null | null | A lot of people in Berland hates rain, but you do not. Rain pacifies, puts your thoughts in order. By these years you have developed a good tradition — when it rains, you go on the street and stay silent for a moment, contemplate all around you, enjoy freshness, think about big deeds you have to do.
Today everything ... | The only line of the input contains four integer numbers *d*,<=*h*,<=*v*,<=*e* (1<=≤<=*d*,<=*h*,<=*v*,<=*e*<=≤<=104), where:
- *d* — the diameter of your cylindrical cup, - *h* — the initial level of water in the cup, - *v* — the speed of drinking process from the cup in milliliters per second, - *e* — the growth ... | If it is impossible to make the cup empty, print "NO" (without quotes).
Otherwise print "YES" (without quotes) in the first line. In the second line print a real number — time in seconds needed the cup will be empty. The answer will be considered correct if its relative or absolute error doesn't exceed 10<=-<=4. It is... | [
"1 2 3 100\n",
"1 1 1 1\n"
] | [
"NO\n",
"YES\n3.659792366325\n"
] | In the first example the water fills the cup faster than you can drink from it.
In the second example area of the cup's bottom equals to <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/419dc74dcd7bc392019c9fe748fe1fdb08ab521a.png" style="max-width: 100.0%;max-height: 100.0%;"/>, thus we ca... | 500 | [
{
"input": "1 2 3 100",
"output": "NO"
},
{
"input": "1 1 1 1",
"output": "YES\n3.659792366325"
},
{
"input": "48 7946 7992 72",
"output": "NO"
},
{
"input": "72 6791 8546 46",
"output": "NO"
},
{
"input": "100 5635 9099 23",
"output": "NO"
},
{
"input... | 1,579,953,952 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 109 | 0 | from math import pi
d,h,v,e = list(map(int,input().split()))
H = (4*v)/(pi*(d**2))
if H <= e:print("NO")
else:
ans = h/(H-e)
print(ans) | Title: Pouring Rain
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
A lot of people in Berland hates rain, but you do not. Rain pacifies, puts your thoughts in order. By these years you have developed a good tradition — when it rains, you go on the street and stay silent for a moment, cont... | ```python
from math import pi
d,h,v,e = list(map(int,input().split()))
H = (4*v)/(pi*(d**2))
if H <= e:print("NO")
else:
ans = h/(H-e)
print(ans)
``` | 0 | |
454 | B | Little Pony and Sort by Shift | PROGRAMMING | 1,200 | [
"implementation"
] | null | null | One day, Twilight Sparkle is interested in how to sort a sequence of integers *a*1,<=*a*2,<=...,<=*a**n* in non-decreasing order. Being a young unicorn, the only operation she can perform is a unit shift. That is, she can move the last element of the sequence to its beginning:
Help Twilight Sparkle to calculate: what ... | The first line contains an integer *n* (2<=≤<=*n*<=≤<=105). The second line contains *n* integer numbers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=105). | If it's impossible to sort the sequence output -1. Otherwise output the minimum number of operations Twilight Sparkle needs to sort it. | [
"2\n2 1\n",
"3\n1 3 2\n",
"2\n1 2\n"
] | [
"1\n",
"-1\n",
"0\n"
] | none | 1,000 | [
{
"input": "2\n2 1",
"output": "1"
},
{
"input": "3\n1 3 2",
"output": "-1"
},
{
"input": "2\n1 2",
"output": "0"
},
{
"input": "6\n3 4 5 6 3 2",
"output": "-1"
},
{
"input": "3\n1 2 1",
"output": "1"
},
{
"input": "5\n1 1 2 1 1",
"output": "2"
}... | 1,587,313,874 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 109 | 409,600 | import copy
import math
input()
arr = list(map(int,list(input().split())))
flag = -1
beacon = -1
arr_sorted = sorted(arr)
c_init = 0
n = len(arr)
flag = math.copysign(1, arr[1] - arr[0])
i = 0
if arr == sorted(arr):
beacon = 1
elif arr[1:] == sorted(arr[1:],reverse=True):
if arr[-1] <= arr[0... | Title: Little Pony and Sort by Shift
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
One day, Twilight Sparkle is interested in how to sort a sequence of integers *a*1,<=*a*2,<=...,<=*a**n* in non-decreasing order. Being a young unicorn, the only operation she can perform is a unit shift. ... | ```python
import copy
import math
input()
arr = list(map(int,list(input().split())))
flag = -1
beacon = -1
arr_sorted = sorted(arr)
c_init = 0
n = len(arr)
flag = math.copysign(1, arr[1] - arr[0])
i = 0
if arr == sorted(arr):
beacon = 1
elif arr[1:] == sorted(arr[1:],reverse=True):
if arr[-1... | 0 | |
141 | A | Amusing Joke | PROGRAMMING | 800 | [
"implementation",
"sortings",
"strings"
] | null | null | So, the New Year holidays are over. Santa Claus and his colleagues can take a rest and have guests at last. When two "New Year and Christmas Men" meet, thear assistants cut out of cardboard the letters from the guest's name and the host's name in honor of this event. Then the hung the letters above the main entrance. O... | The input file consists of three lines: the first line contains the guest's name, the second line contains the name of the residence host and the third line contains letters in a pile that were found at the door in the morning. All lines are not empty and contain only uppercase Latin letters. The length of each line do... | Print "YES" without the quotes, if the letters in the pile could be permuted to make the names of the "New Year and Christmas Men". Otherwise, print "NO" without the quotes. | [
"SANTACLAUS\nDEDMOROZ\nSANTAMOROZDEDCLAUS\n",
"PAPAINOEL\nJOULUPUKKI\nJOULNAPAOILELUPUKKI\n",
"BABBONATALE\nFATHERCHRISTMAS\nBABCHRISTMASBONATALLEFATHER\n"
] | [
"YES\n",
"NO\n",
"NO\n"
] | In the first sample the letters written in the last line can be used to write the names and there won't be any extra letters left.
In the second sample letter "P" is missing from the pile and there's an extra letter "L".
In the third sample there's an extra letter "L". | 500 | [
{
"input": "SANTACLAUS\nDEDMOROZ\nSANTAMOROZDEDCLAUS",
"output": "YES"
},
{
"input": "PAPAINOEL\nJOULUPUKKI\nJOULNAPAOILELUPUKKI",
"output": "NO"
},
{
"input": "BABBONATALE\nFATHERCHRISTMAS\nBABCHRISTMASBONATALLEFATHER",
"output": "NO"
},
{
"input": "B\nA\nAB",
"output": ... | 1,692,878,424 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 54 | 124 | 0 | g = list(input())
g += list(input())
c = list(input())
g.sort()
c.sort()
if g == c:
print("YES")
else:
print("NO") | Title: Amusing Joke
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
So, the New Year holidays are over. Santa Claus and his colleagues can take a rest and have guests at last. When two "New Year and Christmas Men" meet, thear assistants cut out of cardboard the letters from the guest's nam... | ```python
g = list(input())
g += list(input())
c = list(input())
g.sort()
c.sort()
if g == c:
print("YES")
else:
print("NO")
``` | 3 | |
777 | A | Shell Game | PROGRAMMING | 1,000 | [
"constructive algorithms",
"implementation",
"math"
] | null | null | Bomboslav likes to look out of the window in his room and watch lads outside playing famous shell game. The game is played by two persons: operator and player. Operator takes three similar opaque shells and places a ball beneath one of them. Then he shuffles the shells by swapping some pairs and the player has to guess... | The first line of the input contains an integer *n* (1<=≤<=*n*<=≤<=2·109) — the number of movements made by the operator.
The second line contains a single integer *x* (0<=≤<=*x*<=≤<=2) — the index of the shell where the ball was found after *n* movements. | Print one integer from 0 to 2 — the index of the shell where the ball was initially placed. | [
"4\n2\n",
"1\n1\n"
] | [
"1\n",
"0\n"
] | In the first sample, the ball was initially placed beneath the middle shell and the operator completed four movements.
1. During the first move operator swapped the left shell and the middle shell. The ball is now under the left shell. 1. During the second move operator swapped the middle shell and the right one. Th... | 500 | [
{
"input": "4\n2",
"output": "1"
},
{
"input": "1\n1",
"output": "0"
},
{
"input": "2\n2",
"output": "0"
},
{
"input": "3\n1",
"output": "1"
},
{
"input": "3\n2",
"output": "0"
},
{
"input": "3\n0",
"output": "2"
},
{
"input": "2000000000\n... | 1,698,415,541 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 68 | 421 | 21,401,600 | from doctest import master
n=int(input())
x=int(input())
m=n%6
mas=[0,0,0]
mas[x]=1
# mas=[[0,1,2],[1,0,2],[1,2,0],[2,1,0],[2,0,1],[0,2,1]]
# mas.reverse()
for i in range(m,0,-1):
if i%2==0:
mas[1],mas[2]=mas[2],mas[1]
else:
mas[0],mas[1]=mas[1],mas[0]
print(mas.index(1)... | Title: Shell Game
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Bomboslav likes to look out of the window in his room and watch lads outside playing famous shell game. The game is played by two persons: operator and player. Operator takes three similar opaque shells and places a ball ben... | ```python
from doctest import master
n=int(input())
x=int(input())
m=n%6
mas=[0,0,0]
mas[x]=1
# mas=[[0,1,2],[1,0,2],[1,2,0],[2,1,0],[2,0,1],[0,2,1]]
# mas.reverse()
for i in range(m,0,-1):
if i%2==0:
mas[1],mas[2]=mas[2],mas[1]
else:
mas[0],mas[1]=mas[1],mas[0]
print(ma... | 3 | |
90 | A | Cableway | PROGRAMMING | 1,000 | [
"greedy",
"math"
] | A. Cableway | 2 | 256 | A group of university students wants to get to the top of a mountain to have a picnic there. For that they decided to use a cableway.
A cableway is represented by some cablecars, hanged onto some cable stations by a cable. A cable is scrolled cyclically between the first and the last cable stations (the first of them ... | The first line contains three integers *r*, *g* and *b* (0<=≤<=*r*,<=*g*,<=*b*<=≤<=100). It is guaranteed that *r*<=+<=*g*<=+<=*b*<=><=0, it means that the group consists of at least one student. | Print a single number — the minimal time the students need for the whole group to ascend to the top of the mountain. | [
"1 3 2\n",
"3 2 1\n"
] | [
"34",
"33"
] | Let's analyze the first sample.
At the moment of time 0 a red cablecar comes and one student from the *r* group get on it and ascends to the top at the moment of time 30.
At the moment of time 1 a green cablecar arrives and two students from the *g* group get on it; they get to the top at the moment of time 31.
At t... | 500 | [
{
"input": "1 3 2",
"output": "34"
},
{
"input": "3 2 1",
"output": "33"
},
{
"input": "3 5 2",
"output": "37"
},
{
"input": "10 10 10",
"output": "44"
},
{
"input": "29 7 24",
"output": "72"
},
{
"input": "28 94 13",
"output": "169"
},
{
"... | 1,657,156,389 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 3 | 92 | 0 | data = list(map(int, input().split(" ")))
trips = []
biggest = 0
biggest_index = 0
for i in range(3):
trips.append(data[i]//2)
if data[i]%2 != 2:
trips[i] += 1
if trips[i] > biggest:
biggest = trips[i]
biggest_index = i
if biggest_index == 0:
print(30 + ((trips[0]-1 )* 3))
eli... | Title: Cableway
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
A group of university students wants to get to the top of a mountain to have a picnic there. For that they decided to use a cableway.
A cableway is represented by some cablecars, hanged onto some cable stations by a cable. A cabl... | ```python
data = list(map(int, input().split(" ")))
trips = []
biggest = 0
biggest_index = 0
for i in range(3):
trips.append(data[i]//2)
if data[i]%2 != 2:
trips[i] += 1
if trips[i] > biggest:
biggest = trips[i]
biggest_index = i
if biggest_index == 0:
print(30 + ((trips[0]-1 )... | 0 |
919 | D | Substring | PROGRAMMING | 1,700 | [
"dfs and similar",
"dp",
"graphs"
] | null | null | You are given a graph with $n$ nodes and $m$ directed edges. One lowercase letter is assigned to each node. We define a path's value as the number of the most frequently occurring letter. For example, if letters on a path are "abaca", then the value of that path is $3$. Your task is find a path whose value is the large... | The first line contains two positive integers $n, m$ ($1 \leq n, m \leq 300\,000$), denoting that the graph has $n$ nodes and $m$ directed edges.
The second line contains a string $s$ with only lowercase English letters. The $i$-th character is the letter assigned to the $i$-th node.
Then $m$ lines follow. Each line ... | Output a single line with a single integer denoting the largest value. If the value can be arbitrarily large, output -1 instead. | [
"5 4\nabaca\n1 2\n1 3\n3 4\n4 5\n",
"6 6\nxzyabc\n1 2\n3 1\n2 3\n5 4\n4 3\n6 4\n",
"10 14\nxzyzyzyzqx\n1 2\n2 4\n3 5\n4 5\n2 6\n6 8\n6 5\n2 10\n3 9\n10 9\n4 6\n1 10\n2 8\n3 7\n"
] | [
"3\n",
"-1\n",
"4\n"
] | In the first sample, the path with largest value is $1 \to 3 \to 4 \to 5$. The value is $3$ because the letter 'a' appears $3$ times. | 1,500 | [
{
"input": "5 4\nabaca\n1 2\n1 3\n3 4\n4 5",
"output": "3"
},
{
"input": "6 6\nxzyabc\n1 2\n3 1\n2 3\n5 4\n4 3\n6 4",
"output": "-1"
},
{
"input": "10 14\nxzyzyzyzqx\n1 2\n2 4\n3 5\n4 5\n2 6\n6 8\n6 5\n2 10\n3 9\n10 9\n4 6\n1 10\n2 8\n3 7",
"output": "4"
},
{
"input": "1 1\nf... | 1,676,265,204 | 1,704 | Python 3 | WRONG_ANSWER | TESTS | 0 | 30 | 102,400 | from collections import defaultdict
def beauty(n, m, S, X, Y):
adj_list = defaultdict(list)
for i in range(m):
adj_list[X[i]-1].append(Y[i]-1)
s = list(S)
s.sort()
freq = [s.count(c) for c in set(s)]
freq.sort()
freq = freq[::-1]
beauty = [0] * n
for i in range(l... | Title: Substring
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given a graph with $n$ nodes and $m$ directed edges. One lowercase letter is assigned to each node. We define a path's value as the number of the most frequently occurring letter. For example, if letters on a path are... | ```python
from collections import defaultdict
def beauty(n, m, S, X, Y):
adj_list = defaultdict(list)
for i in range(m):
adj_list[X[i]-1].append(Y[i]-1)
s = list(S)
s.sort()
freq = [s.count(c) for c in set(s)]
freq.sort()
freq = freq[::-1]
beauty = [0] * n
for i ... | 0 | |
785 | A | Anton and Polyhedrons | PROGRAMMING | 800 | [
"implementation",
"strings"
] | null | null | Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons:
- Tetrahedron. Tetrahedron has 4 triangular faces. - Cube. Cube has 6 square faces. - Octahedron. Octahedron has 8 triangular faces. - Dodecahedron. Dodecahedron has 12 pentagonal faces. - Icosahed... | The first line of the input contains a single integer *n* (1<=≤<=*n*<=≤<=200<=000) — the number of polyhedrons in Anton's collection.
Each of the following *n* lines of the input contains a string *s**i* — the name of the *i*-th polyhedron in Anton's collection. The string can look like this:
- "Tetrahedron" (withou... | Output one number — the total number of faces in all the polyhedrons in Anton's collection. | [
"4\nIcosahedron\nCube\nTetrahedron\nDodecahedron\n",
"3\nDodecahedron\nOctahedron\nOctahedron\n"
] | [
"42\n",
"28\n"
] | In the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces. | 500 | [
{
"input": "4\nIcosahedron\nCube\nTetrahedron\nDodecahedron",
"output": "42"
},
{
"input": "3\nDodecahedron\nOctahedron\nOctahedron",
"output": "28"
},
{
"input": "25\nIcosahedron\nOctahedron\nTetrahedron\nDodecahedron\nCube\nIcosahedron\nOctahedron\nCube\nTetrahedron\nIcosahedron\nIcosa... | 1,699,197,351 | 2,147,483,647 | PyPy 3 | OK | TESTS | 30 | 1,419 | 9,523,200 | ww=int(input())
count=0
for xx in range(ww):
pp=input()
if pp=="Tetrahedron":
count = count + 4
if pp=="Cube":
count = count + 6
if pp=="Octahedron":
count = count + 8
if pp=="Dodecahedron":
count = count + 12... | Title: Anton and Polyhedrons
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons:
- Tetrahedron. Tetrahedron has 4 triangular faces. - Cube. Cube has 6 square faces. - Octahe... | ```python
ww=int(input())
count=0
for xx in range(ww):
pp=input()
if pp=="Tetrahedron":
count = count + 4
if pp=="Cube":
count = count + 6
if pp=="Octahedron":
count = count + 8
if pp=="Dodecahedron":
count = ... | 3 | |
337 | A | Puzzles | PROGRAMMING | 900 | [
"greedy"
] | null | null | The end of the school year is near and Ms. Manana, the teacher, will soon have to say goodbye to a yet another class. She decided to prepare a goodbye present for her *n* students and give each of them a jigsaw puzzle (which, as wikipedia states, is a tiling puzzle that requires the assembly of numerous small, often od... | The first line contains space-separated integers *n* and *m* (2<=≤<=*n*<=≤<=*m*<=≤<=50). The second line contains *m* space-separated integers *f*1,<=*f*2,<=...,<=*f**m* (4<=≤<=*f**i*<=≤<=1000) — the quantities of pieces in the puzzles sold in the shop. | Print a single integer — the least possible difference the teacher can obtain. | [
"4 6\n10 12 10 7 5 22\n"
] | [
"5\n"
] | Sample 1. The class has 4 students. The shop sells 6 puzzles. If Ms. Manana buys the first four puzzles consisting of 10, 12, 10 and 7 pieces correspondingly, then the difference between the sizes of the largest and the smallest puzzle will be equal to 5. It is impossible to obtain a smaller difference. Note that the t... | 500 | [
{
"input": "4 6\n10 12 10 7 5 22",
"output": "5"
},
{
"input": "2 2\n4 4",
"output": "0"
},
{
"input": "2 10\n4 5 6 7 8 9 10 11 12 12",
"output": "0"
},
{
"input": "4 5\n818 136 713 59 946",
"output": "759"
},
{
"input": "3 20\n446 852 783 313 549 965 40 88 86 617... | 1,689,107,337 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 62 | 0 | # https://codeforces.com/problemset/problem/337/A
n, m = map(int, input().split())
puzzels = list(map(int, input().split()))
puzzels = sorted(puzzels)
puzzels = puzzels[:n]
print(puzzels[-1] - puzzels[0])
| Title: Puzzles
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The end of the school year is near and Ms. Manana, the teacher, will soon have to say goodbye to a yet another class. She decided to prepare a goodbye present for her *n* students and give each of them a jigsaw puzzle (which, a... | ```python
# https://codeforces.com/problemset/problem/337/A
n, m = map(int, input().split())
puzzels = list(map(int, input().split()))
puzzels = sorted(puzzels)
puzzels = puzzels[:n]
print(puzzels[-1] - puzzels[0])
``` | 0 | |
71 | A | Way Too Long Words | PROGRAMMING | 800 | [
"strings"
] | A. Way Too Long Words | 1 | 256 | Sometimes some words like "localization" or "internationalization" are so long that writing them many times in one text is quite tiresome.
Let's consider a word too long, if its length is strictly more than 10 characters. All too long words should be replaced with a special abbreviation.
This abbreviation is made lik... | The first line contains an integer *n* (1<=≤<=*n*<=≤<=100). Each of the following *n* lines contains one word. All the words consist of lowercase Latin letters and possess the lengths of from 1 to 100 characters. | Print *n* lines. The *i*-th line should contain the result of replacing of the *i*-th word from the input data. | [
"4\nword\nlocalization\ninternationalization\npneumonoultramicroscopicsilicovolcanoconiosis\n"
] | [
"word\nl10n\ni18n\np43s\n"
] | none | 500 | [
{
"input": "4\nword\nlocalization\ninternationalization\npneumonoultramicroscopicsilicovolcanoconiosis",
"output": "word\nl10n\ni18n\np43s"
},
{
"input": "5\nabcdefgh\nabcdefghi\nabcdefghij\nabcdefghijk\nabcdefghijklm",
"output": "abcdefgh\nabcdefghi\nabcdefghij\na9k\na11m"
},
{
"input":... | 1,678,097,402 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 30 | 0 | x=input()
l=len(x)
if l>10:
print(x[0]+str(l)+x[l-1])
if(l<10):
print(x) | Title: Way Too Long Words
Time Limit: 1 seconds
Memory Limit: 256 megabytes
Problem Description:
Sometimes some words like "localization" or "internationalization" are so long that writing them many times in one text is quite tiresome.
Let's consider a word too long, if its length is strictly more than 10 character... | ```python
x=input()
l=len(x)
if l>10:
print(x[0]+str(l)+x[l-1])
if(l<10):
print(x)
``` | 0 |
359 | B | Permutation | PROGRAMMING | 1,400 | [
"constructive algorithms",
"dp",
"math"
] | null | null | A permutation *p* is an ordered group of numbers *p*1,<=<=<=*p*2,<=<=<=...,<=<=<=*p**n*, consisting of *n* distinct positive integers, each is no more than *n*. We'll define number *n* as the length of permutation *p*1,<=<=<=*p*2,<=<=<=...,<=<=<=*p**n*.
Simon has a positive integer *n* and a non-negative integer *k*, ... | The first line contains two integers *n* and *k* (1<=≤<=*n*<=≤<=50000, 0<=≤<=2*k*<=≤<=*n*). | Print 2*n* integers *a*1,<=*a*2,<=...,<=*a*2*n* — the required permutation *a*. It is guaranteed that the solution exists. If there are multiple solutions, you can print any of them. | [
"1 0\n",
"2 1\n",
"4 0\n"
] | [
"1 2",
"3 2 1 4\n",
"2 7 4 6 1 3 5 8\n"
] | Record |*x*| represents the absolute value of number *x*.
In the first sample |1 - 2| - |1 - 2| = 0.
In the second sample |3 - 2| + |1 - 4| - |3 - 2 + 1 - 4| = 1 + 3 - 2 = 2.
In the third sample |2 - 7| + |4 - 6| + |1 - 3| + |5 - 8| - |2 - 7 + 4 - 6 + 1 - 3 + 5 - 8| = 12 - 12 = 0. | 1,000 | [
{
"input": "1 0",
"output": "1 2"
},
{
"input": "2 1",
"output": "3 2 1 4"
},
{
"input": "4 0",
"output": "2 7 4 6 1 3 5 8"
},
{
"input": "50000 0",
"output": "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 4... | 1,556,051,135 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 77 | 0 |
n,k=input().split()
n=int(n)
k=int(k)
l=[i for i in range(1,2*n+1)]
print(l)
for i in range(1,k+1):
x=2*i-1
y=2*i
l[x],l[y]=l[y],l[x]
for i in range(2*n):
print(l[i],end=" ") | Title: Permutation
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
A permutation *p* is an ordered group of numbers *p*1,<=<=<=*p*2,<=<=<=...,<=<=<=*p**n*, consisting of *n* distinct positive integers, each is no more than *n*. We'll define number *n* as the length of permutation *p*1,<=<=... | ```python
n,k=input().split()
n=int(n)
k=int(k)
l=[i for i in range(1,2*n+1)]
print(l)
for i in range(1,k+1):
x=2*i-1
y=2*i
l[x],l[y]=l[y],l[x]
for i in range(2*n):
print(l[i],end=" ")
``` | 0 | |
172 | A | Phone Code | PROGRAMMING | 800 | [
"*special",
"brute force",
"implementation"
] | null | null | Polycarpus has *n* friends in Tarasov city. Polycarpus knows phone numbers of all his friends: they are strings *s*1,<=*s*2,<=...,<=*s**n*. All these strings consist only of digits and have the same length.
Once Polycarpus needed to figure out Tarasov city phone code. He assumed that the phone code of the city is the... | The first line of the input contains an integer *n* (2<=≤<=*n*<=≤<=3·104) — the number of Polycarpus's friends. The following *n* lines contain strings *s*1,<=*s*2,<=...,<=*s**n* — the phone numbers of Polycarpus's friends. It is guaranteed that all strings consist only of digits and have the same length from 1 to 20, ... | Print the number of digits in the city phone code. | [
"4\n00209\n00219\n00999\n00909\n",
"2\n1\n2\n",
"3\n77012345678999999999\n77012345678901234567\n77012345678998765432\n"
] | [
"2\n",
"0\n",
"12\n"
] | A prefix of string *t* is a string that is obtained by deleting zero or more digits from the end of string *t*. For example, string "00209" has 6 prefixes: "" (an empty prefix), "0", "00", "002", "0020", "00209".
In the first sample the city phone code is string "00".
In the second sample the city phone code is an em... | 1,000 | [
{
"input": "4\n00209\n00219\n00999\n00909",
"output": "2"
},
{
"input": "2\n1\n2",
"output": "0"
},
{
"input": "3\n77012345678999999999\n77012345678901234567\n77012345678998765432",
"output": "12"
},
{
"input": "5\n4491183345\n4491184811\n4491162340\n4491233399\n4491449214",
... | 1,595,928,952 | 2,147,483,647 | Python 3 | OK | TESTS | 28 | 498 | 8,499,200 | a=[]
n=int(input())
if n==1 or n==0:
print(0)
exit(0)
for i in range(n):
a.append(input())
j=0
ans=0
while j<len(a[0]):
count=0
temp=a[0][j]
count+=1
for i in range(1,len(a)):
if a[i][j]==temp:
count+=1
if count==n:
ans+=1
else:
... | Title: Phone Code
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Polycarpus has *n* friends in Tarasov city. Polycarpus knows phone numbers of all his friends: they are strings *s*1,<=*s*2,<=...,<=*s**n*. All these strings consist only of digits and have the same length.
Once Polycarpus... | ```python
a=[]
n=int(input())
if n==1 or n==0:
print(0)
exit(0)
for i in range(n):
a.append(input())
j=0
ans=0
while j<len(a[0]):
count=0
temp=a[0][j]
count+=1
for i in range(1,len(a)):
if a[i][j]==temp:
count+=1
if count==n:
ans+=1
else... | 3 | |
994 | A | Fingerprints | PROGRAMMING | 800 | [
"implementation"
] | null | null | You are locked in a room with a door that has a keypad with 10 keys corresponding to digits from 0 to 9. To escape from the room, you need to enter a correct code. You also have a sequence of digits.
Some keys on the keypad have fingerprints. You believe the correct code is the longest not necessarily contiguous subse... | The first line contains two integers $n$ and $m$ ($1 \le n, m \le 10$) representing the number of digits in the sequence you have and the number of keys on the keypad that have fingerprints.
The next line contains $n$ distinct space-separated integers $x_1, x_2, \ldots, x_n$ ($0 \le x_i \le 9$) representing the sequen... | In a single line print a space-separated sequence of integers representing the code. If the resulting sequence is empty, both printing nothing and printing a single line break is acceptable. | [
"7 3\n3 5 7 1 6 2 8\n1 2 7\n",
"4 4\n3 4 1 0\n0 1 7 9\n"
] | [
"7 1 2\n",
"1 0\n"
] | In the first example, the only digits with fingerprints are $1$, $2$ and $7$. All three of them appear in the sequence you know, $7$ first, then $1$ and then $2$. Therefore the output is 7 1 2. Note that the order is important, and shall be the same as the order in the original sequence.
In the second example digits $... | 500 | [
{
"input": "7 3\n3 5 7 1 6 2 8\n1 2 7",
"output": "7 1 2"
},
{
"input": "4 4\n3 4 1 0\n0 1 7 9",
"output": "1 0"
},
{
"input": "9 4\n9 8 7 6 5 4 3 2 1\n2 4 6 8",
"output": "8 6 4 2"
},
{
"input": "10 5\n3 7 1 2 4 6 9 0 5 8\n4 3 0 7 9",
"output": "3 7 4 9 0"
},
{
"... | 1,642,581,417 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 15 | 0 | N , M = map(int, input().split())
NN = list(map(int, input().split()))
f = set(int, input().split())
for each in NN:
if each in f:
print(each, end=" ")
| Title: Fingerprints
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are locked in a room with a door that has a keypad with 10 keys corresponding to digits from 0 to 9. To escape from the room, you need to enter a correct code. You also have a sequence of digits.
Some keys on the keyp... | ```python
N , M = map(int, input().split())
NN = list(map(int, input().split()))
f = set(int, input().split())
for each in NN:
if each in f:
print(each, end=" ")
``` | -1 | |
653 | A | Bear and Three Balls | PROGRAMMING | 900 | [
"brute force",
"implementation",
"sortings"
] | null | null | Limak is a little polar bear. He has *n* balls, the *i*-th ball has size *t**i*.
Limak wants to give one ball to each of his three friends. Giving gifts isn't easy — there are two rules Limak must obey to make friends happy:
- No two friends can get balls of the same size. - No two friends can get balls of sizes th... | The first line of the input contains one integer *n* (3<=≤<=*n*<=≤<=50) — the number of balls Limak has.
The second line contains *n* integers *t*1,<=*t*2,<=...,<=*t**n* (1<=≤<=*t**i*<=≤<=1000) where *t**i* denotes the size of the *i*-th ball. | Print "YES" (without quotes) if Limak can choose three balls of distinct sizes, such that any two of them differ by no more than 2. Otherwise, print "NO" (without quotes). | [
"4\n18 55 16 17\n",
"6\n40 41 43 44 44 44\n",
"8\n5 972 3 4 1 4 970 971\n"
] | [
"YES\n",
"NO\n",
"YES\n"
] | In the first sample, there are 4 balls and Limak is able to choose three of them to satisfy the rules. He must must choose balls with sizes 18, 16 and 17.
In the second sample, there is no way to give gifts to three friends without breaking the rules.
In the third sample, there is even more than one way to choose bal... | 500 | [
{
"input": "4\n18 55 16 17",
"output": "YES"
},
{
"input": "6\n40 41 43 44 44 44",
"output": "NO"
},
{
"input": "8\n5 972 3 4 1 4 970 971",
"output": "YES"
},
{
"input": "3\n959 747 656",
"output": "NO"
},
{
"input": "4\n1 2 2 3",
"output": "YES"
},
{
... | 1,683,310,802 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 35 | 46 | 0 | n=int(input())
b=list(map(int,input().split()))
b=sorted(set(b))
c=0
for i in range(len(b)-2):
if b[i+2]-b[i]<=2:
print('YES')
break
else:
c=c+1
if c==len(b)-2:
print('NO') | Title: Bear and Three Balls
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Limak is a little polar bear. He has *n* balls, the *i*-th ball has size *t**i*.
Limak wants to give one ball to each of his three friends. Giving gifts isn't easy — there are two rules Limak must obey to make fri... | ```python
n=int(input())
b=list(map(int,input().split()))
b=sorted(set(b))
c=0
for i in range(len(b)-2):
if b[i+2]-b[i]<=2:
print('YES')
break
else:
c=c+1
if c==len(b)-2:
print('NO')
``` | 0 | |
115 | A | Party | PROGRAMMING | 900 | [
"dfs and similar",
"graphs",
"trees"
] | null | null | A company has *n* employees numbered from 1 to *n*. Each employee either has no immediate manager or exactly one immediate manager, who is another employee with a different number. An employee *A* is said to be the superior of another employee *B* if at least one of the following is true:
- Employee *A* is the immedi... | The first line contains integer *n* (1<=≤<=*n*<=≤<=2000) — the number of employees.
The next *n* lines contain the integers *p**i* (1<=≤<=*p**i*<=≤<=*n* or *p**i*<==<=-1). Every *p**i* denotes the immediate manager for the *i*-th employee. If *p**i* is -1, that means that the *i*-th employee does not have an immediate... | Print a single integer denoting the minimum number of groups that will be formed in the party. | [
"5\n-1\n1\n2\n1\n-1\n"
] | [
"3\n"
] | For the first example, three groups are sufficient, for example:
- Employee 1 - Employees 2 and 4 - Employees 3 and 5 | 500 | [
{
"input": "5\n-1\n1\n2\n1\n-1",
"output": "3"
},
{
"input": "4\n-1\n1\n2\n3",
"output": "4"
},
{
"input": "12\n-1\n1\n2\n3\n-1\n5\n6\n7\n-1\n9\n10\n11",
"output": "4"
},
{
"input": "6\n-1\n-1\n2\n3\n1\n1",
"output": "3"
},
{
"input": "3\n-1\n1\n1",
"output": ... | 1,681,312,130 | 2,147,483,647 | Python 3 | OK | TESTS | 106 | 124 | 1,740,800 | import sys
from collections import defaultdict
sys.setrecursionlimit(10000)
def dfs(employee, depth):
max_depth = depth
for sub in dic[employee]:
max_depth = max(max_depth, dfs(sub, depth+1))
return max_depth
n = int(input())
dic = defaultdict(list)
for i in range(1, n+1):
m... | Title: Party
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
A company has *n* employees numbered from 1 to *n*. Each employee either has no immediate manager or exactly one immediate manager, who is another employee with a different number. An employee *A* is said to be the superior of an... | ```python
import sys
from collections import defaultdict
sys.setrecursionlimit(10000)
def dfs(employee, depth):
max_depth = depth
for sub in dic[employee]:
max_depth = max(max_depth, dfs(sub, depth+1))
return max_depth
n = int(input())
dic = defaultdict(list)
for i in range(1, n+1):
... | 3 | |
9 | A | Die Roll | PROGRAMMING | 800 | [
"math",
"probabilities"
] | A. Die Roll | 1 | 64 | Yakko, Wakko and Dot, world-famous animaniacs, decided to rest from acting in cartoons, and take a leave to travel a bit. Yakko dreamt to go to Pennsylvania, his Motherland and the Motherland of his ancestors. Wakko thought about Tasmania, its beaches, sun and sea. Dot chose Transylvania as the most mysterious and unpr... | The only line of the input file contains two natural numbers Y and W — the results of Yakko's and Wakko's die rolls. | Output the required probability in the form of irreducible fraction in format «A/B», where A — the numerator, and B — the denominator. If the required probability equals to zero, output «0/1». If the required probability equals to 1, output «1/1». | [
"4 2\n"
] | [
"1/2\n"
] | Dot will go to Transylvania, if she is lucky to roll 4, 5 or 6 points. | 0 | [
{
"input": "4 2",
"output": "1/2"
},
{
"input": "1 1",
"output": "1/1"
},
{
"input": "1 2",
"output": "5/6"
},
{
"input": "1 3",
"output": "2/3"
},
{
"input": "1 4",
"output": "1/2"
},
{
"input": "1 5",
"output": "1/3"
},
{
"input": "1 6",
... | 1,578,539,405 | 2,147,483,647 | Python 3 | OK | TESTS | 36 | 218 | 0 | y, w = (int(n) for n in input().split())
d = 7 - max(y, w)
x = str(d) + '/6'
if d == 0:
x = '0/1'
elif d == 2:
x = '1/3'
elif d == 3:
x = '1/2'
elif d == 4:
x = '2/3'
elif d == 6:
x = '1/1'
print(x)
| Title: Die Roll
Time Limit: 1 seconds
Memory Limit: 64 megabytes
Problem Description:
Yakko, Wakko and Dot, world-famous animaniacs, decided to rest from acting in cartoons, and take a leave to travel a bit. Yakko dreamt to go to Pennsylvania, his Motherland and the Motherland of his ancestors. Wakko thought about T... | ```python
y, w = (int(n) for n in input().split())
d = 7 - max(y, w)
x = str(d) + '/6'
if d == 0:
x = '0/1'
elif d == 2:
x = '1/3'
elif d == 3:
x = '1/2'
elif d == 4:
x = '2/3'
elif d == 6:
x = '1/1'
print(x)
``` | 3.891 |
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,076,873 | 2,147,483,647 | Python 3 | OK | TESTS | 20 | 46 | 0 | import math
def flagstones_needed(n, m, a):
rows = math.ceil(n / a)
cols = math.ceil(m / a)
return rows * cols
n, m, a = map(int, input().split())
needed_flagstones = flagstones_needed(n, m, a)
print(needed_flagstones)
| 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
import math
def flagstones_needed(n, m, a):
rows = math.ceil(n / a)
cols = math.ceil(m / a)
return rows * cols
n, m, a = map(int, input().split())
needed_flagstones = flagstones_needed(n, m, a)
print(needed_flagstones)
``` | 3.977 |
858 | B | Which floor? | PROGRAMMING | 1,500 | [
"brute force",
"implementation"
] | null | null | In a building where Polycarp lives there are equal number of flats on each floor. Unfortunately, Polycarp don't remember how many flats are on each floor, but he remembers that the flats are numbered from 1 from lower to upper floors. That is, the first several flats are on the first floor, the next several flats are o... | The first line contains two integers *n* and *m* (1<=≤<=*n*<=≤<=100, 0<=≤<=*m*<=≤<=100), where *n* is the number of the flat you need to restore floor for, and *m* is the number of flats in Polycarp's memory.
*m* lines follow, describing the Polycarp's memory: each of these lines contains a pair of integers *k**i*,<=*... | Print the number of the floor in which the *n*-th flat is located, if it is possible to determine it in a unique way. Print -1 if it is not possible to uniquely restore this floor. | [
"10 3\n6 2\n2 1\n7 3\n",
"8 4\n3 1\n6 2\n5 2\n2 1\n"
] | [
"4\n",
"-1\n"
] | In the first example the 6-th flat is on the 2-nd floor, while the 7-th flat is on the 3-rd, so, the 6-th flat is the last on its floor and there are 3 flats on each floor. Thus, the 10-th flat is on the 4-th floor.
In the second example there can be 3 or 4 flats on each floor, so we can't restore the floor for the 8-... | 750 | [
{
"input": "10 3\n6 2\n2 1\n7 3",
"output": "4"
},
{
"input": "8 4\n3 1\n6 2\n5 2\n2 1",
"output": "-1"
},
{
"input": "8 3\n7 2\n6 2\n1 1",
"output": "2"
},
{
"input": "4 2\n8 3\n3 1",
"output": "2"
},
{
"input": "11 4\n16 4\n11 3\n10 3\n15 4",
"output": "3"
... | 1,505,657,223 | 3,723 | Python 3 | WRONG_ANSWER | PRETESTS | 2 | 46 | 0 | n, m = map(int, input().split())
v = []
for i in range(m):
v.append(list(map(int, input().split())))
ans = []
for i in range(1, 100):
o = True
for p in v:
if (p[0] - 1) // i != p[1] - 1:
o = False
break
if o:
ans.append(i)
if len(ans) == 1:
print... | Title: Which floor?
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
In a building where Polycarp lives there are equal number of flats on each floor. Unfortunately, Polycarp don't remember how many flats are on each floor, but he remembers that the flats are numbered from 1 from lower to u... | ```python
n, m = map(int, input().split())
v = []
for i in range(m):
v.append(list(map(int, input().split())))
ans = []
for i in range(1, 100):
o = True
for p in v:
if (p[0] - 1) // i != p[1] - 1:
o = False
break
if o:
ans.append(i)
if len(ans) == 1:
... | 0 | |
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,685,551,355 | 2,147,483,647 | Python 3 | OK | TESTS | 46 | 857 | 18,329,600 |
# Online Python - IDE, Editor, Compiler, Interpreter
n=int(input())
sum1=[]
sum2=[]
orig=input().split(' ')
orig=[int(x) for x in orig]
sum1.append(orig[0])
for i in range(1,n):
sum1.append(sum1[i-1]+orig[i])
orig.sort()
sum2.append(orig[0])
for i in range(1,n):
sum2.append(sum2[i-1]+orig[i])
... | 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
# Online Python - IDE, Editor, Compiler, Interpreter
n=int(input())
sum1=[]
sum2=[]
orig=input().split(' ')
orig=[int(x) for x in orig]
sum1.append(orig[0])
for i in range(1,n):
sum1.append(sum1[i-1]+orig[i])
orig.sort()
sum2.append(orig[0])
for i in range(1,n):
sum2.append(sum2[i-1]+orig[i])... | 3 | |
312 | A | Whose sentence is it? | PROGRAMMING | 1,100 | [
"implementation",
"strings"
] | null | null | One day, liouzhou_101 got a chat record of Freda and Rainbow. Out of curiosity, he wanted to know which sentences were said by Freda, and which were said by Rainbow. According to his experience, he thought that Freda always said "lala." at the end of her sentences, while Rainbow always said "miao." at the beginning of ... | The first line of the input contains an integer *n* (1<=≤<=*n*<=≤<=10), number of sentences in the chat record. Each of the next *n* lines contains a sentence. A sentence is a string that contains only Latin letters (A-Z, a-z), underline (_), comma (,), point (.) and space ( ). Its length doesn’t exceed 100. | For each sentence, output "Freda's" if the sentence was said by Freda, "Rainbow's" if the sentence was said by Rainbow, or "OMG>.< I don't know!" if liouzhou_101 can’t recognize whose sentence it is. He can’t recognize a sentence if it begins with "miao." and ends with "lala.", or satisfies neither of the conditi... | [
"5\nI will go to play with you lala.\nwow, welcome.\nmiao.lala.\nmiao.\nmiao .\n"
] | [
"Freda's\nOMG>.< I don't know!\nOMG>.< I don't know!\nRainbow's\nOMG>.< I don't know!\n"
] | none | 500 | [
{
"input": "5\nI will go to play with you lala.\nwow, welcome.\nmiao.lala.\nmiao.\nmiao .",
"output": "Freda's\nOMG>.< I don't know!\nOMG>.< I don't know!\nRainbow's\nOMG>.< I don't know!"
},
{
"input": "10\nLpAEKiHVJrzSZqBVSSyY\nYECGBlala.\nUZeGpeM.UCwiHmmA\nqt_,.b_.LSwJtJ.\nFAnXZtHlala.\nmiao.iape... | 1,450,624,792 | 2,147,483,647 | Python 3 | OK | TESTS | 36 | 77 | 0 | def lala(s):
f1 = 0
f2 = 0
l = len(s)
if s[0:5]=="miao.":
f1 = 1
if s[len(s)-5:] =="lala.":
f2 = 1
if f1==1 and f2==0:
return 1
elif f1==0 and f2==1 :
return 2
else:
return 0
n = int(input())
for i in range(0,n,1):
s = input... | Title: Whose sentence is it?
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
One day, liouzhou_101 got a chat record of Freda and Rainbow. Out of curiosity, he wanted to know which sentences were said by Freda, and which were said by Rainbow. According to his experience, he thought that Fr... | ```python
def lala(s):
f1 = 0
f2 = 0
l = len(s)
if s[0:5]=="miao.":
f1 = 1
if s[len(s)-5:] =="lala.":
f2 = 1
if f1==1 and f2==0:
return 1
elif f1==0 and f2==1 :
return 2
else:
return 0
n = int(input())
for i in range(0,n,1):
... | 3 | |
1,000 | B | Light It Up | PROGRAMMING | 1,500 | [
"greedy"
] | null | null | Recently, you bought a brand new smart lamp with programming features. At first, you set up a schedule to the lamp. Every day it will turn power on at moment $0$ and turn power off at moment $M$. Moreover, the lamp allows you to set a program of switching its state (states are "lights on" and "lights off"). Unfortunate... | First line contains two space separated integers $n$ and $M$ ($1 \le n \le 10^5$, $2 \le M \le 10^9$) — the length of program $a$ and the moment when power turns off.
Second line contains $n$ space separated integers $a_1, a_2, \dots, a_n$ ($0 < a_1 < a_2 < \dots < a_n < M$) — initially installed progra... | Print the only integer — maximum possible total time when the lamp is lit. | [
"3 10\n4 6 7\n",
"2 12\n1 10\n",
"2 7\n3 4\n"
] | [
"8\n",
"9\n",
"6\n"
] | In the first example, one of possible optimal solutions is to insert value $x = 3$ before $a_1$, so program will be $[3, 4, 6, 7]$ and time of lamp being lit equals $(3 - 0) + (6 - 4) + (10 - 7) = 8$. Other possible solution is to insert $x = 5$ in appropriate place.
In the second example, there is only one optimal so... | 0 | [
{
"input": "3 10\n4 6 7",
"output": "8"
},
{
"input": "2 12\n1 10",
"output": "9"
},
{
"input": "2 7\n3 4",
"output": "6"
},
{
"input": "1 2\n1",
"output": "1"
},
{
"input": "5 10\n1 3 5 6 8",
"output": "6"
},
{
"input": "7 1000000000\n1 10001 10011 20... | 1,700,556,913 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 8 | 78 | 13,209,600 | # -*- coding: utf-8 -*-
"""
Created on Tue Nov 21 16:33:10 2023
@author: GaoMingze 2300011427
"""
n,M=map(int,input().split())
num=[0]+list(map(int,input().split()))+[M]
on=[]
ans=0
for i in range(1,n+2,2):
ans+=num[i]-num[i-1]
for i in range(2,n+2,2):
s=0
if num[i]-num[i-1]>1:
s+=nu... | Title: Light It Up
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Recently, you bought a brand new smart lamp with programming features. At first, you set up a schedule to the lamp. Every day it will turn power on at moment $0$ and turn power off at moment $M$. Moreover, the lamp allows y... | ```python
# -*- coding: utf-8 -*-
"""
Created on Tue Nov 21 16:33:10 2023
@author: GaoMingze 2300011427
"""
n,M=map(int,input().split())
num=[0]+list(map(int,input().split()))+[M]
on=[]
ans=0
for i in range(1,n+2,2):
ans+=num[i]-num[i-1]
for i in range(2,n+2,2):
s=0
if num[i]-num[i-1]>1:
... | 0 | |
313 | A | Ilya and Bank Account | PROGRAMMING | 900 | [
"implementation",
"number theory"
] | null | null | Ilya is a very clever lion, he lives in an unusual city ZooVille. In this city all the animals have their rights and obligations. Moreover, they even have their own bank accounts. The state of a bank account is an integer. The state of a bank account can be a negative number. This means that the owner of the account ow... | The single line contains integer *n* (10<=≤<=|*n*|<=≤<=109) — the state of Ilya's bank account. | In a single line print an integer — the maximum state of the bank account that Ilya can get. | [
"2230\n",
"-10\n",
"-100003\n"
] | [
"2230\n",
"0\n",
"-10000\n"
] | In the first test sample Ilya doesn't profit from using the present.
In the second test sample you can delete digit 1 and get the state of the account equal to 0. | 500 | [
{
"input": "2230",
"output": "2230"
},
{
"input": "-10",
"output": "0"
},
{
"input": "-100003",
"output": "-10000"
},
{
"input": "544883178",
"output": "544883178"
},
{
"input": "-847251738",
"output": "-84725173"
},
{
"input": "423654797",
"output... | 1,696,252,871 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 1 | 92 | 0 |
n = int(input())
max_balance = n
if n < 0:
last_digit_removed = n // 10
digit_before_last_removed = n // 100 * 10 + n % 10
max_balance = max(n, last_digit_removed, digit_before_last_removed)
print(max_balance)
| Title: Ilya and Bank Account
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Ilya is a very clever lion, he lives in an unusual city ZooVille. In this city all the animals have their rights and obligations. Moreover, they even have their own bank accounts. The state of a bank account is an... | ```python
n = int(input())
max_balance = n
if n < 0:
last_digit_removed = n // 10
digit_before_last_removed = n // 100 * 10 + n % 10
max_balance = max(n, last_digit_removed, digit_before_last_removed)
print(max_balance)
``` | 0 | |
653 | A | Bear and Three Balls | PROGRAMMING | 900 | [
"brute force",
"implementation",
"sortings"
] | null | null | Limak is a little polar bear. He has *n* balls, the *i*-th ball has size *t**i*.
Limak wants to give one ball to each of his three friends. Giving gifts isn't easy — there are two rules Limak must obey to make friends happy:
- No two friends can get balls of the same size. - No two friends can get balls of sizes th... | The first line of the input contains one integer *n* (3<=≤<=*n*<=≤<=50) — the number of balls Limak has.
The second line contains *n* integers *t*1,<=*t*2,<=...,<=*t**n* (1<=≤<=*t**i*<=≤<=1000) where *t**i* denotes the size of the *i*-th ball. | Print "YES" (without quotes) if Limak can choose three balls of distinct sizes, such that any two of them differ by no more than 2. Otherwise, print "NO" (without quotes). | [
"4\n18 55 16 17\n",
"6\n40 41 43 44 44 44\n",
"8\n5 972 3 4 1 4 970 971\n"
] | [
"YES\n",
"NO\n",
"YES\n"
] | In the first sample, there are 4 balls and Limak is able to choose three of them to satisfy the rules. He must must choose balls with sizes 18, 16 and 17.
In the second sample, there is no way to give gifts to three friends without breaking the rules.
In the third sample, there is even more than one way to choose bal... | 500 | [
{
"input": "4\n18 55 16 17",
"output": "YES"
},
{
"input": "6\n40 41 43 44 44 44",
"output": "NO"
},
{
"input": "8\n5 972 3 4 1 4 970 971",
"output": "YES"
},
{
"input": "3\n959 747 656",
"output": "NO"
},
{
"input": "4\n1 2 2 3",
"output": "YES"
},
{
... | 1,594,046,181 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 4 | 93 | 6,656,000 | n=int(input())
m=sorted(map(int,input().split()))
flag=0
for i in range(n-2):
if m[i+2]-m[i]==2 and m[i+1]-m[i]==1:
flag=1
break
else:
flag=0
print(['NO','YES'][flag==1])
| Title: Bear and Three Balls
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Limak is a little polar bear. He has *n* balls, the *i*-th ball has size *t**i*.
Limak wants to give one ball to each of his three friends. Giving gifts isn't easy — there are two rules Limak must obey to make fri... | ```python
n=int(input())
m=sorted(map(int,input().split()))
flag=0
for i in range(n-2):
if m[i+2]-m[i]==2 and m[i+1]-m[i]==1:
flag=1
break
else:
flag=0
print(['NO','YES'][flag==1])
``` | 0 | |
721 | A | One-dimensional Japanese Crossword | PROGRAMMING | 800 | [
"implementation"
] | null | null | Recently Adaltik discovered japanese crosswords. Japanese crossword is a picture, represented as a table sized *a*<=×<=*b* squares, and each square is colored white or black. There are integers to the left of the rows and to the top of the columns, encrypting the corresponding row or column. The number of integers repr... | The first line of the input contains a single integer *n* (1<=≤<=*n*<=≤<=100) — the length of the row. The second line of the input contains a single string consisting of *n* characters 'B' or 'W', ('B' corresponds to black square, 'W' — to white square in the row that Adaltik drew). | The first line should contain a single integer *k* — the number of integers encrypting the row, e.g. the number of groups of black squares in the row.
The second line should contain *k* integers, encrypting the row, e.g. corresponding to sizes of groups of consecutive black squares in the order from left to right. | [
"3\nBBW\n",
"5\nBWBWB\n",
"4\nWWWW\n",
"4\nBBBB\n",
"13\nWBBBBWWBWBBBW\n"
] | [
"1\n2 ",
"3\n1 1 1 ",
"0\n",
"1\n4 ",
"3\n4 1 3 "
] | The last sample case correspond to the picture in the statement. | 500 | [
{
"input": "3\nBBW",
"output": "1\n2 "
},
{
"input": "5\nBWBWB",
"output": "3\n1 1 1 "
},
{
"input": "4\nWWWW",
"output": "0"
},
{
"input": "4\nBBBB",
"output": "1\n4 "
},
{
"input": "13\nWBBBBWWBWBBBW",
"output": "3\n4 1 3 "
},
{
"input": "1\nB",
... | 1,619,504,107 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 62 | 0 | A = int(input())
B = str(input())
Groupcount = 0
Bcount = 0
Bgroup = ""
for i in range(A):
if B[i] == 'B':
if i == 0 or B[i-1] == 'W':
Groupcount = Groupcount + 1
Bcount = Bcount +1
elif B[i] == 'W':
Bgroup += str(Bcount) + " "
Bcount = 0
if B[-1] != 'W':
Bgroup += str(Bcount) + ""
print(Gro... | Title: One-dimensional Japanese Crossword
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Recently Adaltik discovered japanese crosswords. Japanese crossword is a picture, represented as a table sized *a*<=×<=*b* squares, and each square is colored white or black. There are integers to the... | ```python
A = int(input())
B = str(input())
Groupcount = 0
Bcount = 0
Bgroup = ""
for i in range(A):
if B[i] == 'B':
if i == 0 or B[i-1] == 'W':
Groupcount = Groupcount + 1
Bcount = Bcount +1
elif B[i] == 'W':
Bgroup += str(Bcount) + " "
Bcount = 0
if B[-1] != 'W':
Bgroup += str(Bcount) + ""... | 0 | |
200 | B | Drinks | PROGRAMMING | 800 | [
"implementation",
"math"
] | null | null | Little Vasya loves orange juice very much. That's why any food and drink in his kitchen necessarily contains orange juice. There are *n* drinks in his fridge, the volume fraction of orange juice in the *i*-th drink equals *p**i* percent.
One day Vasya decided to make himself an orange cocktail. He took equal proportio... | The first input line contains a single integer *n* (1<=≤<=*n*<=≤<=100) — the number of orange-containing drinks in Vasya's fridge. The second line contains *n* integers *p**i* (0<=≤<=*p**i*<=≤<=100) — the volume fraction of orange juice in the *i*-th drink, in percent. The numbers are separated by a space. | Print the volume fraction in percent of orange juice in Vasya's cocktail. The answer will be considered correct if the absolute or relative error does not exceed 10<=<=-<=4. | [
"3\n50 50 100\n",
"4\n0 25 50 75\n"
] | [
"66.666666666667\n",
"37.500000000000\n"
] | Note to the first sample: let's assume that Vasya takes *x* milliliters of each drink from the fridge. Then the volume of pure juice in the cocktail will equal <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/c1fac6e64d3a8ee6a5ac138cbe51e60039b22473.png" style="max-width: 100.0%;max-height: ... | 500 | [
{
"input": "3\n50 50 100",
"output": "66.666666666667"
},
{
"input": "4\n0 25 50 75",
"output": "37.500000000000"
},
{
"input": "3\n0 1 8",
"output": "3.000000000000"
},
{
"input": "5\n96 89 93 95 70",
"output": "88.600000000000"
},
{
"input": "7\n62 41 78 4 38 39... | 1,683,519,327 | 2,147,483,647 | Python 3 | OK | TESTS | 31 | 92 | 0 | n = int(input())
percentages = list(map(int, input().split()))
total_percent = sum(percentages)
avg_percent = total_percent / n
print(avg_percent)
| Title: Drinks
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Little Vasya loves orange juice very much. That's why any food and drink in his kitchen necessarily contains orange juice. There are *n* drinks in his fridge, the volume fraction of orange juice in the *i*-th drink equals *p**i*... | ```python
n = int(input())
percentages = list(map(int, input().split()))
total_percent = sum(percentages)
avg_percent = total_percent / n
print(avg_percent)
``` | 3 | |
862 | B | Mahmoud and Ehab and the bipartiteness | PROGRAMMING | 1,300 | [
"dfs and similar",
"graphs",
"trees"
] | null | null | Mahmoud and Ehab continue their adventures! As everybody in the evil land knows, Dr. Evil likes bipartite graphs, especially trees.
A tree is a connected acyclic graph. A bipartite graph is a graph, whose vertices can be partitioned into 2 sets in such a way, that for each edge (*u*,<=*v*) that belongs to the graph, *... | The first line of input contains an integer *n* — the number of nodes in the tree (1<=≤<=*n*<=≤<=105).
The next *n*<=-<=1 lines contain integers *u* and *v* (1<=≤<=*u*,<=*v*<=≤<=*n*, *u*<=≠<=*v*) — the description of the edges of the tree.
It's guaranteed that the given graph is a tree. | Output one integer — the maximum number of edges that Mahmoud and Ehab can add to the tree while fulfilling the conditions. | [
"3\n1 2\n1 3\n",
"5\n1 2\n2 3\n3 4\n4 5\n"
] | [
"0\n",
"2\n"
] | Tree definition: [https://en.wikipedia.org/wiki/Tree_(graph_theory)](https://en.wikipedia.org/wiki/Tree_(graph_theory))
Bipartite graph definition: [https://en.wikipedia.org/wiki/Bipartite_graph](https://en.wikipedia.org/wiki/Bipartite_graph)
In the first test case the only edge that can be added in such a way, that ... | 1,000 | [
{
"input": "3\n1 2\n1 3",
"output": "0"
},
{
"input": "5\n1 2\n2 3\n3 4\n4 5",
"output": "2"
},
{
"input": "10\n3 8\n6 2\n9 7\n10 1\n3 5\n1 3\n6 7\n5 4\n3 6",
"output": "16"
},
{
"input": "10\n7 6\n2 7\n4 1\n8 5\n9 4\n5 3\n8 7\n10 8\n10 4",
"output": "16"
},
{
"in... | 1,506,783,544 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 16 | 561 | 10,956,800 | n = int(input())
c = [0, 0]
g = [[] for _ in range(n)]
def col(i, p, cl):
c[cl] += 1
for j in range(len(g[i])):
if g[i][j] != p:
col(g[i][j], i, abs(cl - 1))
for i in range(n - 1):
inp = input().split(' ')
f = int(inp[0]) - 1
t = int(inp[1]) - 1
g[f].appen... | Title: Mahmoud and Ehab and the bipartiteness
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Mahmoud and Ehab continue their adventures! As everybody in the evil land knows, Dr. Evil likes bipartite graphs, especially trees.
A tree is a connected acyclic graph. A bipartite graph is a gra... | ```python
n = int(input())
c = [0, 0]
g = [[] for _ in range(n)]
def col(i, p, cl):
c[cl] += 1
for j in range(len(g[i])):
if g[i][j] != p:
col(g[i][j], i, abs(cl - 1))
for i in range(n - 1):
inp = input().split(' ')
f = int(inp[0]) - 1
t = int(inp[1]) - 1
... | -1 | |
991 | D | Bishwock | PROGRAMMING | 1,500 | [
"dp",
"greedy"
] | null | null | Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states:
Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square.
Vasya has a board wi... | The input contains two nonempty strings that describe Vasya's board. Those strings contain only symbols "0" (zero) that denote the empty squares and symbols "X" (uppercase English letter) that denote the squares occupied by pawns. Strings are nonempty and are of the same length that does not exceed $100$. | Output a single integer — the maximum amount of bishwocks that can be placed onto the given board. | [
"00\n00\n",
"00X00X0XXX0\n0XXX0X00X00\n",
"0X0X0\n0X0X0\n",
"0XXX0\n00000\n"
] | [
"1",
"4",
"0",
"2"
] | none | 1,500 | [
{
"input": "00\n00",
"output": "1"
},
{
"input": "00X00X0XXX0\n0XXX0X00X00",
"output": "4"
},
{
"input": "0X0X0\n0X0X0",
"output": "0"
},
{
"input": "0XXX0\n00000",
"output": "2"
},
{
"input": "0\n0",
"output": "0"
},
{
"input": "0\nX",
"output": "... | 1,675,207,609 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 72 | 62 | 0 | a = input()
b = input()
v2, oa, ob, o2 = 0,0,0,0
if a[0] == b[0] == '0':
v2, oa, ob, o2 = 0,-1,-1,-1
elif a[0] == '0':
v2, oa, ob, o2 = -1,-1,0,-1
elif b[0] == '0':
v2, oa, ob, o2 = -1,0,-1,-1
else:
v2, oa, ob, o2 = -1,-1,-1,0
for i in range(1, len(a)):
nv2 = max(v2, oa, ob, o2)
if a[i] == 'X'... | Title: Bishwock
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states:
Bishwocks don't attack any squares and can even occup... | ```python
a = input()
b = input()
v2, oa, ob, o2 = 0,0,0,0
if a[0] == b[0] == '0':
v2, oa, ob, o2 = 0,-1,-1,-1
elif a[0] == '0':
v2, oa, ob, o2 = -1,-1,0,-1
elif b[0] == '0':
v2, oa, ob, o2 = -1,0,-1,-1
else:
v2, oa, ob, o2 = -1,-1,-1,0
for i in range(1, len(a)):
nv2 = max(v2, oa, ob, o2)
if a... | 3 | |
401 | C | Team | PROGRAMMING | 1,400 | [
"constructive algorithms",
"greedy",
"implementation"
] | null | null | Now it's time of Olympiads. Vanya and Egor decided to make his own team to take part in a programming Olympiad. They've been best friends ever since primary school and hopefully, that can somehow help them in teamwork.
For each team Olympiad, Vanya takes his play cards with numbers. He takes only the cards containing ... | The first line contains two integers: *n* (1<=≤<=*n*<=≤<=106) — the number of cards containing number 0; *m* (1<=≤<=*m*<=≤<=106) — the number of cards containing number 1. | In a single line print the required sequence of zeroes and ones without any spaces. If such sequence is impossible to obtain, print -1. | [
"1 2\n",
"4 8\n",
"4 10\n",
"1 5\n"
] | [
"101\n",
"110110110101\n",
"11011011011011\n",
"-1\n"
] | none | 1,500 | [
{
"input": "1 2",
"output": "101"
},
{
"input": "4 8",
"output": "110110110101"
},
{
"input": "4 10",
"output": "11011011011011"
},
{
"input": "1 5",
"output": "-1"
},
{
"input": "3 4",
"output": "1010101"
},
{
"input": "3 10",
"output": "-1"
},
... | 1,589,354,080 | 2,147,483,647 | PyPy 3 | RUNTIME_ERROR | TESTS | 0 | 187 | 22,220,800 | from math import *
import numpy as np
def arrange(n, m):
div = ceil(m/(n+1))
if div >= 3 or (m < n and n >= 2):
print(-1)
return
num1 = m
num0 = n
ans = np.asarray([])
while num0 > 0:
div = ceil(num1/(num0+1))
ans = np.append(ans,'1'*div)
... | Title: Team
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Now it's time of Olympiads. Vanya and Egor decided to make his own team to take part in a programming Olympiad. They've been best friends ever since primary school and hopefully, that can somehow help them in teamwork.
For each t... | ```python
from math import *
import numpy as np
def arrange(n, m):
div = ceil(m/(n+1))
if div >= 3 or (m < n and n >= 2):
print(-1)
return
num1 = m
num0 = n
ans = np.asarray([])
while num0 > 0:
div = ceil(num1/(num0+1))
ans = np.append(ans,'1'*di... | -1 | |
20 | C | Dijkstra? | PROGRAMMING | 1,900 | [
"graphs",
"shortest paths"
] | C. Dijkstra? | 1 | 64 | You are given a weighted undirected graph. The vertices are enumerated from 1 to *n*. Your task is to find the shortest path between the vertex 1 and the vertex *n*. | The first line contains two integers *n* and *m* (2<=≤<=*n*<=≤<=105,<=0<=≤<=*m*<=≤<=105), where *n* is the number of vertices and *m* is the number of edges. Following *m* lines contain one edge each in form *a**i*, *b**i* and *w**i* (1<=≤<=*a**i*,<=*b**i*<=≤<=*n*,<=1<=≤<=*w**i*<=≤<=106), where *a**i*,<=*b**i* are edge... | Write the only integer -1 in case of no path. Write the shortest path in opposite case. If there are many solutions, print any of them. | [
"5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1\n",
"5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1\n"
] | [
"1 4 3 5 ",
"1 4 3 5 "
] | none | 1,500 | [
{
"input": "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1",
"output": "1 4 3 5 "
},
{
"input": "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1",
"output": "1 4 3 5 "
},
{
"input": "2 1\n1 2 1",
"output": "1 2 "
},
{
"input": "3 1\n1 2 1",
"output": "-1"
},
{
"input... | 1,619,319,864 | 2,147,483,647 | PyPy 3 | TIME_LIMIT_EXCEEDED | TESTS | 19 | 1,000 | 5,324,800 | def solver(n,m,graph):
d = [float("inf")] * n
used = [False] * n
d[0] = 0
parent = [-1] * n
for i in range(n):
v = -1
for j in range(n):
if not used[j] and (v == -1 or d[j] < d[v]):
v =j
used[v] = True
for to,w in graph[v]:
... | Title: Dijkstra?
Time Limit: 1 seconds
Memory Limit: 64 megabytes
Problem Description:
You are given a weighted undirected graph. The vertices are enumerated from 1 to *n*. Your task is to find the shortest path between the vertex 1 and the vertex *n*.
Input Specification:
The first line contains two integers *n* a... | ```python
def solver(n,m,graph):
d = [float("inf")] * n
used = [False] * n
d[0] = 0
parent = [-1] * n
for i in range(n):
v = -1
for j in range(n):
if not used[j] and (v == -1 or d[j] < d[v]):
v =j
used[v] = True
for to,w in graph... | 0 |
731 | A | Night at the Museum | PROGRAMMING | 800 | [
"implementation",
"strings"
] | null | null | Grigoriy, like the hero of one famous comedy film, found a job as a night security guard at the museum. At first night he received embosser and was to take stock of the whole exposition.
Embosser is a special devise that allows to "print" the text of a plastic tape. Text is printed sequentially, character by character... | The only line of input contains the name of some exhibit — the non-empty string consisting of no more than 100 characters. It's guaranteed that the string consists of only lowercase English letters. | Print one integer — the minimum number of rotations of the wheel, required to print the name given in the input. | [
"zeus\n",
"map\n",
"ares\n"
] | [
"18\n",
"35\n",
"34\n"
] | To print the string from the first sample it would be optimal to perform the following sequence of rotations:
1. from 'a' to 'z' (1 rotation counterclockwise), 1. from 'z' to 'e' (5 clockwise rotations), 1. from 'e' to 'u' (10 rotations counterclockwise), 1. from 'u' to 's' (2 counterclockwise rotations). | 500 | [
{
"input": "zeus",
"output": "18"
},
{
"input": "map",
"output": "35"
},
{
"input": "ares",
"output": "34"
},
{
"input": "l",
"output": "11"
},
{
"input": "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuv",
"... | 1,684,203,632 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 44 | 124 | 9,625,600 | import math
from sys import stdin
from collections import Counter, defaultdict, deque, namedtuple
from bisect import bisect_right, bisect_left
from typing import List, DefaultDict
from itertools import permutations
def readarray(typ):
return list(map(typ, stdin.readline().split()))
def readint... | Title: Night at the Museum
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Grigoriy, like the hero of one famous comedy film, found a job as a night security guard at the museum. At first night he received embosser and was to take stock of the whole exposition.
Embosser is a special devis... | ```python
import math
from sys import stdin
from collections import Counter, defaultdict, deque, namedtuple
from bisect import bisect_right, bisect_left
from typing import List, DefaultDict
from itertools import permutations
def readarray(typ):
return list(map(typ, stdin.readline().split()))
d... | 3 | |
55 | C | Pie or die | PROGRAMMING | 1,900 | [
"games"
] | C. Pie or die | 2 | 256 | Volodya and Vlad play the following game. There are *k* pies at the cells of *n*<=<=×<=<=*m* board. Each turn Volodya moves one pie to the neighbouring (by side) cell. If the pie lies at the border of the board then Volodya can move it outside the board, get the pie and win. After Volodya's move, Vlad bans some edge at... | First line contains 3 integers, separated by space: 1<=≤<=*n*,<=*m*<=≤<=100 — dimensions of the board and 0<=≤<=*k*<=≤<=100 — the number of pies. Each of the next *k* lines contains 2 integers, separated by space: 1<=≤<=*x*<=≤<=*n*, 1<=≤<=*y*<=≤<=*m* — coordinates of the corresponding pie. There could be more than one ... | Output only one word: "YES" — if Volodya wins, "NO" — otherwise. | [
"2 2 1\n1 2\n",
"3 4 0\n",
"100 50 2\n50 25\n50 25\n"
] | [
"YES",
"NO",
"NO"
] | none | 1,500 | [
{
"input": "2 2 1\n1 2",
"output": "YES"
},
{
"input": "3 4 0",
"output": "NO"
},
{
"input": "100 50 2\n50 25\n50 25",
"output": "NO"
},
{
"input": "20 20 4\n10 10\n10 10\n10 10\n10 10",
"output": "NO"
},
{
"input": "15 15 1\n8 8",
"output": "NO"
},
{
... | 1,679,894,487 | 2,147,483,647 | Python 3 | COMPILATION_ERROR | TESTS | 0 | 0 | 0 | #include<bits/stdc++.h>
int main(){int n,m,k,x,y;scanf("%d%d%d",&n,&m,&k);while(k--){scanf("%d%d",&x,&y);if(x<6||x>n-5||y<6||y>m-5)return 0&puts("YES");}puts("NO");}
| Title: Pie or die
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Volodya and Vlad play the following game. There are *k* pies at the cells of *n*<=<=×<=<=*m* board. Each turn Volodya moves one pie to the neighbouring (by side) cell. If the pie lies at the border of the board then Volodya can ... | ```python
#include<bits/stdc++.h>
int main(){int n,m,k,x,y;scanf("%d%d%d",&n,&m,&k);while(k--){scanf("%d%d",&x,&y);if(x<6||x>n-5||y<6||y>m-5)return 0&puts("YES");}puts("NO");}
``` | -1 |
254 | A | Cards with Numbers | PROGRAMMING | 1,200 | [
"constructive algorithms",
"sortings"
] | null | null | Petya has got 2*n* cards, each card contains some integer. The numbers on the cards can be the same. Let's index all cards by consecutive integers from 1 to 2*n*. We'll denote the number that is written on a card with number *i*, as *a**i*. In order to play one entertaining game with his friends, Petya needs to split t... | The first line contains integer *n* (1<=≤<=*n*<=≤<=3·105). The second line contains the sequence of 2*n* positive integers *a*1,<=*a*2,<=...,<=*a*2*n* (1<=≤<=*a**i*<=≤<=5000) — the numbers that are written on the cards. The numbers on the line are separated by single spaces. | If it is impossible to divide the cards into pairs so that cards in each pair had the same numbers, print on a single line integer -1. But if the required partition exists, then print *n* pairs of integers, a pair per line — the indices of the cards that form the pairs.
Separate the numbers on the lines by spaces. You... | [
"3\n20 30 10 30 20 10\n",
"1\n1 2\n"
] | [
"4 2\n1 5\n6 3\n",
"-1"
] | none | 500 | [
{
"input": "3\n20 30 10 30 20 10",
"output": "4 2\n1 5\n6 3"
},
{
"input": "1\n1 2",
"output": "-1"
},
{
"input": "5\n2 2 2 2 2 1 2 2 1 2",
"output": "2 1\n3 4\n7 5\n6 9\n10 8"
},
{
"input": "5\n2 1 2 2 1 1 1 1 1 2",
"output": "3 1\n2 5\n7 6\n8 9\n10 4"
},
{
"inpu... | 1,453,202,167 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 30 | 409,600 | # n = int(input())
# w, h = map(int, input().split())
# to_zero_based = lambda x: int(x) - 1
from collections import defaultdict
def main():
with open('input.txt') as fin:
n = int(fin.readline())
nums = list(map(int, fin.readline().split()))
distincts = defaultdict(list)
for i, num in enum... | Title: Cards with Numbers
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Petya has got 2*n* cards, each card contains some integer. The numbers on the cards can be the same. Let's index all cards by consecutive integers from 1 to 2*n*. We'll denote the number that is written on a card wit... | ```python
# n = int(input())
# w, h = map(int, input().split())
# to_zero_based = lambda x: int(x) - 1
from collections import defaultdict
def main():
with open('input.txt') as fin:
n = int(fin.readline())
nums = list(map(int, fin.readline().split()))
distincts = defaultdict(list)
for i, n... | -1 | |
980 | B | Marlin | PROGRAMMING | 1,600 | [
"constructive algorithms"
] | null | null | The city of Fishtopia can be imagined as a grid of $4$ rows and an odd number of columns. It has two main villages; the first is located at the top-left cell $(1,1)$, people who stay there love fishing at the Tuna pond at the bottom-right cell $(4, n)$. The second village is located at $(4, 1)$ and its people love the ... | The first line of input contain two integers, $n$ and $k$ ($3 \leq n \leq 99$, $0 \leq k \leq 2\times(n-2)$), $n$ is odd, the width of the city, and the number of hotels to be placed, respectively. | Print "YES", if it is possible to place all the hotels in a way that satisfies the problem statement, otherwise print "NO".
If it is possible, print an extra $4$ lines that describe the city, each line should have $n$ characters, each of which is "#" if that cell has a hotel on it, or "." if not. | [
"7 2\n",
"5 3\n"
] | [
"YES\n.......\n.#.....\n.#.....\n.......\n",
"YES\n.....\n.###.\n.....\n.....\n"
] | none | 1,000 | [
{
"input": "7 2",
"output": "YES\n.......\n.#.....\n.#.....\n......."
},
{
"input": "5 3",
"output": "YES\n.....\n.###.\n.....\n....."
},
{
"input": "3 2",
"output": "YES\n...\n.#.\n.#.\n..."
},
{
"input": "3 0",
"output": "YES\n...\n...\n...\n..."
},
{
"input": "... | 1,525,807,146 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 62 | 6,963,200 | n, k = [int(i) for i in input().split(" ")]
print('YES')
A = [['.' for i in range(n)] for j in range(4)]
for i in range(1,3):
for j in range(1,n-1):
if k>0:
A[i][j] = '#'
k-=1
else:
break
for i in A:
print(*i, sep='')
| Title: Marlin
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The city of Fishtopia can be imagined as a grid of $4$ rows and an odd number of columns. It has two main villages; the first is located at the top-left cell $(1,1)$, people who stay there love fishing at the Tuna pond at the bo... | ```python
n, k = [int(i) for i in input().split(" ")]
print('YES')
A = [['.' for i in range(n)] for j in range(4)]
for i in range(1,3):
for j in range(1,n-1):
if k>0:
A[i][j] = '#'
k-=1
else:
break
for i in A:
print(*i, sep='')
``` | 0 | |
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,647,958,509 | 2,147,483,647 | Python 3 | OK | TESTS | 19 | 92 | 0 | stones = list(input())
instruction = list(input())
pos = 0
for i in range(len(instruction)):
if stones[pos] == instruction[i]:
pos+=1
print(pos+1) | 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
stones = list(input())
instruction = list(input())
pos = 0
for i in range(len(instruction)):
if stones[pos] == instruction[i]:
pos+=1
print(pos+1)
``` | 3 | |
579 | A | Raising Bacteria | PROGRAMMING | 1,000 | [
"bitmasks"
] | null | null | You are a lover of bacteria. You want to raise some bacteria in a box.
Initially, the box is empty. Each morning, you can put any number of bacteria into the box. And each night, every bacterium in the box will split into two bacteria. You hope to see exactly *x* bacteria in the box at some moment.
What is the mini... | The only line containing one integer *x* (1<=≤<=*x*<=≤<=109). | The only line containing one integer: the answer. | [
"5\n",
"8\n"
] | [
"2\n",
"1\n"
] | For the first sample, we can add one bacterium in the box in the first day morning and at the third morning there will be 4 bacteria in the box. Now we put one more resulting 5 in the box. We added 2 bacteria in the process so the answer is 2.
For the second sample, we can put one in the first morning and in the 4-th ... | 250 | [
{
"input": "5",
"output": "2"
},
{
"input": "8",
"output": "1"
},
{
"input": "536870911",
"output": "29"
},
{
"input": "1",
"output": "1"
},
{
"input": "343000816",
"output": "14"
},
{
"input": "559980448",
"output": "12"
},
{
"input": "697... | 1,670,863,488 | 2,147,483,647 | Python 3 | OK | TESTS | 36 | 46 | 0 | from sys import stdin
def Binary(n):
string = ""
while n != 0:
string += str(n%2)
n //= 2
return string[::-1]
def main():
n, total = int(stdin.readline().strip()), 0
for i in Binary(n):
total += (1 if i == "1" else 0)
print(total)
main() | Title: Raising Bacteria
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are a lover of bacteria. You want to raise some bacteria in a box.
Initially, the box is empty. Each morning, you can put any number of bacteria into the box. And each night, every bacterium in the box will split... | ```python
from sys import stdin
def Binary(n):
string = ""
while n != 0:
string += str(n%2)
n //= 2
return string[::-1]
def main():
n, total = int(stdin.readline().strip()), 0
for i in Binary(n):
total += (1 if i == "1" else 0)
print(total)
main()
``` | 3 | |
805 | A | Fake NP | PROGRAMMING | 1,000 | [
"greedy",
"math"
] | null | null | Tavak and Seyyed are good friends. Seyyed is very funny and he told Tavak to solve the following problem instead of longest-path.
You are given *l* and *r*. For all integers from *l* to *r*, inclusive, we wrote down all of their integer divisors except 1. Find the integer that we wrote down the maximum number of times... | The first line contains two integers *l* and *r* (2<=≤<=*l*<=≤<=*r*<=≤<=109). | Print single integer, the integer that appears maximum number of times in the divisors.
If there are multiple answers, print any of them. | [
"19 29\n",
"3 6\n"
] | [
"2\n",
"3\n"
] | Definition of a divisor: [https://www.mathsisfun.com/definitions/divisor-of-an-integer-.html](https://www.mathsisfun.com/definitions/divisor-of-an-integer-.html)
The first example: from 19 to 29 these numbers are divisible by 2: {20, 22, 24, 26, 28}.
The second example: from 3 to 6 these numbers are divisible by 3: {... | 500 | [
{
"input": "19 29",
"output": "2"
},
{
"input": "3 6",
"output": "2"
},
{
"input": "39 91",
"output": "2"
},
{
"input": "76 134",
"output": "2"
},
{
"input": "93 95",
"output": "2"
},
{
"input": "17 35",
"output": "2"
},
{
"input": "94 95",... | 1,660,576,779 | 2,147,483,647 | Python 3 | OK | TESTS | 93 | 61 | 409,600 | import math
from re import L
import sys,bisect
from collections import deque,OrderedDict,defaultdict
import heapq
from collections import Counter
def inp(): return sys.stdin.readline().rstrip()
def mpp(): return map(int,inp().split())
def lis(): return list(mpp())
def yn(n):
if n:
return "YES"
... | Title: Fake NP
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Tavak and Seyyed are good friends. Seyyed is very funny and he told Tavak to solve the following problem instead of longest-path.
You are given *l* and *r*. For all integers from *l* to *r*, inclusive, we wrote down all of the... | ```python
import math
from re import L
import sys,bisect
from collections import deque,OrderedDict,defaultdict
import heapq
from collections import Counter
def inp(): return sys.stdin.readline().rstrip()
def mpp(): return map(int,inp().split())
def lis(): return list(mpp())
def yn(n):
if n:
retur... | 3 | |
0 | none | none | none | 0 | [
"none"
] | null | null | You are given an array *a*1,<=*a*2,<=...,<=*a**n* consisting of *n* integers, and an integer *k*. You have to split the array into exactly *k* non-empty subsegments. You'll then compute the minimum integer on each subsegment, and take the maximum integer over the *k* obtained minimums. What is the maximum possible inte... | The first line contains two integers *n* and *k* (1<=≤<=*k*<=≤<=*n*<=≤<=<=105) — the size of the array *a* and the number of subsegments you have to split the array to.
The second line contains *n* integers *a*1,<=<=*a*2,<=<=...,<=<=*a**n* (<=-<=109<=<=≤<=<=*a**i*<=≤<=<=109). | Print single integer — the maximum possible integer you can get if you split the array into *k* non-empty subsegments and take maximum of minimums on the subsegments. | [
"5 2\n1 2 3 4 5\n",
"5 1\n-4 -5 -3 -2 -1\n"
] | [
"5\n",
"-5\n"
] | A subsegment [*l*, *r*] (*l* ≤ *r*) of array *a* is the sequence *a*<sub class="lower-index">*l*</sub>, *a*<sub class="lower-index">*l* + 1</sub>, ..., *a*<sub class="lower-index">*r*</sub>.
Splitting of array *a* of *n* elements into *k* subsegments [*l*<sub class="lower-index">1</sub>, *r*<sub class="lower-index... | 0 | [
{
"input": "5 2\n1 2 3 4 5",
"output": "5"
},
{
"input": "5 1\n-4 -5 -3 -2 -1",
"output": "-5"
},
{
"input": "10 2\n10 9 1 -9 -7 -9 3 8 -10 5",
"output": "10"
},
{
"input": "10 4\n-8 -1 2 -3 9 -8 4 -3 5 9",
"output": "9"
},
{
"input": "1 1\n504262064",
"output... | 1,508,085,490 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 31 | 0 | x=input().split()
y=input().split()
a=[]
z=[]
for i in y:
a.append(int(i))
if int(x[1])>2:
print(max(a))
if int(x[1])==1:
print(min(a))
if int(x[1])==2:
for e in range(a):
z.append(min(a[:e]))
z.append(min(a[e:]))
print(max(z)) | Title: none
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given an array *a*1,<=*a*2,<=...,<=*a**n* consisting of *n* integers, and an integer *k*. You have to split the array into exactly *k* non-empty subsegments. You'll then compute the minimum integer on each subsegment, and ... | ```python
x=input().split()
y=input().split()
a=[]
z=[]
for i in y:
a.append(int(i))
if int(x[1])>2:
print(max(a))
if int(x[1])==1:
print(min(a))
if int(x[1])==2:
for e in range(a):
z.append(min(a[:e]))
z.append(min(a[e:]))
print(max(z))
``` | -1 | |
0 | none | none | none | 0 | [
"none"
] | null | null | Leha decided to move to a quiet town Vičkopolis, because he was tired by living in Bankopolis. Upon arrival he immediately began to expand his network of hacked computers. During the week Leha managed to get access to *n* computers throughout the town. Incidentally all the computers, which were hacked by Leha, lie on t... | The first line contains one integer *n* (1<=≤<=*n*<=≤<=3·105) denoting the number of hacked computers.
The second line contains *n* integers *x*1,<=*x*2,<=...,<=*x**n* (1<=≤<=*x**i*<=≤<=109) denoting the coordinates of hacked computers. It is guaranteed that all *x**i* are distinct. | Print a single integer — the required sum modulo 109<=+<=7. | [
"2\n4 7\n",
"3\n4 3 1\n"
] | [
"3\n",
"9\n"
] | There are three non-empty subsets in the first sample test:<img align="middle" class="tex-formula" src="https://espresso.codeforces.com/02b2d12556dad85f1c6c6912786eb87d4be2ea17.png" style="max-width: 100.0%;max-height: 100.0%;"/>, <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/22f6a537962c... | 0 | [
{
"input": "2\n4 7",
"output": "3"
},
{
"input": "3\n4 3 1",
"output": "9"
},
{
"input": "20\n8 11 13 19 21 34 36 44 57 58 61 63 76 78 79 81 85 86 90 95",
"output": "83396599"
},
{
"input": "20\n1 8 9 12 15 17 18 24 30 33 36 41 53 54 59 62 64 66 72 73",
"output": "6805914... | 1,689,193,355 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 0 | 62 | 0 | print("_RANDOM_GUESS_1689193354.922567")# 1689193354.9226089 | Title: none
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Leha decided to move to a quiet town Vičkopolis, because he was tired by living in Bankopolis. Upon arrival he immediately began to expand his network of hacked computers. During the week Leha managed to get access to *n* computer... | ```python
print("_RANDOM_GUESS_1689193354.922567")# 1689193354.9226089
``` | 0 | |
323 | A | Black-and-White Cube | PROGRAMMING | 1,600 | [
"combinatorics",
"constructive algorithms"
] | null | null | You are given a cube of size *k*<=×<=*k*<=×<=*k*, which consists of unit cubes. Two unit cubes are considered neighbouring, if they have common face.
Your task is to paint each of *k*3 unit cubes one of two colours (black or white), so that the following conditions must be satisfied:
- each white cube has exactly 2 ... | The first line contains integer *k* (1<=≤<=*k*<=≤<=100), which is size of the cube. | Print -1 if there is no solution. Otherwise, print the required painting of the cube consequently by layers. Print a *k*<=×<=*k* matrix in the first *k* lines, showing how the first layer of the cube should be painted. In the following *k* lines print a *k*<=×<=*k* matrix — the way the second layer should be painted. A... | [
"1\n",
"2\n"
] | [
"-1\n",
"bb\nww\n\nbb\nww\n"
] | none | 500 | [
{
"input": "1",
"output": "-1"
},
{
"input": "2",
"output": "bb\nww\n\nbb\nww"
},
{
"input": "3",
"output": "-1"
},
{
"input": "4",
"output": "bbbb\nbwwb\nbwwb\nbbbb\n\nwwww\nwbbw\nwbbw\nwwww\n\nbbbb\nbwwb\nbwwb\nbbbb\n\nwwww\nwbbw\nwbbw\nwwww"
},
{
"input": "5",
... | 1,590,389,759 | 2,147,483,647 | PyPy 3 | OK | TESTS | 101 | 249 | 3,993,600 | n=int(input())
if(n%2==1):
print(-1)
else:
for i in range(n):
for j in range(n):
s = ''
if (i // 2 + j)&1:
s = 'wwbb' * (n//4)
if n % 4 != 0:
s += 'ww'
else:
s = 'bbww' * (n//4)
... | Title: Black-and-White Cube
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given a cube of size *k*<=×<=*k*<=×<=*k*, which consists of unit cubes. Two unit cubes are considered neighbouring, if they have common face.
Your task is to paint each of *k*3 unit cubes one of two colour... | ```python
n=int(input())
if(n%2==1):
print(-1)
else:
for i in range(n):
for j in range(n):
s = ''
if (i // 2 + j)&1:
s = 'wwbb' * (n//4)
if n % 4 != 0:
s += 'ww'
else:
s = 'bbww' * (n//4)
... | 3 | |
500 | A | New Year Transportation | PROGRAMMING | 1,000 | [
"dfs and similar",
"graphs",
"implementation"
] | null | null | New Year is coming in Line World! In this world, there are *n* cells numbered by integers from 1 to *n*, as a 1<=×<=*n* board. People live in cells. However, it was hard to move between distinct cells, because of the difficulty of escaping the cell. People wanted to meet people who live in other cells.
So, user tncks0... | The first line contains two space-separated integers *n* (3<=≤<=*n*<=≤<=3<=×<=104) and *t* (2<=≤<=*t*<=≤<=*n*) — the number of cells, and the index of the cell which I want to go to.
The second line contains *n*<=-<=1 space-separated integers *a*1,<=*a*2,<=...,<=*a**n*<=-<=1 (1<=≤<=*a**i*<=≤<=*n*<=-<=*i*). It is guara... | If I can go to cell *t* using the transportation system, print "YES". Otherwise, print "NO". | [
"8 4\n1 2 1 2 1 2 1\n",
"8 5\n1 2 1 2 1 1 1\n"
] | [
"YES\n",
"NO\n"
] | In the first sample, the visited cells are: 1, 2, 4; so we can successfully visit the cell 4.
In the second sample, the possible cells to visit are: 1, 2, 4, 6, 7, 8; so we can't visit the cell 5, which we want to visit. | 500 | [
{
"input": "8 4\n1 2 1 2 1 2 1",
"output": "YES"
},
{
"input": "8 5\n1 2 1 2 1 1 1",
"output": "NO"
},
{
"input": "20 19\n13 16 7 6 12 1 5 7 8 6 5 7 5 5 3 3 2 2 1",
"output": "YES"
},
{
"input": "50 49\n11 7 1 41 26 36 19 16 38 14 36 35 37 27 20 27 3 6 21 2 27 11 18 17 19 16 ... | 1,672,206,305 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 30 | 0 | x,a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
x=0
y=0
if a==1 or a==2:
print("YES")
else:
for i in b:
x=x+i
if x==a:
print("YES")
y=1
break
elif x>a:
print("NO")
break
if y==0:
print("NO")
| Title: New Year Transportation
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
New Year is coming in Line World! In this world, there are *n* cells numbered by integers from 1 to *n*, as a 1<=×<=*n* board. People live in cells. However, it was hard to move between distinct cells, because o... | ```python
x,a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
x=0
y=0
if a==1 or a==2:
print("YES")
else:
for i in b:
x=x+i
if x==a:
print("YES")
y=1
break
elif x>a:
print("NO")
break
if y==0:
print("NO")
``` | 0 | |
875 | A | Classroom Watch | PROGRAMMING | 1,200 | [
"brute force",
"math"
] | null | null | Eighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on it the number *n*. He asked what is this number and the teacher of mathematics Inna Petrovna answered Vova that *n* is the answer to the arithmetic task for first-graders. In the textbook, a certain ... | The first line contains integer *n* (1<=≤<=*n*<=≤<=109). | In the first line print one integer *k* — number of different values of *x* satisfying the condition.
In next *k* lines print these values in ascending order. | [
"21\n",
"20\n"
] | [
"1\n15\n",
"0\n"
] | In the first test case *x* = 15 there is only one variant: 15 + 1 + 5 = 21.
In the second test case there are no such *x*. | 500 | [
{
"input": "21",
"output": "1\n15"
},
{
"input": "20",
"output": "0"
},
{
"input": "1",
"output": "0"
},
{
"input": "2",
"output": "1\n1"
},
{
"input": "3",
"output": "0"
},
{
"input": "100000001",
"output": "2\n99999937\n100000000"
},
{
"i... | 1,508,316,158 | 2,147,483,647 | Python 3 | OK | TESTS | 18 | 62 | 5,529,600 | n = int(input())
def digits(v):
s = 0
while v > 0:
s += v % 10
v //= 10
return s
a = []
for x in range(max(0, n - 81), n):
if x + digits(x) == n:
a.append(x)
print(len(a))
if len(a) > 0:
print(" ".join(map(str, a)))
| Title: Classroom Watch
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Eighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on it the number *n*. He asked what is this number and the teacher of mathematics Inna Petrovna answe... | ```python
n = int(input())
def digits(v):
s = 0
while v > 0:
s += v % 10
v //= 10
return s
a = []
for x in range(max(0, n - 81), n):
if x + digits(x) == n:
a.append(x)
print(len(a))
if len(a) > 0:
print(" ".join(map(str, a)))
``` | 3 | |
237 | D | T-decomposition | PROGRAMMING | 2,000 | [
"dfs and similar",
"graphs",
"greedy",
"trees"
] | null | null | You've got a undirected tree *s*, consisting of *n* nodes. Your task is to build an optimal T-decomposition for it. Let's define a T-decomposition as follows.
Let's denote the set of all nodes *s* as *v*. Let's consider an undirected tree *t*, whose nodes are some non-empty subsets of *v*, we'll call them *x**i* . The... | The first line contains a single integer *n* (2<=≤<=*n*<=≤<=105), that denotes the number of nodes in tree *s*.
Each of the following *n*<=-<=1 lines contains two space-separated integers *a**i*,<=*b**i* (1<=≤<=*a**i*,<=*b**i*<=≤<=*n*; *a**i*<=≠<=*b**i*), denoting that the nodes of tree *s* with indices *a**i* and *b*... | In the first line print a single integer *m* that denotes the number of nodes in the required T-decomposition.
Then print *m* lines, containing descriptions of the T-decomposition nodes. In the *i*-th (1<=≤<=*i*<=≤<=*m*) of them print the description of node *x**i* of the T-decomposition. The description of each node ... | [
"2\n1 2\n",
"3\n1 2\n2 3\n",
"4\n2 1\n3 1\n4 1\n"
] | [
"1\n2 1 2\n",
"2\n2 1 2\n2 2 3\n1 2\n",
"3\n2 2 1\n2 3 1\n2 4 1\n1 2\n2 3\n"
] | none | 2,000 | [
{
"input": "2\n1 2",
"output": "1\n2 1 2"
},
{
"input": "3\n1 2\n2 3",
"output": "2\n2 1 2\n2 2 3\n1 2"
},
{
"input": "4\n2 1\n3 1\n4 1",
"output": "3\n2 2 1\n2 3 1\n2 4 1\n1 2\n2 3"
},
{
"input": "6\n2 5\n4 3\n4 2\n4 6\n3 1",
"output": "5\n2 2 5\n2 4 3\n2 4 2\n2 4 6\n2 3... | 1,616,104,890 | 2,147,483,647 | PyPy 3 | TIME_LIMIT_EXCEEDED | TESTS | 8 | 2,000 | 23,859,200 | N = 10**5 + 5
g = [[] for _ in range(N)]
p = [0]*N
def dfs(cur, par):
p[cur] = par
for nxt in g[cur]:
if nxt != par:
dfs(nxt, cur)
n = int(input())
for i in range(n-1):
a, b = map(int, input().split())
g[a].append(b)
g[b].append(a)
dfs(1, 0)
print(n-1)
for i in range(2, n+1):
print(2, str(i), str(p[i]))
for ... | Title: T-decomposition
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You've got a undirected tree *s*, consisting of *n* nodes. Your task is to build an optimal T-decomposition for it. Let's define a T-decomposition as follows.
Let's denote the set of all nodes *s* as *v*. Let's conside... | ```python
N = 10**5 + 5
g = [[] for _ in range(N)]
p = [0]*N
def dfs(cur, par):
p[cur] = par
for nxt in g[cur]:
if nxt != par:
dfs(nxt, cur)
n = int(input())
for i in range(n-1):
a, b = map(int, input().split())
g[a].append(b)
g[b].append(a)
dfs(1, 0)
print(n-1)
for i in range(2, n+1):
print(2, str(i), str(p... | 0 | |
478 | C | Table Decorations | PROGRAMMING | 1,800 | [
"greedy"
] | null | null | You have *r* red, *g* green and *b* blue balloons. To decorate a single table for the banquet you need exactly three balloons. Three balloons attached to some table shouldn't have the same color. What maximum number *t* of tables can be decorated if we know number of balloons of each color?
Your task is to write a pro... | The single line contains three integers *r*, *g* and *b* (0<=≤<=*r*,<=*g*,<=*b*<=≤<=2·109) — the number of red, green and blue baloons respectively. The numbers are separated by exactly one space. | Print a single integer *t* — the maximum number of tables that can be decorated in the required manner. | [
"5 4 3\n",
"1 1 1\n",
"2 3 3\n"
] | [
"4\n",
"1\n",
"2\n"
] | In the first sample you can decorate the tables with the following balloon sets: "rgg", "gbb", "brr", "rrg", where "r", "g" and "b" represent the red, green and blue balls, respectively. | 1,500 | [
{
"input": "5 4 3",
"output": "4"
},
{
"input": "1 1 1",
"output": "1"
},
{
"input": "2 3 3",
"output": "2"
},
{
"input": "0 1 0",
"output": "0"
},
{
"input": "0 3 3",
"output": "2"
},
{
"input": "4 0 4",
"output": "2"
},
{
"input": "100000... | 1,656,985,297 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 9 | 61 | 0 | from math import floor
r, g, b = list(map(int, input().split()))
s = r + g + b
s = floor(s / 3)
print(min(g + b, s))
| Title: Table Decorations
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You have *r* red, *g* green and *b* blue balloons. To decorate a single table for the banquet you need exactly three balloons. Three balloons attached to some table shouldn't have the same color. What maximum number *... | ```python
from math import floor
r, g, b = list(map(int, input().split()))
s = r + g + b
s = floor(s / 3)
print(min(g + b, s))
``` | 0 | |
893 | C | Rumor | PROGRAMMING | 1,300 | [
"dfs and similar",
"graphs",
"greedy"
] | null | null | Vova promised himself that he would never play computer games... But recently Firestorm — a well-known game developing company — published their newest game, World of Farcraft, and it became really popular. Of course, Vova started playing it.
Now he tries to solve a quest. The task is to come to a settlement named Ove... | The first line contains two integer numbers *n* and *m* (1<=≤<=*n*<=≤<=105,<=0<=≤<=*m*<=≤<=105) — the number of characters in Overcity and the number of pairs of friends.
The second line contains *n* integer numbers *c**i* (0<=≤<=*c**i*<=≤<=109) — the amount of gold *i*-th character asks to start spreading the rumor.
... | Print one number — the minimum amount of gold Vova has to spend in order to finish the quest. | [
"5 2\n2 5 3 4 8\n1 4\n4 5\n",
"10 0\n1 2 3 4 5 6 7 8 9 10\n",
"10 5\n1 6 2 7 3 8 4 9 5 10\n1 2\n3 4\n5 6\n7 8\n9 10\n"
] | [
"10\n",
"55\n",
"15\n"
] | In the first example the best decision is to bribe the first character (he will spread the rumor to fourth character, and the fourth one will spread it to fifth). Also Vova has to bribe the second and the third characters, so they know the rumor.
In the second example Vova has to bribe everyone.
In the third example ... | 0 | [
{
"input": "5 2\n2 5 3 4 8\n1 4\n4 5",
"output": "10"
},
{
"input": "10 0\n1 2 3 4 5 6 7 8 9 10",
"output": "55"
},
{
"input": "10 5\n1 6 2 7 3 8 4 9 5 10\n1 2\n3 4\n5 6\n7 8\n9 10",
"output": "15"
},
{
"input": "1 0\n0",
"output": "0"
},
{
"input": "1 0\n10000000... | 1,610,863,604 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 3 | 358 | 18,124,800 | from collections import defaultdict
import sys
sys.setrecursionlimit(15000)
def dfs(v,graph,visited,mini,l):
visited[v]=True
for i in graph[v]:
if(visited[i]==False):
mini=min(mini,l[i])
dfs(i,graph,visited,mini,l)
return mini
ver,edg=map(int,input().split())
l=l... | Title: Rumor
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vova promised himself that he would never play computer games... But recently Firestorm — a well-known game developing company — published their newest game, World of Farcraft, and it became really popular. Of course, Vova starte... | ```python
from collections import defaultdict
import sys
sys.setrecursionlimit(15000)
def dfs(v,graph,visited,mini,l):
visited[v]=True
for i in graph[v]:
if(visited[i]==False):
mini=min(mini,l[i])
dfs(i,graph,visited,mini,l)
return mini
ver,edg=map(int,input().spl... | -1 | |
938 | C | Constructing Tests | PROGRAMMING | 1,700 | [
"binary search",
"brute force",
"constructive algorithms"
] | null | null | Let's denote a *m*-free matrix as a binary (that is, consisting of only 1's and 0's) matrix such that every square submatrix of size *m*<=×<=*m* of this matrix contains at least one zero.
Consider the following problem:
You are given two integers *n* and *m*. You have to construct an *m*-free square matrix of size *... | The first line contains one integer *t* (1<=≤<=*t*<=≤<=100) — the number of tests you have to construct.
Then *t* lines follow, *i*-th line containing one integer *x**i* (0<=≤<=*x**i*<=≤<=109).
Note that in hacks you have to set *t*<==<=1. | For each test you have to construct, output two positive numbers *n**i* and *m**i* (1<=≤<=*m**i*<=≤<=*n**i*<=≤<=109) such that the maximum number of 1's in a *m**i*-free *n**i*<=×<=*n**i* matrix is exactly *x**i*. If there are multiple solutions, you may output any of them; and if this is impossible to construct a test... | [
"3\n21\n0\n1\n"
] | [
"5 2\n1 1\n-1\n"
] | none | 0 | [
{
"input": "3\n21\n0\n1",
"output": "5 2\n1 1\n-1"
},
{
"input": "1\n420441920",
"output": "-1"
},
{
"input": "1\n4",
"output": "-1"
},
{
"input": "1\n297540",
"output": "546 22"
},
{
"input": "1\n9",
"output": "-1"
},
{
"input": "1\n144",
"output"... | 1,690,911,768 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 0 | 30 | 0 | print("_RANDOM_GUESS_1690911768.8700302")# 1690911768.8700488 | Title: Constructing Tests
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Let's denote a *m*-free matrix as a binary (that is, consisting of only 1's and 0's) matrix such that every square submatrix of size *m*<=×<=*m* of this matrix contains at least one zero.
Consider the following pro... | ```python
print("_RANDOM_GUESS_1690911768.8700302")# 1690911768.8700488
``` | 0 | |
248 | B | Chilly Willy | PROGRAMMING | 1,400 | [
"math",
"number theory"
] | null | null | Chilly Willy loves playing with numbers. He only knows prime numbers that are digits yet. These numbers are 2, 3, 5 and 7. But Willy grew rather bored of such numbers, so he came up with a few games that were connected with them.
Chilly Willy wants to find the minimum number of length *n*, such that it is simultaneous... | A single input line contains a single integer *n* (1<=≤<=*n*<=≤<=105). | Print a single integer — the answer to the problem without leading zeroes, or "-1" (without the quotes), if the number that meet the problem condition does not exist. | [
"1\n",
"5\n"
] | [
"-1\n",
"10080"
] | none | 1,000 | [
{
"input": "1",
"output": "-1"
},
{
"input": "5",
"output": "10080"
},
{
"input": "6",
"output": "100170"
},
{
"input": "4",
"output": "1050"
},
{
"input": "15",
"output": "100000000000110"
},
{
"input": "16",
"output": "1000000000000050"
},
{
... | 1,695,631,633 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 0 | 92 | 0 | e = int(input("Enter: "))
if e < 3:
print("-1")
else:
x = 10**(e - 1)
f = x % 210
print(x - f + 210) | Title: Chilly Willy
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Chilly Willy loves playing with numbers. He only knows prime numbers that are digits yet. These numbers are 2, 3, 5 and 7. But Willy grew rather bored of such numbers, so he came up with a few games that were connected wit... | ```python
e = int(input("Enter: "))
if e < 3:
print("-1")
else:
x = 10**(e - 1)
f = x % 210
print(x - f + 210)
``` | 0 | |
217 | A | Ice Skating | PROGRAMMING | 1,200 | [
"brute force",
"dfs and similar",
"dsu",
"graphs"
] | null | null | Bajtek is learning to skate on ice. He's a beginner, so his only mode of transportation is pushing off from a snow drift to the north, east, south or west and sliding until he lands in another snow drift. He has noticed that in this way it's impossible to get from some snow drifts to some other by any sequence of moves... | The first line of input contains a single integer *n* (1<=≤<=*n*<=≤<=100) — the number of snow drifts. Each of the following *n* lines contains two integers *x**i* and *y**i* (1<=≤<=*x**i*,<=*y**i*<=≤<=1000) — the coordinates of the *i*-th snow drift.
Note that the north direction coinсides with the direction of *Oy* ... | Output the minimal number of snow drifts that need to be created in order for Bajtek to be able to reach any snow drift from any other one. | [
"2\n2 1\n1 2\n",
"2\n2 1\n4 1\n"
] | [
"1\n",
"0\n"
] | none | 500 | [
{
"input": "2\n2 1\n1 2",
"output": "1"
},
{
"input": "2\n2 1\n4 1",
"output": "0"
},
{
"input": "24\n171 35\n261 20\n4 206\n501 446\n961 912\n581 748\n946 978\n463 514\n841 889\n341 466\n842 967\n54 102\n235 261\n925 889\n682 672\n623 636\n268 94\n635 710\n474 510\n697 794\n586 663\n182... | 1,584,555,263 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 218 | 409,600 | from collections import Counter
n = int(input())
List = []
for i in range(n):
a,b = map(int,input().split())
List.append(a)
List.append(b)
Dict = Counter(List)
if(len(Dict.keys())==n+1):
print(0)
else:
print(1) | Title: Ice Skating
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Bajtek is learning to skate on ice. He's a beginner, so his only mode of transportation is pushing off from a snow drift to the north, east, south or west and sliding until he lands in another snow drift. He has noticed tha... | ```python
from collections import Counter
n = int(input())
List = []
for i in range(n):
a,b = map(int,input().split())
List.append(a)
List.append(b)
Dict = Counter(List)
if(len(Dict.keys())==n+1):
print(0)
else:
print(1)
``` | 0 | |
835 | A | Key races | PROGRAMMING | 800 | [
"math"
] | null | null | Two boys decided to compete in text typing on the site "Key races". During the competition, they have to type a text consisting of *s* characters. The first participant types one character in *v*1 milliseconds and has ping *t*1 milliseconds. The second participant types one character in *v*2 milliseconds and has ping *... | The first line contains five integers *s*, *v*1, *v*2, *t*1, *t*2 (1<=≤<=*s*,<=*v*1,<=*v*2,<=*t*1,<=*t*2<=≤<=1000) — the number of characters in the text, the time of typing one character for the first participant, the time of typing one character for the the second participant, the ping of the first participant and th... | If the first participant wins, print "First". If the second participant wins, print "Second". In case of a draw print "Friendship". | [
"5 1 2 1 2\n",
"3 3 1 1 1\n",
"4 5 3 1 5\n"
] | [
"First\n",
"Second\n",
"Friendship\n"
] | In the first example, information on the success of the first participant comes in 7 milliseconds, of the second participant — in 14 milliseconds. So, the first wins.
In the second example, information on the success of the first participant comes in 11 milliseconds, of the second participant — in 5 milliseconds. So, ... | 500 | [
{
"input": "5 1 2 1 2",
"output": "First"
},
{
"input": "3 3 1 1 1",
"output": "Second"
},
{
"input": "4 5 3 1 5",
"output": "Friendship"
},
{
"input": "1000 1000 1000 1000 1000",
"output": "Friendship"
},
{
"input": "1 1 1 1 1",
"output": "Friendship"
},
... | 1,587,005,677 | 2,147,483,647 | Python 3 | COMPILATION_ERROR | TESTS | 0 | 0 | 0 | #include<bits/stdc++.h>
using namespace std;
int main(){
int s,v1,v2,t1,t2,f,se;
cin >>s >> v1 >> v2 >> t1 >> t2;
f = v1*s + 2*t1;
se = v2*s + 2*t2;
if(f > se) cout << "Second" << endl;
else if ( f == se) cout << "Friendship" << endl;
else cout << "First" << endl... | Title: Key races
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Two boys decided to compete in text typing on the site "Key races". During the competition, they have to type a text consisting of *s* characters. The first participant types one character in *v*1 milliseconds and has ping *t... | ```python
#include<bits/stdc++.h>
using namespace std;
int main(){
int s,v1,v2,t1,t2,f,se;
cin >>s >> v1 >> v2 >> t1 >> t2;
f = v1*s + 2*t1;
se = v2*s + 2*t2;
if(f > se) cout << "Second" << endl;
else if ( f == se) cout << "Friendship" << endl;
else cout << "Firs... | -1 | |
0 | none | none | none | 0 | [
"none"
] | null | null | Innokenty is a president of a new football league in Byteland. The first task he should do is to assign short names to all clubs to be shown on TV next to the score. Of course, the short names should be distinct, and Innokenty wants that all short names consist of three letters.
Each club's full name consist of two wo... | The first line contains a single integer *n* (1<=≤<=*n*<=≤<=1000) — the number of clubs in the league.
Each of the next *n* lines contains two words — the team's name and the hometown's name for some club. Both team's name and hometown's name consist of uppercase English letters and have length at least 3 and at most ... | It it is not possible to choose short names and satisfy all constraints, print a single line "NO".
Otherwise, in the first line print "YES". Then print *n* lines, in each line print the chosen short name for the corresponding club. Print the clubs in the same order as they appeared in input.
If there are multiple ans... | [
"2\nDINAMO BYTECITY\nFOOTBALL MOSCOW\n",
"2\nDINAMO BYTECITY\nDINAMO BITECITY\n",
"3\nPLAYFOOTBALL MOSCOW\nPLAYVOLLEYBALL SPB\nGOGO TECHNOCUP\n",
"3\nABC DEF\nABC EFG\nABD OOO\n"
] | [
"YES\nDIN\nFOO\n",
"NO\n",
"YES\nPLM\nPLS\nGOG\n",
"YES\nABD\nABE\nABO\n"
] | In the first sample Innokenty can choose first option for both clubs.
In the second example it is not possible to choose short names, because it is not possible that one club has first option, and the other has second option if the first options are equal for both clubs.
In the third example Innokenty can choose the ... | 0 | [
{
"input": "2\nDINAMO BYTECITY\nFOOTBALL MOSCOW",
"output": "YES\nDIN\nFOO"
},
{
"input": "2\nDINAMO BYTECITY\nDINAMO BITECITY",
"output": "NO"
},
{
"input": "3\nPLAYFOOTBALL MOSCOW\nPLAYVOLLEYBALL SPB\nGOGO TECHNOCUP",
"output": "YES\nPLM\nPLS\nGOG"
},
{
"input": "3\nABC DEF... | 1,689,423,249 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 0 | 46 | 0 | print("_RANDOM_GUESS_1689423249.2576973")# 1689423249.2577193 | Title: none
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Innokenty is a president of a new football league in Byteland. The first task he should do is to assign short names to all clubs to be shown on TV next to the score. Of course, the short names should be distinct, and Innokenty wan... | ```python
print("_RANDOM_GUESS_1689423249.2576973")# 1689423249.2577193
``` | 0 | |
1,003 | A | Polycarp's Pockets | PROGRAMMING | 800 | [
"implementation"
] | null | null | Polycarp has $n$ coins, the value of the $i$-th coin is $a_i$. Polycarp wants to distribute all the coins between his pockets, but he cannot put two coins with the same value into the same pocket.
For example, if Polycarp has got six coins represented as an array $a = [1, 2, 4, 3, 3, 2]$, he can distribute the coins i... | The first line of the input contains one integer $n$ ($1 \le n \le 100$) — the number of coins.
The second line of the input contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 100$) — values of coins. | Print only one integer — the minimum number of pockets Polycarp needs to distribute all the coins so no two coins with the same value are put into the same pocket. | [
"6\n1 2 4 3 3 2\n",
"1\n100\n"
] | [
"2\n",
"1\n"
] | none | 0 | [
{
"input": "6\n1 2 4 3 3 2",
"output": "2"
},
{
"input": "1\n100",
"output": "1"
},
{
"input": "100\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100... | 1,592,632,521 | 2,147,483,647 | Python 3 | OK | TESTS | 37 | 109 | 0 | n = input()
arr = list(map(int, input().split()))
arrS = set(arr)
c=0
for x in arrS:
y = arr.count(x)
if y>c:
c=y
print(c) | Title: Polycarp's Pockets
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Polycarp has $n$ coins, the value of the $i$-th coin is $a_i$. Polycarp wants to distribute all the coins between his pockets, but he cannot put two coins with the same value into the same pocket.
For example, if Po... | ```python
n = input()
arr = list(map(int, input().split()))
arrS = set(arr)
c=0
for x in arrS:
y = arr.count(x)
if y>c:
c=y
print(c)
``` | 3 | |
244 | A | Dividing Orange | PROGRAMMING | 900 | [
"implementation"
] | null | null | One day Ms Swan bought an orange in a shop. The orange consisted of *n*·*k* segments, numbered with integers from 1 to *n*·*k*.
There were *k* children waiting for Ms Swan at home. The children have recently learned about the orange and they decided to divide it between them. For that each child took a piece of paper... | The first line contains two integers *n*, *k* (1<=≤<=*n*,<=*k*<=≤<=30). The second line contains *k* space-separated integers *a*1,<=*a*2,<=...,<=*a**k* (1<=≤<=*a**i*<=≤<=*n*·*k*), where *a**i* is the number of the orange segment that the *i*-th child would like to get.
It is guaranteed that all numbers *a**i* are dis... | Print exactly *n*·*k* distinct integers. The first *n* integers represent the indexes of the segments the first child will get, the second *n* integers represent the indexes of the segments the second child will get, and so on. Separate the printed numbers with whitespaces.
You can print a child's segment indexes in a... | [
"2 2\n4 1\n",
"3 1\n2\n"
] | [
"2 4 \n1 3 \n",
"3 2 1 \n"
] | none | 500 | [
{
"input": "2 2\n4 1",
"output": "2 4 \n1 3 "
},
{
"input": "3 1\n2",
"output": "3 2 1 "
},
{
"input": "5 5\n25 24 23 22 21",
"output": "2 3 1 25 4 \n7 6 8 5 24 \n10 12 9 23 11 \n13 15 14 16 22 \n19 21 20 17 18 "
},
{
"input": "1 30\n8 22 13 25 10 30 12 27 6 4 7 2 20 16 26 14... | 1,555,325,533 | 2,147,483,647 | Python 3 | OK | TESTS | 29 | 218 | 0 | N, K = map(int, input().split())
A = list(map(int, input().split()))
vals = set(range(1, N * K + 1))
answer = [[] for k in range(K)]
for k in range(K):
answer[k].append(A[k])
vals.remove(A[k])
k = 0
while len(vals) > 0:
answer[k].append(vals.pop())
k = (k + 1) % K
for k in range(K):
print(" ".join([str(x)... | Title: Dividing Orange
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
One day Ms Swan bought an orange in a shop. The orange consisted of *n*·*k* segments, numbered with integers from 1 to *n*·*k*.
There were *k* children waiting for Ms Swan at home. The children have recently learned a... | ```python
N, K = map(int, input().split())
A = list(map(int, input().split()))
vals = set(range(1, N * K + 1))
answer = [[] for k in range(K)]
for k in range(K):
answer[k].append(A[k])
vals.remove(A[k])
k = 0
while len(vals) > 0:
answer[k].append(vals.pop())
k = (k + 1) % K
for k in range(K):
print(" ".jo... | 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,697,249,440 | 2,147,483,647 | Python 3 | OK | TESTS | 44 | 62 | 0 | players = input()
length = len(players)
previous = players[0]
count = 1
flag = False
for i in range(1, length):
if players[i] == previous:
count += 1
else:
previous = players[i]
count = 1
if count == 7:
flag = True
break
if flag:
print("YES")
else:... | 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
players = input()
length = len(players)
previous = players[0]
count = 1
flag = False
for i in range(1, length):
if players[i] == previous:
count += 1
else:
previous = players[i]
count = 1
if count == 7:
flag = True
break
if flag:
print("YE... | 3.9845 |
950 | A | Left-handers, Right-handers and Ambidexters | PROGRAMMING | 800 | [
"implementation",
"math"
] | null | null | You are at a water bowling training. There are *l* people who play with their left hand, *r* people, who play with their right hand, and *a* ambidexters, who can play with left or right hand.
The coach decided to form a team of even number of players, exactly half of the players should play with their right hand, and ... | The only line contains three integers *l*, *r* and *a* (0<=≤<=*l*,<=*r*,<=*a*<=≤<=100) — the number of left-handers, the number of right-handers and the number of ambidexters at the training. | Print a single even integer — the maximum number of players in the team. It is possible that the team can only have zero number of players. | [
"1 4 2\n",
"5 5 5\n",
"0 2 0\n"
] | [
"6\n",
"14\n",
"0\n"
] | In the first example you can form a team of 6 players. You should take the only left-hander and two ambidexters to play with left hand, and three right-handers to play with right hand. The only person left can't be taken into the team.
In the second example you can form a team of 14 people. You have to take all five l... | 500 | [
{
"input": "1 4 2",
"output": "6"
},
{
"input": "5 5 5",
"output": "14"
},
{
"input": "0 2 0",
"output": "0"
},
{
"input": "30 70 34",
"output": "128"
},
{
"input": "89 32 24",
"output": "112"
},
{
"input": "89 44 77",
"output": "210"
},
{
... | 1,666,342,953 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 5 | 31 | 0 | l,r,a=(map(int,input().split()))
if(l==0 or r==0):
print(0)
elif(l==r and l==a and r==a):
x=l+r+a
if(x%2==0):
print(x)
else:
print(x-1);
exit()
else:
if(l<r):
l=l+a
elif(r<l):
r=r+a
if(l<r):
print(l*2)
else:
print(r*2) | Title: Left-handers, Right-handers and Ambidexters
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are at a water bowling training. There are *l* people who play with their left hand, *r* people, who play with their right hand, and *a* ambidexters, who can play with left or right hand.... | ```python
l,r,a=(map(int,input().split()))
if(l==0 or r==0):
print(0)
elif(l==r and l==a and r==a):
x=l+r+a
if(x%2==0):
print(x)
else:
print(x-1);
exit()
else:
if(l<r):
l=l+a
elif(r<l):
r=r+a
if(l<r):
print(l*2)
else:
pr... | 0 | |
141 | A | Amusing Joke | PROGRAMMING | 800 | [
"implementation",
"sortings",
"strings"
] | null | null | So, the New Year holidays are over. Santa Claus and his colleagues can take a rest and have guests at last. When two "New Year and Christmas Men" meet, thear assistants cut out of cardboard the letters from the guest's name and the host's name in honor of this event. Then the hung the letters above the main entrance. O... | The input file consists of three lines: the first line contains the guest's name, the second line contains the name of the residence host and the third line contains letters in a pile that were found at the door in the morning. All lines are not empty and contain only uppercase Latin letters. The length of each line do... | Print "YES" without the quotes, if the letters in the pile could be permuted to make the names of the "New Year and Christmas Men". Otherwise, print "NO" without the quotes. | [
"SANTACLAUS\nDEDMOROZ\nSANTAMOROZDEDCLAUS\n",
"PAPAINOEL\nJOULUPUKKI\nJOULNAPAOILELUPUKKI\n",
"BABBONATALE\nFATHERCHRISTMAS\nBABCHRISTMASBONATALLEFATHER\n"
] | [
"YES\n",
"NO\n",
"NO\n"
] | In the first sample the letters written in the last line can be used to write the names and there won't be any extra letters left.
In the second sample letter "P" is missing from the pile and there's an extra letter "L".
In the third sample there's an extra letter "L". | 500 | [
{
"input": "SANTACLAUS\nDEDMOROZ\nSANTAMOROZDEDCLAUS",
"output": "YES"
},
{
"input": "PAPAINOEL\nJOULUPUKKI\nJOULNAPAOILELUPUKKI",
"output": "NO"
},
{
"input": "BABBONATALE\nFATHERCHRISTMAS\nBABCHRISTMASBONATALLEFATHER",
"output": "NO"
},
{
"input": "B\nA\nAB",
"output": ... | 1,685,696,165 | 2,147,483,647 | Python 3 | OK | TESTS | 54 | 92 | 0 | n=list(input())
n1=list(input())
n2=sorted(list(input()))
ll=sorted(n+n1)
if ll==n2:print("YES")
else:print("NO") | Title: Amusing Joke
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
So, the New Year holidays are over. Santa Claus and his colleagues can take a rest and have guests at last. When two "New Year and Christmas Men" meet, thear assistants cut out of cardboard the letters from the guest's nam... | ```python
n=list(input())
n1=list(input())
n2=sorted(list(input()))
ll=sorted(n+n1)
if ll==n2:print("YES")
else:print("NO")
``` | 3 | |
934 | A | A Compatible Pair | PROGRAMMING | 1,400 | [
"brute force",
"games"
] | null | null | Nian is a monster which lives deep in the oceans. Once a year, it shows up on the land, devouring livestock and even people. In order to keep the monster away, people fill their villages with red colour, light, and cracking noise, all of which frighten the monster out of coming.
Little Tommy has *n* lanterns and Big B... | The first line contains two space-separated integers *n* and *m* (2<=≤<=*n*,<=*m*<=≤<=50).
The second line contains *n* space-separated integers *a*1,<=*a*2,<=...,<=*a**n*.
The third line contains *m* space-separated integers *b*1,<=*b*2,<=...,<=*b**m*.
All the integers range from <=-<=109 to 109. | Print a single integer — the brightness of the chosen pair. | [
"2 2\n20 18\n2 14\n",
"5 3\n-1 0 1 2 3\n-1 0 1\n"
] | [
"252\n",
"2\n"
] | In the first example, Tommy will hide 20 and Banban will choose 18 from Tommy and 14 from himself.
In the second example, Tommy will hide 3 and Banban will choose 2 from Tommy and 1 from himself. | 500 | [
{
"input": "2 2\n20 18\n2 14",
"output": "252"
},
{
"input": "5 3\n-1 0 1 2 3\n-1 0 1",
"output": "2"
},
{
"input": "10 2\n1 6 2 10 2 3 2 10 6 4\n5 7",
"output": "70"
},
{
"input": "50 50\n1 6 2 10 2 3 2 10 6 4 5 0 3 1 7 3 2 4 4 2 1 5 0 6 10 1 8 0 10 9 0 4 10 5 5 7 4 9 9 5 5 ... | 1,518,794,917 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 46 | 5,632,000 | s=input()
n=input()
m=input()
n=n.split()
m=m.split()
n=list(n)
m=list(m)
a=max(n)
n.remove(str(a))
a=max(n)
b=max(m)
print(a*b)
| Title: A Compatible Pair
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Nian is a monster which lives deep in the oceans. Once a year, it shows up on the land, devouring livestock and even people. In order to keep the monster away, people fill their villages with red colour, light, and cr... | ```python
s=input()
n=input()
m=input()
n=n.split()
m=m.split()
n=list(n)
m=list(m)
a=max(n)
n.remove(str(a))
a=max(n)
b=max(m)
print(a*b)
``` | -1 |
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.