contestId int64 0 1.01k | index stringclasses 55
values | name stringlengths 2 58 | type stringclasses 2
values | rating int64 0 3.5k | tags listlengths 0 7 | title stringclasses 495
values | time-limit stringclasses 8
values | memory-limit stringclasses 8
values | problem-description stringlengths 0 7.15k | input-specification stringlengths 0 2.05k | output-specification stringlengths 0 1.5k | demo-input listlengths 0 7 | demo-output listlengths 0 7 | note stringlengths 0 5.24k | points float64 0 425k | test_cases listlengths 0 402 | creationTimeSeconds int64 1.37B 1.7B | relativeTimeSeconds int64 8 2.15B | programmingLanguage stringclasses 3
values | verdict stringclasses 14
values | testset stringclasses 12
values | passedTestCount int64 0 1k | timeConsumedMillis int64 0 15k | memoryConsumedBytes int64 0 805M | code stringlengths 5 65.5k | instruction_seed stringlengths 262 8.2k | response stringlengths 19 65.5k | score float64 -1 3.99 | _source stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
281 | A | Word Capitalization | PROGRAMMING | 800 | [
"implementation",
"strings"
] | null | null | Capitalization is writing a word with its first letter as a capital letter. Your task is to capitalize the given word.
Note, that during capitalization all the letters except the first one remains unchanged. | A single line contains a non-empty word. This word consists of lowercase and uppercase English letters. The length of the word will not exceed 103. | Output the given word after capitalization. | [
"ApPLe\n",
"konjac\n"
] | [
"ApPLe\n",
"Konjac\n"
] | none | 500 | [
{
"input": "ApPLe",
"output": "ApPLe"
},
{
"input": "konjac",
"output": "Konjac"
},
{
"input": "a",
"output": "A"
},
{
"input": "A",
"output": "A"
},
{
"input": "z",
"output": "Z"
},
{
"input": "ABACABA",
"output": "ABACABA"
},
{
"input": "... | 1,695,232,497 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 25 | 124 | 0 | T=input()
T=[i for i in T]
T[0]=T[0].upper()
print(''.join(T)) | Title: Word Capitalization
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Capitalization is writing a word with its first letter as a capital letter. Your task is to capitalize the given word.
Note, that during capitalization all the letters except the first one remains unchanged.
Input... | ```python
T=input()
T=[i for i in T]
T[0]=T[0].upper()
print(''.join(T))
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
518 | B | Tanya and Postcard | PROGRAMMING | 1,400 | [
"greedy",
"implementation",
"strings"
] | null | null | Little Tanya decided to present her dad a postcard on his Birthday. She has already created a message — string *s* of length *n*, consisting of uppercase and lowercase English letters. Tanya can't write yet, so she found a newspaper and decided to cut out the letters and glue them into the postcard to achieve string *s... | The first line contains line *s* (1<=≤<=|*s*|<=≤<=2·105), consisting of uppercase and lowercase English letters — the text of Tanya's message.
The second line contains line *t* (|*s*|<=≤<=|*t*|<=≤<=2·105), consisting of uppercase and lowercase English letters — the text written in the newspaper.
Here |*a*| means the ... | Print two integers separated by a space:
- the first number is the number of times Tanya shouts "YAY!" while making the message, - the second number is the number of times Tanya says "WHOOPS" while making the message. | [
"AbC\nDCbA\n",
"ABC\nabc\n",
"abacaba\nAbaCaBA\n"
] | [
"3 0\n",
"0 3\n",
"3 4\n"
] | none | 1,000 | [
{
"input": "AbC\nDCbA",
"output": "3 0"
},
{
"input": "ABC\nabc",
"output": "0 3"
},
{
"input": "abacaba\nAbaCaBA",
"output": "3 4"
},
{
"input": "zzzzz\nZZZZZ",
"output": "0 5"
},
{
"input": "zzzZZZ\nZZZzzZ",
"output": "5 1"
},
{
"input": "abcdefghijk... | 1,603,520,996 | 2,147,483,647 | PyPy 3 | OK | TESTS | 49 | 217 | 3,891,200 | import sys
from collections import defaultdict
def solve(ts, ns):
tsDict = defaultdict(int)
nsDict = defaultdict(int)
whoops = 0
yay = 0
for i in ts:
tsDict[i] += 1
for i in ns:
nsDict[i] += 1
alphabet = 'abcdefghijklmnopqrstuvwxyz'
for i in alphabet:
k = i.... | Title: Tanya and Postcard
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Little Tanya decided to present her dad a postcard on his Birthday. She has already created a message — string *s* of length *n*, consisting of uppercase and lowercase English letters. Tanya can't write yet, so she f... | ```python
import sys
from collections import defaultdict
def solve(ts, ns):
tsDict = defaultdict(int)
nsDict = defaultdict(int)
whoops = 0
yay = 0
for i in ts:
tsDict[i] += 1
for i in ns:
nsDict[i] += 1
alphabet = 'abcdefghijklmnopqrstuvwxyz'
for i in alphabet:
... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
847 | A | Union of Doubly Linked Lists | PROGRAMMING | 1,500 | [
"implementation"
] | null | null | Doubly linked list is one of the fundamental data structures. A doubly linked list is a sequence of elements, each containing information about the previous and the next elements of the list. In this problem all lists have linear structure. I.e. each element except the first has exactly one previous element, each eleme... | The first line contains a single integer *n* (1<=≤<=*n*<=≤<=100) — the number of memory cells where the doubly linked lists are located.
Each of the following *n* lines contains two integers *l**i*, *r**i* (0<=≤<=*l**i*,<=*r**i*<=≤<=*n*) — the cells of the previous and the next element of list for cell *i*. Value *l**... | Print *n* lines, the *i*-th line must contain two integers *l**i* and *r**i* — the cells of the previous and the next element of list for cell *i* after all lists from the input are united in a single list. If there are many solutions print any of them. | [
"7\n4 7\n5 0\n0 0\n6 1\n0 2\n0 4\n1 0\n"
] | [
"4 7\n5 6\n0 5\n6 1\n3 2\n2 4\n1 0\n"
] | none | 0 | [
{
"input": "7\n4 7\n5 0\n0 0\n6 1\n0 2\n0 4\n1 0",
"output": "4 7\n5 6\n0 5\n6 1\n3 2\n2 4\n1 0"
},
{
"input": "2\n2 0\n0 1",
"output": "2 0\n0 1"
},
{
"input": "1\n0 0",
"output": "0 0"
},
{
"input": "4\n0 2\n1 0\n0 4\n3 0",
"output": "0 2\n1 3\n2 4\n3 0"
},
{
"i... | 1,675,201,212 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 11 | 62 | 0 | n = int(input())
a = []
tl = tr = 0
for i in range(n):
l, r = map(int, input().split())
a.append(str(l)+str(i+1)+str(r))
if l == 0: tl += 1
if r == 0: tr += 1
if tl==1 and tr==1:
for i in range(0, n):
print(int(a[i][0]), int(a[i][2]))
else:
s = ''
p = a.copy()
l =... | Title: Union of Doubly Linked Lists
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Doubly linked list is one of the fundamental data structures. A doubly linked list is a sequence of elements, each containing information about the previous and the next elements of the list. In this proble... | ```python
n = int(input())
a = []
tl = tr = 0
for i in range(n):
l, r = map(int, input().split())
a.append(str(l)+str(i+1)+str(r))
if l == 0: tl += 1
if r == 0: tr += 1
if tl==1 and tr==1:
for i in range(0, n):
print(int(a[i][0]), int(a[i][2]))
else:
s = ''
p = a.copy(... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
59 | A | Word | PROGRAMMING | 800 | [
"implementation",
"strings"
] | A. Word | 2 | 256 | Vasya is very upset that many people on the Net mix uppercase and lowercase letters in one word. That's why he decided to invent an extension for his favorite browser that would change the letters' register in every word so that it either only consisted of lowercase letters or, vice versa, only of uppercase ones. At th... | The first line contains a word *s* — it consists of uppercase and lowercase Latin letters and possesses the length from 1 to 100. | Print the corrected word *s*. If the given word *s* has strictly more uppercase letters, make the word written in the uppercase register, otherwise - in the lowercase one. | [
"HoUse\n",
"ViP\n",
"maTRIx\n"
] | [
"house\n",
"VIP\n",
"matrix\n"
] | none | 500 | [
{
"input": "HoUse",
"output": "house"
},
{
"input": "ViP",
"output": "VIP"
},
{
"input": "maTRIx",
"output": "matrix"
},
{
"input": "BNHWpnpawg",
"output": "bnhwpnpawg"
},
{
"input": "VTYGP",
"output": "VTYGP"
},
{
"input": "CHNenu",
"output": "chn... | 1,631,837,370 | 2,147,483,647 | PyPy 3 | OK | TESTS | 30 | 310 | 20,172,800 | s = input()
u = sum([c.isupper() for c in s])
print(s.upper() if u > len(s)//2 else s.lower()) | Title: Word
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Vasya is very upset that many people on the Net mix uppercase and lowercase letters in one word. That's why he decided to invent an extension for his favorite browser that would change the letters' register in every word so that it ei... | ```python
s = input()
u = sum([c.isupper() for c in s])
print(s.upper() if u > len(s)//2 else s.lower())
``` | 3.884925 | MatrixStudio/Codeforces-Python-Submissions |
466 | A | Cheap Travel | PROGRAMMING | 1,200 | [
"implementation"
] | null | null | Ann has recently started commuting by subway. We know that a one ride subway ticket costs *a* rubles. Besides, Ann found out that she can buy a special ticket for *m* rides (she can buy it several times). It costs *b* rubles. Ann did the math; she will need to use subway *n* times. Help Ann, tell her what is the minimu... | The single line contains four space-separated integers *n*, *m*, *a*, *b* (1<=≤<=*n*,<=*m*,<=*a*,<=*b*<=≤<=1000) — the number of rides Ann has planned, the number of rides covered by the *m* ride ticket, the price of a one ride ticket and the price of an *m* ride ticket. | Print a single integer — the minimum sum in rubles that Ann will need to spend. | [
"6 2 1 2\n",
"5 2 2 3\n"
] | [
"6\n",
"8\n"
] | In the first sample one of the optimal solutions is: each time buy a one ride ticket. There are other optimal solutions. For example, buy three *m* ride tickets. | 500 | [
{
"input": "6 2 1 2",
"output": "6"
},
{
"input": "5 2 2 3",
"output": "8"
},
{
"input": "10 3 5 1",
"output": "4"
},
{
"input": "1000 1 1000 1000",
"output": "1000000"
},
{
"input": "1000 3 1000 1000",
"output": "334000"
},
{
"input": "1 1 1 1",
"... | 1,686,146,913 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 31 | 0 | a,b,c,d=map(int,input().split())
h=int (c*a)
k=int (b/c)
l=int (k*c)
j=int (d*b+l)
if h>j :
print(j)
else :
print(h) | Title: Cheap Travel
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Ann has recently started commuting by subway. We know that a one ride subway ticket costs *a* rubles. Besides, Ann found out that she can buy a special ticket for *m* rides (she can buy it several times). It costs *b* rubl... | ```python
a,b,c,d=map(int,input().split())
h=int (c*a)
k=int (b/c)
l=int (k*c)
j=int (d*b+l)
if h>j :
print(j)
else :
print(h)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
342 | A | Xenia and Divisors | PROGRAMMING | 1,200 | [
"greedy",
"implementation"
] | null | null | Xenia the mathematician has a sequence consisting of *n* (*n* is divisible by 3) positive integers, each of them is at most 7. She wants to split the sequence into groups of three so that for each group of three *a*,<=*b*,<=*c* the following conditions held:
- *a*<=<<=*b*<=<<=*c*; - *a* divides *b*, *b* divide... | The first line contains integer *n* (3<=≤<=*n*<=≤<=99999) — the number of elements in the sequence. The next line contains *n* positive integers, each of them is at most 7.
It is guaranteed that *n* is divisible by 3. | If the required partition exists, print groups of three. Print each group as values of the elements it contains. You should print values in increasing order. Separate the groups and integers in groups by whitespaces. If there are multiple solutions, you can print any of them.
If there is no solution, print -1. | [
"6\n1 1 1 2 2 2\n",
"6\n2 2 1 1 4 6\n"
] | [
"-1\n",
"1 2 4\n1 2 6\n"
] | none | 500 | [
{
"input": "6\n1 1 1 2 2 2",
"output": "-1"
},
{
"input": "6\n2 2 1 1 4 6",
"output": "1 2 4\n1 2 6"
},
{
"input": "3\n1 2 3",
"output": "-1"
},
{
"input": "3\n7 5 7",
"output": "-1"
},
{
"input": "3\n1 3 4",
"output": "-1"
},
{
"input": "3\n1 1 1",
... | 1,532,814,160 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 1 | 139 | 204,800 | from collections import Counter
def go():
n = int(input())
c = Counter(int(i) for i in input().split(' '))
o = ''
if len(c) < 3:
return -1
keys = list(sorted(c.keys()))
while len(keys) > 2:
current = '{} {} {}\n'.format(keys[0], keys[1], keys[2])
o += current
if ... | Title: Xenia and Divisors
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Xenia the mathematician has a sequence consisting of *n* (*n* is divisible by 3) positive integers, each of them is at most 7. She wants to split the sequence into groups of three so that for each group of three *a*,... | ```python
from collections import Counter
def go():
n = int(input())
c = Counter(int(i) for i in input().split(' '))
o = ''
if len(c) < 3:
return -1
keys = list(sorted(c.keys()))
while len(keys) > 2:
current = '{} {} {}\n'.format(keys[0], keys[1], keys[2])
o += current
... | -1 | MatrixStudio/Codeforces-Python-Submissions | |
710 | A | King Moves | PROGRAMMING | 800 | [
"implementation"
] | null | null | The only king stands on the standard chess board. You are given his position in format "cd", where *c* is the column from 'a' to 'h' and *d* is the row from '1' to '8'. Find the number of moves permitted for the king.
Check the king's moves here [https://en.wikipedia.org/wiki/King_(chess)](https://en.wikipedia.org/wik... | The only line contains the king's position in the format "cd", where 'c' is the column from 'a' to 'h' and 'd' is the row from '1' to '8'. | Print the only integer *x* — the number of moves permitted for the king. | [
"e4\n"
] | [
"8\n"
] | none | 0 | [
{
"input": "e4",
"output": "8"
},
{
"input": "a1",
"output": "3"
},
{
"input": "h8",
"output": "3"
},
{
"input": "a4",
"output": "5"
},
{
"input": "g7",
"output": "8"
},
{
"input": "e1",
"output": "5"
},
{
"input": "b2",
"output": "8"
... | 1,670,400,318 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 46 | 0 | s=input()
if s[0]=='a' or s[0]=='h' or s[1]=='1' or s[1]=='8':
print(5)
else:
print(8) | Title: King Moves
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The only king stands on the standard chess board. You are given his position in format "cd", where *c* is the column from 'a' to 'h' and *d* is the row from '1' to '8'. Find the number of moves permitted for the king.
Check... | ```python
s=input()
if s[0]=='a' or s[0]=='h' or s[1]=='1' or s[1]=='8':
print(5)
else:
print(8)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
822 | A | I'm bored with life | PROGRAMMING | 800 | [
"implementation",
"math",
"number theory"
] | null | null | Holidays have finished. Thanks to the help of the hacker Leha, Noora managed to enter the university of her dreams which is located in a town Pavlopolis. It's well known that universities provide students with dormitory for the period of university studies. Consequently Noora had to leave Vičkopolis and move to Pavlopo... | The first and single line contains two integers *A* and *B* (1<=≤<=*A*,<=*B*<=≤<=109,<=*min*(*A*,<=*B*)<=≤<=12). | Print a single integer denoting the greatest common divisor of integers *A*! and *B*!. | [
"4 3\n"
] | [
"6\n"
] | Consider the sample.
4! = 1·2·3·4 = 24. 3! = 1·2·3 = 6. The greatest common divisor of integers 24 and 6 is exactly 6. | 500 | [
{
"input": "4 3",
"output": "6"
},
{
"input": "10 399603090",
"output": "3628800"
},
{
"input": "6 973151934",
"output": "720"
},
{
"input": "2 841668075",
"output": "2"
},
{
"input": "7 415216919",
"output": "5040"
},
{
"input": "3 283733059",
"ou... | 1,665,347,567 | 2,147,483,647 | PyPy 3-64 | TIME_LIMIT_EXCEEDED | TESTS | 1 | 1,000 | 15,257,600 | import sys
import math
#sys.stdin = open("input.txt", "r")
II = lambda: int(input())
LI = lambda: list(map(int, list(input().split(" "))))
MI = lambda: map(int, LI())
SI = lambda: input()
a, b = MI()
def fact(s):
return math.factorial(s)
fact(a)
fact(b)
print(math.gcd(fact(a), fact(b)))
| Title: I'm bored with life
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Holidays have finished. Thanks to the help of the hacker Leha, Noora managed to enter the university of her dreams which is located in a town Pavlopolis. It's well known that universities provide students with dormi... | ```python
import sys
import math
#sys.stdin = open("input.txt", "r")
II = lambda: int(input())
LI = lambda: list(map(int, list(input().split(" "))))
MI = lambda: map(int, LI())
SI = lambda: input()
a, b = MI()
def fact(s):
return math.factorial(s)
fact(a)
fact(b)
print(math.gcd(fact(a), fact(b)))
... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
13 | A | Numbers | PROGRAMMING | 1,000 | [
"implementation",
"math"
] | A. Numbers | 1 | 64 | Little Petya likes numbers a lot. He found that number 123 in base 16 consists of two digits: the first is 7 and the second is 11. So the sum of digits of 123 in base 16 is equal to 18.
Now he wonders what is an average value of sum of digits of the number *A* written in all bases from 2 to *A*<=-<=1.
Note that all c... | Input contains one integer number *A* (3<=≤<=*A*<=≤<=1000). | Output should contain required average value in format «X/Y», where X is the numerator and Y is the denominator. | [
"5\n",
"3\n"
] | [
"7/3\n",
"2/1\n"
] | In the first sample number 5 written in all bases from 2 to 4 looks so: 101, 12, 11. Sums of digits are 2, 3 and 2, respectively. | 0 | [
{
"input": "5",
"output": "7/3"
},
{
"input": "3",
"output": "2/1"
},
{
"input": "1000",
"output": "90132/499"
},
{
"input": "927",
"output": "155449/925"
},
{
"input": "260",
"output": "6265/129"
},
{
"input": "131",
"output": "3370/129"
},
{
... | 1,616,678,564 | 2,147,483,647 | Python 3 | OK | TESTS | 99 | 154 | 0 | from math import gcd
n = int(input())
s = 0
for i in range(2, n):
copy = n
while copy > 0:
s += copy % i
copy //= i
a = s
b = n - 2
g = gcd(a, b)
print(f"{a // g}/{b // g}")
| Title: Numbers
Time Limit: 1 seconds
Memory Limit: 64 megabytes
Problem Description:
Little Petya likes numbers a lot. He found that number 123 in base 16 consists of two digits: the first is 7 and the second is 11. So the sum of digits of 123 in base 16 is equal to 18.
Now he wonders what is an average value of su... | ```python
from math import gcd
n = int(input())
s = 0
for i in range(2, n):
copy = n
while copy > 0:
s += copy % i
copy //= i
a = s
b = n - 2
g = gcd(a, b)
print(f"{a // g}/{b // g}")
``` | 3.923 | MatrixStudio/Codeforces-Python-Submissions |
510 | A | Fox And Snake | PROGRAMMING | 800 | [
"implementation"
] | null | null | Fox Ciel starts to learn programming. The first task is drawing a fox! However, that turns out to be too hard for a beginner, so she decides to draw a snake instead.
A snake is a pattern on a *n* by *m* table. Denote *c*-th cell of *r*-th row as (*r*,<=*c*). The tail of the snake is located at (1,<=1), then it's body ... | The only line contains two integers: *n* and *m* (3<=≤<=*n*,<=*m*<=≤<=50).
*n* is an odd number. | Output *n* lines. Each line should contain a string consisting of *m* characters. Do not output spaces. | [
"3 3\n",
"3 4\n",
"5 3\n",
"9 9\n"
] | [
"###\n..#\n###\n",
"####\n...#\n####\n",
"###\n..#\n###\n#..\n###\n",
"#########\n........#\n#########\n#........\n#########\n........#\n#########\n#........\n#########\n"
] | none | 500 | [
{
"input": "3 3",
"output": "###\n..#\n###"
},
{
"input": "3 4",
"output": "####\n...#\n####"
},
{
"input": "5 3",
"output": "###\n..#\n###\n#..\n###"
},
{
"input": "9 9",
"output": "#########\n........#\n#########\n#........\n#########\n........#\n#########\n#........\n#... | 1,677,170,902 | 2,147,483,647 | Python 3 | OK | TESTS | 28 | 46 | 0 | n,m = list(map(int,input().split()))
for i in range(n):
if i%2==0:print('#'*m)
elif i%4==1:print('.'*(m-1)+'#')
else:print('#'+'.'*(m-1)) | Title: Fox And Snake
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Fox Ciel starts to learn programming. The first task is drawing a fox! However, that turns out to be too hard for a beginner, so she decides to draw a snake instead.
A snake is a pattern on a *n* by *m* table. Denote *c*... | ```python
n,m = list(map(int,input().split()))
for i in range(n):
if i%2==0:print('#'*m)
elif i%4==1:print('.'*(m-1)+'#')
else:print('#'+'.'*(m-1))
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
0 | none | none | none | 0 | [
"none"
] | null | null | Julia is going to cook a chicken in the kitchen of her dormitory. To save energy, the stove in the kitchen automatically turns off after *k* minutes after turning on.
During cooking, Julia goes to the kitchen every *d* minutes and turns on the stove if it is turned off. While the cooker is turned off, it stays warm. T... | The single line contains three integers *k*, *d* and *t* (1<=≤<=*k*,<=*d*,<=*t*<=≤<=1018). | Print a single number, the total time of cooking in minutes. The relative or absolute error must not exceed 10<=-<=9.
Namely, let's assume that your answer is *x* and the answer of the jury is *y*. The checker program will consider your answer correct if . | [
"3 2 6\n",
"4 2 20\n"
] | [
"6.5\n",
"20.0\n"
] | In the first example, the chicken will be cooked for 3 minutes on the turned on stove, after this it will be cooked for <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/cce5d3f2f46552034d5ae5d487725705429ec7a5.png" style="max-width: 100.0%;max-height: 100.0%;"/>. Then the chicken will be coo... | 0 | [
{
"input": "3 2 6",
"output": "6.5"
},
{
"input": "4 2 20",
"output": "20.0"
},
{
"input": "8 10 9",
"output": "10.0"
},
{
"input": "43 50 140",
"output": "150.5"
},
{
"input": "251 79 76",
"output": "76.0"
},
{
"input": "892 67 1000",
"output": "1... | 1,538,657,430 | 2,147,483,647 | Python 3 | COMPILATION_ERROR | TESTS | 0 | 0 | 0 | k,d,t=map(int,raw_input().split())
if k%d == 0 or t<=k:
print t
else:
u=k+(d-k%d)
dt=k*2 + (d - k%d)
t*=2
n=int(t/dt)
ans=0
if(t%dt<=k*2):
ans=u*n+(t%dt)/2
else:
ans=u*n+k+(t%dt-k*2)
print ans | Title: none
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Julia is going to cook a chicken in the kitchen of her dormitory. To save energy, the stove in the kitchen automatically turns off after *k* minutes after turning on.
During cooking, Julia goes to the kitchen every *d* minutes an... | ```python
k,d,t=map(int,raw_input().split())
if k%d == 0 or t<=k:
print t
else:
u=k+(d-k%d)
dt=k*2 + (d - k%d)
t*=2
n=int(t/dt)
ans=0
if(t%dt<=k*2):
ans=u*n+(t%dt)/2
else:
ans=u*n+k+(t%dt-k*2)
print ans
``` | -1 | MatrixStudio/Codeforces-Python-Submissions | |
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,680,966,733 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 39 | 358 | 9,318,400 | n=int(input())
d=[]
for i in range(n):
a=input().split()
b=[int(j) for j in a]
d.append(b)
c=0
for i in range(len(d)-1):
if d[i][0]<d[i+1][0] and d[i][1]>d[i+1][1]:
c=1
if c==1:
print("Happy Alex")
else:
print("Poor Alex")
| 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
n=int(input())
d=[]
for i in range(n):
a=input().split()
b=[int(j) for j in a]
d.append(b)
c=0
for i in range(len(d)-1):
if d[i][0]<d[i+1][0] and d[i][1]>d[i+1][1]:
c=1
if c==1:
print("Happy Alex")
else:
print("Poor Alex")
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
0 | none | none | none | 0 | [
"none"
] | null | null | You are an experienced Codeforces user. Today you found out that during your activity on Codeforces you have made *y* submissions, out of which *x* have been successful. Thus, your current success rate on Codeforces is equal to *x*<=/<=*y*.
Your favorite rational number in the [0;1] range is *p*<=/<=*q*. Now you wonde... | The first line contains a single integer *t* (1<=≤<=*t*<=≤<=1000) — the number of test cases.
Each of the next *t* lines contains four integers *x*, *y*, *p* and *q* (0<=≤<=*x*<=≤<=*y*<=≤<=109; 0<=≤<=*p*<=≤<=*q*<=≤<=109; *y*<=><=0; *q*<=><=0).
It is guaranteed that *p*<=/<=*q* is an irreducible fraction.
Hacks... | For each test case, output a single integer equal to the smallest number of submissions you have to make if you want your success rate to be equal to your favorite rational number, or -1 if this is impossible to achieve. | [
"4\n3 10 1 2\n7 14 3 8\n20 70 2 7\n5 6 1 1\n"
] | [
"4\n10\n0\n-1\n"
] | In the first example, you have to make 4 successful submissions. Your success rate will be equal to 7 / 14, or 1 / 2.
In the second example, you have to make 2 successful and 8 unsuccessful submissions. Your success rate will be equal to 9 / 24, or 3 / 8.
In the third example, there is no need to make any new submiss... | 0 | [
{
"input": "4\n3 10 1 2\n7 14 3 8\n20 70 2 7\n5 6 1 1",
"output": "4\n10\n0\n-1"
},
{
"input": "8\n0 1 0 1\n0 2 1 2\n0 3 1 1\n1 2 0 1\n1 2 1 1\n2 2 0 1\n3 3 1 2\n4 4 1 1",
"output": "0\n2\n-1\n-1\n-1\n-1\n3\n0"
},
{
"input": "5\n1 1000000000 1 2\n1 1000000000 1 2\n1 1000000000 1 2\n1 100... | 1,626,501,772 | 2,147,483,647 | PyPy 3 | RUNTIME_ERROR | TESTS | 1 | 109 | 22,630,400 | import sys
input=sys.stdin.readline
import math
t=int(input())
for you in range(t):
l=input().split()
x=int(l[0])
y=int(l[1])
p=int(l[2])
q=int(l[3])
g=math.gcd(p,q)
p=p//g
q=q//g
if(q==p and y==x):
print(0)
continue
if(q==p):
print(-1)
... | Title: none
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are an experienced Codeforces user. Today you found out that during your activity on Codeforces you have made *y* submissions, out of which *x* have been successful. Thus, your current success rate on Codeforces is equal to *x... | ```python
import sys
input=sys.stdin.readline
import math
t=int(input())
for you in range(t):
l=input().split()
x=int(l[0])
y=int(l[1])
p=int(l[2])
q=int(l[3])
g=math.gcd(p,q)
p=p//g
q=q//g
if(q==p and y==x):
print(0)
continue
if(q==p):
pr... | -1 | MatrixStudio/Codeforces-Python-Submissions | |
119 | A | Epic Game | PROGRAMMING | 800 | [
"implementation"
] | null | null | Simon and Antisimon play a game. Initially each player receives one fixed positive integer that doesn't change throughout the game. Simon receives number *a* and Antisimon receives number *b*. They also have a heap of *n* stones. The players take turns to make a move and Simon starts. During a move a player should take... | The only string contains space-separated integers *a*, *b* and *n* (1<=≤<=*a*,<=*b*,<=*n*<=≤<=100) — the fixed numbers Simon and Antisimon have received correspondingly and the initial number of stones in the pile. | If Simon wins, print "0" (without the quotes), otherwise print "1" (without the quotes). | [
"3 5 9\n",
"1 1 100\n"
] | [
"0",
"1"
] | The greatest common divisor of two non-negative integers *a* and *b* is such maximum positive integer *k*, that *a* is divisible by *k* without remainder and similarly, *b* is divisible by *k* without remainder. Let *gcd*(*a*, *b*) represent the operation of calculating the greatest common divisor of numbers *a* and *b... | 500 | [
{
"input": "3 5 9",
"output": "0"
},
{
"input": "1 1 100",
"output": "1"
},
{
"input": "23 12 16",
"output": "1"
},
{
"input": "95 26 29",
"output": "1"
},
{
"input": "73 32 99",
"output": "1"
},
{
"input": "1 1 1",
"output": "0"
},
{
"inpu... | 1,652,581,950 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 62 | 0 | from math import gcd
a,b,n=map(int,input().split())
i=0
while(n>0):
if(i%2==0):
n=n-gcd(a,n)
else:
n=n-gcd(b,n)
i=i+1
if(i%2==0):
print(0)
else:
print(1) | 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
from math import gcd
a,b,n=map(int,input().split())
i=0
while(n>0):
if(i%2==0):
n=n-gcd(a,n)
else:
n=n-gcd(b,n)
i=i+1
if(i%2==0):
print(0)
else:
print(1)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
801 | A | Vicious Keyboard | PROGRAMMING | 1,100 | [
"brute force"
] | null | null | Tonio has a keyboard with only two letters, "V" and "K".
One day, he has typed out a string *s* with only these two letters. He really likes it when the string "VK" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maxi... | The first line will contain a string *s* consisting only of uppercase English letters "V" and "K" with length not less than 1 and not greater than 100. | Output a single integer, the maximum number of times "VK" can appear as a substring of the given string after changing at most one character. | [
"VK\n",
"VV\n",
"V\n",
"VKKKKKKKKKVVVVVVVVVK\n",
"KVKV\n"
] | [
"1\n",
"1\n",
"0\n",
"3\n",
"1\n"
] | For the first case, we do not change any letters. "VK" appears once, which is the maximum number of times it could appear.
For the second case, we can change the second character from a "V" to a "K". This will give us the string "VK". This has one occurrence of the string "VK" as a substring.
For the fourth case, we ... | 500 | [
{
"input": "VK",
"output": "1"
},
{
"input": "VV",
"output": "1"
},
{
"input": "V",
"output": "0"
},
{
"input": "VKKKKKKKKKVVVVVVVVVK",
"output": "3"
},
{
"input": "KVKV",
"output": "1"
},
{
"input": "VKKVVVKVKVK",
"output": "5"
},
{
"input... | 1,492,358,742 | 1,842 | Python 3 | OK | TESTS | 63 | 62 | 5,529,600 | s = input()
i = 0
ans = 0
yet = False
if len(s)==1:
print(0)
exit(0)
ans = s.count("VK")
s = s.replace("VK","ZZ")
while i<len(s)-1:
if s[i]=='V' and s[i+1]=='V':
ans += 1
break
elif s[i]=='K' and s[i+1]=='K':
ans += 1
break
i += 1
print(ans)
| Title: Vicious Keyboard
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Tonio has a keyboard with only two letters, "V" and "K".
One day, he has typed out a string *s* with only these two letters. He really likes it when the string "VK" appears, so he wishes to change at most one letter i... | ```python
s = input()
i = 0
ans = 0
yet = False
if len(s)==1:
print(0)
exit(0)
ans = s.count("VK")
s = s.replace("VK","ZZ")
while i<len(s)-1:
if s[i]=='V' and s[i+1]=='V':
ans += 1
break
elif s[i]=='K' and s[i+1]=='K':
ans += 1
break
i += 1
print(ans)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
556 | A | Case of the Zeros and Ones | PROGRAMMING | 900 | [
"greedy"
] | null | null | Andrewid the Android is a galaxy-famous detective. In his free time he likes to think about strings containing zeros and ones.
Once he thought about a string of length *n* consisting of zeroes and ones. Consider the following operation: we choose any two adjacent positions in the string, and if one them contains 0, an... | First line of the input contains a single integer *n* (1<=≤<=*n*<=≤<=2·105), the length of the string that Andreid has.
The second line contains the string of length *n* consisting only from zeros and ones. | Output the minimum length of the string that may remain after applying the described operations several times. | [
"4\n1100\n",
"5\n01010\n",
"8\n11101111\n"
] | [
"0\n",
"1\n",
"6\n"
] | In the first sample test it is possible to change the string like the following: <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/10df55364c21c6e8d5da31b6ab6f6294c4fc26b3.png" style="max-width: 100.0%;max-height: 100.0%;"/>.
In the second sample test it is possible to change the string like... | 250 | [
{
"input": "4\n1100",
"output": "0"
},
{
"input": "5\n01010",
"output": "1"
},
{
"input": "8\n11101111",
"output": "6"
},
{
"input": "1\n0",
"output": "1"
},
{
"input": "1\n1",
"output": "1"
},
{
"input": "2\n00",
"output": "2"
},
{
"input"... | 1,697,305,143 | 2,147,483,647 | Python 3 | OK | TESTS | 49 | 46 | 409,600 | a = input()
b = input()
null = b.count("0")
one = b.count("1")
print(null-one) if null > one else print(one-null) | Title: Case of the Zeros and Ones
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Andrewid the Android is a galaxy-famous detective. In his free time he likes to think about strings containing zeros and ones.
Once he thought about a string of length *n* consisting of zeroes and ones. Cons... | ```python
a = input()
b = input()
null = b.count("0")
one = b.count("1")
print(null-one) if null > one else print(one-null)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
22 | A | Second Order Statistics | PROGRAMMING | 800 | [
"brute force"
] | A. Second Order Statistics | 2 | 256 | Once Bob needed to find the second order statistics of a sequence of integer numbers. Lets choose each number from the sequence exactly once and sort them. The value on the second position is the second order statistics of the given sequence. In other words it is the smallest element strictly greater than the minimum. ... | The first input line contains integer *n* (1<=≤<=*n*<=≤<=100) — amount of numbers in the sequence. The second line contains *n* space-separated integer numbers — elements of the sequence. These numbers don't exceed 100 in absolute value. | If the given sequence has the second order statistics, output this order statistics, otherwise output NO. | [
"4\n1 2 2 -4\n",
"5\n1 2 3 1 1\n"
] | [
"1\n",
"2\n"
] | none | 0 | [
{
"input": "4\n1 2 2 -4",
"output": "1"
},
{
"input": "5\n1 2 3 1 1",
"output": "2"
},
{
"input": "1\n28",
"output": "NO"
},
{
"input": "2\n-28 12",
"output": "12"
},
{
"input": "3\n-83 40 -80",
"output": "-80"
},
{
"input": "8\n93 77 -92 26 21 -48 53 ... | 1,651,656,236 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 30 | 0 | num=int(input())
a=list(map(int,input().split()))
a.sort
b=set(a)
c=list(b)
print(c[1])
| Title: Second Order Statistics
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Once Bob needed to find the second order statistics of a sequence of integer numbers. Lets choose each number from the sequence exactly once and sort them. The value on the second position is the second order statis... | ```python
num=int(input())
a=list(map(int,input().split()))
a.sort
b=set(a)
c=list(b)
print(c[1])
``` | 0 | MatrixStudio/Codeforces-Python-Submissions |
471 | A | MUH and Sticks | PROGRAMMING | 1,100 | [
"implementation"
] | null | null | Two polar bears Menshykov and Uslada from the St.Petersburg zoo and elephant Horace from the Kiev zoo got six sticks to play with and assess the animals' creativity. Menshykov, Uslada and Horace decided to make either an elephant or a bear from those sticks. They can make an animal from sticks in the following way:
-... | The single line contains six space-separated integers *l**i* (1<=≤<=*l**i*<=≤<=9) — the lengths of the six sticks. It is guaranteed that the input is such that you cannot make both animals from the sticks. | If you can make a bear from the given set, print string "Bear" (without the quotes). If you can make an elephant, print string "Elephant" (wıthout the quotes). If you can make neither a bear nor an elephant, print string "Alien" (without the quotes). | [
"4 2 5 4 4 4\n",
"4 4 5 4 4 5\n",
"1 2 3 4 5 6\n"
] | [
"Bear",
"Elephant",
"Alien"
] | If you're out of creative ideas, see instructions below which show how to make a bear and an elephant in the first two samples. The stick of length 2 is in red, the sticks of length 4 are in green, the sticks of length 5 are in blue. | 500 | [
{
"input": "4 2 5 4 4 4",
"output": "Bear"
},
{
"input": "4 4 5 4 4 5",
"output": "Elephant"
},
{
"input": "1 2 3 4 5 6",
"output": "Alien"
},
{
"input": "5 5 5 5 5 5",
"output": "Elephant"
},
{
"input": "1 1 1 2 3 5",
"output": "Alien"
},
{
"input": "... | 1,420,274,137 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 8 | 61 | 0 | a_list = [int(x) for x in input().split()]
a_set = set()
for i in a_list:
a_set.add(i)
if len(a_set) <= 2:
print('Elephant')
elif len(a_set) == 3:
print('Bear')
else:
print('Alien')
| Title: MUH and Sticks
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Two polar bears Menshykov and Uslada from the St.Petersburg zoo and elephant Horace from the Kiev zoo got six sticks to play with and assess the animals' creativity. Menshykov, Uslada and Horace decided to make either an... | ```python
a_list = [int(x) for x in input().split()]
a_set = set()
for i in a_list:
a_set.add(i)
if len(a_set) <= 2:
print('Elephant')
elif len(a_set) == 3:
print('Bear')
else:
print('Alien')
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
474 | A | Keyboard | PROGRAMMING | 900 | [
"implementation"
] | null | null | Our good friend Mole is trying to code a big message. He is typing on an unusual keyboard with characters arranged in following way:
Unfortunately Mole is blind, so sometimes it is problem for him to put his hands accurately. He accidentally moved both his hands with one position to the left or to the right. That mean... | First line of the input contains one letter describing direction of shifting ('L' or 'R' respectively for left or right).
Second line contains a sequence of characters written by Mole. The size of this sequence will be no more than 100. Sequence contains only symbols that appear on Mole's keyboard. It doesn't contain ... | Print a line that contains the original message. | [
"R\ns;;upimrrfod;pbr\n"
] | [
"allyouneedislove\n"
] | none | 500 | [
{
"input": "R\ns;;upimrrfod;pbr",
"output": "allyouneedislove"
},
{
"input": "R\nwertyuiop;lkjhgfdsxcvbnm,.",
"output": "qwertyuiolkjhgfdsazxcvbnm,"
},
{
"input": "L\nzxcvbnm,kjhgfdsaqwertyuio",
"output": "xcvbnm,.lkjhgfdswertyuiop"
},
{
"input": "R\nbubbuduppudup",
"outp... | 1,673,614,003 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 31 | 78 | 0 | a1='qwertyuiop'
a2='asdfghjkl;'
a3='zxcvbnm,./'
s = input()
q = input()
if(s=='R'):
w=-1
else:
w=1
for o in q:
f1=a1.find(o)
if(f1!=-1):
print(a1[f1+w], end="")
f2=a2.find(o)
if(f2!=-1):
print(a2[f2+w],end="")
f3=a3.find(o)
if(f3!=-1):
print(a3[f... | Title: Keyboard
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Our good friend Mole is trying to code a big message. He is typing on an unusual keyboard with characters arranged in following way:
Unfortunately Mole is blind, so sometimes it is problem for him to put his hands accurately.... | ```python
a1='qwertyuiop'
a2='asdfghjkl;'
a3='zxcvbnm,./'
s = input()
q = input()
if(s=='R'):
w=-1
else:
w=1
for o in q:
f1=a1.find(o)
if(f1!=-1):
print(a1[f1+w], end="")
f2=a2.find(o)
if(f2!=-1):
print(a2[f2+w],end="")
f3=a3.find(o)
if(f3!=-1):
... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
116 | A | Tram | PROGRAMMING | 800 | [
"implementation"
] | null | null | Linear Kingdom has exactly one tram line. It has *n* stops, numbered from 1 to *n* in the order of tram's movement. At the *i*-th stop *a**i* passengers exit the tram, while *b**i* passengers enter it. The tram is empty before it arrives at the first stop. Also, when the tram arrives at the last stop, all passengers ex... | The first line contains a single number *n* (2<=≤<=*n*<=≤<=1000) — the number of the tram's stops.
Then *n* lines follow, each contains two integers *a**i* and *b**i* (0<=≤<=*a**i*,<=*b**i*<=≤<=1000) — the number of passengers that exits the tram at the *i*-th stop, and the number of passengers that enter the tram at... | Print a single integer denoting the minimum possible capacity of the tram (0 is allowed). | [
"4\n0 3\n2 5\n4 2\n4 0\n"
] | [
"6\n"
] | For the first example, a capacity of 6 is sufficient:
- At the first stop, the number of passengers inside the tram before arriving is 0. Then, 3 passengers enter the tram, and the number of passengers inside the tram becomes 3. - At the second stop, 2 passengers exit the tram (1 passenger remains inside). Then, 5 ... | 500 | [
{
"input": "4\n0 3\n2 5\n4 2\n4 0",
"output": "6"
},
{
"input": "5\n0 4\n4 6\n6 5\n5 4\n4 0",
"output": "6"
},
{
"input": "10\n0 5\n1 7\n10 8\n5 3\n0 5\n3 3\n8 8\n0 6\n10 1\n9 0",
"output": "18"
},
{
"input": "3\n0 1\n1 1\n1 0",
"output": "1"
},
{
"input": "4\n0 1... | 1,686,733,880 | 2,147,483,647 | Python 3 | OK | TESTS | 71 | 92 | 0 | x=int(input())
p=0
maks=0
for i in range(x):
y,z=list(map(int,input().split(" ")))
maks=max(p+z-y,maks)
p=p+z-y
# p=max(p+z-y,p)
print(maks) | Title: Tram
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Linear Kingdom has exactly one tram line. It has *n* stops, numbered from 1 to *n* in the order of tram's movement. At the *i*-th stop *a**i* passengers exit the tram, while *b**i* passengers enter it. The tram is empty before it ... | ```python
x=int(input())
p=0
maks=0
for i in range(x):
y,z=list(map(int,input().split(" ")))
maks=max(p+z-y,maks)
p=p+z-y
# p=max(p+z-y,p)
print(maks)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
748 | A | Santa Claus and a Place in a Class | PROGRAMMING | 800 | [
"implementation",
"math"
] | null | null | Santa Claus is the first who came to the Christmas Olympiad, and he is going to be the first to take his place at a desk! In the classroom there are *n* lanes of *m* desks each, and there are two working places at each of the desks. The lanes are numbered from 1 to *n* from the left to the right, the desks in a lane ar... | The only line contains three integers *n*, *m* and *k* (1<=≤<=*n*,<=*m*<=≤<=10<=000, 1<=≤<=*k*<=≤<=2*nm*) — the number of lanes, the number of desks in each lane and the number of Santa Claus' place. | Print two integers: the number of lane *r*, the number of desk *d*, and a character *s*, which stands for the side of the desk Santa Claus. The character *s* should be "L", if Santa Clause should sit on the left, and "R" if his place is on the right. | [
"4 3 9\n",
"4 3 24\n",
"2 4 4\n"
] | [
"2 2 L\n",
"4 3 R\n",
"1 2 R\n"
] | The first and the second samples are shown on the picture. The green place corresponds to Santa Claus' place in the first example, the blue place corresponds to Santa Claus' place in the second example.
In the third sample there are two lanes with four desks in each, and Santa Claus has the fourth place. Thus, his pla... | 500 | [
{
"input": "4 3 9",
"output": "2 2 L"
},
{
"input": "4 3 24",
"output": "4 3 R"
},
{
"input": "2 4 4",
"output": "1 2 R"
},
{
"input": "3 10 24",
"output": "2 2 R"
},
{
"input": "10 3 59",
"output": "10 3 L"
},
{
"input": "10000 10000 160845880",
"... | 1,518,103,468 | 2,147,483,647 | Python 3 | OK | TESTS | 46 | 62 | 5,632,000 | n,m,k=[int(i) for i in input().split()]
if k%2==0:
z='R'
else:
z='L'
m1=(k-1)//(2*m)+1
n1=((k-1)%(2*m))//2+1
print(m1,n1,z)
| Title: Santa Claus and a Place in a Class
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Santa Claus is the first who came to the Christmas Olympiad, and he is going to be the first to take his place at a desk! In the classroom there are *n* lanes of *m* desks each, and there are two work... | ```python
n,m,k=[int(i) for i in input().split()]
if k%2==0:
z='R'
else:
z='L'
m1=(k-1)//(2*m)+1
n1=((k-1)%(2*m))//2+1
print(m1,n1,z)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
25 | A | IQ test | PROGRAMMING | 1,300 | [
"brute force"
] | A. IQ test | 2 | 256 | Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given *n* numbers differs from the others. Bob observed that one number usually differs from the others in evenness. Help Bob — to check his answers, he needs a program that among the given *n* numbers finds one that i... | The first line contains integer *n* (3<=≤<=*n*<=≤<=100) — amount of numbers in the task. The second line contains *n* space-separated natural numbers, not exceeding 100. It is guaranteed, that exactly one of these numbers differs from the others in evenness. | Output index of number that differs from the others in evenness. Numbers are numbered from 1 in the input order. | [
"5\n2 4 7 8 10\n",
"4\n1 2 1 1\n"
] | [
"3\n",
"2\n"
] | none | 0 | [
{
"input": "5\n2 4 7 8 10",
"output": "3"
},
{
"input": "4\n1 2 1 1",
"output": "2"
},
{
"input": "3\n1 2 2",
"output": "1"
},
{
"input": "3\n100 99 100",
"output": "2"
},
{
"input": "3\n5 3 2",
"output": "3"
},
{
"input": "4\n43 28 1 91",
"output"... | 1,615,102,963 | 2,147,483,647 | Python 3 | OK | TESTS | 32 | 154 | 0 | n=int(input())
a=[int(x) for x in input().split()]
e=[]
o=[]
for i in range(n):
if a[i]%2==0:
e.append(i+1)
else:
o.append(i+1)
if len(e)==1:
print(e[0])
else:
print(o[0])
| Title: IQ test
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given *n* numbers differs from the others. Bob observed that one number usually differs from the others in evenness. Help Bob — t... | ```python
n=int(input())
a=[int(x) for x in input().split()]
e=[]
o=[]
for i in range(n):
if a[i]%2==0:
e.append(i+1)
else:
o.append(i+1)
if len(e)==1:
print(e[0])
else:
print(o[0])
``` | 3.9615 | MatrixStudio/Codeforces-Python-Submissions |
748 | A | Santa Claus and a Place in a Class | PROGRAMMING | 800 | [
"implementation",
"math"
] | null | null | Santa Claus is the first who came to the Christmas Olympiad, and he is going to be the first to take his place at a desk! In the classroom there are *n* lanes of *m* desks each, and there are two working places at each of the desks. The lanes are numbered from 1 to *n* from the left to the right, the desks in a lane ar... | The only line contains three integers *n*, *m* and *k* (1<=≤<=*n*,<=*m*<=≤<=10<=000, 1<=≤<=*k*<=≤<=2*nm*) — the number of lanes, the number of desks in each lane and the number of Santa Claus' place. | Print two integers: the number of lane *r*, the number of desk *d*, and a character *s*, which stands for the side of the desk Santa Claus. The character *s* should be "L", if Santa Clause should sit on the left, and "R" if his place is on the right. | [
"4 3 9\n",
"4 3 24\n",
"2 4 4\n"
] | [
"2 2 L\n",
"4 3 R\n",
"1 2 R\n"
] | The first and the second samples are shown on the picture. The green place corresponds to Santa Claus' place in the first example, the blue place corresponds to Santa Claus' place in the second example.
In the third sample there are two lanes with four desks in each, and Santa Claus has the fourth place. Thus, his pla... | 500 | [
{
"input": "4 3 9",
"output": "2 2 L"
},
{
"input": "4 3 24",
"output": "4 3 R"
},
{
"input": "2 4 4",
"output": "1 2 R"
},
{
"input": "3 10 24",
"output": "2 2 R"
},
{
"input": "10 3 59",
"output": "10 3 L"
},
{
"input": "10000 10000 160845880",
"... | 1,482,657,909 | 1,209 | Python 3 | WRONG_ANSWER | PRETESTS | 4 | 46 | 4,608,000 | s=input().split( )
n=int(s[0])
m=int(s[1])
k=int(s[2])
r=0
a=0
while k>2*m:
k=k-2*m
r+=1
while k>=2:
k=k-2
a+=1
if (a%2!=0) and (a+1<m):
a+=1
if k % 2 ==0:
print(r + 1,' ',a,' R')
else:
print(r + 1,' ',a,' L') | Title: Santa Claus and a Place in a Class
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Santa Claus is the first who came to the Christmas Olympiad, and he is going to be the first to take his place at a desk! In the classroom there are *n* lanes of *m* desks each, and there are two work... | ```python
s=input().split( )
n=int(s[0])
m=int(s[1])
k=int(s[2])
r=0
a=0
while k>2*m:
k=k-2*m
r+=1
while k>=2:
k=k-2
a+=1
if (a%2!=0) and (a+1<m):
a+=1
if k % 2 ==0:
print(r + 1,' ',a,' R')
else:
print(r + 1,' ',a,' L')
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
116 | A | Tram | PROGRAMMING | 800 | [
"implementation"
] | null | null | Linear Kingdom has exactly one tram line. It has *n* stops, numbered from 1 to *n* in the order of tram's movement. At the *i*-th stop *a**i* passengers exit the tram, while *b**i* passengers enter it. The tram is empty before it arrives at the first stop. Also, when the tram arrives at the last stop, all passengers ex... | The first line contains a single number *n* (2<=≤<=*n*<=≤<=1000) — the number of the tram's stops.
Then *n* lines follow, each contains two integers *a**i* and *b**i* (0<=≤<=*a**i*,<=*b**i*<=≤<=1000) — the number of passengers that exits the tram at the *i*-th stop, and the number of passengers that enter the tram at... | Print a single integer denoting the minimum possible capacity of the tram (0 is allowed). | [
"4\n0 3\n2 5\n4 2\n4 0\n"
] | [
"6\n"
] | For the first example, a capacity of 6 is sufficient:
- At the first stop, the number of passengers inside the tram before arriving is 0. Then, 3 passengers enter the tram, and the number of passengers inside the tram becomes 3. - At the second stop, 2 passengers exit the tram (1 passenger remains inside). Then, 5 ... | 500 | [
{
"input": "4\n0 3\n2 5\n4 2\n4 0",
"output": "6"
},
{
"input": "5\n0 4\n4 6\n6 5\n5 4\n4 0",
"output": "6"
},
{
"input": "10\n0 5\n1 7\n10 8\n5 3\n0 5\n3 3\n8 8\n0 6\n10 1\n9 0",
"output": "18"
},
{
"input": "3\n0 1\n1 1\n1 0",
"output": "1"
},
{
"input": "4\n0 1... | 1,693,478,685 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 71 | 186 | 1,638,400 | n = int(input())
passengers_inside = 0
max_capacity = 0
for _ in range(n):
exit_count, enter_count = map(int, input().split())
passengers_inside = passengers_inside - exit_count + enter_count
max_capacity = max(max_capacity, passengers_inside)
print(max_capacity)
| Title: Tram
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Linear Kingdom has exactly one tram line. It has *n* stops, numbered from 1 to *n* in the order of tram's movement. At the *i*-th stop *a**i* passengers exit the tram, while *b**i* passengers enter it. The tram is empty before it ... | ```python
n = int(input())
passengers_inside = 0
max_capacity = 0
for _ in range(n):
exit_count, enter_count = map(int, input().split())
passengers_inside = passengers_inside - exit_count + enter_count
max_capacity = max(max_capacity, passengers_inside)
print(max_capacity)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
50 | A | Domino piling | PROGRAMMING | 800 | [
"greedy",
"math"
] | A. Domino piling | 2 | 256 | You are given a rectangular board of *M*<=×<=*N* squares. Also you are given an unlimited number of standard domino pieces of 2<=×<=1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as possible on the board so as to meet the following conditions:
1. Each domino completely covers ... | In a single line you are given two integers *M* and *N* — board sizes in squares (1<=≤<=*M*<=≤<=*N*<=≤<=16). | Output one number — the maximal number of dominoes, which can be placed. | [
"2 4\n",
"3 3\n"
] | [
"4\n",
"4\n"
] | none | 500 | [
{
"input": "2 4",
"output": "4"
},
{
"input": "3 3",
"output": "4"
},
{
"input": "1 5",
"output": "2"
},
{
"input": "1 6",
"output": "3"
},
{
"input": "1 15",
"output": "7"
},
{
"input": "1 16",
"output": "8"
},
{
"input": "2 5",
"outpu... | 1,617,417,347 | 2,147,483,647 | Python 3 | OK | TESTS | 35 | 154 | 0 | m, n = input().split()
size = int(m) * int(n)
amount_of_dominoes = (size - size % 2) / 2
print(int(amount_of_dominoes)) | Title: Domino piling
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
You are given a rectangular board of *M*<=×<=*N* squares. Also you are given an unlimited number of standard domino pieces of 2<=×<=1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as p... | ```python
m, n = input().split()
size = int(m) * int(n)
amount_of_dominoes = (size - size % 2) / 2
print(int(amount_of_dominoes))
``` | 3.9615 | MatrixStudio/Codeforces-Python-Submissions |
66 | B | Petya and Countryside | PROGRAMMING | 1,100 | [
"brute force",
"implementation"
] | B. Petya and Countryside | 2 | 256 | Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1<=×<=*n* in size, when viewed from above. This rectangle is divided into *n* equal square sections. The garden is very unusual as each of the square sections possesses its own f... | The first line contains a positive integer *n* (1<=≤<=*n*<=≤<=1000). The second line contains *n* positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000. | Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section. | [
"1\n2\n",
"5\n1 2 1 2 1\n",
"8\n1 2 1 1 1 3 3 4\n"
] | [
"1\n",
"3\n",
"6\n"
] | none | 1,000 | [
{
"input": "1\n2",
"output": "1"
},
{
"input": "5\n1 2 1 2 1",
"output": "3"
},
{
"input": "8\n1 2 1 1 1 3 3 4",
"output": "6"
},
{
"input": "10\n1 2 3 4 5 6 7 8 9 10",
"output": "10"
},
{
"input": "10\n10 9 8 7 6 5 4 3 2 1",
"output": "10"
},
{
"input... | 1,680,734,339 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 80 | 218 | 9,011,200 | import sys
import math
from typing import Callable
def main() -> None:
read: Callable[[], str] = sys.stdin.readline
n = int(read())
heights = [int(i) for i in read().split()]
idx_to_l = {}
idx_to_r = {}
length = 0
max_value_seen = float('inf')
for i, val in enumerate(hei... | Title: Petya and Countryside
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1<=×<=*n* in size, when viewed from above. This rectangle is divided into *... | ```python
import sys
import math
from typing import Callable
def main() -> None:
read: Callable[[], str] = sys.stdin.readline
n = int(read())
heights = [int(i) for i in read().split()]
idx_to_l = {}
idx_to_r = {}
length = 0
max_value_seen = float('inf')
for i, val in enu... | 3.928715 | MatrixStudio/Codeforces-Python-Submissions |
209 | B | Pixels | PROGRAMMING | 2,100 | [
"constructive algorithms",
"math"
] | null | null | Flatland is inhabited by pixels of three colors: red, green and blue. We know that if two pixels of different colors meet in a violent fight, only one of them survives the fight (that is, the total number of pixels decreases by one). Besides, if pixels of colors *x* and *y* (*x*<=≠<=*y*) meet in a violent fight, then t... | The first line contains three space-separated integers *a*, *b* and *c* (0<=≤<=*a*,<=*b*,<=*c*<=≤<=231; *a*<=+<=*b*<=+<=*c*<=><=0) — the number of red, green and blue pixels, correspondingly. | Print a single number — the minimum number of pixel fights before the country becomes peaceful and prosperous. If making the country peaceful and prosperous is impossible, print -1. | [
"1 1 1\n",
"3 1 0\n"
] | [
"1\n",
"3\n"
] | In the first test sample the country needs only one fight to achieve peace and prosperity. Besides, it can be any fight whatsoever. For example, let's assume that the green and the blue pixels fight, then the surviving pixel will be red. As a result, after the fight there are two red pixels. There won't be other pixels... | 500 | [
{
"input": "1 1 1",
"output": "1"
},
{
"input": "3 1 0",
"output": "3"
},
{
"input": "1 4 4",
"output": "4"
},
{
"input": "5 10 6",
"output": "10"
},
{
"input": "6 8 10",
"output": "8"
},
{
"input": "1 10 2",
"output": "10"
},
{
"input": "1... | 1,540,200,876 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 13 | 2,000 | 0 | def pixel(input):
red, green, blue = input.split()
pixels = [int(red), int(green), int(blue)]
red = 0
green = 1
blue = 2
battles = 0
f1 = None
f2 = None
w = None
while True:
if pixels[red] == pixels[green]:
break
if pixels[red] =... | Title: Pixels
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Flatland is inhabited by pixels of three colors: red, green and blue. We know that if two pixels of different colors meet in a violent fight, only one of them survives the fight (that is, the total number of pixels decreases by ... | ```python
def pixel(input):
red, green, blue = input.split()
pixels = [int(red), int(green), int(blue)]
red = 0
green = 1
blue = 2
battles = 0
f1 = None
f2 = None
w = None
while True:
if pixels[red] == pixels[green]:
break
if pix... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
227 | A | Where do I Turn? | PROGRAMMING | 1,300 | [
"geometry"
] | null | null | Trouble came from the overseas lands: a three-headed dragon Gorynych arrived. The dragon settled at point *C* and began to terrorize the residents of the surrounding villages.
A brave hero decided to put an end to the dragon. He moved from point *A* to fight with Gorynych. The hero rode from point *A* along a straight... | The first input line contains two space-separated integers *x**a*,<=*y**a* (|*x**a*|,<=|*y**a*|<=≤<=109) — the coordinates of point *A*. The second line contains the coordinates of point *B* in the same form, the third line contains the coordinates of point *C*.
It is guaranteed that all points are pairwise different.... | Print a single line. If a hero must turn left, print "LEFT" (without the quotes); If he must go straight ahead, print "TOWARDS" (without the quotes); if he should turn right, print "RIGHT" (without the quotes). | [
"0 0\n0 1\n1 1\n",
"-1 -1\n-3 -3\n-4 -4\n",
"-4 -6\n-3 -7\n-2 -6\n"
] | [
"RIGHT\n",
"TOWARDS\n",
"LEFT\n"
] | The picture to the first sample:
The red color shows points A, B and C. The blue arrow shows the hero's direction. The green color shows the hero's trajectory.
The picture to the second sample: | 500 | [
{
"input": "0 0\n0 1\n1 1",
"output": "RIGHT"
},
{
"input": "-1 -1\n-3 -3\n-4 -4",
"output": "TOWARDS"
},
{
"input": "-4 -6\n-3 -7\n-2 -6",
"output": "LEFT"
},
{
"input": "-44 57\n-118 -41\n-216 33",
"output": "RIGHT"
},
{
"input": "39 100\n90 85\n105 136",
"o... | 1,630,555,272 | 2,147,483,647 | Python 3 | COMPILATION_ERROR | TESTS | 0 | 0 | 0 | def nums():
return map(int, raw_input().split())
x1, y1 = nums()
x2, y2 = nums()
x3, y3 = nums()
d = (x2 - x1)*(y3 - y2) - (y2 - y1) * (x3 - x2)
if d < 0:
print 'RIGHT'
elif d == 0:
print 'TOWARDS'
else:
print 'LEFT'
| Title: Where do I Turn?
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Trouble came from the overseas lands: a three-headed dragon Gorynych arrived. The dragon settled at point *C* and began to terrorize the residents of the surrounding villages.
A brave hero decided to put an end to the... | ```python
def nums():
return map(int, raw_input().split())
x1, y1 = nums()
x2, y2 = nums()
x3, y3 = nums()
d = (x2 - x1)*(y3 - y2) - (y2 - y1) * (x3 - x2)
if d < 0:
print 'RIGHT'
elif d == 0:
print 'TOWARDS'
else:
print 'LEFT'
``` | -1 | MatrixStudio/Codeforces-Python-Submissions | |
347 | A | Difference Row | PROGRAMMING | 1,300 | [
"constructive algorithms",
"implementation",
"sortings"
] | null | null | You want to arrange *n* integers *a*1,<=*a*2,<=...,<=*a**n* in some order in a row. Let's define the value of an arrangement as the sum of differences between all pairs of adjacent integers.
More formally, let's denote some arrangement as a sequence of integers *x*1,<=*x*2,<=...,<=*x**n*, where sequence *x* is a permu... | The first line of the input contains integer *n* (2<=≤<=*n*<=≤<=100). The second line contains *n* space-separated integers *a*1, *a*2, ..., *a**n* (|*a**i*|<=≤<=1000). | Print the required sequence *x*1,<=*x*2,<=...,<=*x**n*. Sequence *x* should be the lexicographically smallest permutation of *a* that corresponds to an arrangement of the largest possible value. | [
"5\n100 -100 50 0 -50\n"
] | [
"100 -50 0 50 -100 \n"
] | In the sample test case, the value of the output arrangement is (100 - ( - 50)) + (( - 50) - 0) + (0 - 50) + (50 - ( - 100)) = 200. No other arrangement has a larger value, and among all arrangements with the value of 200, the output arrangement is the lexicographically smallest one.
Sequence *x*<sub class="lower-inde... | 500 | [
{
"input": "5\n100 -100 50 0 -50",
"output": "100 -50 0 50 -100 "
},
{
"input": "10\n764 -367 0 963 -939 -795 -26 -49 948 -282",
"output": "963 -795 -367 -282 -49 -26 0 764 948 -939 "
},
{
"input": "20\n262 -689 -593 161 -678 -555 -633 -697 369 258 673 50 833 737 -650 198 -651 -621 -396 ... | 1,418,378,398 | 2,147,483,647 | Python 3 | OK | TESTS | 16 | 154 | 0 | input()
a=sorted(map(int,input().split()))
print(a[-1],' '.join(map(str,a[1:-1])),a[0])
| Title: Difference Row
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You want to arrange *n* integers *a*1,<=*a*2,<=...,<=*a**n* in some order in a row. Let's define the value of an arrangement as the sum of differences between all pairs of adjacent integers.
More formally, let's denote ... | ```python
input()
a=sorted(map(int,input().split()))
print(a[-1],' '.join(map(str,a[1:-1])),a[0])
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
965 | C | Greedy Arkady | PROGRAMMING | 2,000 | [
"math"
] | null | null | $k$ people want to split $n$ candies between them. Each candy should be given to exactly one of them or be thrown away.
The people are numbered from $1$ to $k$, and Arkady is the first of them. To split the candies, Arkady will choose an integer $x$ and then give the first $x$ candies to himself, the next $x$ candies ... | The only line contains four integers $n$, $k$, $M$ and $D$ ($2 \le n \le 10^{18}$, $2 \le k \le n$, $1 \le M \le n$, $1 \le D \le \min{(n, 1000)}$, $M \cdot D \cdot k \ge n$) — the number of candies, the number of people, the maximum number of candies given to a person at once, the maximum number of times a person can ... | Print a single integer — the maximum possible number of candies Arkady can give to himself.
Note that it is always possible to choose some valid $x$. | [
"20 4 5 2\n",
"30 9 4 1\n"
] | [
"8\n",
"4\n"
] | In the first example Arkady should choose $x = 4$. He will give $4$ candies to himself, $4$ candies to the second person, $4$ candies to the third person, then $4$ candies to the fourth person and then again $4$ candies to himself. No person is given candies more than $2$ times, and Arkady receives $8$ candies in total... | 1,500 | [
{
"input": "20 4 5 2",
"output": "8"
},
{
"input": "30 9 4 1",
"output": "4"
},
{
"input": "2 2 1 1",
"output": "1"
},
{
"input": "42 20 5 29",
"output": "5"
},
{
"input": "1000000000000000000 135 1000000000000000 1000",
"output": "8325624421831635"
},
{
... | 1,527,191,350 | 3,010 | Python 3 | WRONG_ANSWER | TESTS | 11 | 139 | 0 |
import math
def check(x):
xx = float(n)/float(x)
if math.floor(xx) <= m :
return 0
else:
return 1
n, k, m, d= map(int, input().strip().split())
ans = 0
for i in range(1, d+1):
l = (i-1)*k + 1
r = i*k
while l<r:
mid = (l+r)//2
if... | Title: Greedy Arkady
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
$k$ people want to split $n$ candies between them. Each candy should be given to exactly one of them or be thrown away.
The people are numbered from $1$ to $k$, and Arkady is the first of them. To split the candies, Arka... | ```python
import math
def check(x):
xx = float(n)/float(x)
if math.floor(xx) <= m :
return 0
else:
return 1
n, k, m, d= map(int, input().strip().split())
ans = 0
for i in range(1, d+1):
l = (i-1)*k + 1
r = i*k
while l<r:
mid = (l+r)//2
... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
652 | D | Nested Segments | PROGRAMMING | 1,800 | [
"data structures",
"sortings"
] | null | null | You are given *n* segments on a line. There are no ends of some segments that coincide. For each segment find the number of segments it contains. | The first line contains a single integer *n* (1<=≤<=*n*<=≤<=2·105) — the number of segments on a line.
Each of the next *n* lines contains two integers *l**i* and *r**i* (<=-<=109<=≤<=*l**i*<=<<=*r**i*<=≤<=109) — the coordinates of the left and the right ends of the *i*-th segment. It is guaranteed that there are n... | Print *n* lines. The *j*-th of them should contain the only integer *a**j* — the number of segments contained in the *j*-th segment. | [
"4\n1 8\n2 3\n4 7\n5 6\n",
"3\n3 4\n1 5\n2 6\n"
] | [
"3\n0\n1\n0\n",
"0\n1\n1\n"
] | none | 0 | [
{
"input": "4\n1 8\n2 3\n4 7\n5 6",
"output": "3\n0\n1\n0"
},
{
"input": "3\n3 4\n1 5\n2 6",
"output": "0\n1\n1"
},
{
"input": "1\n-1000000000 1000000000",
"output": "0"
},
{
"input": "2\n-1000000000 999999999\n-999999999 1000000000",
"output": "0\n0"
},
{
"input"... | 1,698,058,917 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 52 | 1,466 | 69,836,800 | '''
Descripttion: your project
version: 1.0
Author: ElysiaRealme
Date: 2023-10-23 16:56:58
LastEditors: ElysiaRealme
Language: Python
'''
from io import BytesIO, IOBase
import sys
import os
# import time
import bisect
# import functools
import math
import random
# import re
from collections import Co... | Title: Nested Segments
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given *n* segments on a line. There are no ends of some segments that coincide. For each segment find the number of segments it contains.
Input Specification:
The first line contains a single integer *n* (1<=≤<... | ```python
'''
Descripttion: your project
version: 1.0
Author: ElysiaRealme
Date: 2023-10-23 16:56:58
LastEditors: ElysiaRealme
Language: Python
'''
from io import BytesIO, IOBase
import sys
import os
# import time
import bisect
# import functools
import math
import random
# import re
from collections... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
546 | A | Soldier and Bananas | PROGRAMMING | 800 | [
"brute force",
"implementation",
"math"
] | null | null | A soldier wants to buy *w* bananas in the shop. He has to pay *k* dollars for the first banana, 2*k* dollars for the second one and so on (in other words, he has to pay *i*·*k* dollars for the *i*-th banana).
He has *n* dollars. How many dollars does he have to borrow from his friend soldier to buy *w* bananas? | The first line contains three positive integers *k*,<=*n*,<=*w* (1<=<=≤<=<=*k*,<=*w*<=<=≤<=<=1000, 0<=≤<=*n*<=≤<=109), the cost of the first banana, initial number of dollars the soldier has and number of bananas he wants. | Output one integer — the amount of dollars that the soldier must borrow from his friend. If he doesn't have to borrow money, output 0. | [
"3 17 4\n"
] | [
"13"
] | none | 500 | [
{
"input": "3 17 4",
"output": "13"
},
{
"input": "1 2 1",
"output": "0"
},
{
"input": "1 1 1",
"output": "0"
},
{
"input": "1 5 6",
"output": "16"
},
{
"input": "1 1000000000 1",
"output": "0"
},
{
"input": "1000 0 1000",
"output": "500500000"
}... | 1,694,085,705 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 15 | 0 | k,n,w = map(int,input().split())
sum = 0
while(i>=k):
x= i*k
sum=sum+x
print(n - sum) | Title: Soldier and Bananas
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
A soldier wants to buy *w* bananas in the shop. He has to pay *k* dollars for the first banana, 2*k* dollars for the second one and so on (in other words, he has to pay *i*·*k* dollars for the *i*-th banana).
He h... | ```python
k,n,w = map(int,input().split())
sum = 0
while(i>=k):
x= i*k
sum=sum+x
print(n - sum)
``` | -1 | MatrixStudio/Codeforces-Python-Submissions | |
32 | B | Borze | PROGRAMMING | 800 | [
"expression parsing",
"implementation"
] | B. Borze | 2 | 256 | Ternary numeric notation is quite popular in Berland. To telegraph the ternary number the Borze alphabet is used. Digit 0 is transmitted as «.», 1 as «-.» and 2 as «--». You are to decode the Borze code, i.e. to find out the ternary number given its representation in Borze alphabet. | The first line contains a number in Borze code. The length of the string is between 1 and 200 characters. It's guaranteed that the given string is a valid Borze code of some ternary number (this number can have leading zeroes). | Output the decoded ternary number. It can have leading zeroes. | [
".-.--\n",
"--.\n",
"-..-.--\n"
] | [
"012",
"20",
"1012"
] | none | 1,000 | [
{
"input": ".-.--",
"output": "012"
},
{
"input": "--.",
"output": "20"
},
{
"input": "-..-.--",
"output": "1012"
},
{
"input": "---..",
"output": "210"
},
{
"input": "..--.---..",
"output": "0020210"
},
{
"input": "-.....----.",
"output": "1000022... | 1,621,759,545 | 2,147,483,647 | Python 3 | OK | TESTS | 30 | 186 | 512,000 | import string
import math
import time
def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
def lcm(x, y):
return (x*y)//gcd(x,y)
code = input()
decode = ""
i = 0
while i < len(code):
if code[i] == ".":
decode += "0"
i += 1
elif code[i + 1]== ".":
... | Title: Borze
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Ternary numeric notation is quite popular in Berland. To telegraph the ternary number the Borze alphabet is used. Digit 0 is transmitted as «.», 1 as «-.» and 2 as «--». You are to decode the Borze code, i.e. to find out the ternary ... | ```python
import string
import math
import time
def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
def lcm(x, y):
return (x*y)//gcd(x,y)
code = input()
decode = ""
i = 0
while i < len(code):
if code[i] == ".":
decode += "0"
i += 1
elif code[i + 1]=... | 3.952546 | MatrixStudio/Codeforces-Python-Submissions |
515 | C | Drazil and Factorial | PROGRAMMING | 1,400 | [
"greedy",
"math",
"sortings"
] | null | null | Drazil is playing a math game with Varda.
Let's define for positive integer *x* as a product of factorials of its digits. For example, .
First, they choose a decimal number *a* consisting of *n* digits that contains at least one digit larger than 1. This number may possibly start with leading zeroes. Then they shoul... | The first line contains an integer *n* (1<=≤<=*n*<=≤<=15) — the number of digits in *a*.
The second line contains *n* digits of *a*. There is at least one digit in *a* that is larger than 1. Number *a* may possibly contain leading zeroes. | Output a maximum possible integer satisfying the conditions above. There should be no zeroes and ones in this number decimal representation. | [
"4\n1234\n",
"3\n555\n"
] | [
"33222\n",
"555\n"
] | In the first case, <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/f5a4207f23215fddce977ab5ea9e9d2e7578fb52.png" style="max-width: 100.0%;max-height: 100.0%;"/> | 1,000 | [
{
"input": "4\n1234",
"output": "33222"
},
{
"input": "3\n555",
"output": "555"
},
{
"input": "15\n012345781234578",
"output": "7777553333222222222222"
},
{
"input": "1\n8",
"output": "7222"
},
{
"input": "10\n1413472614",
"output": "75333332222222"
},
{
... | 1,586,096,516 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 93 | 307,200 | ip = int(input())
n = input()
d = dict()
for i in range(0,10):
d[i]=0
for num in n:
if int(num) == 4:
d[2]+=2
d[3]+=1
elif int(num) == 6:
d[3]+=1
d[5]+=1
elif int(num) == 8:
d[2]+=3
d[2]+=7
else :
d[int(num)]+=1
rs = ""
for ... | Title: Drazil and Factorial
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Drazil is playing a math game with Varda.
Let's define for positive integer *x* as a product of factorials of its digits. For example, .
First, they choose a decimal number *a* consisting of *n* digits that cont... | ```python
ip = int(input())
n = input()
d = dict()
for i in range(0,10):
d[i]=0
for num in n:
if int(num) == 4:
d[2]+=2
d[3]+=1
elif int(num) == 6:
d[3]+=1
d[5]+=1
elif int(num) == 8:
d[2]+=3
d[2]+=7
else :
d[int(num)]+=1
rs ... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
723 | A | The New Year: Meeting Friends | PROGRAMMING | 800 | [
"implementation",
"math",
"sortings"
] | null | null | There are three friend living on the straight line *Ox* in Lineland. The first friend lives at the point *x*1, the second friend lives at the point *x*2, and the third friend lives at the point *x*3. They plan to celebrate the New Year together, so they need to meet at one point. What is the minimum total distance they... | The first line of the input contains three distinct integers *x*1, *x*2 and *x*3 (1<=≤<=*x*1,<=*x*2,<=*x*3<=≤<=100) — the coordinates of the houses of the first, the second and the third friends respectively. | Print one integer — the minimum total distance the friends need to travel in order to meet together. | [
"7 1 4\n",
"30 20 10\n"
] | [
"6\n",
"20\n"
] | In the first sample, friends should meet at the point 4. Thus, the first friend has to travel the distance of 3 (from the point 7 to the point 4), the second friend also has to travel the distance of 3 (from the point 1 to the point 4), while the third friend should not go anywhere because he lives at the point 4. | 500 | [
{
"input": "7 1 4",
"output": "6"
},
{
"input": "30 20 10",
"output": "20"
},
{
"input": "1 4 100",
"output": "99"
},
{
"input": "100 1 91",
"output": "99"
},
{
"input": "1 45 100",
"output": "99"
},
{
"input": "1 2 3",
"output": "2"
},
{
"... | 1,696,044,328 | 2,147,483,647 | Python 3 | OK | TESTS | 48 | 46 | 0 | x=[int(_) for _ in input().split()]
print(max(x)-min(x))
| Title: The New Year: Meeting Friends
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
There are three friend living on the straight line *Ox* in Lineland. The first friend lives at the point *x*1, the second friend lives at the point *x*2, and the third friend lives at the point *x*3. They ... | ```python
x=[int(_) for _ in input().split()]
print(max(x)-min(x))
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
56 | A | Bar | PROGRAMMING | 1,000 | [
"implementation"
] | A. Bar | 2 | 256 | According to Berland laws it is only allowed to sell alcohol to people not younger than 18 years. Vasya's job is to monitor the law's enforcement. Tonight he entered a bar and saw *n* people sitting there. For every one of them Vasya happened to determine either the age or the drink the person is having. Vasya can chec... | The first line contains an integer *n* (1<=≤<=*n*<=≤<=100) which is the number of the bar's clients. Then follow *n* lines, each describing one visitor. A line either contains his age (an integer from 0 to 1000) or his drink (a string of capital Latin letters from 1 to 100 in length). It is guaranteed that the input da... | Print a single number which is the number of people Vasya should check to guarantee the law enforcement. | [
"5\n18\nVODKA\nCOKE\n19\n17\n"
] | [
"2\n"
] | In the sample test the second and fifth clients should be checked. | 500 | [
{
"input": "5\n18\nVODKA\nCOKE\n19\n17",
"output": "2"
},
{
"input": "2\n2\nGIN",
"output": "2"
},
{
"input": "3\nWHISKEY\n3\nGIN",
"output": "3"
},
{
"input": "4\n813\nIORBQITQXMPTFAEMEQDQIKFGKGOTNKTOSZCBRPXJLUKVLVHJYNRUJXK\nRUM\nRHVRWGODYWWTYZFLFYKCVUFFRTQDINKNWPKFHZBFWBHWI... | 1,679,922,521 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 5 | 92 | 0 | c=0
for i in range(int(input())):
x=input()
if x[0] in '0123456789':
x=int(x)
if x<18:
c+=1
else:
if x=="ABSINTH" or x=="BEER" or x=="BRANDY" or x=="CHAMPAGNE" or x=="GIN" or x=="RUM" or x=="SAKE" or x=="TEQUILLA" or x=="VODKA" or x=="WHISKEY" or x=="WINE":
... | Title: Bar
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
According to Berland laws it is only allowed to sell alcohol to people not younger than 18 years. Vasya's job is to monitor the law's enforcement. Tonight he entered a bar and saw *n* people sitting there. For every one of them Vasya h... | ```python
c=0
for i in range(int(input())):
x=input()
if x[0] in '0123456789':
x=int(x)
if x<18:
c+=1
else:
if x=="ABSINTH" or x=="BEER" or x=="BRANDY" or x=="CHAMPAGNE" or x=="GIN" or x=="RUM" or x=="SAKE" or x=="TEQUILLA" or x=="VODKA" or x=="WHISKEY" or x=="WIN... | 0 | MatrixStudio/Codeforces-Python-Submissions |
58 | A | Chat room | PROGRAMMING | 1,000 | [
"greedy",
"strings"
] | A. Chat room | 1 | 256 | Vasya has recently learned to type and log on to the Internet. He immediately entered a chat room and decided to say hello to everybody. Vasya typed the word *s*. It is considered that Vasya managed to say hello if several letters can be deleted from the typed word so that it resulted in the word "hello". For example, ... | The first and only line contains the word *s*, which Vasya typed. This word consisits of small Latin letters, its length is no less that 1 and no more than 100 letters. | If Vasya managed to say hello, print "YES", otherwise print "NO". | [
"ahhellllloou\n",
"hlelo\n"
] | [
"YES\n",
"NO\n"
] | none | 500 | [
{
"input": "ahhellllloou",
"output": "YES"
},
{
"input": "hlelo",
"output": "NO"
},
{
"input": "helhcludoo",
"output": "YES"
},
{
"input": "hehwelloho",
"output": "YES"
},
{
"input": "pnnepelqomhhheollvlo",
"output": "YES"
},
{
"input": "tymbzjyqhymeda... | 1,607,799,454 | 2,147,483,647 | PyPy 3 | OK | TESTS | 40 | 140 | 0 | s, al, s1 = input(), ['h','e','l','o'], ''
for i in range( len(s) ):
if s[i] in al:
s1 += s[i]
s = s1
h,e,l1,l2,o = 0,0,0,0,0
for i in range(len(s)):
x = 1
if s[i] == 'h' or h == 1:
h = 1
if s[i] == 'e' or e == 1:
e = 1
if s[i] == 'l' or l1 =... | Title: Chat room
Time Limit: 1 seconds
Memory Limit: 256 megabytes
Problem Description:
Vasya has recently learned to type and log on to the Internet. He immediately entered a chat room and decided to say hello to everybody. Vasya typed the word *s*. It is considered that Vasya managed to say hello if several letter... | ```python
s, al, s1 = input(), ['h','e','l','o'], ''
for i in range( len(s) ):
if s[i] in al:
s1 += s[i]
s = s1
h,e,l1,l2,o = 0,0,0,0,0
for i in range(len(s)):
x = 1
if s[i] == 'h' or h == 1:
h = 1
if s[i] == 'e' or e == 1:
e = 1
if s[i] == '... | 3.93 | MatrixStudio/Codeforces-Python-Submissions |
767 | A | Snacktower | PROGRAMMING | 1,100 | [
"data structures",
"implementation"
] | null | null | According to an old legeng, a long time ago Ankh-Morpork residents did something wrong to miss Fortune, and she cursed them. She said that at some time *n* snacks of distinct sizes will fall on the city, and the residents should build a Snacktower of them by placing snacks one on another. Of course, big snacks should b... | The first line contains single integer *n* (1<=≤<=*n*<=≤<=100<=000) — the total number of snacks.
The second line contains *n* integers, the *i*-th of them equals the size of the snack which fell on the *i*-th day. Sizes are distinct integers from 1 to *n*. | Print *n* lines. On the *i*-th of them print the sizes of the snacks which the residents placed on the top of the Snacktower on the *i*-th day in the order they will do that. If no snack is placed on some day, leave the corresponding line empty. | [
"3\n3 1 2\n",
"5\n4 5 1 2 3\n"
] | [
"3\n \n2 1",
"5 4\n \n \n3 2 1\n"
] | In the example a snack of size 3 fell on the first day, and the residents immediately placed it. On the second day a snack of size 1 fell, and the residents weren't able to place it because they were missing the snack of size 2. On the third day a snack of size 2 fell, and the residents immediately placed it. Right aft... | 500 | [
{
"input": "3\n3 1 2",
"output": "3 \n\n2 1 "
},
{
"input": "5\n4 5 1 2 3",
"output": "5 4 \n\n\n3 2 1 "
},
{
"input": "1\n1",
"output": "1 "
},
{
"input": "2\n1 2",
"output": "2 1 "
},
{
"input": "10\n5 1 6 2 8 3 4 10 9 7",
"output": "10 \n9 8 \n7 6 5 4 3 2 1... | 1,578,929,565 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 4 | 93 | 307,200 | n=int(input())
a=list(map(int,input().split()))
l=[]
for i in range(0,n):
if i==n-1 and len(l)==0:
print(a[i])
elif i==n-1 and len(l)!=0:
l.append(a[i])
l.sort(reverse=True)
print(*l)
elif a[i+1]>=a[i]:
l.append(a[i])
print()
else:
l.... | Title: Snacktower
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
According to an old legeng, a long time ago Ankh-Morpork residents did something wrong to miss Fortune, and she cursed them. She said that at some time *n* snacks of distinct sizes will fall on the city, and the residents sh... | ```python
n=int(input())
a=list(map(int,input().split()))
l=[]
for i in range(0,n):
if i==n-1 and len(l)==0:
print(a[i])
elif i==n-1 and len(l)!=0:
l.append(a[i])
l.sort(reverse=True)
print(*l)
elif a[i+1]>=a[i]:
l.append(a[i])
print()
else:
... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
886 | A | ACM ICPC | PROGRAMMING | 1,000 | [
"brute force"
] | null | null | In a small but very proud high school it was decided to win ACM ICPC. This goal requires to compose as many teams of three as possible, but since there were only 6 students who wished to participate, the decision was to build exactly two teams.
After practice competition, participant number *i* got a score of *a**i*. ... | The single line contains six integers *a*1,<=...,<=*a*6 (0<=≤<=*a**i*<=≤<=1000) — scores of the participants | Print "YES" (quotes for clarity), if it is possible to build teams with equal score, and "NO" otherwise.
You can print each character either upper- or lowercase ("YeS" and "yes" are valid when the answer is "YES"). | [
"1 3 2 1 2 1\n",
"1 1 1 1 1 99\n"
] | [
"YES\n",
"NO\n"
] | In the first sample, first team can be composed of 1st, 2nd and 6th participant, second — of 3rd, 4th and 5th: team scores are 1 + 3 + 1 = 2 + 1 + 2 = 5.
In the second sample, score of participant number 6 is too high: his team score will be definitely greater. | 500 | [
{
"input": "1 3 2 1 2 1",
"output": "YES"
},
{
"input": "1 1 1 1 1 99",
"output": "NO"
},
{
"input": "1000 1000 1000 1000 1000 1000",
"output": "YES"
},
{
"input": "0 0 0 0 0 0",
"output": "YES"
},
{
"input": "633 609 369 704 573 416",
"output": "NO"
},
{
... | 1,592,473,851 | 2,147,483,647 | PyPy 3 | OK | TESTS | 53 | 202 | 1,740,800 | from functools import reduce
L=list(map(int,input().split()))
L.sort()
s=reduce(lambda x,y:x+y,L)
if(s%2!=0):
print("NO")
else:
count=0
for i in range(0,6):
for j in range(0,i):
for k in range(0,j):
if(L[i]+L[j]+L[k]==s//2):
count+=1
if(count>=2):
print("YES")
else:
print("NO")
... | Title: ACM ICPC
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
In a small but very proud high school it was decided to win ACM ICPC. This goal requires to compose as many teams of three as possible, but since there were only 6 students who wished to participate, the decision was to build ... | ```python
from functools import reduce
L=list(map(int,input().split()))
L.sort()
s=reduce(lambda x,y:x+y,L)
if(s%2!=0):
print("NO")
else:
count=0
for i in range(0,6):
for j in range(0,i):
for k in range(0,j):
if(L[i]+L[j]+L[k]==s//2):
count+=1
if(count>=2):
print("YES")
else:
pr... | 3 | MatrixStudio/Codeforces-Python-Submissions |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.