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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
166 | E | Tetrahedron | PROGRAMMING | 1,500 | [
"dp",
"math",
"matrices"
] | null | null | You are given a tetrahedron. Let's mark its vertices with letters *A*, *B*, *C* and *D* correspondingly.
An ant is standing in the vertex *D* of the tetrahedron. The ant is quite active and he wouldn't stay idle. At each moment of time he makes a step from one vertex to another one along some edge of the tetrahedron. ... | The first line contains the only integer *n* (1<=≤<=*n*<=≤<=107) — the required length of the cyclic path. | Print the only integer — the required number of ways modulo 1000000007 (109<=+<=7). | [
"2\n",
"4\n"
] | [
"3\n",
"21\n"
] | The required paths in the first sample are:
- *D* - *A* - *D* - *D* - *B* - *D* - *D* - *C* - *D* | 1,000 | [
{
"input": "2",
"output": "3"
},
{
"input": "4",
"output": "21"
},
{
"input": "1",
"output": "0"
},
{
"input": "3",
"output": "6"
},
{
"input": "5",
"output": "60"
},
{
"input": "6",
"output": "183"
},
{
"input": "7",
"output": "546"
... | 1,629,492,221 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 12 | 2,000 | 6,758,400 | n = int(input())
a, b = 1, 0
mod = 10**9+7
for i in range(n):
a, b = (b * 3) % mod, (a + b * 2) % mod
print(a)
| Title: Tetrahedron
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given a tetrahedron. Let's mark its vertices with letters *A*, *B*, *C* and *D* correspondingly.
An ant is standing in the vertex *D* of the tetrahedron. The ant is quite active and he wouldn't stay idle. At each m... | ```python
n = int(input())
a, b = 1, 0
mod = 10**9+7
for i in range(n):
a, b = (b * 3) % mod, (a + b * 2) % mod
print(a)
``` | 0 | |
0 | none | none | none | 0 | [
"none"
] | null | null | The mobile application store has a new game called "Subway Roller".
The protagonist of the game Philip is located in one end of the tunnel and wants to get out of the other one. The tunnel is a rectangular field consisting of three rows and *n* columns. At the beginning of the game the hero is in some cell of the left... | Each test contains from one to ten sets of the input data. The first line of the test contains a single integer *t* (1<=≤<=*t*<=≤<=10 for pretests and tests or *t*<==<=1 for hacks; see the Notes section for details) — the number of sets.
Then follows the description of *t* sets of the input data.
The first line of t... | For each set of the input data print on a single line word YES, if it is possible to win the game and word NO otherwise. | [
"2\n16 4\n...AAAAA........\ns.BBB......CCCCC\n........DDDDD...\n16 4\n...AAAAA........\ns.BBB....CCCCC..\n.......DDDDD....\n",
"2\n10 4\ns.ZZ......\n.....AAABB\n.YYYYYY...\n10 4\ns.ZZ......\n....AAAABB\n.YYYYYY...\n"
] | [
"YES\nNO\n",
"YES\nNO\n"
] | In the first set of the input of the first sample Philip must first go forward and go down to the third row of the field, then go only forward, then go forward and climb to the second row, go forward again and go up to the first row. After that way no train blocks Philip's path, so he can go straight to the end of the ... | 0 | [] | 1,444,646,254 | 5,254 | Python 3 | WRONG_ANSWER | PRETESTS | 3 | 46 | 0 | ress=[]
for asdf in range(int(input())):
a=list(map(int,input().split(' ')))
n=a[0]
res='YES'
lvl=[]
lvl.append(list(input()+'.'))
lvl.append(list(input()+'.'))
lvl.append(list(input()+'.'))
k=1
dom=set()
if lvl[0][0]=='s':
ph=0
elif lvl[0][1]=='s':
... | Title: none
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The mobile application store has a new game called "Subway Roller".
The protagonist of the game Philip is located in one end of the tunnel and wants to get out of the other one. The tunnel is a rectangular field consisting of thr... | ```python
ress=[]
for asdf in range(int(input())):
a=list(map(int,input().split(' ')))
n=a[0]
res='YES'
lvl=[]
lvl.append(list(input()+'.'))
lvl.append(list(input()+'.'))
lvl.append(list(input()+'.'))
k=1
dom=set()
if lvl[0][0]=='s':
ph=0
elif lvl[0][1]==... | 0 | |
758 | A | Holiday Of Equality | PROGRAMMING | 800 | [
"implementation",
"math"
] | null | null | In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury.
Totally in Berland there are *n* citizens, the welfare of each of them is estimated as the integer in *a**i* burles (burle is the currency in Berl... | The first line contains the integer *n* (1<=≤<=*n*<=≤<=100) — the number of citizens in the kingdom.
The second line contains *n* integers *a*1,<=*a*2,<=...,<=*a**n*, where *a**i* (0<=≤<=*a**i*<=≤<=106) — the welfare of the *i*-th citizen. | In the only line print the integer *S* — the minimum number of burles which are had to spend. | [
"5\n0 1 2 3 4\n",
"5\n1 1 0 1 1\n",
"3\n1 3 1\n",
"1\n12\n"
] | [
"10",
"1",
"4",
"0"
] | In the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.
In the second example it is enough to give one burle to the third citizen.
In the third example it is necessary to give two burles to the first and the thi... | 500 | [
{
"input": "5\n0 1 2 3 4",
"output": "10"
},
{
"input": "5\n1 1 0 1 1",
"output": "1"
},
{
"input": "3\n1 3 1",
"output": "4"
},
{
"input": "1\n12",
"output": "0"
},
{
"input": "3\n1 2 3",
"output": "3"
},
{
"input": "14\n52518 718438 358883 462189 853... | 1,649,350,713 | 2,147,483,647 | PyPy 3 | OK | TESTS | 41 | 93 | 0 | n= int(input())
arr = [int(x) for x in input().split()]
val = max(arr)
equal = [abs(val-i) for i in arr]
print(sum(equal)) | Title: Holiday Of Equality
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury.
Totally in Berland there are *n* citizens... | ```python
n= int(input())
arr = [int(x) for x in input().split()]
val = max(arr)
equal = [abs(val-i) for i in arr]
print(sum(equal))
``` | 3 | |
0 | none | none | none | 0 | [
"none"
] | null | null | Little Petya is now fond of data compression algorithms. He has already studied gz, bz, zip algorithms and many others. Inspired by the new knowledge, Petya is now developing the new compression algorithm which he wants to name dis.
Petya decided to compress tables. He is given a table *a* consisting of *n* rows and *... | The first line of the input contains two integers *n* and *m* (, the number of rows and the number of columns of the table respectively.
Each of the following *n* rows contain *m* integers *a**i*,<=*j* (1<=≤<=*a**i*,<=*j*<=≤<=109) that are the values in the table. | Output the compressed table in form of *n* lines each containing *m* integers.
If there exist several answers such that the maximum number in the compressed table is minimum possible, you are allowed to output any of them. | [
"2 2\n1 2\n3 4\n",
"4 3\n20 10 30\n50 40 30\n50 60 70\n90 80 70\n"
] | [
"1 2\n2 3\n",
"2 1 3\n5 4 3\n5 6 7\n9 8 7\n"
] | In the first sample test, despite the fact *a*<sub class="lower-index">1, 2</sub> ≠ *a*<sub class="lower-index">21</sub>, they are not located in the same row or column so they may become equal after the compression. | 0 | [] | 1,692,374,946 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 0 | 46 | 0 | print("_RANDOM_GUESS_1692374946.5639102")# 1692374946.5639243 | Title: none
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Little Petya is now fond of data compression algorithms. He has already studied gz, bz, zip algorithms and many others. Inspired by the new knowledge, Petya is now developing the new compression algorithm which he wants to name di... | ```python
print("_RANDOM_GUESS_1692374946.5639102")# 1692374946.5639243
``` | 0 | |
948 | A | Protect Sheep | PROGRAMMING | 900 | [
"brute force",
"dfs and similar",
"graphs",
"implementation"
] | null | null | Bob is a farmer. He has a large pasture with many sheep. Recently, he has lost some of them due to wolf attacks. He thus decided to place some shepherd dogs in such a way that all his sheep are protected.
The pasture is a rectangle consisting of *R*<=×<=*C* cells. Each cell is either empty, contains a sheep, a wolf or... | First line contains two integers *R* (1<=≤<=*R*<=≤<=500) and *C* (1<=≤<=*C*<=≤<=500), denoting the number of rows and the numbers of columns respectively.
Each of the following *R* lines is a string consisting of exactly *C* characters, representing one row of the pasture. Here, 'S' means a sheep, 'W' a wolf and '.' a... | If it is impossible to protect all sheep, output a single line with the word "No".
Otherwise, output a line with the word "Yes". Then print *R* lines, representing the pasture after placing dogs. Again, 'S' means a sheep, 'W' a wolf, 'D' is a dog and '.' an empty space. You are not allowed to move, remove or add a she... | [
"6 6\n..S...\n..S.W.\n.S....\n..W...\n...W..\n......\n",
"1 2\nSW\n",
"5 5\n.S...\n...S.\nS....\n...S.\n.S...\n"
] | [
"Yes\n..SD..\n..SDW.\n.SD...\n.DW...\nDD.W..\n......\n",
"No\n",
"Yes\n.S...\n...S.\nS.D..\n...S.\n.S...\n"
] | In the first example, we can split the pasture into two halves, one containing wolves and one containing sheep. Note that the sheep at (2,1) is safe, as wolves cannot move diagonally.
In the second example, there are no empty spots to put dogs that would guard the lone sheep.
In the third example, there are no wolves... | 500 | [
{
"input": "1 2\nSW",
"output": "No"
},
{
"input": "10 10\n....W.W.W.\n.........S\n.S.S...S..\nW.......SS\n.W..W.....\n.W...W....\nS..S...S.S\n....W...S.\n..S..S.S.S\nSS.......S",
"output": "Yes\nDDDDWDWDWD\nDDDDDDDDDS\nDSDSDDDSDD\nWDDDDDDDSS\nDWDDWDDDDD\nDWDDDWDDDD\nSDDSDDDSDS\nDDDDWDDDSD\nDDSD... | 1,663,279,233 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 30 | 0 | def protect(pasture, row, col):
for y in range(row):
for x in range(col):
if pasture[x][y] == S:
if pasture[x][y] == 'W':
print("NO")
def print_pasture(matrix):
for line in range(len(matrix)):
print(matrix[line])
rows, columns = input().split()... | Title: Protect Sheep
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Bob is a farmer. He has a large pasture with many sheep. Recently, he has lost some of them due to wolf attacks. He thus decided to place some shepherd dogs in such a way that all his sheep are protected.
The pasture is ... | ```python
def protect(pasture, row, col):
for y in range(row):
for x in range(col):
if pasture[x][y] == S:
if pasture[x][y] == 'W':
print("NO")
def print_pasture(matrix):
for line in range(len(matrix)):
print(matrix[line])
rows, columns = input... | -1 | |
591 | B | Rebranding | PROGRAMMING | 1,200 | [
"implementation",
"strings"
] | null | null | The name of one small but proud corporation consists of *n* lowercase English letters. The Corporation has decided to try rebranding — an active marketing strategy, that includes a set of measures to change either the brand (both for the company and the goods it produces) or its components: the name, the logo, the slog... | The first line of the input contains two integers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=200<=000) — the length of the initial name and the number of designers hired, respectively.
The second line consists of *n* lowercase English letters and represents the original name of the corporation.
Next *m* lines contain the descr... | Print the new name of the corporation. | [
"6 1\npolice\np m\n",
"11 6\nabacabadaba\na b\nb c\na d\ne g\nf a\nb b\n"
] | [
"molice\n",
"cdcbcdcfcdc\n"
] | In the second sample the name of the corporation consecutively changes as follows:
<img align="middle" class="tex-formula" src="https://espresso.codeforces.com/c7648432f7138ca53234357d7e08d1d119166055.png" style="max-width: 100.0%;max-height: 100.0%;"/>
<img align="middle" class="tex-formula" src="https://espresso.co... | 1,000 | [
{
"input": "6 1\npolice\np m",
"output": "molice"
},
{
"input": "11 6\nabacabadaba\na b\nb c\na d\ne g\nf a\nb b",
"output": "cdcbcdcfcdc"
},
{
"input": "1 1\nf\nz h",
"output": "f"
},
{
"input": "1 1\na\na b",
"output": "b"
},
{
"input": "10 10\nlellelleel\ne l\n... | 1,445,765,096 | 1,496 | PyPy 3 | OK | TESTS | 27 | 1,762 | 12,492,800 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
n, m = map(int,input().split())
S = input()
char = {chr(i) : chr(i) for i in range(ord('a'), ord('z')+1 )}
keys = char.keys()
for i in range(m):
x, y = input().split()
for c in keys:
if char[c] == x:
char[c] = y
elif char[c... | Title: Rebranding
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The name of one small but proud corporation consists of *n* lowercase English letters. The Corporation has decided to try rebranding — an active marketing strategy, that includes a set of measures to change either the brand ... | ```python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
n, m = map(int,input().split())
S = input()
char = {chr(i) : chr(i) for i in range(ord('a'), ord('z')+1 )}
keys = char.keys()
for i in range(m):
x, y = input().split()
for c in keys:
if char[c] == x:
char[c] = y
e... | 3 | |
611 | A | New Year and Days | PROGRAMMING | 900 | [
"implementation"
] | null | null | Today is Wednesday, the third day of the week. What's more interesting is that tomorrow is the last day of the year 2015.
Limak is a little polar bear. He enjoyed this year a lot. Now, he is so eager to the coming year 2016.
Limak wants to prove how responsible a bear he is. He is going to regularly save candies for ... | The only line of the input is in one of the following two formats:
- "*x* of week" where *x* (1<=≤<=*x*<=≤<=7) denotes the day of the week. The 1-st day is Monday and the 7-th one is Sunday. - "*x* of month" where *x* (1<=≤<=*x*<=≤<=31) denotes the day of the month. | Print one integer — the number of candies Limak will save in the year 2016. | [
"4 of week\n",
"30 of month\n"
] | [
"52\n",
"11\n"
] | Polar bears use the Gregorian calendar. It is the most common calendar and you likely use it too. You can read about it on Wikipedia if you want to – [https://en.wikipedia.org/wiki/Gregorian_calendar](https://en.wikipedia.org/wiki/Gregorian_calendar). The week starts with Monday.
In the first sample Limak wants to sav... | 500 | [
{
"input": "4 of week",
"output": "52"
},
{
"input": "30 of month",
"output": "11"
},
{
"input": "17 of month",
"output": "12"
},
{
"input": "31 of month",
"output": "7"
},
{
"input": "6 of week",
"output": "53"
},
{
"input": "1 of week",
"output":... | 1,454,438,357 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 46 | 409,600 | import re
n = input()
is_week = "week" in n
x = int(re.findall("[0-9]+", n)[0])
if is_week:
print(52 if x<5 and x>6 else 53)
else:
print(7 if x>30 else (11 if x>28 else 12))
| Title: New Year and Days
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Today is Wednesday, the third day of the week. What's more interesting is that tomorrow is the last day of the year 2015.
Limak is a little polar bear. He enjoyed this year a lot. Now, he is so eager to the coming ye... | ```python
import re
n = input()
is_week = "week" in n
x = int(re.findall("[0-9]+", n)[0])
if is_week:
print(52 if x<5 and x>6 else 53)
else:
print(7 if x>30 else (11 if x>28 else 12))
``` | 0 | |
363 | B | Fence | PROGRAMMING | 1,100 | [
"brute force",
"dp"
] | null | null | There is a fence in front of Polycarpus's home. The fence consists of *n* planks of the same width which go one after another from left to right. The height of the *i*-th plank is *h**i* meters, distinct planks can have distinct heights.
Polycarpus has bought a posh piano and is thinking about how to get it into the h... | The first line of the input contains integers *n* and *k* (1<=≤<=*n*<=≤<=1.5·105,<=1<=≤<=*k*<=≤<=*n*) — the number of planks in the fence and the width of the hole for the piano. The second line contains the sequence of integers *h*1,<=*h*2,<=...,<=*h**n* (1<=≤<=*h**i*<=≤<=100), where *h**i* is the height of the *i*-th... | Print such integer *j* that the sum of the heights of planks *j*, *j*<=+<=1, ..., *j*<=+<=*k*<=-<=1 is the minimum possible. If there are multiple such *j*'s, print any of them. | [
"7 3\n1 2 6 1 1 7 1\n"
] | [
"3\n"
] | In the sample, your task is to find three consecutive planks with the minimum sum of heights. In the given case three planks with indexes 3, 4 and 5 have the required attribute, their total height is 8. | 1,000 | [
{
"input": "7 3\n1 2 6 1 1 7 1",
"output": "3"
},
{
"input": "1 1\n100",
"output": "1"
},
{
"input": "2 1\n10 20",
"output": "1"
},
{
"input": "10 5\n1 2 3 1 2 2 3 1 4 5",
"output": "1"
},
{
"input": "10 2\n3 1 4 1 4 6 2 1 4 6",
"output": "7"
},
{
"inp... | 1,690,300,447 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 2 | 46 | 0 | n, k = map(int, input().split())
heights = list(map(int, input().split()))
min_sum = float('inf')
start_index = 0
current_sum = sum(heights[:k])
for i in range(1, n - k + 1):
current_sum = current_sum - heights[i - 1] + heights[i + k - 1]
if current_sum < min_sum:
min_sum = current_sum
... | Title: Fence
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
There is a fence in front of Polycarpus's home. The fence consists of *n* planks of the same width which go one after another from left to right. The height of the *i*-th plank is *h**i* meters, distinct planks can have distinct ... | ```python
n, k = map(int, input().split())
heights = list(map(int, input().split()))
min_sum = float('inf')
start_index = 0
current_sum = sum(heights[:k])
for i in range(1, n - k + 1):
current_sum = current_sum - heights[i - 1] + heights[i + k - 1]
if current_sum < min_sum:
min_sum = cur... | 0 | |
893 | D | Credit Card | PROGRAMMING | 1,900 | [
"data structures",
"dp",
"greedy",
"implementation"
] | null | null | Recenlty Luba got a credit card and started to use it. Let's consider *n* consecutive days Luba uses the card.
She starts with 0 money on her account.
In the evening of *i*-th day a transaction *a**i* occurs. If *a**i*<=><=0, then *a**i* bourles are deposited to Luba's account. If *a**i*<=<<=0, then *a**i* bour... | The first line contains two integers *n*, *d* (1<=≤<=*n*<=≤<=105, 1<=≤<=*d*<=≤<=109) —the number of days and the money limitation.
The second line contains *n* integer numbers *a*1,<=*a*2,<=... *a**n* (<=-<=104<=≤<=*a**i*<=≤<=104), where *a**i* represents the transaction in *i*-th day. | Print -1 if Luba cannot deposit the money to her account in such a way that the requirements are met. Otherwise print the minimum number of days Luba has to deposit money. | [
"5 10\n-1 5 0 -5 3\n",
"3 4\n-10 0 20\n",
"5 10\n-5 0 10 -11 0\n"
] | [
"0\n",
"-1\n",
"2\n"
] | none | 0 | [
{
"input": "5 10\n-1 5 0 -5 3",
"output": "0"
},
{
"input": "3 4\n-10 0 20",
"output": "-1"
},
{
"input": "5 10\n-5 0 10 -11 0",
"output": "2"
},
{
"input": "5 13756\n-2 -9 -10 0 10",
"output": "1"
},
{
"input": "20 23036\n-1 1 -1 -1 -1 -1 1 -1 -1 0 0 1 1 0 0 1 0 ... | 1,614,591,482 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 6 | 77 | 0 | n,d=map(int,input().split())
arr=list(map(int,input().split()))
def main():
curr=0
ans=0
for a in arr:
if a>0:
curr+=a
elif a<0:
curr+=a
else:
if curr<0:
curr=0
ans+=1
if curr>d:
return -1
ret... | Title: Credit Card
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Recenlty Luba got a credit card and started to use it. Let's consider *n* consecutive days Luba uses the card.
She starts with 0 money on her account.
In the evening of *i*-th day a transaction *a**i* occurs. If *a**i*<=&... | ```python
n,d=map(int,input().split())
arr=list(map(int,input().split()))
def main():
curr=0
ans=0
for a in arr:
if a>0:
curr+=a
elif a<0:
curr+=a
else:
if curr<0:
curr=0
ans+=1
if curr>d:
return ... | 0 | |
492 | B | Vanya and Lanterns | PROGRAMMING | 1,200 | [
"binary search",
"implementation",
"math",
"sortings"
] | null | null | Vanya walks late at night along a straight street of length *l*, lit by *n* lanterns. Consider the coordinate system with the beginning of the street corresponding to the point 0, and its end corresponding to the point *l*. Then the *i*-th lantern is at the point *a**i*. The lantern lights all points of the street that... | The first line contains two integers *n*, *l* (1<=≤<=*n*<=≤<=1000, 1<=≤<=*l*<=≤<=109) — the number of lanterns and the length of the street respectively.
The next line contains *n* integers *a**i* (0<=≤<=*a**i*<=≤<=*l*). Multiple lanterns can be located at the same point. The lanterns may be located at the ends of th... | Print the minimum light radius *d*, needed to light the whole street. The answer will be considered correct if its absolute or relative error doesn't exceed 10<=-<=9. | [
"7 15\n15 5 3 7 9 14 0\n",
"2 5\n2 5\n"
] | [
"2.5000000000\n",
"2.0000000000\n"
] | Consider the second sample. At *d* = 2 the first lantern will light the segment [0, 4] of the street, and the second lantern will light segment [3, 5]. Thus, the whole street will be lit. | 1,000 | [
{
"input": "7 15\n15 5 3 7 9 14 0",
"output": "2.5000000000"
},
{
"input": "2 5\n2 5",
"output": "2.0000000000"
},
{
"input": "46 615683844\n431749087 271781274 274974690 324606253 480870261 401650581 13285442 478090364 266585394 425024433 588791449 492057200 391293435 563090494 317950 1... | 1,696,821,076 | 2,147,483,647 | PyPy 3-64 | COMPILATION_ERROR | TESTS | 0 | 0 | 0 | n,t = map(int, input().split())
l = list(map(int, input().split()))
l = sort(l)
m = float(0)
for i in range(0, n-1):
m1 = max(l[i+1]-l[i],m)
m = float(m)/2
if(l[0] != 0):
m = max(m, l[0]-0
if(l[n-1]!=t):
m = max(m, t-l[n-1])
m= float(m)
print str(m) +'0'*8 | Title: Vanya and Lanterns
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vanya walks late at night along a straight street of length *l*, lit by *n* lanterns. Consider the coordinate system with the beginning of the street corresponding to the point 0, and its end corresponding to the poi... | ```python
n,t = map(int, input().split())
l = list(map(int, input().split()))
l = sort(l)
m = float(0)
for i in range(0, n-1):
m1 = max(l[i+1]-l[i],m)
m = float(m)/2
if(l[0] != 0):
m = max(m, l[0]-0
if(l[n-1]!=t):
m = max(m, t-l[n-1])
m= float(m)
print str(m) +'0'*8
``` | -1 | |
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,646,340,938 | 2,147,483,647 | Python 3 | OK | TESTS | 44 | 46 | 0 | Q = input()
W = "abcdefghijklmnopqrstuvwxyz"
W1=''
result =0
for i in range(len(Q)):
result += min(W.index(Q[i]),abs(26-W.index(Q[i])))
W1= W[W.index(Q[i]):]+W[:W.index(Q[i])]
W=W1
print(result) | 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
Q = input()
W = "abcdefghijklmnopqrstuvwxyz"
W1=''
result =0
for i in range(len(Q)):
result += min(W.index(Q[i]),abs(26-W.index(Q[i])))
W1= W[W.index(Q[i]):]+W[:W.index(Q[i])]
W=W1
print(result)
``` | 3 | |
540 | A | Combination Lock | PROGRAMMING | 800 | [
"implementation"
] | null | null | Scrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to put there the treasures that he's earned fair and square, he has to open the lock.
The combination lock is represented by *n* rotating disks with digits from 0 to 9 written on them. Scrooge McDuck has to turn ... | The first line contains a single integer *n* (1<=≤<=*n*<=≤<=1000) — the number of disks on the combination lock.
The second line contains a string of *n* digits — the original state of the disks.
The third line contains a string of *n* digits — Scrooge McDuck's combination that opens the lock. | Print a single integer — the minimum number of moves Scrooge McDuck needs to open the lock. | [
"5\n82195\n64723\n"
] | [
"13\n"
] | In the sample he needs 13 moves:
- 1 disk: <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/b8967f65a723782358b93eff9ce69f336817cf70.png" style="max-width: 100.0%;max-height: 100.0%;"/> - 2 disk: <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/07fa58573ece0d32... | 500 | [
{
"input": "5\n82195\n64723",
"output": "13"
},
{
"input": "12\n102021090898\n010212908089",
"output": "16"
},
{
"input": "1\n8\n1",
"output": "3"
},
{
"input": "2\n83\n57",
"output": "7"
},
{
"input": "10\n0728592530\n1362615763",
"output": "27"
},
{
... | 1,600,049,696 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 1 | 124 | 0 | n1=int(input())
n=input()
m=input()
sum=0
k=int(n)-int(m)
k=str(k)
for i in range(len(k)):
if int(k[i])>5:
sum+=(10-int(k[i]))
else:
sum+=int(k[i])
print(sum)
| Title: Combination Lock
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Scrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to put there the treasures that he's earned fair and square, he has to open the lock.
The combination lock is ... | ```python
n1=int(input())
n=input()
m=input()
sum=0
k=int(n)-int(m)
k=str(k)
for i in range(len(k)):
if int(k[i])>5:
sum+=(10-int(k[i]))
else:
sum+=int(k[i])
print(sum)
``` | 0 | |
706 | B | Interesting drink | PROGRAMMING | 1,100 | [
"binary search",
"dp",
"implementation"
] | null | null | Vasiliy likes to rest after a hard work, so you may often meet him in some bar nearby. As all programmers do, he loves the famous drink "Beecola", which can be bought in *n* different shops in the city. It's known that the price of one bottle in the shop *i* is equal to *x**i* coins.
Vasiliy plans to buy his favorite ... | The first line of the input contains a single integer *n* (1<=≤<=*n*<=≤<=100<=000) — the number of shops in the city that sell Vasiliy's favourite drink.
The second line contains *n* integers *x**i* (1<=≤<=*x**i*<=≤<=100<=000) — prices of the bottles of the drink in the *i*-th shop.
The third line contains a single i... | Print *q* integers. The *i*-th of them should be equal to the number of shops where Vasiliy will be able to buy a bottle of the drink on the *i*-th day. | [
"5\n3 10 8 6 11\n4\n1\n10\n3\n11\n"
] | [
"0\n4\n1\n5\n"
] | On the first day, Vasiliy won't be able to buy a drink in any of the shops.
On the second day, Vasiliy can buy a drink in the shops 1, 2, 3 and 4.
On the third day, Vasiliy can buy a drink only in the shop number 1.
Finally, on the last day Vasiliy can buy a drink in any shop. | 1,000 | [
{
"input": "5\n3 10 8 6 11\n4\n1\n10\n3\n11",
"output": "0\n4\n1\n5"
},
{
"input": "5\n868 987 714 168 123\n10\n424\n192\n795\n873\n117\n914\n735\n158\n631\n471",
"output": "2\n2\n3\n4\n0\n4\n3\n1\n2\n2"
},
{
"input": "3\n435 482 309\n7\n245\n241\n909\n745\n980\n29\n521",
"output": "... | 1,695,553,560 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 10 | 2,000 | 12,390,400 | n = int(input())
prices = list(map(int, input().split()))
prices.sort()
for i in range(int(input())):
num = int(input())
i = 0
answer = 0
while True:
if i == n:
break
if num >= prices[i]:
answer+=1
i+=1
else:
... | Title: Interesting drink
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vasiliy likes to rest after a hard work, so you may often meet him in some bar nearby. As all programmers do, he loves the famous drink "Beecola", which can be bought in *n* different shops in the city. It's known tha... | ```python
n = int(input())
prices = list(map(int, input().split()))
prices.sort()
for i in range(int(input())):
num = int(input())
i = 0
answer = 0
while True:
if i == n:
break
if num >= prices[i]:
answer+=1
i+=1
else... | 0 | |
577 | A | Multiplication Table | PROGRAMMING | 1,000 | [
"implementation",
"number theory"
] | null | null | Let's consider a table consisting of *n* rows and *n* columns. The cell located at the intersection of *i*-th row and *j*-th column contains number *i*<=×<=*j*. The rows and columns are numbered starting from 1.
You are given a positive integer *x*. Your task is to count the number of cells in a table that contain num... | The single line contains numbers *n* and *x* (1<=≤<=*n*<=≤<=105, 1<=≤<=*x*<=≤<=109) — the size of the table and the number that we are looking for in the table. | Print a single number: the number of times *x* occurs in the table. | [
"10 5\n",
"6 12\n",
"5 13\n"
] | [
"2\n",
"4\n",
"0\n"
] | A table for the second sample test is given below. The occurrences of number 12 are marked bold. | 500 | [
{
"input": "10 5",
"output": "2"
},
{
"input": "6 12",
"output": "4"
},
{
"input": "5 13",
"output": "0"
},
{
"input": "1 1",
"output": "1"
},
{
"input": "2 1",
"output": "1"
},
{
"input": "100000 1",
"output": "1"
},
{
"input": "1 10000000... | 1,685,279,507 | 2,147,483,647 | PyPy 3-64 | MEMORY_LIMIT_EXCEEDED | TESTS | 5 | 951 | 268,390,400 | n,x = map(int,input().split())
l = []
for i in range (1,n+1):
for j in range (1,n+1):
a = i*j
l.append(a)
print(l.count(x)) | Title: Multiplication Table
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Let's consider a table consisting of *n* rows and *n* columns. The cell located at the intersection of *i*-th row and *j*-th column contains number *i*<=×<=*j*. The rows and columns are numbered starting from 1.
Y... | ```python
n,x = map(int,input().split())
l = []
for i in range (1,n+1):
for j in range (1,n+1):
a = i*j
l.append(a)
print(l.count(x))
``` | 0 | |
349 | A | Cinema Line | PROGRAMMING | 1,100 | [
"greedy",
"implementation"
] | null | null | The new "Die Hard" movie has just been released! There are *n* people at the cinema box office standing in a huge line. Each of them has a single 100, 50 or 25 ruble bill. A "Die Hard" ticket costs 25 rubles. Can the booking clerk sell a ticket to each person and give the change if he initially has no money and sells t... | The first line contains integer *n* (1<=≤<=*n*<=≤<=105) — the number of people in the line. The next line contains *n* integers, each of them equals 25, 50 or 100 — the values of the bills the people have. The numbers are given in the order from the beginning of the line (at the box office) to the end of the line. | Print "YES" (without the quotes) if the booking clerk can sell a ticket to each person and give the change. Otherwise print "NO". | [
"4\n25 25 50 50\n",
"2\n25 100\n",
"4\n50 50 25 25\n"
] | [
"YES\n",
"NO\n",
"NO\n"
] | none | 500 | [
{
"input": "4\n25 25 50 50",
"output": "YES"
},
{
"input": "2\n25 100",
"output": "NO"
},
{
"input": "4\n50 50 25 25",
"output": "NO"
},
{
"input": "3\n25 50 100",
"output": "NO"
},
{
"input": "10\n25 25 25 25 25 25 25 25 25 25",
"output": "YES"
},
{
"... | 1,666,975,687 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 40 | 154 | 13,824,000 | import sys
n = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
num_25 = 0
num_50 = 0
ok = True
for a in A:
if a == 25:
num_25 += 1
elif a == 50:
num_50 += 1
if num_25 >= 1:
num_25 -= 1
else:
ok = False
el... | Title: Cinema Line
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The new "Die Hard" movie has just been released! There are *n* people at the cinema box office standing in a huge line. Each of them has a single 100, 50 or 25 ruble bill. A "Die Hard" ticket costs 25 rubles. Can the bookin... | ```python
import sys
n = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
num_25 = 0
num_50 = 0
ok = True
for a in A:
if a == 25:
num_25 += 1
elif a == 50:
num_50 += 1
if num_25 >= 1:
num_25 -= 1
else:
ok = Fal... | 3 | |
903 | A | Hungry Student Problem | PROGRAMMING | 900 | [
"greedy",
"implementation"
] | null | null | Ivan's classes at the university have just finished, and now he wants to go to the local CFK cafe and eat some fried chicken.
CFK sells chicken chunks in small and large portions. A small portion contains 3 chunks; a large one — 7 chunks. Ivan wants to eat exactly *x* chunks. Now he wonders whether he can buy exactly ... | The first line contains one integer *n* (1<=≤<=*n*<=≤<=100) — the number of testcases.
The *i*-th of the following *n* lines contains one integer *x**i* (1<=≤<=*x**i*<=≤<=100) — the number of chicken chunks Ivan wants to eat. | Print *n* lines, in *i*-th line output YES if Ivan can buy exactly *x**i* chunks. Otherwise, print NO. | [
"2\n6\n5\n"
] | [
"YES\nNO\n"
] | In the first example Ivan can buy two small portions.
In the second example Ivan cannot buy exactly 5 chunks, since one small portion is not enough, but two small portions or one large is too much. | 0 | [
{
"input": "2\n6\n5",
"output": "YES\nNO"
},
{
"input": "100\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n49\n50\n51\n52\n53\n54\n55\n56\n57\n58\n59\n60\n61\n62\... | 1,630,943,864 | 2,147,483,647 | Python 3 | OK | TESTS | 8 | 62 | 6,758,400 | n = int(input())
for zzz in range(n):
x = int(input())
for a in range(40):
for b in range(20):
if(3*a + 7*b==x):
print('YES')
break
else:
continue
break
else:
print('NO') | Title: Hungry Student Problem
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Ivan's classes at the university have just finished, and now he wants to go to the local CFK cafe and eat some fried chicken.
CFK sells chicken chunks in small and large portions. A small portion contains 3 chun... | ```python
n = int(input())
for zzz in range(n):
x = int(input())
for a in range(40):
for b in range(20):
if(3*a + 7*b==x):
print('YES')
break
else:
continue
break
else:
print('NO')
``` | 3 | |
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,660,152,791 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 41 | 77 | 5,324,800 | n = int(input())
t = [[], [], []]
for i, x in enumerate(int(x) for x in input().split()):
t[x - 1].append(i + 1)
nt = min(len(x) for x in t)
print(nt)
for i in range(nt):
print(t[0][i], t[1][i], t[2][i])
| 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())
t = [[], [], []]
for i, x in enumerate(int(x) for x in input().split()):
t[x - 1].append(i + 1)
nt = min(len(x) for x in t)
print(nt)
for i in range(nt):
print(t[0][i], t[1][i], t[2][i])
``` | 3 | |
903 | A | Hungry Student Problem | PROGRAMMING | 900 | [
"greedy",
"implementation"
] | null | null | Ivan's classes at the university have just finished, and now he wants to go to the local CFK cafe and eat some fried chicken.
CFK sells chicken chunks in small and large portions. A small portion contains 3 chunks; a large one — 7 chunks. Ivan wants to eat exactly *x* chunks. Now he wonders whether he can buy exactly ... | The first line contains one integer *n* (1<=≤<=*n*<=≤<=100) — the number of testcases.
The *i*-th of the following *n* lines contains one integer *x**i* (1<=≤<=*x**i*<=≤<=100) — the number of chicken chunks Ivan wants to eat. | Print *n* lines, in *i*-th line output YES if Ivan can buy exactly *x**i* chunks. Otherwise, print NO. | [
"2\n6\n5\n"
] | [
"YES\nNO\n"
] | In the first example Ivan can buy two small portions.
In the second example Ivan cannot buy exactly 5 chunks, since one small portion is not enough, but two small portions or one large is too much. | 0 | [
{
"input": "2\n6\n5",
"output": "YES\nNO"
},
{
"input": "100\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n49\n50\n51\n52\n53\n54\n55\n56\n57\n58\n59\n60\n61\n62\... | 1,589,734,185 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 93 | 6,656,000 | t=int(input())
for i in range(t):
f=0
x=int(input())
if(x%3==0 or x%7==0):
f=1
for p in range(1,x//3):
for q in range(1,x//7):
if(p*3+q*7 == x):
f=1
break
if(f==1):
print("YES")
else:
print("NO")
| Title: Hungry Student Problem
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Ivan's classes at the university have just finished, and now he wants to go to the local CFK cafe and eat some fried chicken.
CFK sells chicken chunks in small and large portions. A small portion contains 3 chun... | ```python
t=int(input())
for i in range(t):
f=0
x=int(input())
if(x%3==0 or x%7==0):
f=1
for p in range(1,x//3):
for q in range(1,x//7):
if(p*3+q*7 == x):
f=1
break
if(f==1):
print("YES")
else:
print(... | 0 | |
615 | A | Bulbs | PROGRAMMING | 800 | [
"implementation"
] | null | null | Vasya wants to turn on Christmas lights consisting of *m* bulbs. Initially, all bulbs are turned off. There are *n* buttons, each of them is connected to some set of bulbs. Vasya can press any of these buttons. When the button is pressed, it turns on all the bulbs it's connected to. Can Vasya light up all the bulbs?
I... | The first line of the input contains integers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=100) — the number of buttons and the number of bulbs respectively.
Each of the next *n* lines contains *x**i* (0<=≤<=*x**i*<=≤<=*m*) — the number of bulbs that are turned on by the *i*-th button, and then *x**i* numbers *y**ij* (1<=≤<=*y**... | If it's possible to turn on all *m* bulbs print "YES", otherwise print "NO". | [
"3 4\n2 1 4\n3 1 3 1\n1 2\n",
"3 3\n1 1\n1 2\n1 1\n"
] | [
"YES\n",
"NO\n"
] | In the first sample you can press each button once and turn on all the bulbs. In the 2 sample it is impossible to turn on the 3-rd lamp. | 500 | [
{
"input": "3 4\n2 1 4\n3 1 3 1\n1 2",
"output": "YES"
},
{
"input": "3 3\n1 1\n1 2\n1 1",
"output": "NO"
},
{
"input": "3 4\n1 1\n1 2\n1 3",
"output": "NO"
},
{
"input": "1 5\n5 1 2 3 4 5",
"output": "YES"
},
{
"input": "1 5\n5 4 4 1 2 3",
"output": "NO"
},... | 1,605,010,554 | 2,147,483,647 | PyPy 3 | RUNTIME_ERROR | TESTS | 0 | 202 | 2,150,400 | a,b=map(int,input().split())
list=[]
for i in range(a):
d=input().split()
list.append(d)
if len(set(list))==b:
print('YES')
else:
print('NO') | Title: Bulbs
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vasya wants to turn on Christmas lights consisting of *m* bulbs. Initially, all bulbs are turned off. There are *n* buttons, each of them is connected to some set of bulbs. Vasya can press any of these buttons. When the button is... | ```python
a,b=map(int,input().split())
list=[]
for i in range(a):
d=input().split()
list.append(d)
if len(set(list))==b:
print('YES')
else:
print('NO')
``` | -1 | |
460 | A | Vasya and Socks | PROGRAMMING | 900 | [
"brute force",
"implementation",
"math"
] | null | null | Vasya has *n* pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When he comes home in the evening, Vasya takes off the used socks and throws them away. Every *m*-th day (at days with numbers *m*,<=2*m*,<=3*m*,<=...) mom buys a pair of socks to Vasya. She does it la... | The single line contains two integers *n* and *m* (1<=≤<=*n*<=≤<=100; 2<=≤<=*m*<=≤<=100), separated by a space. | Print a single integer — the answer to the problem. | [
"2 2\n",
"9 3\n"
] | [
"3\n",
"13\n"
] | In the first sample Vasya spends the first two days wearing the socks that he had initially. Then on day three he puts on the socks that were bought on day two.
In the second sample Vasya spends the first nine days wearing the socks that he had initially. Then he spends three days wearing the socks that were bought on... | 500 | [
{
"input": "2 2",
"output": "3"
},
{
"input": "9 3",
"output": "13"
},
{
"input": "1 2",
"output": "1"
},
{
"input": "2 3",
"output": "2"
},
{
"input": "1 99",
"output": "1"
},
{
"input": "4 4",
"output": "5"
},
{
"input": "10 2",
"outp... | 1,638,962,598 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 1 | 1,000 | 0 | n = input().split()
d = 1
for i in range(2):
n[i] = int(n[i])
step = n[1]
n = n[0]
while n != 0:
n -= 1
d += 1
if n // step:
n += 1
print(d) | Title: Vasya and Socks
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vasya has *n* pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When he comes home in the evening, Vasya takes off the used socks and throws them away. Every *m*-th... | ```python
n = input().split()
d = 1
for i in range(2):
n[i] = int(n[i])
step = n[1]
n = n[0]
while n != 0:
n -= 1
d += 1
if n // step:
n += 1
print(d)
``` | 0 | |
142 | B | Help General | PROGRAMMING | 1,800 | [
"constructive algorithms",
"greedy",
"implementation"
] | null | null | Once upon a time in the Kingdom of Far Far Away lived Sir Lancelot, the chief Royal General. He was very proud of his men and he liked to invite the King to come and watch drill exercises which demonstrated the fighting techniques and tactics of the squad he was in charge of. But time went by and one day Sir Lancelot h... | The single line contains space-separated integers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=1000) that represent the size of the drill exercise field. | Print the desired maximum number of warriors. | [
"2 4\n",
"3 4\n"
] | [
"4",
"6"
] | In the first sample test Sir Lancelot can place his 4 soldiers on the 2 × 4 court as follows (the soldiers' locations are marked with gray circles on the scheme):
In the second sample test he can place 6 soldiers on the 3 × 4 site in the following manner: | 1,000 | [
{
"input": "2 4",
"output": "4"
},
{
"input": "3 4",
"output": "6"
},
{
"input": "4 4",
"output": "8"
},
{
"input": "4 3",
"output": "6"
},
{
"input": "4 2",
"output": "4"
},
{
"input": "1 1",
"output": "1"
},
{
"input": "3 5",
"output"... | 1,610,919,548 | 2,147,483,647 | PyPy 3 | RUNTIME_ERROR | TESTS | 0 | 248 | 2,252,800 | a=int(input())
b=int(input())
print (a*b//2) | Title: Help General
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Once upon a time in the Kingdom of Far Far Away lived Sir Lancelot, the chief Royal General. He was very proud of his men and he liked to invite the King to come and watch drill exercises which demonstrated the fighting te... | ```python
a=int(input())
b=int(input())
print (a*b//2)
``` | -1 | |
948 | A | Protect Sheep | PROGRAMMING | 900 | [
"brute force",
"dfs and similar",
"graphs",
"implementation"
] | null | null | Bob is a farmer. He has a large pasture with many sheep. Recently, he has lost some of them due to wolf attacks. He thus decided to place some shepherd dogs in such a way that all his sheep are protected.
The pasture is a rectangle consisting of *R*<=×<=*C* cells. Each cell is either empty, contains a sheep, a wolf or... | First line contains two integers *R* (1<=≤<=*R*<=≤<=500) and *C* (1<=≤<=*C*<=≤<=500), denoting the number of rows and the numbers of columns respectively.
Each of the following *R* lines is a string consisting of exactly *C* characters, representing one row of the pasture. Here, 'S' means a sheep, 'W' a wolf and '.' a... | If it is impossible to protect all sheep, output a single line with the word "No".
Otherwise, output a line with the word "Yes". Then print *R* lines, representing the pasture after placing dogs. Again, 'S' means a sheep, 'W' a wolf, 'D' is a dog and '.' an empty space. You are not allowed to move, remove or add a she... | [
"6 6\n..S...\n..S.W.\n.S....\n..W...\n...W..\n......\n",
"1 2\nSW\n",
"5 5\n.S...\n...S.\nS....\n...S.\n.S...\n"
] | [
"Yes\n..SD..\n..SDW.\n.SD...\n.DW...\nDD.W..\n......\n",
"No\n",
"Yes\n.S...\n...S.\nS.D..\n...S.\n.S...\n"
] | In the first example, we can split the pasture into two halves, one containing wolves and one containing sheep. Note that the sheep at (2,1) is safe, as wolves cannot move diagonally.
In the second example, there are no empty spots to put dogs that would guard the lone sheep.
In the third example, there are no wolves... | 500 | [
{
"input": "1 2\nSW",
"output": "No"
},
{
"input": "10 10\n....W.W.W.\n.........S\n.S.S...S..\nW.......SS\n.W..W.....\n.W...W....\nS..S...S.S\n....W...S.\n..S..S.S.S\nSS.......S",
"output": "Yes\nDDDDWDWDWD\nDDDDDDDDDS\nDSDSDDDSDD\nWDDDDDDDSS\nDWDDWDDDDD\nDWDDDWDDDD\nSDDSDDDSDS\nDDDDWDDDSD\nDDSD... | 1,605,194,677 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 0 | 108 | 0 | r, c = map(int, input().split())
s = []
error = False
for i in range(r):
s.append(input())
s[i] = s[i].replace('.','D')
if s.count('SW') >= 1 or s.count('WS') >= 1:
error = True
if error == True:
print('NO')
else:
for i in range(r):
for j in range(c):
if s[i]... | Title: Protect Sheep
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Bob is a farmer. He has a large pasture with many sheep. Recently, he has lost some of them due to wolf attacks. He thus decided to place some shepherd dogs in such a way that all his sheep are protected.
The pasture is ... | ```python
r, c = map(int, input().split())
s = []
error = False
for i in range(r):
s.append(input())
s[i] = s[i].replace('.','D')
if s.count('SW') >= 1 or s.count('WS') >= 1:
error = True
if error == True:
print('NO')
else:
for i in range(r):
for j in range(c):
... | 0 | |
125 | A | Measuring Lengths in Baden | PROGRAMMING | 1,400 | [
"math"
] | null | null | Lengths are measures in Baden in inches and feet. To a length from centimeters it is enough to know that an inch equals three centimeters in Baden and one foot contains 12 inches.
You are given a length equal to *n* centimeters. Your task is to convert it to feet and inches so that the number of feet was maximum. The ... | The only line contains an integer *n* (1<=≤<=*n*<=≤<=10000). | Print two non-negative space-separated integers *a* and *b*, where *a* is the numbers of feet and *b* is the number of inches. | [
"42\n",
"5\n"
] | [
"1 2\n",
"0 2\n"
] | none | 1,000 | [
{
"input": "42",
"output": "1 2"
},
{
"input": "5",
"output": "0 2"
},
{
"input": "24",
"output": "0 8"
},
{
"input": "1",
"output": "0 0"
},
{
"input": "2",
"output": "0 1"
},
{
"input": "3",
"output": "0 1"
},
{
"input": "4",
"output"... | 1,589,197,889 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 20 | 218 | 6,656,000 | n = int(input())
a = int(n / 36)
b = int(n % 36)
c = int(b / 3)
d = int(b % 3)
if d == 2:
c = c + 1
print(str(a) + " " + str(c))
| Title: Measuring Lengths in Baden
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Lengths are measures in Baden in inches and feet. To a length from centimeters it is enough to know that an inch equals three centimeters in Baden and one foot contains 12 inches.
You are given a length equa... | ```python
n = int(input())
a = int(n / 36)
b = int(n % 36)
c = int(b / 3)
d = int(b % 3)
if d == 2:
c = c + 1
print(str(a) + " " + str(c))
``` | 0 | |
868 | C | Qualification Rounds | PROGRAMMING | 1,500 | [
"bitmasks",
"brute force",
"constructive algorithms",
"dp"
] | null | null | Snark and Philip are preparing the problemset for the upcoming pre-qualification round for semi-quarter-finals. They have a bank of *n* problems, and they want to select any non-empty subset of it as a problemset.
*k* experienced teams are participating in the contest. Some of these teams already know some of the prob... | The first line contains two integers *n*, *k* (1<=≤<=*n*<=≤<=105, 1<=≤<=*k*<=≤<=4) — the number of problems and the number of experienced teams.
Each of the next *n* lines contains *k* integers, each equal to 0 or 1. The *j*-th number in the *i*-th line is 1 if *j*-th team knows *i*-th problem and 0 otherwise. | Print "YES" (quotes for clarity), if it is possible to make an interesting problemset, and "NO" otherwise.
You can print each character either upper- or lowercase ("YeS" and "yes" are valid when the answer is "YES"). | [
"5 3\n1 0 1\n1 1 0\n1 0 0\n1 0 0\n1 0 0\n",
"3 2\n1 0\n1 1\n0 1\n"
] | [
"NO\n",
"YES\n"
] | In the first example you can't make any interesting problemset, because the first team knows all problems.
In the second example you can choose the first and the third problems. | 1,000 | [
{
"input": "5 3\n1 0 1\n1 1 0\n1 0 0\n1 0 0\n1 0 0",
"output": "NO"
},
{
"input": "3 2\n1 0\n1 1\n0 1",
"output": "YES"
},
{
"input": "10 2\n1 0\n1 0\n0 0\n1 1\n0 0\n1 1\n0 0\n1 1\n0 1\n0 1",
"output": "YES"
},
{
"input": "10 3\n1 0 0\n0 1 1\n1 0 0\n0 1 0\n0 0 1\n1 0 1\n0 1 1... | 1,635,526,578 | 2,147,483,647 | Python 3 | OK | TESTS | 143 | 265 | 4,505,600 | # def qual(arr:list[list[int]]):
# hashmap={}
# for i in range(len(arr)):
# hashmap[i]=[]
# for j in range(len(arr[i])):
# if arr[i][j]==0:
#
# hashmap[i].append(j)
#
n,k=map(int,input().split())
s=set()
for i in range(n):
s.add(int("".join(map(str,inp... | Title: Qualification Rounds
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Snark and Philip are preparing the problemset for the upcoming pre-qualification round for semi-quarter-finals. They have a bank of *n* problems, and they want to select any non-empty subset of it as a problemset.
... | ```python
# def qual(arr:list[list[int]]):
# hashmap={}
# for i in range(len(arr)):
# hashmap[i]=[]
# for j in range(len(arr[i])):
# if arr[i][j]==0:
#
# hashmap[i].append(j)
#
n,k=map(int,input().split())
s=set()
for i in range(n):
s.add(int("".join(m... | 3 | |
4 | A | Watermelon | PROGRAMMING | 800 | [
"brute force",
"math"
] | A. Watermelon | 1 | 64 | One hot summer day Pete and his friend Billy decided to buy a watermelon. They chose the biggest and the ripest one, in their opinion. After that the watermelon was weighed, and the scales showed *w* kilos. They rushed home, dying of thirst, and decided to divide the berry, however they faced a hard problem.
Pete and ... | The first (and the only) input line contains integer number *w* (1<=≤<=*w*<=≤<=100) — the weight of the watermelon bought by the boys. | Print YES, if the boys can divide the watermelon into two parts, each of them weighing even number of kilos; and NO in the opposite case. | [
"8\n"
] | [
"YES\n"
] | For example, the boys can divide the watermelon into two parts of 2 and 6 kilos respectively (another variant — two parts of 4 and 4 kilos). | 0 | [
{
"input": "8",
"output": "YES"
},
{
"input": "5",
"output": "NO"
},
{
"input": "4",
"output": "YES"
},
{
"input": "3",
"output": "NO"
},
{
"input": "2",
"output": "NO"
},
{
"input": "1",
"output": "NO"
},
{
"input": "7",
"output": "NO"... | 1,692,035,190 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 30 | 0 | n=int(input())
for i in range(1,101):
if i%2==0:
print("YES")
else:
print("NO")
| Title: Watermelon
Time Limit: 1 seconds
Memory Limit: 64 megabytes
Problem Description:
One hot summer day Pete and his friend Billy decided to buy a watermelon. They chose the biggest and the ripest one, in their opinion. After that the watermelon was weighed, and the scales showed *w* kilos. They rushed home, dyin... | ```python
n=int(input())
for i in range(1,101):
if i%2==0:
print("YES")
else:
print("NO")
``` | 0 |
545 | C | Woodcutters | PROGRAMMING | 1,500 | [
"dp",
"greedy"
] | null | null | Little Susie listens to fairy tales before bed every day. Today's fairy tale was about wood cutters and the little girl immediately started imagining the choppers cutting wood. She imagined the situation that is described below.
There are *n* trees located along the road at points with coordinates *x*1,<=*x*2,<=...,<=... | The first line contains integer *n* (1<=≤<=*n*<=≤<=105) — the number of trees.
Next *n* lines contain pairs of integers *x**i*,<=*h**i* (1<=≤<=*x**i*,<=*h**i*<=≤<=109) — the coordinate and the height of the *і*-th tree.
The pairs are given in the order of ascending *x**i*. No two trees are located at the point with t... | Print a single number — the maximum number of trees that you can cut down by the given rules. | [
"5\n1 2\n2 1\n5 10\n10 9\n19 1\n",
"5\n1 2\n2 1\n5 10\n10 9\n20 1\n"
] | [
"3\n",
"4\n"
] | In the first sample you can fell the trees like that:
- fell the 1-st tree to the left — now it occupies segment [ - 1;1] - fell the 2-nd tree to the right — now it occupies segment [2;3] - leave the 3-rd tree — it occupies point 5 - leave the 4-th tree — it occupies point 10 - fell the 5-th tree to the right — ... | 1,750 | [
{
"input": "5\n1 2\n2 1\n5 10\n10 9\n19 1",
"output": "3"
},
{
"input": "5\n1 2\n2 1\n5 10\n10 9\n20 1",
"output": "4"
},
{
"input": "4\n10 4\n15 1\n19 3\n20 1",
"output": "4"
},
{
"input": "35\n1 7\n3 11\n6 12\n7 6\n8 5\n9 11\n15 3\n16 10\n22 2\n23 3\n25 7\n27 3\n34 5\n35 10... | 1,696,002,163 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 67 | 779 | 12,595,200 | n=int(input())
l=[]
d=[]
for i in range(n):
t1,t2=map(int,input().split())
l.append(t1)
d.append(t2)
if n>=2:
out=2
elif n<2:
out=n
for i in range(1,n-1):
if d[i]<l[i]-l[i-1]:
out+=1
elif d[i]<l[i+1]-l[i]:
out+=1
l[i]+=d[i]
print(out) | Title: Woodcutters
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Little Susie listens to fairy tales before bed every day. Today's fairy tale was about wood cutters and the little girl immediately started imagining the choppers cutting wood. She imagined the situation that is described b... | ```python
n=int(input())
l=[]
d=[]
for i in range(n):
t1,t2=map(int,input().split())
l.append(t1)
d.append(t2)
if n>=2:
out=2
elif n<2:
out=n
for i in range(1,n-1):
if d[i]<l[i]-l[i-1]:
out+=1
elif d[i]<l[i+1]-l[i]:
out+=1
l[i]+=d[i]
print(out)
``` | 3 | |
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,670,584,348 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 31 | 0 | import sys
tests=int(sys.stdin.readline().split()[0])
for test in range (tests):
numbers= [int(i) for i in sys.stdin.readline().split()]
n,m= numbers[0], numbers[1]
if (n%2==0) or (m%2==0):
print(n*m//2)
else:
print((n*m+1)//2)
| 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 sys
tests=int(sys.stdin.readline().split()[0])
for test in range (tests):
numbers= [int(i) for i in sys.stdin.readline().split()]
n,m= numbers[0], numbers[1]
if (n%2==0) or (m%2==0):
print(n*m//2)
else:
print((n*m+1)//2)
``` | -1 | |
592 | D | Super M | PROGRAMMING | 2,200 | [
"dfs and similar",
"dp",
"graphs",
"trees"
] | null | null | Ari the monster is not an ordinary monster. She is the hidden identity of Super M, the Byteforces’ superhero. Byteforces is a country that consists of *n* cities, connected by *n*<=-<=1 bidirectional roads. Every road connects exactly two distinct cities, and the whole road system is designed in a way that one is able ... | The first line of the input contains two integers *n* and *m* (1<=≤<=*m*<=≤<=*n*<=≤<=123456) - the number of cities in Byteforces, and the number of cities being attacked respectively.
Then follow *n*<=-<=1 lines, describing the road system. Each line contains two city numbers *u**i* and *v**i* (1<=≤<=*u**i*,<=*v**i*<... | First print the number of the city Super M should teleport to. If there are many possible optimal answers, print the one with the lowest city number.
Then print the minimum possible time needed to scare all humans in cities being attacked, measured in Krons.
Note that the correct answer is always unique. | [
"7 2\n1 2\n1 3\n1 4\n3 5\n3 6\n3 7\n2 7\n",
"6 4\n1 2\n2 3\n2 4\n4 5\n4 6\n2 4 5 6\n"
] | [
"2\n3\n",
"2\n4\n"
] | In the first sample, there are two possibilities to finish the Super M's job in 3 krons. They are:
<img align="middle" class="tex-formula" src="https://espresso.codeforces.com/93d3c0306b529e9c2324f68158ca2156587473a2.png" style="max-width: 100.0%;max-height: 100.0%;"/> and <img align="middle" class="tex-formula" src="... | 2,000 | [
{
"input": "7 2\n1 2\n1 3\n1 4\n3 5\n3 6\n3 7\n2 7",
"output": "2\n3"
},
{
"input": "6 4\n1 2\n2 3\n2 4\n4 5\n4 6\n2 4 5 6",
"output": "2\n4"
},
{
"input": "2 1\n2 1\n1",
"output": "1\n0"
},
{
"input": "1 1\n1",
"output": "1\n0"
},
{
"input": "10 2\n6 9\n6 2\n1 6\... | 1,446,388,287 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 794 | 21,606,400 | n, m = map(int, input().split())
vertices = [[] for i in range(n + 1)]
after = [True for i in range(n + 1)]
war = [False for i in range(n + 1)]
point = float('inf')
cnt, ans, ret = 0, 0, 0
for i in range(n - 1):
a, b = map(int, input().split())
vertices[a].append(b)
vertices[b].append(a)
d... | Title: Super M
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Ari the monster is not an ordinary monster. She is the hidden identity of Super M, the Byteforces’ superhero. Byteforces is a country that consists of *n* cities, connected by *n*<=-<=1 bidirectional roads. Every road connects ... | ```python
n, m = map(int, input().split())
vertices = [[] for i in range(n + 1)]
after = [True for i in range(n + 1)]
war = [False for i in range(n + 1)]
point = float('inf')
cnt, ans, ret = 0, 0, 0
for i in range(n - 1):
a, b = map(int, input().split())
vertices[a].append(b)
vertices[b].append(a... | 0 | |
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,686,486,044 | 2,147,483,647 | Python 3 | OK | TESTS | 101 | 92 | 0 | n = int(input())
p = list(map(int,input().split(' ')))
list1 = [0]*len(p)
for i in range(len(p)):
list1[p[i]-1] = i+1
s = ''
for j in range(len(list1)):
if j==len(list1):
s+=str(list1[j])
else:
s+=(str(list1[j])+' ')
print(s) | 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())
p = list(map(int,input().split(' ')))
list1 = [0]*len(p)
for i in range(len(p)):
list1[p[i]-1] = i+1
s = ''
for j in range(len(list1)):
if j==len(list1):
s+=str(list1[j])
else:
s+=(str(list1[j])+' ')
print(s)
``` | 3 | |
260 | A | Adding Digits | PROGRAMMING | 1,400 | [
"implementation",
"math"
] | null | null | Vasya has got two number: *a* and *b*. However, Vasya finds number *a* too short. So he decided to repeat the operation of lengthening number *a* *n* times.
One operation of lengthening a number means adding exactly one digit to the number (in the decimal notation) to the right provided that the resulting number is di... | The first line contains three integers: *a*,<=*b*,<=*n* (1<=≤<=*a*,<=*b*,<=*n*<=≤<=105). | In a single line print the integer without leading zeros, which Vasya can get when he applies the lengthening operations to number *a* *n* times. If no such number exists, then print number -1. If there are multiple possible answers, print any of them. | [
"5 4 5\n",
"12 11 1\n",
"260 150 10\n"
] | [
"524848\n",
"121\n",
"-1\n"
] | none | 500 | [
{
"input": "5 4 5",
"output": "524848"
},
{
"input": "12 11 1",
"output": "121"
},
{
"input": "260 150 10",
"output": "-1"
},
{
"input": "78843 5684 42717",
"output": "-1"
},
{
"input": "93248 91435 1133",
"output": "-1"
},
{
"input": "100000 10 64479"... | 1,606,040,851 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 0 | 109 | 0 | s,b,n=input().split()
add,n1,n,b='-1',0,int(n),int(b)
for i in range(0,9):
if int(s+str(i))%b==0:
add=str(i)
break
if add=='-1':print(-1)
else:
print(add)
while n1<n:
s+=add
n1+=1
print(int(s))
| Title: Adding Digits
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vasya has got two number: *a* and *b*. However, Vasya finds number *a* too short. So he decided to repeat the operation of lengthening number *a* *n* times.
One operation of lengthening a number means adding exactly one ... | ```python
s,b,n=input().split()
add,n1,n,b='-1',0,int(n),int(b)
for i in range(0,9):
if int(s+str(i))%b==0:
add=str(i)
break
if add=='-1':print(-1)
else:
print(add)
while n1<n:
s+=add
n1+=1
print(int(s))
``` | 0 | |
854 | B | Maxim Buys an Apartment | PROGRAMMING | 1,200 | [
"constructive algorithms",
"math"
] | null | null | Maxim wants to buy an apartment in a new house at Line Avenue of Metropolis. The house has *n* apartments that are numbered from 1 to *n* and are arranged in a row. Two apartments are adjacent if their indices differ by 1. Some of the apartments can already be inhabited, others are available for sale.
Maxim often visi... | The only line of the input contains two integers: *n* and *k* (1<=≤<=*n*<=≤<=109, 0<=≤<=*k*<=≤<=*n*). | Print the minimum possible and the maximum possible number of apartments good for Maxim. | [
"6 3\n"
] | [
"1 3\n"
] | In the sample test, the number of good apartments could be minimum possible if, for example, apartments with indices 1, 2 and 3 were inhabited. In this case only apartment 4 is good. The maximum possible number could be, for example, if apartments with indices 1, 3 and 5 were inhabited. In this case all other apartment... | 1,000 | [
{
"input": "6 3",
"output": "1 3"
},
{
"input": "10 1",
"output": "1 2"
},
{
"input": "10 9",
"output": "1 1"
},
{
"input": "8 0",
"output": "0 0"
},
{
"input": "8 8",
"output": "0 0"
},
{
"input": "966871928 890926970",
"output": "1 75944958"
},... | 1,675,021,284 | 1,764 | PyPy 3 | RUNTIME_ERROR | TESTS | 3 | 77 | 2,048,000 | n,m=map(int,input().split())
if n-m>=1:
print(1,end=' ')
else:
print(0,end=' ')
if n%m==1:
print(n-m)
elif n%m!=0 and n%2==0:
print(min(n-m,m)+1)
elif m*2+1<=n:
print(min((n-m),m)+1)
else:
print(min(n-m,m))
| Title: Maxim Buys an Apartment
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Maxim wants to buy an apartment in a new house at Line Avenue of Metropolis. The house has *n* apartments that are numbered from 1 to *n* and are arranged in a row. Two apartments are adjacent if their indices d... | ```python
n,m=map(int,input().split())
if n-m>=1:
print(1,end=' ')
else:
print(0,end=' ')
if n%m==1:
print(n-m)
elif n%m!=0 and n%2==0:
print(min(n-m,m)+1)
elif m*2+1<=n:
print(min((n-m),m)+1)
else:
print(min(n-m,m))
``` | -1 | |
534 | A | Exam | PROGRAMMING | 1,100 | [
"constructive algorithms",
"implementation",
"math"
] | null | null | An exam for *n* students will take place in a long and narrow room, so the students will sit in a line in some order. The teacher suspects that students with adjacent numbers (*i* and *i*<=+<=1) always studied side by side and became friends and if they take an exam sitting next to each other, they will help each other... | A single line contains integer *n* (1<=≤<=*n*<=≤<=5000) — the number of students at an exam. | In the first line print integer *k* — the maximum number of students who can be seated so that no two students with adjacent numbers sit next to each other.
In the second line print *k* distinct integers *a*1,<=*a*2,<=...,<=*a**k* (1<=≤<=*a**i*<=≤<=*n*), where *a**i* is the number of the student on the *i*-th position... | [
"6",
"3\n"
] | [
"6\n1 5 3 6 2 4",
"2\n1 3"
] | none | 500 | [
{
"input": "6",
"output": "6\n5 3 1 6 4 2 "
},
{
"input": "3",
"output": "2\n1 3"
},
{
"input": "1",
"output": "1\n1 "
},
{
"input": "2",
"output": "1\n1"
},
{
"input": "4",
"output": "4\n3 1 4 2 "
},
{
"input": "5",
"output": "5\n5 3 1 4 2 "
},
... | 1,601,836,913 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 93 | 307,200 | n=int(input())
if n==5:
print(1,4,2,5,3)
elif n==4:
print(3)
print(4,1,3)
elif n==3:
print(2)
print(1,3)
elif n==2 or n==1:
print(1)
print(1)
else:
l=[i for i in range(1,n+1)]
for i in range(1,n//2,2):
l[i],l[n//2+i]=l[n//2+i],l[i]
l[n//2],l[-1]=l[-1],l[n/... | Title: Exam
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
An exam for *n* students will take place in a long and narrow room, so the students will sit in a line in some order. The teacher suspects that students with adjacent numbers (*i* and *i*<=+<=1) always studied side by side and bec... | ```python
n=int(input())
if n==5:
print(1,4,2,5,3)
elif n==4:
print(3)
print(4,1,3)
elif n==3:
print(2)
print(1,3)
elif n==2 or n==1:
print(1)
print(1)
else:
l=[i for i in range(1,n+1)]
for i in range(1,n//2,2):
l[i],l[n//2+i]=l[n//2+i],l[i]
l[n//2],l[-1]=... | 0 | |
698 | A | Vacations | PROGRAMMING | 1,400 | [
"dp"
] | null | null | Vasya has *n* days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this *n* days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the *i*-th day there are four options:
1. on this day the gym is close... | The first line contains a positive integer *n* (1<=≤<=*n*<=≤<=100) — the number of days of Vasya's vacations.
The second line contains the sequence of integers *a*1,<=*a*2,<=...,<=*a**n* (0<=≤<=*a**i*<=≤<=3) separated by space, where:
- *a**i* equals 0, if on the *i*-th day of vacations the gym is closed and the co... | Print the minimum possible number of days on which Vasya will have a rest. Remember that Vasya refuses:
- to do sport on any two consecutive days, - to write the contest on any two consecutive days. | [
"4\n1 3 2 0\n",
"7\n1 3 3 2 1 2 3\n",
"2\n2 2\n"
] | [
"2\n",
"0\n",
"1\n"
] | In the first test Vasya can write the contest on the day number 1 and do sport on the day number 3. Thus, he will have a rest for only 2 days.
In the second test Vasya should write contests on days number 1, 3, 5 and 7, in other days do sport. Thus, he will not have a rest for a single day.
In the third test Vasya ca... | 500 | [
{
"input": "4\n1 3 2 0",
"output": "2"
},
{
"input": "7\n1 3 3 2 1 2 3",
"output": "0"
},
{
"input": "2\n2 2",
"output": "1"
},
{
"input": "1\n0",
"output": "1"
},
{
"input": "10\n0 0 1 1 0 0 0 0 1 0",
"output": "8"
},
{
"input": "100\n3 2 3 3 3 2 3 1 ... | 1,665,208,314 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 3 | 46 | 0 | n = int(input())
dni= input().split()[:n]
for i in range(len(dni)):
dni[i]=int(dni[i])
k=0
for i in range(0, n-1):
if dni[i+1]==3:
dni[i+1]=dni[i+1]-dni[i]
if dni[i+1]==0:
k+=1
if dni[i+1]==dni[i]:
k+=1
print(k)
| Title: Vacations
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vasya has *n* days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this *n* days: whether that gym opened and whether a contest was carried out in the Int... | ```python
n = int(input())
dni= input().split()[:n]
for i in range(len(dni)):
dni[i]=int(dni[i])
k=0
for i in range(0, n-1):
if dni[i+1]==3:
dni[i+1]=dni[i+1]-dni[i]
if dni[i+1]==0:
k+=1
if dni[i+1]==dni[i]:
k+=1
print(k)
``` | 0 | |
65 | A | Harry Potter and Three Spells | PROGRAMMING | 1,800 | [
"implementation",
"math"
] | A. Harry Potter and Three Spells | 2 | 256 | A long time ago (probably even in the first book), Nicholas Flamel, a great alchemist and the creator of the Philosopher's Stone, taught Harry Potter three useful spells. The first one allows you to convert *a* grams of sand into *b* grams of lead, the second one allows you to convert *c* grams of lead into *d* grams o... | The first line contains 6 integers *a*, *b*, *c*, *d*, *e*, *f* (0<=≤<=*a*,<=*b*,<=*c*,<=*d*,<=*e*,<=*f*<=≤<=1000). | Print "Ron", if it is possible to get an infinitely large amount of gold having a certain finite amount of sand (and not having any gold and lead at all), i.e., Ron is right. Otherwise, print "Hermione". | [
"100 200 250 150 200 250\n",
"100 50 50 200 200 100\n",
"100 10 200 20 300 30\n",
"0 0 0 0 0 0\n",
"1 1 0 1 1 1\n",
"1 0 1 2 1 2\n",
"100 1 100 1 0 1\n"
] | [
"Ron\n",
"Hermione\n",
"Hermione\n",
"Hermione\n",
"Ron\n",
"Hermione\n",
"Ron\n"
] | Consider the first sample. Let's start with the 500 grams of sand. Apply the first spell 5 times and turn the sand into 1000 grams of lead. Then apply the second spell 4 times to get 600 grams of gold. Let’s take 400 grams from the resulting amount of gold turn them back into sand. We get 500 grams of sand and 200 gram... | 500 | [
{
"input": "100 200 250 150 200 250",
"output": "Ron"
},
{
"input": "100 50 50 200 200 100",
"output": "Hermione"
},
{
"input": "100 10 200 20 300 30",
"output": "Hermione"
},
{
"input": "0 0 0 0 0 0",
"output": "Hermione"
},
{
"input": "1 1 0 1 1 1",
"output"... | 1,399,638,791 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 19 | 124 | 0 | a, b, c, d, e, f = map(int, input().split())
if b == 0 or d == 0 or f == 0:
print('Hermione')
elif a == 0 or c == 0 or e == 0:
print('Ron')
elif b/a * d/c * f/e > 1:
print('Ron')
else:
print('Hermione')
| Title: Harry Potter and Three Spells
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
A long time ago (probably even in the first book), Nicholas Flamel, a great alchemist and the creator of the Philosopher's Stone, taught Harry Potter three useful spells. The first one allows you to convert *a... | ```python
a, b, c, d, e, f = map(int, input().split())
if b == 0 or d == 0 or f == 0:
print('Hermione')
elif a == 0 or c == 0 or e == 0:
print('Ron')
elif b/a * d/c * f/e > 1:
print('Ron')
else:
print('Hermione')
``` | 0 |
108 | A | Palindromic Times | PROGRAMMING | 1,000 | [
"implementation",
"strings"
] | A. Palindromic Times | 2 | 256 | Tattah is asleep if and only if Tattah is attending a lecture. This is a well-known formula among Tattah's colleagues.
On a Wednesday afternoon, Tattah was attending Professor HH's lecture. At 12:21, right before falling asleep, he was staring at the digital watch around Saher's wrist. He noticed that the digits on th... | The first and only line of the input starts with a string with the format "HH:MM" where "HH" is from "00" to "23" and "MM" is from "00" to "59". Both "HH" and "MM" have exactly two digits. | Print the palindromic time of day that comes soonest after the time given in the input. If the input time is palindromic, output the soonest palindromic time after the input time. | [
"12:21\n",
"23:59\n"
] | [
"13:31\n",
"00:00\n"
] | none | 500 | [
{
"input": "12:21",
"output": "13:31"
},
{
"input": "23:59",
"output": "00:00"
},
{
"input": "15:51",
"output": "20:02"
},
{
"input": "10:44",
"output": "11:11"
},
{
"input": "04:02",
"output": "04:40"
},
{
"input": "02:11",
"output": "02:20"
},
... | 1,680,167,464 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 2 | 92 | 0 | def st():return str(input())
def ls():return list(map(int, input().split()))
def mx(a):return max(a)
def it():return int(input())
def mn(a):return min(a)
def yes():return print('YES')
def no():return print('NO')
def re(a):return range(a)
def pr(a):return print(a)
def prs(a):return print(str(a))
def mapa():ret... | Title: Palindromic Times
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Tattah is asleep if and only if Tattah is attending a lecture. This is a well-known formula among Tattah's colleagues.
On a Wednesday afternoon, Tattah was attending Professor HH's lecture. At 12:21, right before falling... | ```python
def st():return str(input())
def ls():return list(map(int, input().split()))
def mx(a):return max(a)
def it():return int(input())
def mn(a):return min(a)
def yes():return print('YES')
def no():return print('NO')
def re(a):return range(a)
def pr(a):return print(a)
def prs(a):return print(str(a))
def ... | 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,646,167,652 | 2,147,483,647 | Python 3 | OK | TESTS | 76 | 92 | 0 | def dfs(index):
visited[index] = 0
for i in range(n):
if((graph[i][0] == graph[index][0] or graph[i][1] == graph[index][1] ) and visited[i] == -1 ):
dfs(i)
n = int(input())
if(n >= 1 and n <= 100):
visited = []
graph = {}
count = -1
for i in range(n):
x, y = input().... | 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
def dfs(index):
visited[index] = 0
for i in range(n):
if((graph[i][0] == graph[index][0] or graph[i][1] == graph[index][1] ) and visited[i] == -1 ):
dfs(i)
n = int(input())
if(n >= 1 and n <= 100):
visited = []
graph = {}
count = -1
for i in range(n):
x, y ... | 3 | |
766 | B | Mahmoud and a Triangle | PROGRAMMING | 1,000 | [
"constructive algorithms",
"geometry",
"greedy",
"math",
"number theory",
"sortings"
] | null | null | Mahmoud has *n* line segments, the *i*-th of them has length *a**i*. Ehab challenged him to use exactly 3 line segments to form a non-degenerate triangle. Mahmoud doesn't accept challenges unless he is sure he can win, so he asked you to tell him if he should accept the challenge. Given the lengths of the line segments... | The first line contains single integer *n* (3<=≤<=*n*<=≤<=105) — the number of line segments Mahmoud has.
The second line contains *n* integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=109) — the lengths of line segments Mahmoud has. | In the only line print "YES" if he can choose exactly three line segments and form a non-degenerate triangle with them, and "NO" otherwise. | [
"5\n1 5 3 2 4\n",
"3\n4 1 2\n"
] | [
"YES\n",
"NO\n"
] | For the first example, he can use line segments with lengths 2, 4 and 5 to form a non-degenerate triangle. | 1,000 | [
{
"input": "5\n1 5 3 2 4",
"output": "YES"
},
{
"input": "3\n4 1 2",
"output": "NO"
},
{
"input": "30\n197 75 517 39724 7906061 1153471 3 15166 168284 3019844 272293 316 16 24548 42 118 5792 5 9373 1866366 4886214 24 2206 712886 104005 1363 836 64273 440585 3576",
"output": "NO"
},... | 1,681,820,076 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 87 | 187 | 13,926,400 | n = int(input())
a = list(sorted([int(i) for i in input().split()]))
flag = True
for i in range(2, n):
if a[i - 2] + a[i - 1] > a[i] and flag:
print('YES')
flag = False
if flag:
print('NO') | Title: Mahmoud and a Triangle
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Mahmoud has *n* line segments, the *i*-th of them has length *a**i*. Ehab challenged him to use exactly 3 line segments to form a non-degenerate triangle. Mahmoud doesn't accept challenges unless he is sure he ca... | ```python
n = int(input())
a = list(sorted([int(i) for i in input().split()]))
flag = True
for i in range(2, n):
if a[i - 2] + a[i - 1] > a[i] and flag:
print('YES')
flag = False
if flag:
print('NO')
``` | 3 | |
0 | none | none | none | 0 | [
"none"
] | null | null | Giant chess is quite common in Geraldion. We will not delve into the rules of the game, we'll just say that the game takes place on an *h*<=×<=*w* field, and it is painted in two colors, but not like in chess. Almost all cells of the field are white and only some of them are black. Currently Gerald is finishing a game ... | The first line of the input contains three integers: *h*,<=*w*,<=*n* — the sides of the board and the number of black cells (1<=≤<=*h*,<=*w*<=≤<=105,<=1<=≤<=*n*<=≤<=2000).
Next *n* lines contain the description of black cells. The *i*-th of these lines contains numbers *r**i*,<=*c**i* (1<=≤<=*r**i*<=≤<=*h*,<=1<=≤<=*c... | Print a single line — the remainder of the number of ways to move Gerald's pawn from the upper left to the lower right corner modulo 109<=+<=7. | [
"3 4 2\n2 2\n2 3\n",
"100 100 3\n15 16\n16 15\n99 88\n"
] | [
"2\n",
"545732279\n"
] | none | 0 | [
{
"input": "3 4 2\n2 2\n2 3",
"output": "2"
},
{
"input": "100 100 3\n15 16\n16 15\n99 88",
"output": "545732279"
},
{
"input": "1000 1000 4\n50 50\n51 50\n50 51\n51 51",
"output": "899660737"
},
{
"input": "100000 100000 4\n50001 50001\n50000 50000\n50000 50001\n50001 50000"... | 1,437,576,088 | 2,488 | Python 3 | WRONG_ANSWER | PRETESTS | 0 | 61 | 409,600 | from copy import copy
h, w, n = list(map(int, input().split()))
black = [list(map(int, input().split())) for i in range(n)]
prev = [0]*(w+1)
graph = [0]*(w+1)
graph[1] = 1
for row in range(1, len(graph)):
for column in range(1, w+1):
if [row, column] not in black and not (row == 1 and column == 1):
... | Title: none
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Giant chess is quite common in Geraldion. We will not delve into the rules of the game, we'll just say that the game takes place on an *h*<=×<=*w* field, and it is painted in two colors, but not like in chess. Almost all cells of ... | ```python
from copy import copy
h, w, n = list(map(int, input().split()))
black = [list(map(int, input().split())) for i in range(n)]
prev = [0]*(w+1)
graph = [0]*(w+1)
graph[1] = 1
for row in range(1, len(graph)):
for column in range(1, w+1):
if [row, column] not in black and not (row == 1 and column == 1)... | 0 | |
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,691,853,683 | 2,147,483,647 | PyPy 3 | OK | TESTS | 48 | 78 | 0 | import math
lst=list(map(int,input().split()))
lst.sort()
print(lst[-1]-lst[0])
| 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
import math
lst=list(map(int,input().split()))
lst.sort()
print(lst[-1]-lst[0])
``` | 3 | |
25 | A | IQ test | PROGRAMMING | 1,300 | [
"brute force"
] | A. IQ test | 2 | 256 | Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given *n* numbers differs from the others. Bob observed that one number usually differs from the others in evenness. Help Bob — to check his answers, he needs a program that among the given *n* numbers finds one that i... | The first line contains integer *n* (3<=≤<=*n*<=≤<=100) — amount of numbers in the task. The second line contains *n* space-separated natural numbers, not exceeding 100. It is guaranteed, that exactly one of these numbers differs from the others in evenness. | Output index of number that differs from the others in evenness. Numbers are numbered from 1 in the input order. | [
"5\n2 4 7 8 10\n",
"4\n1 2 1 1\n"
] | [
"3\n",
"2\n"
] | none | 0 | [
{
"input": "5\n2 4 7 8 10",
"output": "3"
},
{
"input": "4\n1 2 1 1",
"output": "2"
},
{
"input": "3\n1 2 2",
"output": "1"
},
{
"input": "3\n100 99 100",
"output": "2"
},
{
"input": "3\n5 3 2",
"output": "3"
},
{
"input": "4\n43 28 1 91",
"output"... | 1,570,463,441 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 186 | 0 | #IQTest.py
n = int(input())
arr = list(map(int, input().split()))
state = []
cOdd = 0
for x in range(n):
if arr[x] & 1:
cOdd += 1
state.append(1)
else:
state.append(0)
checkVal = 1
if cOdd >= 2:
checkVal = 0
#odd one out is even!
for x in range(n):
if state[... | 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
#IQTest.py
n = int(input())
arr = list(map(int, input().split()))
state = []
cOdd = 0
for x in range(n):
if arr[x] & 1:
cOdd += 1
state.append(1)
else:
state.append(0)
checkVal = 1
if cOdd >= 2:
checkVal = 0
#odd one out is even!
for x in range(n):
... | 0 |
784 | C | INTERCALC | PROGRAMMING | 1,800 | [
"*special",
"implementation"
] | null | null | DO YOU EXPECT ME TO FIND THIS OUT?
WHAT BASE AND/XOR LANGUAGE INCLUDES string?
DON'T BYTE OF MORE THAN YOU CAN CHEW
YOU CAN ONLY DISTORT THE LARGEST OF MATHEMATICS SO FAR
SAYING "ABRACADABRA" WITHOUT A MAGIC AND WON'T DO YOU ANY GOOD
THE LAST STACK RUPTURES. ALL DIE. OH, THE EMBARRASSMENT!
I HAVE NO ARRAY AND I M... | The first line of input data contains a single integer *n* (1<=≤<=*n*<=≤<=10).
The second line of input data contains *n* space-separated integers *a**i* (1<=≤<=*a**i*<=≤<=11). | Output a single integer. | [
"4\n2 5 3 1\n"
] | [
"4\n"
] | none | 0 | [
{
"input": "4\n2 5 3 1",
"output": "4"
},
{
"input": "2\n1 5",
"output": "0"
},
{
"input": "1\n8",
"output": "0"
},
{
"input": "6\n1 1 1 3 2 9",
"output": "0"
},
{
"input": "5\n8 9 3 1 9",
"output": "0"
},
{
"input": "6\n1 5 2 1 7 11",
"output": "0... | 1,491,725,999 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 30 | 4,608,000 | input()
a=list(map(int, input().split()))
for x in range(1, 100):
if x not in a:
print(x)
exit() | Title: INTERCALC
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
DO YOU EXPECT ME TO FIND THIS OUT?
WHAT BASE AND/XOR LANGUAGE INCLUDES string?
DON'T BYTE OF MORE THAN YOU CAN CHEW
YOU CAN ONLY DISTORT THE LARGEST OF MATHEMATICS SO FAR
SAYING "ABRACADABRA" WITHOUT A MAGIC AND WON'T DO ... | ```python
input()
a=list(map(int, input().split()))
for x in range(1, 100):
if x not in a:
print(x)
exit()
``` | 0 | |
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,679,764,661 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 60 | 0 | n=int(input())
print(input()[::-1][1::]) | 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())
print(input()[::-1][1::])
``` | 0 | |
721 | B | Passwords | PROGRAMMING | 1,100 | [
"implementation",
"math",
"sortings",
"strings"
] | null | null | Vanya is managed to enter his favourite site Codehorses. Vanya uses *n* distinct passwords for sites at all, however he can't remember which one exactly he specified during Codehorses registration.
Vanya will enter passwords in order of non-decreasing their lengths, and he will enter passwords of same length in arbitr... | The first line of the input contains two integers *n* and *k* (1<=≤<=*n*,<=*k*<=≤<=100) — the number of Vanya's passwords and the number of failed tries, after which the access to the site is blocked for 5 seconds.
The next *n* lines contains passwords, one per line — pairwise distinct non-empty strings consisting of ... | Print two integers — time (in seconds), Vanya needs to be authorized to Codehorses in the best case for him and in the worst case respectively. | [
"5 2\ncba\nabc\nbb1\nabC\nABC\nabc\n",
"4 100\n11\n22\n1\n2\n22\n"
] | [
"1 15\n",
"3 4\n"
] | Consider the first sample case. As soon as all passwords have the same length, Vanya can enter the right password at the first try as well as at the last try. If he enters it at the first try, he spends exactly 1 second. Thus in the best case the answer is 1. If, at the other hand, he enters it at the last try, he ente... | 1,000 | [
{
"input": "5 2\ncba\nabc\nbb1\nabC\nABC\nabc",
"output": "1 15"
},
{
"input": "4 100\n11\n22\n1\n2\n22",
"output": "3 4"
},
{
"input": "1 1\na1\na1",
"output": "1 1"
},
{
"input": "1 100\na1\na1",
"output": "1 1"
},
{
"input": "2 1\nabc\nAbc\nAbc",
"output": ... | 1,630,158,948 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 46 | 6,963,200 |
n,k=map(int,input().split())
l=(n+1)*[0]
for i in range(n+1):
s=input()
l[i]=len(s)
if l.count(l[-1])==n+1:
print(1,(n//k)*5+n)
else:
for i in range(n,0,-1):
if l[i]==l[i-1]:
print(i,(n//k)*5+n)
break | Title: Passwords
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vanya is managed to enter his favourite site Codehorses. Vanya uses *n* distinct passwords for sites at all, however he can't remember which one exactly he specified during Codehorses registration.
Vanya will enter passwords... | ```python
n,k=map(int,input().split())
l=(n+1)*[0]
for i in range(n+1):
s=input()
l[i]=len(s)
if l.count(l[-1])==n+1:
print(1,(n//k)*5+n)
else:
for i in range(n,0,-1):
if l[i]==l[i-1]:
print(i,(n//k)*5+n)
break
``` | 0 | |
897 | B | Chtholly's request | PROGRAMMING | 1,300 | [
"brute force"
] | null | null | — I experienced so many great things.
— You gave me memories like dreams... But I have to leave now...
— One last request, can you...
— Help me solve a Codeforces problem?
— ......
— What?
Chtholly has been thinking about a problem for days:
If a number is palindrome and length of its decimal representation with... | The first line contains two integers *k* and *p* (1<=≤<=*k*<=≤<=105,<=1<=≤<=*p*<=≤<=109). | Output single integer — answer to the problem. | [
"2 100\n",
"5 30\n"
] | [
"33\n",
"15\n"
] | In the first example, the smallest zcy number is 11, and the second smallest zcy number is 22.
In the second example, <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/68fffad54395f7d920ad0384e07c6215ddc64141.png" style="max-width: 100.0%;max-height: 100.0%;"/>. | 1,000 | [
{
"input": "2 100",
"output": "33"
},
{
"input": "5 30",
"output": "15"
},
{
"input": "42147 412393322",
"output": "251637727"
},
{
"input": "77809 868097296",
"output": "440411873"
},
{
"input": "5105 443422097",
"output": "363192634"
},
{
"input": "7... | 1,523,684,495 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 2 | 2,000 | 7,372,800 | masukkan = input().split()
k = int(masukkan[0])
p = int(masukkan[1])
loop = 0
i = 10
arr=[0]*k
while(loop != k):
i += 1
i = str(i)
count = 2
for j in range(0, count,1):
if(i[0] != i[len(i)-1]):
break
count += 2
if(count > len(i)):
arr[lo... | Title: Chtholly's request
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
— I experienced so many great things.
— You gave me memories like dreams... But I have to leave now...
— One last request, can you...
— Help me solve a Codeforces problem?
— ......
— What?
Chtholly has been thi... | ```python
masukkan = input().split()
k = int(masukkan[0])
p = int(masukkan[1])
loop = 0
i = 10
arr=[0]*k
while(loop != k):
i += 1
i = str(i)
count = 2
for j in range(0, count,1):
if(i[0] != i[len(i)-1]):
break
count += 2
if(count > len(i)):
... | 0 | |
59 | A | Word | PROGRAMMING | 800 | [
"implementation",
"strings"
] | A. Word | 2 | 256 | Vasya is very upset that many people on the Net mix uppercase and lowercase letters in one word. That's why he decided to invent an extension for his favorite browser that would change the letters' register in every word so that it either only consisted of lowercase letters or, vice versa, only of uppercase ones. At th... | The first line contains a word *s* — it consists of uppercase and lowercase Latin letters and possesses the length from 1 to 100. | Print the corrected word *s*. If the given word *s* has strictly more uppercase letters, make the word written in the uppercase register, otherwise - in the lowercase one. | [
"HoUse\n",
"ViP\n",
"maTRIx\n"
] | [
"house\n",
"VIP\n",
"matrix\n"
] | none | 500 | [
{
"input": "HoUse",
"output": "house"
},
{
"input": "ViP",
"output": "VIP"
},
{
"input": "maTRIx",
"output": "matrix"
},
{
"input": "BNHWpnpawg",
"output": "bnhwpnpawg"
},
{
"input": "VTYGP",
"output": "VTYGP"
},
{
"input": "CHNenu",
"output": "chn... | 1,677,331,478 | 2,147,483,647 | Python 3 | OK | TESTS | 30 | 92 | 0 | s = input("")
n = len(s)
l = 0
u = 0
for i in range(n):
if s[i].islower():
l += 1
else:
u += 1
if l>u or l==u:
s = s.lower()
else:
s = s.upper()
print(s)
| 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("")
n = len(s)
l = 0
u = 0
for i in range(n):
if s[i].islower():
l += 1
else:
u += 1
if l>u or l==u:
s = s.lower()
else:
s = s.upper()
print(s)
``` | 3.977 |
278 | A | Circle Line | PROGRAMMING | 800 | [
"implementation"
] | null | null | The circle line of the Berland subway has *n* stations. We know the distances between all pairs of neighboring stations:
- *d*1 is the distance between the 1-st and the 2-nd station;- *d*2 is the distance between the 2-nd and the 3-rd station;...- *d**n*<=-<=1 is the distance between the *n*<=-<=1-th and the *n*-th ... | The first line contains integer *n* (3<=≤<=*n*<=≤<=100) — the number of stations on the circle line. The second line contains *n* integers *d*1,<=*d*2,<=...,<=*d**n* (1<=≤<=*d**i*<=≤<=100) — the distances between pairs of neighboring stations. The third line contains two integers *s* and *t* (1<=≤<=*s*,<=*t*<=≤<=*n*) —... | Print a single number — the length of the shortest path between stations number *s* and *t*. | [
"4\n2 3 4 9\n1 3\n",
"4\n5 8 2 100\n4 1\n",
"3\n1 1 1\n3 1\n",
"3\n31 41 59\n1 1\n"
] | [
"5\n",
"15\n",
"1\n",
"0\n"
] | In the first sample the length of path 1 → 2 → 3 equals 5, the length of path 1 → 4 → 3 equals 13.
In the second sample the length of path 4 → 1 is 100, the length of path 4 → 3 → 2 → 1 is 15.
In the third sample the length of path 3 → 1 is 1, the length of path 3 → 2 → 1 is 2.
In the fourth sample the numbers of st... | 500 | [
{
"input": "4\n2 3 4 9\n1 3",
"output": "5"
},
{
"input": "4\n5 8 2 100\n4 1",
"output": "15"
},
{
"input": "3\n1 1 1\n3 1",
"output": "1"
},
{
"input": "3\n31 41 59\n1 1",
"output": "0"
},
{
"input": "5\n16 13 10 30 15\n4 2",
"output": "23"
},
{
"inpu... | 1,588,940,993 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 9 | 280 | 20,172,800 | n=int(input())
l=list(map(int,input().split()))
x,y=map(int,input().split())
x,y=x-1,y-1
d=[]
for i in range(n-1):
xx=l[i]
d.append(xx)
if(x==y):
print(0)
else:
s,c=0,0
if(x<y):
for i in range(x,y):
s=s+l[i]
j=x
while(l[j]!=l[y]):
c=c+... | Title: Circle Line
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The circle line of the Berland subway has *n* stations. We know the distances between all pairs of neighboring stations:
- *d*1 is the distance between the 1-st and the 2-nd station;- *d*2 is the distance between the 2-nd... | ```python
n=int(input())
l=list(map(int,input().split()))
x,y=map(int,input().split())
x,y=x-1,y-1
d=[]
for i in range(n-1):
xx=l[i]
d.append(xx)
if(x==y):
print(0)
else:
s,c=0,0
if(x<y):
for i in range(x,y):
s=s+l[i]
j=x
while(l[j]!=l[y]):
... | 0 | |
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,585,908,632 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 93 | 307,200 | n = int(input())
k = []
t = list(map(int, input().rstrip()))
for i in range(n):
if t[i] == 2:
k.append(2)
elif t[i] == 3:
k.append(3)
elif t[i] == 4:
k.append(3)
k.append(2)
k.append(2)
elif t[i] == 5:
k.append(3)
elif t[i] == 6:
... | Title: Drazil and Factorial
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Drazil is playing a math game with Varda.
Let's define for positive integer *x* as a product of factorials of its digits. For example, .
First, they choose a decimal number *a* consisting of *n* digits that cont... | ```python
n = int(input())
k = []
t = list(map(int, input().rstrip()))
for i in range(n):
if t[i] == 2:
k.append(2)
elif t[i] == 3:
k.append(3)
elif t[i] == 4:
k.append(3)
k.append(2)
k.append(2)
elif t[i] == 5:
k.append(3)
elif t[i] == 6... | 0 | |
69 | A | Young Physicist | PROGRAMMING | 1,000 | [
"implementation",
"math"
] | A. Young Physicist | 2 | 256 | A guy named Vasya attends the final grade of a high school. One day Vasya decided to watch a match of his favorite hockey team. And, as the boy loves hockey very much, even more than physics, he forgot to do the homework. Specifically, he forgot to complete his physics tasks. Next day the teacher got very angry at Vasy... | The first line contains a positive integer *n* (1<=≤<=*n*<=≤<=100), then follow *n* lines containing three integers each: the *x**i* coordinate, the *y**i* coordinate and the *z**i* coordinate of the force vector, applied to the body (<=-<=100<=≤<=*x**i*,<=*y**i*,<=*z**i*<=≤<=100). | Print the word "YES" if the body is in equilibrium, or the word "NO" if it is not. | [
"3\n4 1 7\n-2 4 -1\n1 -5 -3\n",
"3\n3 -1 7\n-5 2 -4\n2 -1 -3\n"
] | [
"NO",
"YES"
] | none | 500 | [
{
"input": "3\n4 1 7\n-2 4 -1\n1 -5 -3",
"output": "NO"
},
{
"input": "3\n3 -1 7\n-5 2 -4\n2 -1 -3",
"output": "YES"
},
{
"input": "10\n21 32 -46\n43 -35 21\n42 2 -50\n22 40 20\n-27 -9 38\n-4 1 1\n-40 6 -31\n-13 -2 34\n-21 34 -12\n-32 -29 41",
"output": "NO"
},
{
"input": "10... | 1,659,972,205 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 80 | 122 | 0 | total = 0
for i in range(int(input())):
data = input().split()
x = int(data[0])
y = int(data[1])
z = int(data[2])
total += x+y+z
if total != 0:
print("NO")
else:
print("YES") | Title: Young Physicist
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
A guy named Vasya attends the final grade of a high school. One day Vasya decided to watch a match of his favorite hockey team. And, as the boy loves hockey very much, even more than physics, he forgot to do the homework. S... | ```python
total = 0
for i in range(int(input())):
data = input().split()
x = int(data[0])
y = int(data[1])
z = int(data[2])
total += x+y+z
if total != 0:
print("NO")
else:
print("YES")
``` | 0 |
405 | B | Domino Effect | PROGRAMMING | 1,100 | [] | null | null | Little Chris knows there's no fun in playing dominoes, he thinks it's too random and doesn't require skill. Instead, he decided to play with the dominoes and make a "domino show".
Chris arranges *n* dominoes in a line, placing each piece vertically upright. In the beginning, he simultaneously pushes some of the domino... | The first line contains a single integer *n* (1<=≤<=*n*<=≤<=3000), the number of the dominoes in the line. The next line contains a character string *s* of length *n*. The *i*-th character of the string *s**i* is equal to
- "L", if the *i*-th domino has been pushed to the left; - "R", if the *i*-th domino has been ... | Output a single integer, the number of the dominoes that remain vertical at the end of the process. | [
"14\n.L.R...LR..L..\n",
"5\nR....\n",
"1\n.\n"
] | [
"4\n",
"0\n",
"1\n"
] | The first example case is shown on the figure. The four pieces that remain standing vertically are highlighted with orange.
In the second example case, all pieces fall down since the first piece topples all the other pieces.
In the last example case, a single piece has not been pushed in either direction. | 1,000 | [
{
"input": "14\n.L.R...LR..L..",
"output": "4"
},
{
"input": "1\n.",
"output": "1"
},
{
"input": "1\nL",
"output": "0"
},
{
"input": "1\nR",
"output": "0"
},
{
"input": "2\nL.",
"output": "1"
},
{
"input": "2\nRL",
"output": "0"
},
{
"input... | 1,694,612,034 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 61 | 62 | 1,638,400 | n=int(input())
s=input()
c=0
m,l,r=0,-1,-1
for i in range(n):
if c==0:
if s[i]=='R':
m+=i
c=1
r=i
elif s[i]=='L':
c=1
l=i
elif r>-1 and s[i]=='L':
if (i-r)%2==0:
m+=1
r=-1
l=i
el... | Title: Domino Effect
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Little Chris knows there's no fun in playing dominoes, he thinks it's too random and doesn't require skill. Instead, he decided to play with the dominoes and make a "domino show".
Chris arranges *n* dominoes in a line, p... | ```python
n=int(input())
s=input()
c=0
m,l,r=0,-1,-1
for i in range(n):
if c==0:
if s[i]=='R':
m+=i
c=1
r=i
elif s[i]=='L':
c=1
l=i
elif r>-1 and s[i]=='L':
if (i-r)%2==0:
m+=1
r=-1
l... | 3 | |
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,645,188,925 | 2,147,483,647 | Python 3 | COMPILATION_ERROR | TESTS | 0 | 0 | 0 | kelime=str(input())
Bharf=0
Kharf=0
for harf in kelime :
if harf.isupper() true :
Bharf=Bharf+1
else :
Kharf=Kharf+1
if BharF>Kharf :
print(kelime.upper)
else:print(kelime.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
kelime=str(input())
Bharf=0
Kharf=0
for harf in kelime :
if harf.isupper() true :
Bharf=Bharf+1
else :
Kharf=Kharf+1
if BharF>Kharf :
print(kelime.upper)
else:print(kelime.lower)
``` | -1 |
282 | A | Bit++ | PROGRAMMING | 800 | [
"implementation"
] | null | null | The classic programming language of Bitland is Bit++. This language is so peculiar and complicated.
The language is that peculiar as it has exactly one variable, called *x*. Also, there are two operations:
- Operation ++ increases the value of variable *x* by 1. - Operation -- decreases the value of variable *x* by... | The first line contains a single integer *n* (1<=≤<=*n*<=≤<=150) — the number of statements in the programme.
Next *n* lines contain a statement each. Each statement contains exactly one operation (++ or --) and exactly one variable *x* (denoted as letter «X»). Thus, there are no empty statements. The operation and th... | Print a single integer — the final value of *x*. | [
"1\n++X\n",
"2\nX++\n--X\n"
] | [
"1\n",
"0\n"
] | none | 500 | [
{
"input": "1\n++X",
"output": "1"
},
{
"input": "2\nX++\n--X",
"output": "0"
},
{
"input": "3\n++X\n++X\n++X",
"output": "3"
},
{
"input": "2\n--X\n--X",
"output": "-2"
},
{
"input": "5\n++X\n--X\n++X\n--X\n--X",
"output": "-1"
},
{
"input": "28\nX--\... | 1,697,466,527 | 2,147,483,647 | Python 3 | OK | TESTS | 36 | 46 | 0 | n=int(input())
sum=0
for _ in range(n):
str=input()
if(str=="++X") or (str=="X++"):
sum+=1
else:
sum-=1
print(sum) | Title: Bit++
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The classic programming language of Bitland is Bit++. This language is so peculiar and complicated.
The language is that peculiar as it has exactly one variable, called *x*. Also, there are two operations:
- Operation ++ incre... | ```python
n=int(input())
sum=0
for _ in range(n):
str=input()
if(str=="++X") or (str=="X++"):
sum+=1
else:
sum-=1
print(sum)
``` | 3 | |
218 | B | Airport | PROGRAMMING | 1,100 | [
"implementation"
] | null | null | Lolek and Bolek are about to travel abroad by plane. The local airport has a special "Choose Your Plane" offer. The offer's conditions are as follows:
- it is up to a passenger to choose a plane to fly on; - if the chosen plane has *x* (*x*<=><=0) empty seats at the given moment, then the ticket for such a plane ... | The first line contains two integers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=1000) — the number of passengers in the queue and the number of planes in the airport, correspondingly. The next line contains *m* integers *a*1,<=*a*2,<=...,<=*a**m* (1<=≤<=*a**i*<=≤<=1000) — *a**i* stands for the number of empty seats in the *i*-th... | Print two integers — the maximum and the minimum number of zlotys that the airport administration can earn, correspondingly. | [
"4 3\n2 1 1\n",
"4 3\n2 2 2\n"
] | [
"5 5\n",
"7 6\n"
] | In the first test sample the number of passengers is equal to the number of empty seats, so regardless of the way the planes are chosen, the administration will earn the same sum.
In the second sample the sum is maximized if the 1-st person in the queue buys a ticket to the 1-st plane, the 2-nd person — to the 2-nd pl... | 500 | [
{
"input": "4 3\n2 1 1",
"output": "5 5"
},
{
"input": "4 3\n2 2 2",
"output": "7 6"
},
{
"input": "10 5\n10 3 3 1 2",
"output": "58 26"
},
{
"input": "10 1\n10",
"output": "55 55"
},
{
"input": "10 1\n100",
"output": "955 955"
},
{
"input": "10 2\n4 7... | 1,632,307,400 | 2,147,483,647 | Python 3 | OK | TESTS | 33 | 186 | 6,963,200 | n,m = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = sorted(a)
k = n
mincount = 0
maxcount = 0
while k > 0:
t = b.index(min(b))
mincount += b[t]
k -=1
if b[t]-1 == 0:
b.remove(b[t])
else:
b[t] = b[t]-1
k = n
while k > 0:
t = a.index(ma... | Title: Airport
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Lolek and Bolek are about to travel abroad by plane. The local airport has a special "Choose Your Plane" offer. The offer's conditions are as follows:
- it is up to a passenger to choose a plane to fly on; - if the chosen pl... | ```python
n,m = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = sorted(a)
k = n
mincount = 0
maxcount = 0
while k > 0:
t = b.index(min(b))
mincount += b[t]
k -=1
if b[t]-1 == 0:
b.remove(b[t])
else:
b[t] = b[t]-1
k = n
while k > 0:
t = ... | 3 | |
723 | A | The New Year: Meeting Friends | PROGRAMMING | 800 | [
"implementation",
"math",
"sortings"
] | null | null | There are three friend living on the straight line *Ox* in Lineland. The first friend lives at the point *x*1, the second friend lives at the point *x*2, and the third friend lives at the point *x*3. They plan to celebrate the New Year together, so they need to meet at one point. What is the minimum total distance they... | The first line of the input contains three distinct integers *x*1, *x*2 and *x*3 (1<=≤<=*x*1,<=*x*2,<=*x*3<=≤<=100) — the coordinates of the houses of the first, the second and the third friends respectively. | Print one integer — the minimum total distance the friends need to travel in order to meet together. | [
"7 1 4\n",
"30 20 10\n"
] | [
"6\n",
"20\n"
] | In the first sample, friends should meet at the point 4. Thus, the first friend has to travel the distance of 3 (from the point 7 to the point 4), the second friend also has to travel the distance of 3 (from the point 1 to the point 4), while the third friend should not go anywhere because he lives at the point 4. | 500 | [
{
"input": "7 1 4",
"output": "6"
},
{
"input": "30 20 10",
"output": "20"
},
{
"input": "1 4 100",
"output": "99"
},
{
"input": "100 1 91",
"output": "99"
},
{
"input": "1 45 100",
"output": "99"
},
{
"input": "1 2 3",
"output": "2"
},
{
"... | 1,677,920,630 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 48 | 62 | 0 |
a, b, c = map(int, input().split())
print(max(a,b,c) - min(a,b,c))
| Title: The New Year: Meeting Friends
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
There are three friend living on the straight line *Ox* in Lineland. The first friend lives at the point *x*1, the second friend lives at the point *x*2, and the third friend lives at the point *x*3. They ... | ```python
a, b, c = map(int, input().split())
print(max(a,b,c) - min(a,b,c))
``` | 3 | |
522 | A | Reposts | PROGRAMMING | 1,200 | [
"*special",
"dfs and similar",
"dp",
"graphs",
"trees"
] | null | null | One day Polycarp published a funny picture in a social network making a poll about the color of his handle. Many of his friends started reposting Polycarp's joke to their news feed. Some of them reposted the reposts and so on.
These events are given as a sequence of strings "name1 reposted name2", where name1 is the n... | The first line of the input contains integer *n* (1<=≤<=*n*<=≤<=200) — the number of reposts. Next follow the reposts in the order they were made. Each of them is written on a single line and looks as "name1 reposted name2". All the names in the input consist of lowercase or uppercase English letters and/or digits and ... | Print a single integer — the maximum length of a repost chain. | [
"5\ntourist reposted Polycarp\nPetr reposted Tourist\nWJMZBMR reposted Petr\nsdya reposted wjmzbmr\nvepifanov reposted sdya\n",
"6\nMike reposted Polycarp\nMax reposted Polycarp\nEveryOne reposted Polycarp\n111 reposted Polycarp\nVkCup reposted Polycarp\nCodeforces reposted Polycarp\n",
"1\nSoMeStRaNgEgUe repos... | [
"6\n",
"2\n",
"2\n"
] | none | 500 | [
{
"input": "5\ntourist reposted Polycarp\nPetr reposted Tourist\nWJMZBMR reposted Petr\nsdya reposted wjmzbmr\nvepifanov reposted sdya",
"output": "6"
},
{
"input": "6\nMike reposted Polycarp\nMax reposted Polycarp\nEveryOne reposted Polycarp\n111 reposted Polycarp\nVkCup reposted Polycarp\nCodeforc... | 1,568,351,160 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 108 | 0 | n = int(input())
repost_height = {}
repost_height['polycarp'] = 1
for i in range(n):
repost = input()
person1, person2 = repost.split(' ')[0].lower(), repost.split(' ')[-1].lower()
if person2 in list(repost_height.keys()):
repost_height[person1] = repost_height[person2] + 1
print(repost_height[... | Title: Reposts
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
One day Polycarp published a funny picture in a social network making a poll about the color of his handle. Many of his friends started reposting Polycarp's joke to their news feed. Some of them reposted the reposts and so on.
... | ```python
n = int(input())
repost_height = {}
repost_height['polycarp'] = 1
for i in range(n):
repost = input()
person1, person2 = repost.split(' ')[0].lower(), repost.split(' ')[-1].lower()
if person2 in list(repost_height.keys()):
repost_height[person1] = repost_height[person2] + 1
print(repo... | 0 | |
593 | A | 2Char | PROGRAMMING | 1,200 | [
"brute force",
"implementation"
] | null | null | Andrew often reads articles in his favorite magazine 2Char. The main feature of these articles is that each of them uses at most two distinct letters. Andrew decided to send an article to the magazine, but as he hasn't written any article, he just decided to take a random one from magazine 26Char. However, before sendi... | The first line of the input contains number *n* (1<=≤<=*n*<=≤<=100) — the number of words in the article chosen by Andrew. Following are *n* lines, each of them contains one word. All the words consist only of small English letters and their total length doesn't exceed 1000. The words are not guaranteed to be distinct,... | Print a single integer — the maximum possible total length of words in Andrew's article. | [
"4\nabb\ncacc\naaa\nbbb\n",
"5\na\na\nbcbcb\ncdecdecdecdecdecde\naaaa\n"
] | [
"9",
"6"
] | In the first sample the optimal way to choose words is {'abb', 'aaa', 'bbb'}.
In the second sample the word 'cdecdecdecdecdecde' consists of three distinct letters, and thus cannot be used in the article. The optimal answer is {'a', 'a', 'aaaa'}. | 250 | [
{
"input": "4\nabb\ncacc\naaa\nbbb",
"output": "9"
},
{
"input": "5\na\na\nbcbcb\ncdecdecdecdecdecde\naaaa",
"output": "6"
},
{
"input": "1\na",
"output": "1"
},
{
"input": "2\nz\nz",
"output": "2"
},
{
"input": "5\nabcde\nfghij\nklmno\npqrst\nuvwxy",
"output"... | 1,681,149,340 | 2,147,483,647 | Python 3 | OK | TESTS | 49 | 46 | 0 | n = int(input())
w = []
for i in range(n):
wd = input()
w.append(wd)
length = 0
for i in range(26):
for j in range(i+1, 26):
c1, c2 = chr(i+97), chr(j+97)
total_len = 0
for wd in w:
v = True
for ch in wd:
if ch != c1 and ch != c2:
... | Title: 2Char
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Andrew often reads articles in his favorite magazine 2Char. The main feature of these articles is that each of them uses at most two distinct letters. Andrew decided to send an article to the magazine, but as he hasn't written an... | ```python
n = int(input())
w = []
for i in range(n):
wd = input()
w.append(wd)
length = 0
for i in range(26):
for j in range(i+1, 26):
c1, c2 = chr(i+97), chr(j+97)
total_len = 0
for wd in w:
v = True
for ch in wd:
if ch != c1 and ch != c2:
... | 3 | |
925 | B | Resource Distribution | PROGRAMMING | 1,700 | [
"binary search",
"implementation",
"sortings"
] | null | null | One department of some software company has $n$ servers of different specifications. Servers are indexed with consecutive integers from $1$ to $n$. Suppose that the specifications of the $j$-th server may be expressed with a single integer number $c_j$ of artificial resource units.
In order for production to work, it ... | The first line contains three integers $n$, $x_1$, $x_2$ ($2 \leq n \leq 300\,000$, $1 \leq x_1, x_2 \leq 10^9$) — the number of servers that the department may use, and resource units requirements for each of the services.
The second line contains $n$ space-separated integers $c_1, c_2, \ldots, c_n$ ($1 \leq c_i \leq... | If it is impossible to deploy both services using the given servers, print the only word "No" (without the quotes).
Otherwise print the word "Yes" (without the quotes).
In the second line print two integers $k_1$ and $k_2$ ($1 \leq k_1, k_2 \leq n$) — the number of servers used for each of the services.
In the thir... | [
"6 8 16\n3 5 2 9 8 7\n",
"4 20 32\n21 11 11 12\n",
"4 11 32\n5 5 16 16\n",
"5 12 20\n7 8 4 11 9\n"
] | [
"Yes\n3 2\n1 2 6\n5 4",
"Yes\n1 3\n1\n2 3 4\n",
"No\n",
"No\n"
] | In the first sample test each of the servers 1, 2 and 6 will will provide $8 / 3 = 2.(6)$ resource units and each of the servers 5, 4 will provide $16 / 2 = 8$ resource units.
In the second sample test the first server will provide $20$ resource units and each of the remaining servers will provide $32 / 3 = 10.(6)$ re... | 1,000 | [
{
"input": "6 8 16\n3 5 2 9 8 7",
"output": "Yes\n4 2\n3 1 2 6\n5 4"
},
{
"input": "4 20 32\n21 11 11 12",
"output": "Yes\n1 3\n1\n2 3 4"
},
{
"input": "4 11 32\n5 5 16 16",
"output": "No"
},
{
"input": "5 12 20\n7 8 4 11 9",
"output": "No"
},
{
"input": "2 1 1\n1... | 1,525,866,104 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 61 | 7,065,600 | from math import ceil
def merge(arr, l, m, r):
n1 = m - l + 1
n2 = r- m
# create temp arrays
L = [0] * (n1)
R = [0] * (n2)
# Copy data to temp arrays L[] and R[]
for i in range(0 , n1):
L[i] = arr[l + i]
for j in range(0 , n2):
R[j] = arr[m + 1 + j]
... | Title: Resource Distribution
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
One department of some software company has $n$ servers of different specifications. Servers are indexed with consecutive integers from $1$ to $n$. Suppose that the specifications of the $j$-th server may be expre... | ```python
from math import ceil
def merge(arr, l, m, r):
n1 = m - l + 1
n2 = r- m
# create temp arrays
L = [0] * (n1)
R = [0] * (n2)
# Copy data to temp arrays L[] and R[]
for i in range(0 , n1):
L[i] = arr[l + i]
for j in range(0 , n2):
R[j] = arr[m +... | 0 | |
195 | A | Let's Watch Football | PROGRAMMING | 1,000 | [
"binary search",
"brute force",
"math"
] | null | null | Valeric and Valerko missed the last Euro football game, so they decided to watch the game's key moments on the Net. They want to start watching as soon as possible but the connection speed is too low. If they turn on the video right now, it will "hang up" as the size of data to watch per second will be more than the si... | The first line contains three space-separated integers *a*, *b* and *c* (1<=≤<=*a*,<=*b*,<=*c*<=≤<=1000,<=*a*<=><=*b*). The first number (*a*) denotes the size of data needed to watch one second of the video. The second number (*b*) denotes the size of data Valeric and Valerko can download from the Net per second. T... | Print a single number — the minimum integer number of seconds that Valeric and Valerko must wait to watch football without pauses. | [
"4 1 1\n",
"10 3 2\n",
"13 12 1\n"
] | [
"3\n",
"5\n",
"1\n"
] | In the first sample video's length is 1 second and it is necessary 4 units of data for watching 1 second of video, so guys should download 4 · 1 = 4 units of data to watch the whole video. The most optimal way is to wait 3 seconds till 3 units of data will be downloaded and then start watching. While guys will be watch... | 500 | [
{
"input": "4 1 1",
"output": "3"
},
{
"input": "10 3 2",
"output": "5"
},
{
"input": "13 12 1",
"output": "1"
},
{
"input": "2 1 3",
"output": "3"
},
{
"input": "6 2 4",
"output": "8"
},
{
"input": "5 2 1",
"output": "2"
},
{
"input": "2 1... | 1,612,558,189 | 2,147,483,647 | Python 3 | OK | TESTS | 49 | 1,154 | 0 | tamanho_video_p_sg, tamanho_podem_baixar, duracao = input().split()
b = (int(tamanho_video_p_sg) * int(duracao)) #/int(tamanho_podem_baixar)
c = int(tamanho_podem_baixar)
aux = 0
aux2 = 0
while(True):
# if b > c or b > (c*int(duracao)):
if (c * int(duracao)) + aux2 < b:
aux = aux + 1
aux2 = aux... | Title: Let's Watch Football
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Valeric and Valerko missed the last Euro football game, so they decided to watch the game's key moments on the Net. They want to start watching as soon as possible but the connection speed is too low. If they turn ... | ```python
tamanho_video_p_sg, tamanho_podem_baixar, duracao = input().split()
b = (int(tamanho_video_p_sg) * int(duracao)) #/int(tamanho_podem_baixar)
c = int(tamanho_podem_baixar)
aux = 0
aux2 = 0
while(True):
# if b > c or b > (c*int(duracao)):
if (c * int(duracao)) + aux2 < b:
aux = aux + 1
... | 3 | |
540 | A | Combination Lock | PROGRAMMING | 800 | [
"implementation"
] | null | null | Scrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to put there the treasures that he's earned fair and square, he has to open the lock.
The combination lock is represented by *n* rotating disks with digits from 0 to 9 written on them. Scrooge McDuck has to turn ... | The first line contains a single integer *n* (1<=≤<=*n*<=≤<=1000) — the number of disks on the combination lock.
The second line contains a string of *n* digits — the original state of the disks.
The third line contains a string of *n* digits — Scrooge McDuck's combination that opens the lock. | Print a single integer — the minimum number of moves Scrooge McDuck needs to open the lock. | [
"5\n82195\n64723\n"
] | [
"13\n"
] | In the sample he needs 13 moves:
- 1 disk: <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/b8967f65a723782358b93eff9ce69f336817cf70.png" style="max-width: 100.0%;max-height: 100.0%;"/> - 2 disk: <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/07fa58573ece0d32... | 500 | [
{
"input": "5\n82195\n64723",
"output": "13"
},
{
"input": "12\n102021090898\n010212908089",
"output": "16"
},
{
"input": "1\n8\n1",
"output": "3"
},
{
"input": "2\n83\n57",
"output": "7"
},
{
"input": "10\n0728592530\n1362615763",
"output": "27"
},
{
... | 1,604,792,781 | 2,147,483,647 | Python 3 | OK | TESTS | 43 | 109 | 0 | n = int(input())
start = [int(x) for x in input()]
end = [int(x) for x in input()]
ans = 0
for i in range(n):
a = abs(start[i] - end[i])
b = start[i] + 10 - end[i]
c = end[i] + 10 - start[i]
ans += min(a, b, c)
print(ans) | Title: Combination Lock
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Scrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to put there the treasures that he's earned fair and square, he has to open the lock.
The combination lock is ... | ```python
n = int(input())
start = [int(x) for x in input()]
end = [int(x) for x in input()]
ans = 0
for i in range(n):
a = abs(start[i] - end[i])
b = start[i] + 10 - end[i]
c = end[i] + 10 - start[i]
ans += min(a, b, c)
print(ans)
``` | 3 | |
742 | A | Arpa’s hard exam and Mehrdad’s naive cheat | PROGRAMMING | 1,000 | [
"implementation",
"math",
"number theory"
] | null | null | There exists an island called Arpa’s land, some beautiful girls live there, as ugly ones do.
Mehrdad wants to become minister of Arpa’s land. Arpa has prepared an exam. Exam has only one question, given *n*, print the last digit of 1378*n*.
Mehrdad has become quite confused and wants you to help him. Please help, al... | The single line of input contains one integer *n* (0<=<=≤<=<=*n*<=<=≤<=<=109). | Print single integer — the last digit of 1378*n*. | [
"1\n",
"2\n"
] | [
"8",
"4"
] | In the first example, last digit of 1378<sup class="upper-index">1</sup> = 1378 is 8.
In the second example, last digit of 1378<sup class="upper-index">2</sup> = 1378·1378 = 1898884 is 4. | 500 | [
{
"input": "1",
"output": "8"
},
{
"input": "2",
"output": "4"
},
{
"input": "1000",
"output": "6"
},
{
"input": "3",
"output": "2"
},
{
"input": "4",
"output": "6"
},
{
"input": "1000000000",
"output": "6"
},
{
"input": "5",
"output": ... | 1,670,351,126 | 2,147,483,647 | PyPy 3-64 | TIME_LIMIT_EXCEEDED | TESTS | 5 | 1,000 | 24,985,600 | #author : Rohanbiswas
n = int(input())
print(pow(1378,n)%10)
| Title: Arpa’s hard exam and Mehrdad’s naive cheat
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
There exists an island called Arpa’s land, some beautiful girls live there, as ugly ones do.
Mehrdad wants to become minister of Arpa’s land. Arpa has prepared an exam. Exam has only one ques... | ```python
#author : Rohanbiswas
n = int(input())
print(pow(1378,n)%10)
``` | 0 | |
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,060 | 3,560 | Python 3 | WRONG_ANSWER | PRETESTS | 2 | 46 | 0 | x, y = [int(i) for i in input().split()]
a = []
for i in range(y):
a.append([int(i) for i in input().split()])
n = []
k = 1
while True:
z = True
for i in range(len(a)):
if not((a[i][1] - 1) * k < a[i][0] <= (a[i][1]) * k):
z = False
if z == True:
n.append(k)
... | 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
x, y = [int(i) for i in input().split()]
a = []
for i in range(y):
a.append([int(i) for i in input().split()])
n = []
k = 1
while True:
z = True
for i in range(len(a)):
if not((a[i][1] - 1) * k < a[i][0] <= (a[i][1]) * k):
z = False
if z == True:
n.appen... | 0 | |
703 | A | Mishka and Game | PROGRAMMING | 800 | [
"implementation"
] | null | null | Mishka is a little polar bear. As known, little bears loves spending their free time playing dice for chocolates. Once in a wonderful sunny morning, walking around blocks of ice, Mishka met her friend Chris, and they started playing the game.
Rules of the game are very simple: at first number of rounds *n* is defined.... | The first line of the input contains single integer *n* *n* (1<=≤<=*n*<=≤<=100) — the number of game rounds.
The next *n* lines contains rounds description. *i*-th of them contains pair of integers *m**i* and *c**i* (1<=≤<=*m**i*,<=<=*c**i*<=≤<=6) — values on dice upper face after Mishka's and Chris' throws in *i*-th ... | If Mishka is the winner of the game, print "Mishka" (without quotes) in the only line.
If Chris is the winner of the game, print "Chris" (without quotes) in the only line.
If the result of the game is draw, print "Friendship is magic!^^" (without quotes) in the only line. | [
"3\n3 5\n2 1\n4 2\n",
"2\n6 1\n1 6\n",
"3\n1 5\n3 3\n2 2\n"
] | [
"Mishka",
"Friendship is magic!^^",
"Chris"
] | In the first sample case Mishka loses the first round, but wins second and third rounds and thus she is the winner of the game.
In the second sample case Mishka wins the first round, Chris wins the second round, and the game ends with draw with score 1:1.
In the third sample case Chris wins the first round, but there... | 500 | [
{
"input": "3\n3 5\n2 1\n4 2",
"output": "Mishka"
},
{
"input": "2\n6 1\n1 6",
"output": "Friendship is magic!^^"
},
{
"input": "3\n1 5\n3 3\n2 2",
"output": "Chris"
},
{
"input": "6\n4 1\n4 2\n5 3\n5 1\n5 3\n4 1",
"output": "Mishka"
},
{
"input": "8\n2 4\n1 4\n1 ... | 1,688,450,253 | 2,147,483,647 | Python 3 | OK | TESTS | 69 | 46 | 0 | #https://codeforces.com/problemset/problem/703/A
t = int(input())
t2 = t
winM=0
winC=0
draw=0
while t > 0:
m, c = map(int, input().split())
if (m > c) :
winM += 1
elif (m < c):
winC += 1
elif (m == c):
draw += 1
t -= 1
if(draw== t2 or winM==winC):
pr... | Title: Mishka and Game
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Mishka is a little polar bear. As known, little bears loves spending their free time playing dice for chocolates. Once in a wonderful sunny morning, walking around blocks of ice, Mishka met her friend Chris, and they st... | ```python
#https://codeforces.com/problemset/problem/703/A
t = int(input())
t2 = t
winM=0
winC=0
draw=0
while t > 0:
m, c = map(int, input().split())
if (m > c) :
winM += 1
elif (m < c):
winC += 1
elif (m == c):
draw += 1
t -= 1
if(draw== t2 or winM==winC):
... | 3 | |
932 | A | Palindromic Supersequence | PROGRAMMING | 800 | [
"constructive algorithms"
] | null | null | You are given a string *A*. Find a string *B*, where *B* is a palindrome and *A* is a subsequence of *B*.
A subsequence of a string is a string that can be derived from it by deleting some (not necessarily consecutive) characters without changing the order of the remaining characters. For example, "cotst" is a subsequ... | First line contains a string *A* (1<=≤<=|*A*|<=≤<=103) consisting of lowercase Latin letters, where |*A*| is a length of *A*. | Output single line containing *B* consisting of only lowercase Latin letters. You do not need to find the shortest answer, the only restriction is that the length of string *B* should not exceed 104. If there are many possible *B*, print any of them. | [
"aba\n",
"ab\n"
] | [
"aba",
"aabaa"
] | In the first example, "aba" is a subsequence of "aba" which is a palindrome.
In the second example, "ab" is a subsequence of "aabaa" which is a palindrome. | 500 | [
{
"input": "aba",
"output": "abaaba"
},
{
"input": "ab",
"output": "abba"
},
{
"input": "krnyoixirslfszfqivgkaflgkctvbvksipwomqxlyqxhlbceuhbjbfnhofcgpgwdseffycthmlpcqejgskwjkbkbbmifnurnwyhevsoqzmtvzgfiqajfrgyuzxnrtxectcnlyoisbglpdbjbslxlpoymrcxmdtqhcnlvtqdwftuzgbdxsyscwbrguostbelnvtaqdmk... | 1,518,791,039 | 2,147,483,647 | Python 3 | OK | TESTS | 48 | 62 | 5,632,000 | A = input()
print(A+A[::-1]) | Title: Palindromic Supersequence
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given a string *A*. Find a string *B*, where *B* is a palindrome and *A* is a subsequence of *B*.
A subsequence of a string is a string that can be derived from it by deleting some (not necessarily co... | ```python
A = input()
print(A+A[::-1])
``` | 3 | |
62 | A | A Student's Dream | PROGRAMMING | 1,300 | [
"greedy",
"math"
] | A. A Student's Dream | 2 | 256 | Statistics claims that students sleep no more than three hours a day. But even in the world of their dreams, while they are snoring peacefully, the sense of impending doom is still upon them.
A poor student is dreaming that he is sitting the mathematical analysis exam. And he is examined by the most formidable profess... | The first line contains two positive integers not exceeding 100. They are the number of fingers on the Venusian girl's left and right hand correspondingly. The second line contains two integers not exceeding 100. They are the number of fingers on the Marsian boy's left and right hands correspondingly. | Print YES or NO, that is, the answer to Petr Palych's question. | [
"5 1\n10 5\n",
"4 5\n3 3\n",
"1 2\n11 6\n"
] | [
"YES",
"YES",
"NO"
] | The boy and the girl don't really care who goes to the left. | 500 | [
{
"input": "5 1\n10 5",
"output": "YES"
},
{
"input": "4 5\n3 3",
"output": "YES"
},
{
"input": "1 2\n11 6",
"output": "NO"
},
{
"input": "1 1\n1 1",
"output": "YES"
},
{
"input": "2 2\n1 1",
"output": "YES"
},
{
"input": "3 3\n1 1",
"output": "NO"... | 1,631,779,096 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 11 | 124 | 6,758,400 | pd,ld=list(map(int,input().split()))
pm,lm=list(map(int,input().split()))
if pd-lm==1 or pd-lm==0 or ld-pm==1 or ld-pm==0 or pm-ld==2 or \
pm-ld==1 or pm-ld==0 or lm-pd==2 or lm-pd==1 or lm-pd==0:
print("YES")
else:
print("NO") | Title: A Student's Dream
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Statistics claims that students sleep no more than three hours a day. But even in the world of their dreams, while they are snoring peacefully, the sense of impending doom is still upon them.
A poor student is dreaming t... | ```python
pd,ld=list(map(int,input().split()))
pm,lm=list(map(int,input().split()))
if pd-lm==1 or pd-lm==0 or ld-pm==1 or ld-pm==0 or pm-ld==2 or \
pm-ld==1 or pm-ld==0 or lm-pd==2 or lm-pd==1 or lm-pd==0:
print("YES")
else:
print("NO")
``` | 0 |
629 | A | Far Relative’s Birthday Cake | PROGRAMMING | 800 | [
"brute force",
"combinatorics",
"constructive algorithms",
"implementation"
] | null | null | Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a *n*<=×<=*n* square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly sta... | In the first line of the input, you are given a single integer *n* (1<=≤<=*n*<=≤<=100) — the length of the side of the cake.
Then follow *n* lines, each containing *n* characters. Empty cells are denoted with '.', while cells that contain chocolates are denoted by 'C'. | Print the value of Famil Door's happiness, i.e. the number of pairs of chocolate pieces that share the same row or the same column. | [
"3\n.CC\nC..\nC.C\n",
"4\nCC..\nC..C\n.CC.\n.CC.\n"
] | [
"4\n",
"9\n"
] | If we number rows from top to bottom and columns from left to right, then, pieces that share the same row in the first sample are:
1. (1, 2) and (1, 3) 1. (3, 1) and (3, 3) 1. (2, 1) and (3, 1) 1. (1, 3) and (3, 3) | 500 | [
{
"input": "3\n.CC\nC..\nC.C",
"output": "4"
},
{
"input": "4\nCC..\nC..C\n.CC.\n.CC.",
"output": "9"
},
{
"input": "5\n.CCCC\nCCCCC\n.CCC.\nCC...\n.CC.C",
"output": "46"
},
{
"input": "7\n.CC..CC\nCC.C..C\nC.C..C.\nC...C.C\nCCC.CCC\n.CC...C\n.C.CCC.",
"output": "84"
},... | 1,455,986,971 | 871 | Python 3 | WRONG_ANSWER | PRETESTS | 2 | 46 | 0 | #!/usr/bin/env python
import math
n = int(input())
l = []
for i in range(n):
l.append(input())
answer = 0
for s in l:
chocolate = 0
for c in s:
if c == 'C':
chocolate += 1
answer += int(math.factorial(chocolate) / 2)
for i in range(n):
chocolate = 0
for s in l:
if s[i... | Title: Far Relative’s Birthday Cake
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a *n*<=×<=*n* square consisting of equal squares with s... | ```python
#!/usr/bin/env python
import math
n = int(input())
l = []
for i in range(n):
l.append(input())
answer = 0
for s in l:
chocolate = 0
for c in s:
if c == 'C':
chocolate += 1
answer += int(math.factorial(chocolate) / 2)
for i in range(n):
chocolate = 0
for s in l:
... | 0 | |
766 | A | Mahmoud and Longest Uncommon Subsequence | PROGRAMMING | 1,000 | [
"constructive algorithms",
"strings"
] | null | null | While Mahmoud and Ehab were practicing for IOI, they found a problem which name was Longest common subsequence. They solved it, and then Ehab challenged Mahmoud with another problem.
Given two strings *a* and *b*, find the length of their longest uncommon subsequence, which is the longest string that is a subsequence ... | The first line contains string *a*, and the second line — string *b*. Both of these strings are non-empty and consist of lowercase letters of English alphabet. The length of each string is not bigger than 105 characters. | If there's no uncommon subsequence, print "-1". Otherwise print the length of the longest uncommon subsequence of *a* and *b*. | [
"abcd\ndefgh\n",
"a\na\n"
] | [
"5\n",
"-1\n"
] | In the first example: you can choose "defgh" from string *b* as it is the longest subsequence of string *b* that doesn't appear as a subsequence of string *a*. | 500 | [
{
"input": "abcd\ndefgh",
"output": "5"
},
{
"input": "a\na",
"output": "-1"
},
{
"input": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaacccccccccccccccccccccccccccccccccccccccccccccccccc\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaadddddddddddddddddddddddddddddddddddddddddddd... | 1,675,488,273 | 2,147,483,647 | Python 3 | OK | TESTS | 73 | 46 | 4,710,400 | # Online Python compiler (interpreter) to run Python online.
# Write Python 3 code in this online editor and run it.
str1 = input()
str2 = input()
if str1 == str2:
print(-1)
else:
print(max(len(str1), len(str2)))
| Title: Mahmoud and Longest Uncommon Subsequence
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
While Mahmoud and Ehab were practicing for IOI, they found a problem which name was Longest common subsequence. They solved it, and then Ehab challenged Mahmoud with another problem.
Given two ... | ```python
# Online Python compiler (interpreter) to run Python online.
# Write Python 3 code in this online editor and run it.
str1 = input()
str2 = input()
if str1 == str2:
print(-1)
else:
print(max(len(str1), len(str2)))
``` | 3 | |
591 | A | Wizards' Duel | PROGRAMMING | 900 | [
"implementation",
"math"
] | null | null | Harry Potter and He-Who-Must-Not-Be-Named engaged in a fight to the death once again. This time they are located at opposite ends of the corridor of length *l*. Two opponents simultaneously charge a deadly spell in the enemy. We know that the impulse of Harry's magic spell flies at a speed of *p* meters per second, and... | The first line of the input contains a single integer *l* (1<=≤<=*l*<=≤<=1<=000) — the length of the corridor where the fight takes place.
The second line contains integer *p*, the third line contains integer *q* (1<=≤<=*p*,<=*q*<=≤<=500) — the speeds of magical impulses for Harry Potter and He-Who-Must-Not-Be-Named, ... | Print a single real number — the distance from the end of the corridor, where Harry is located, to the place of the second meeting of the spell impulses. Your answer will be considered correct if its absolute or relative error will not exceed 10<=-<=4.
Namely: let's assume that your answer equals *a*, and the answer ... | [
"100\n50\n50\n",
"199\n60\n40\n"
] | [
"50\n",
"119.4\n"
] | In the first sample the speeds of the impulses are equal, so both of their meetings occur exactly in the middle of the corridor. | 500 | [
{
"input": "100\n50\n50",
"output": "50"
},
{
"input": "199\n60\n40",
"output": "119.4"
},
{
"input": "1\n1\n1",
"output": "0.5"
},
{
"input": "1\n1\n500",
"output": "0.001996007984"
},
{
"input": "1\n500\n1",
"output": "0.998003992"
},
{
"input": "1\n... | 1,614,463,756 | 2,147,483,647 | Python 3 | OK | TESTS | 45 | 62 | 0 | def solve(l,p,q):
t = l / (p+q)
return round(t*p,4)
def main() :
l = int(input())
p = int(input())
q = int(input())
print(solve(l,p,q))
main()
| Title: Wizards' Duel
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Harry Potter and He-Who-Must-Not-Be-Named engaged in a fight to the death once again. This time they are located at opposite ends of the corridor of length *l*. Two opponents simultaneously charge a deadly spell in the en... | ```python
def solve(l,p,q):
t = l / (p+q)
return round(t*p,4)
def main() :
l = int(input())
p = int(input())
q = int(input())
print(solve(l,p,q))
main()
``` | 3 | |
709 | A | Juicer | PROGRAMMING | 900 | [
"implementation"
] | null | null | Kolya is going to make fresh orange juice. He has *n* oranges of sizes *a*1,<=*a*2,<=...,<=*a**n*. Kolya will put them in the juicer in the fixed order, starting with orange of size *a*1, then orange of size *a*2 and so on. To be put in the juicer the orange must have size not exceeding *b*, so if Kolya sees an orange ... | The first line of the input contains three integers *n*, *b* and *d* (1<=≤<=*n*<=≤<=100<=000, 1<=≤<=*b*<=≤<=*d*<=≤<=1<=000<=000) — the number of oranges, the maximum size of the orange that fits in the juicer and the value *d*, which determines the condition when the waste section should be emptied.
The second line co... | Print one integer — the number of times Kolya will have to empty the waste section. | [
"2 7 10\n5 6\n",
"1 5 10\n7\n",
"3 10 10\n5 7 7\n",
"1 1 1\n1\n"
] | [
"1\n",
"0\n",
"1\n",
"0\n"
] | In the first sample, Kolya will squeeze the juice from two oranges and empty the waste section afterwards.
In the second sample, the orange won't fit in the juicer so Kolya will have no juice at all. | 500 | [
{
"input": "2 7 10\n5 6",
"output": "1"
},
{
"input": "1 5 10\n7",
"output": "0"
},
{
"input": "3 10 10\n5 7 7",
"output": "1"
},
{
"input": "1 1 1\n1",
"output": "0"
},
{
"input": "2 951637 951638\n44069 951637",
"output": "1"
},
{
"input": "50 100 12... | 1,676,640,342 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 4 | 93 | 6,963,200 | list_in = [int(x) for x in input().split(' ')]
list_a = [int(x) for x in input().split(' ')]
b = list_in[1]
d = list_in[2]
sum = 0
num = 0
for a in list_a:
if a <= b:
sum += a
if sum > d:
sum -= d
num += 1
print(num) | Title: Juicer
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Kolya is going to make fresh orange juice. He has *n* oranges of sizes *a*1,<=*a*2,<=...,<=*a**n*. Kolya will put them in the juicer in the fixed order, starting with orange of size *a*1, then orange of size *a*2 and so on. To b... | ```python
list_in = [int(x) for x in input().split(' ')]
list_a = [int(x) for x in input().split(' ')]
b = list_in[1]
d = list_in[2]
sum = 0
num = 0
for a in list_a:
if a <= b:
sum += a
if sum > d:
sum -= d
num += 1
print(num)
``` | 0 | |
70 | A | Cookies | PROGRAMMING | 1,300 | [
"math"
] | A. Cookies | 1 | 256 | Fangy collects cookies. Once he decided to take a box and put cookies into it in some way. If we take a square *k*<=×<=*k* in size, divided into blocks 1<=×<=1 in size and paint there the main diagonal together with cells, which lie above it, then the painted area will be equal to the area occupied by one cookie *k* in... | The first line contains a single integer *n* (0<=≤<=*n*<=≤<=1000). | Print the single number, equal to the number of empty cells in the box. The answer should be printed modulo 106<=+<=3. | [
"3\n"
] | [
"9"
] | If the box possesses the base of 2<sup class="upper-index">3</sup> × 2<sup class="upper-index">3</sup> (as in the example), then the cookies will be put there in the following manner: | 500 | [
{
"input": "3",
"output": "9"
},
{
"input": "1",
"output": "1"
},
{
"input": "2",
"output": "3"
},
{
"input": "4",
"output": "27"
},
{
"input": "6",
"output": "243"
},
{
"input": "11",
"output": "59049"
},
{
"input": "14",
"output": "59... | 1,692,176,311 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 31 | 0 | # LUOGU_RID: 121238263
import math
n=int(input())
print(math.pow(3,n-1,1000003)) | Title: Cookies
Time Limit: 1 seconds
Memory Limit: 256 megabytes
Problem Description:
Fangy collects cookies. Once he decided to take a box and put cookies into it in some way. If we take a square *k*<=×<=*k* in size, divided into blocks 1<=×<=1 in size and paint there the main diagonal together with cells, which li... | ```python
# LUOGU_RID: 121238263
import math
n=int(input())
print(math.pow(3,n-1,1000003))
``` | -1 |
705 | A | Hulk | PROGRAMMING | 800 | [
"implementation"
] | null | null | Dr. Bruce Banner hates his enemies (like others don't). As we all know, he can barely talk when he turns into the incredible Hulk. That's why he asked you to help him to express his feelings.
Hulk likes the Inception so much, and like that his feelings are complicated. They have *n* layers. The first layer is hate, se... | The only line of the input contains a single integer *n* (1<=≤<=*n*<=≤<=100) — the number of layers of love and hate. | Print Dr.Banner's feeling in one line. | [
"1\n",
"2\n",
"3\n"
] | [
"I hate it\n",
"I hate that I love it\n",
"I hate that I love that I hate it\n"
] | none | 500 | [
{
"input": "1",
"output": "I hate it"
},
{
"input": "2",
"output": "I hate that I love it"
},
{
"input": "3",
"output": "I hate that I love that I hate it"
},
{
"input": "4",
"output": "I hate that I love that I hate that I love it"
},
{
"input": "5",
"output"... | 1,685,647,486 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 21 | 62 | 0 | n = int(input())
for i in range(n):
if i % 2 == 0:
print('I hate', end=' ')
else:
print('I love', end=' ')
if i == n - 1:
print('it')
else:
print('that', end=' ') | Title: Hulk
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Dr. Bruce Banner hates his enemies (like others don't). As we all know, he can barely talk when he turns into the incredible Hulk. That's why he asked you to help him to express his feelings.
Hulk likes the Inception so much, and... | ```python
n = int(input())
for i in range(n):
if i % 2 == 0:
print('I hate', end=' ')
else:
print('I love', end=' ')
if i == n - 1:
print('it')
else:
print('that', end=' ')
``` | 3 | |
0 | none | none | none | 0 | [
"none"
] | null | null | Limak is a little polar bear. He doesn't have many toys and thus he often plays with polynomials.
He considers a polynomial valid if its degree is *n* and its coefficients are integers not exceeding *k* by the absolute value. More formally:
Let *a*0,<=*a*1,<=...,<=*a**n* denote the coefficients, so . Then, a polynomi... | The first line contains two integers *n* and *k* (1<=≤<=*n*<=≤<=200<=000,<=1<=≤<=*k*<=≤<=109) — the degree of the polynomial and the limit for absolute values of coefficients.
The second line contains *n*<=+<=1 integers *a*0,<=*a*1,<=...,<=*a**n* (|*a**i*|<=≤<=*k*,<=*a**n*<=≠<=0) — describing a valid polynomial . It's... | Print the number of ways to change one coefficient to get a valid polynomial *Q* that *Q*(2)<==<=0. | [
"3 1000000000\n10 -9 -3 5\n",
"3 12\n10 -9 -3 5\n",
"2 20\n14 -7 19\n"
] | [
"3\n",
"2\n",
"0\n"
] | In the first sample, we are given a polynomial *P*(*x*) = 10 - 9*x* - 3*x*<sup class="upper-index">2</sup> + 5*x*<sup class="upper-index">3</sup>.
Limak can change one coefficient in three ways:
1. He can set *a*<sub class="lower-index">0</sub> = - 10. Then he would get *Q*(*x*) = - 10 - 9*x* - 3*x*<sup class="upp... | 0 | [
{
"input": "3 1000000000\n10 -9 -3 5",
"output": "3"
},
{
"input": "3 12\n10 -9 -3 5",
"output": "2"
},
{
"input": "2 20\n14 -7 19",
"output": "0"
},
{
"input": "5 5\n0 -4 -2 -2 0 5",
"output": "1"
},
{
"input": "6 10\n-2 -1 7 -3 2 7 -6",
"output": "2"
},
... | 1,459,189,125 | 6,225 | Python 3 | WRONG_ANSWER | PRETESTS | 4 | 61 | 5,222,400 | n,k=map(int,input().split())
val=0;
A=list(map(int,input().split()))
B=list()
res=1;
for i in range (0,n+1):
Y=res*A[i];
val=val+Y;
res=res*2;
Ans=0;
res=1;
for i in range (0,n+1):
Sex=val-A[i]*res;
Sex=Sex*(-1);
T=Sex/res;
if(T<0):
T=T*(-1);
if(Sex%res==0 and T<... | Title: none
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Limak is a little polar bear. He doesn't have many toys and thus he often plays with polynomials.
He considers a polynomial valid if its degree is *n* and its coefficients are integers not exceeding *k* by the absolute value. Mor... | ```python
n,k=map(int,input().split())
val=0;
A=list(map(int,input().split()))
B=list()
res=1;
for i in range (0,n+1):
Y=res*A[i];
val=val+Y;
res=res*2;
Ans=0;
res=1;
for i in range (0,n+1):
Sex=val-A[i]*res;
Sex=Sex*(-1);
T=Sex/res;
if(T<0):
T=T*(-1);
if(Sex%res... | 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,476,972,753 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 6 | 61 | 0 | n=int(input())
p=[0]*n
for i in range(n):
p[i]=input()
compteur=0
for i in range(n):
if i<n-compteur-1:
if p.count(p[i])>1:
p.remove(p[i])
compteur+=1
r=len(p)
for i in range(r):
print(p[r-1-i], end="\n")
| 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
n=int(input())
p=[0]*n
for i in range(n):
p[i]=input()
compteur=0
for i in range(n):
if i<n-compteur-1:
if p.count(p[i])>1:
p.remove(p[i])
compteur+=1
r=len(p)
for i in range(r):
print(p[r-1-i], end="\n")
``` | 0 | |
227 | B | Effective Approach | PROGRAMMING | 1,100 | [
"implementation"
] | null | null | Once at a team training Vasya, Petya and Sasha got a problem on implementing linear search in an array.
According to the boys, linear search works as follows. The array elements in a pre-selected order are in turn compared with the number that you need to find. Once you find the array element that is equal to the requ... | The first line contains integer *n* (1<=≤<=*n*<=≤<=105) — the number of elements in the array. The second line contains *n* distinct space-separated integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=*n*) — the elements of array.
The third line contains integer *m* (1<=≤<=*m*<=≤<=105) — the number of queries. The ... | Print two integers, showing how many comparisons Vasya's approach needs and how many comparisons Petya's approach needs. Separate the numbers by spaces.
Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specifier. | [
"2\n1 2\n1\n1\n",
"2\n2 1\n1\n1\n",
"3\n3 1 2\n3\n1 2 3\n"
] | [
"1 2\n",
"2 1\n",
"6 6\n"
] | In the first sample Vasya's approach will make one comparison (it starts with the 1-st element and immediately finds the required number), and Petya's approach makes two comparisons (first he compares with the 2-nd array element, doesn't find the search item and compares with the 1-st element).
In the second sample, o... | 1,000 | [
{
"input": "2\n1 2\n1\n1",
"output": "1 2"
},
{
"input": "2\n2 1\n1\n1",
"output": "2 1"
},
{
"input": "3\n3 1 2\n3\n1 2 3",
"output": "6 6"
},
{
"input": "9\n2 9 3 1 6 4 7 8 5\n9\n5 1 5 2 8 4 4 4 5",
"output": "58 32"
},
{
"input": "10\n3 10 9 2 7 6 5 8 4 1\n1\n4... | 1,633,142,215 | 2,147,483,647 | PyPy 3 | TIME_LIMIT_EXCEEDED | TESTS | 6 | 2,000 | 33,484,800 | v = 0
p = 0
n = int(input())
a = list(map(int, input().split()))
x = int(input())
m = list(map(int, input().split()))
for b in m:
counter = 0
while a[counter] != b:
counter += 1
v += counter + 1
p += n - counter
print(v, p) | Title: Effective Approach
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Once at a team training Vasya, Petya and Sasha got a problem on implementing linear search in an array.
According to the boys, linear search works as follows. The array elements in a pre-selected order are in turn c... | ```python
v = 0
p = 0
n = int(input())
a = list(map(int, input().split()))
x = int(input())
m = list(map(int, input().split()))
for b in m:
counter = 0
while a[counter] != b:
counter += 1
v += counter + 1
p += n - counter
print(v, p)
``` | 0 | |
499 | A | Watching a movie | PROGRAMMING | 1,000 | [
"greedy",
"implementation"
] | null | null | You have decided to watch the best moments of some movie. There are two buttons on your player:
1. Watch the current minute of the movie. By pressing this button, you watch the current minute of the movie and the player automatically proceeds to the next minute of the movie. 1. Skip exactly *x* minutes of the movie... | The first line contains two space-separated integers *n*, *x* (1<=≤<=*n*<=≤<=50, 1<=≤<=*x*<=≤<=105) — the number of the best moments of the movie and the value of *x* for the second button.
The following *n* lines contain the descriptions of the best moments of the movie, the *i*-th line of the description contains tw... | Output a single number — the answer to the problem. | [
"2 3\n5 6\n10 12\n",
"1 1\n1 100000\n"
] | [
"6\n",
"100000\n"
] | In the first sample, the player was initially standing on the first minute. As the minutes from the 1-st to the 4-th one don't contain interesting moments, we press the second button. Now we can not press the second button and skip 3 more minutes, because some of them contain interesting moments. Therefore, we watch th... | 500 | [
{
"input": "2 3\n5 6\n10 12",
"output": "6"
},
{
"input": "1 1\n1 100000",
"output": "100000"
},
{
"input": "10 1\n2156 3497\n4784 7775\n14575 31932\n33447 35902\n36426 47202\n48772 60522\n63982 68417\n78537 79445\n90081 90629\n94325 95728",
"output": "53974"
},
{
"input": "1... | 1,592,758,278 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 93 | 0 | n,x=list(map(int,input().split()))
s=0
total_min=0
for i in range(n):
l,r=list(map(int,input().split()))
if (l-s)>x:
a=(l-s)//x
total_min+=(r-s)-(a*x)
s=r
else:
total_min+=(r-s)
s=r
print(total_min) | Title: Watching a movie
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You have decided to watch the best moments of some movie. There are two buttons on your player:
1. Watch the current minute of the movie. By pressing this button, you watch the current minute of the movie and the pl... | ```python
n,x=list(map(int,input().split()))
s=0
total_min=0
for i in range(n):
l,r=list(map(int,input().split()))
if (l-s)>x:
a=(l-s)//x
total_min+=(r-s)-(a*x)
s=r
else:
total_min+=(r-s)
s=r
print(total_min)
``` | 0 | |
681 | A | A Good Contest | PROGRAMMING | 800 | [
"implementation"
] | null | null | Codeforces user' handle color depends on his rating — it is red if his rating is greater or equal to 2400; it is orange if his rating is less than 2400 but greater or equal to 2200, etc. Each time participant takes part in a rated contest, his rating is changed depending on his performance.
Anton wants the color of hi... | The first line of the input contains a single integer *n* (1<=≤<=*n*<=≤<=100) — the number of participants Anton has outscored in this contest .
The next *n* lines describe participants results: the *i*-th of them consists of a participant handle *name**i* and two integers *before**i* and *after**i* (<=-<=4000<=≤<=*be... | Print «YES» (quotes for clarity), if Anton has performed good in the contest and «NO» (quotes for clarity) otherwise. | [
"3\nBurunduk1 2526 2537\nBudAlNik 2084 2214\nsubscriber 2833 2749\n",
"3\nApplejack 2400 2400\nFluttershy 2390 2431\nPinkie_Pie -2500 -2450\n"
] | [
"YES",
"NO"
] | In the first sample, Anton has outscored user with handle Burunduk1, whose handle was colored red before the contest and his rating has increased after the contest.
In the second sample, Applejack's rating has not increased after the contest, while both Fluttershy's and Pinkie_Pie's handles were not colored red before... | 500 | [
{
"input": "3\nBurunduk1 2526 2537\nBudAlNik 2084 2214\nsubscriber 2833 2749",
"output": "YES"
},
{
"input": "3\nApplejack 2400 2400\nFluttershy 2390 2431\nPinkie_Pie -2500 -2450",
"output": "NO"
},
{
"input": "1\nDb -3373 3591",
"output": "NO"
},
{
"input": "5\nQ2bz 960 2342... | 1,678,810,119 | 219 | PyPy 3 | OK | TESTS | 60 | 108 | 0 | import sys, os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
n = int(input())
ans = "NO"
for _ in range(n):
_, b, a = input().rstrip().decode().split()
if 2400 <= int(b) < int(a):
ans = "YES"
print(ans) | Title: A Good Contest
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Codeforces user' handle color depends on his rating — it is red if his rating is greater or equal to 2400; it is orange if his rating is less than 2400 but greater or equal to 2200, etc. Each time participant takes part ... | ```python
import sys, os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
n = int(input())
ans = "NO"
for _ in range(n):
_, b, a = input().rstrip().decode().split()
if 2400 <= int(b) < int(a):
ans = "YES"
print(ans)
``` | 3 | |
727 | C | Guess the Array | PROGRAMMING | 1,400 | [
"constructive algorithms",
"interactive",
"math"
] | null | null | This is an interactive problem. You should use flush operation after each printed line. For example, in C++ you should use fflush(stdout), in Java you should use System.out.flush(), and in Pascal — flush(output).
In this problem you should guess an array *a* which is unknown for you. The only information you have init... | none | none | [
"5\n \n9\n \n7\n \n9\n \n11\n \n6\n "
] | [
"? 1 5\n \n? 2 3\n \n? 4 1\n \n? 5 2\n \n? 3 4\n \n! 4 6 1 5 5"
] | The format of a test to make a hack is:
- The first line contains an integer number *n* (3 ≤ *n* ≤ 5000) — the length of the array.- The second line contains *n* numbers *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub> (1 ≤ *a*<sub class="lower-inde... | 1,500 | [
{
"input": "5\n4 6 1 5 5",
"output": "5 out of 5"
},
{
"input": "3\n1 1 1",
"output": "3 out of 3"
},
{
"input": "4\n100 1 100 1",
"output": "4 out of 4"
},
{
"input": "10\n9 5 10 7 4 4 8 5 10 5",
"output": "10 out of 10"
},
{
"input": "3\n1 1 1",
"output": "3... | 1,602,376,760 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 92 | 307,200 | # @author Nayara Souza
# UFCG - Universidade Federal de Campina Grande
# AA - Basico
n = int(input())
print('? 1 2')
a = int(input())
print('? 2 3')
b = int(input())
print('? 1 3')
c = int(input())
x = (a-b+c)//2
ans = [a-x,x,b-x]
for i in range(3,n):
print('? 1 '+ str(i) + ' ' + str(i+1))
w = in... | Title: Guess the Array
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
This is an interactive problem. You should use flush operation after each printed line. For example, in C++ you should use fflush(stdout), in Java you should use System.out.flush(), and in Pascal — flush(output).
In th... | ```python
# @author Nayara Souza
# UFCG - Universidade Federal de Campina Grande
# AA - Basico
n = int(input())
print('? 1 2')
a = int(input())
print('? 2 3')
b = int(input())
print('? 1 3')
c = int(input())
x = (a-b+c)//2
ans = [a-x,x,b-x]
for i in range(3,n):
print('? 1 '+ str(i) + ' ' + str(i+1))
... | 0 | |
452 | A | Eevee | PROGRAMMING | 1,000 | [
"brute force",
"implementation",
"strings"
] | null | null | You are solving the crossword problem K from IPSC 2014. You solved all the clues except for one: who does Eevee evolve into? You are not very into pokemons, but quick googling helped you find out, that Eevee can evolve into eight different pokemons: Vaporeon, Jolteon, Flareon, Espeon, Umbreon, Leafeon, Glaceon, and Syl... | First line contains an integer *n* (6<=≤<=*n*<=≤<=8) – the length of the string.
Next line contains a string consisting of *n* characters, each of which is either a lower case english letter (indicating a known letter) or a dot character (indicating an empty cell in the crossword). | Print a name of the pokemon that Eevee can evolve into that matches the pattern in the input. Use lower case letters only to print the name (in particular, do not capitalize the first letter). | [
"7\nj......\n",
"7\n...feon\n",
"7\n.l.r.o.\n"
] | [
"jolteon\n",
"leafeon\n",
"flareon\n"
] | Here's a set of names in a form you can paste into your solution:
["vaporeon", "jolteon", "flareon", "espeon", "umbreon", "leafeon", "glaceon", "sylveon"]
{"vaporeon", "jolteon", "flareon", "espeon", "umbreon", "leafeon", "glaceon", "sylveon"} | 500 | [
{
"input": "7\n...feon",
"output": "leafeon"
},
{
"input": "7\n.l.r.o.",
"output": "flareon"
},
{
"input": "6\n.s..o.",
"output": "espeon"
},
{
"input": "7\nglaceon",
"output": "glaceon"
},
{
"input": "8\n.a.o.e.n",
"output": "vaporeon"
},
{
"input": "... | 1,672,865,585 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 20 | 62 | 0 | from sys import stdin; inp = stdin.readline
from math import dist, ceil, floor, sqrt, log
from collections import defaultdict, Counter
def IA(sep=' '): return list(map(int, inp().split(sep)))
def FA(): return list(map(float, inp().split()))
def SA(): return inp().split()
def I(): return int(inp())
def F(): retur... | Title: Eevee
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are solving the crossword problem K from IPSC 2014. You solved all the clues except for one: who does Eevee evolve into? You are not very into pokemons, but quick googling helped you find out, that Eevee can evolve into eight... | ```python
from sys import stdin; inp = stdin.readline
from math import dist, ceil, floor, sqrt, log
from collections import defaultdict, Counter
def IA(sep=' '): return list(map(int, inp().split(sep)))
def FA(): return list(map(float, inp().split()))
def SA(): return inp().split()
def I(): return int(inp())
def ... | 3 | |
0 | none | none | none | 0 | [
"none"
] | null | null | A tree is a connected undirected graph consisting of *n* vertices and *n*<=<=-<=<=1 edges. Vertices are numbered 1 through *n*.
Limak is a little polar bear and Radewoosh is his evil enemy. Limak once had a tree but Radewoosh stolen it. Bear is very sad now because he doesn't remember much about the tree — he can tell... | The first line contains three integers *n*, *d* and *h* (2<=≤<=*n*<=≤<=100<=000,<=1<=≤<=*h*<=≤<=*d*<=≤<=*n*<=-<=1) — the number of vertices, diameter, and height after rooting in vertex 1, respectively. | If there is no tree matching what Limak remembers, print the only line with "-1" (without the quotes).
Otherwise, describe any tree matching Limak's description. Print *n*<=-<=1 lines, each with two space-separated integers – indices of vertices connected by an edge. If there are many valid trees, print any of them. Y... | [
"5 3 2\n",
"8 5 2\n",
"8 4 2\n"
] | [
"1 2\n1 3\n3 4\n3 5",
"-1\n",
"4 8\n5 7\n2 3\n8 1\n2 1\n5 6\n1 5\n"
] | Below you can see trees printed to the output in the first sample and the third sample. | 0 | [
{
"input": "5 3 2",
"output": "1 2\n2 3\n1 4\n5 1"
},
{
"input": "8 5 2",
"output": "-1"
},
{
"input": "8 4 2",
"output": "4 8\n5 7\n2 3\n8 1\n2 1\n5 6\n1 5"
},
{
"input": "2 1 1",
"output": "1 2"
},
{
"input": "10 3 3",
"output": "1 2\n2 3\n3 4\n5 2\n6 2\n7 2... | 1,459,185,288 | 2,388 | Python 3 | WRONG_ANSWER | PRETESTS | 4 | 46 | 4,608,000 | #!/usr/bin/env python3
n, d, h = map(int,input().split())
def solve():
t = []
i, j = 1, 2
while len(t) < h:
t.append((i, j))
i, j = j, j+1
i, j = 1, j
while len(t) < d:
t.append((i, j))
i, j = j, j+1
if len(t) != d:
return None
if len(t) > 2*h:
... | Title: none
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
A tree is a connected undirected graph consisting of *n* vertices and *n*<=<=-<=<=1 edges. Vertices are numbered 1 through *n*.
Limak is a little polar bear and Radewoosh is his evil enemy. Limak once had a tree but Radewoosh sto... | ```python
#!/usr/bin/env python3
n, d, h = map(int,input().split())
def solve():
t = []
i, j = 1, 2
while len(t) < h:
t.append((i, j))
i, j = j, j+1
i, j = 1, j
while len(t) < d:
t.append((i, j))
i, j = j, j+1
if len(t) != d:
return None
if len(t) > 2*... | 0 | |
260 | A | Adding Digits | PROGRAMMING | 1,400 | [
"implementation",
"math"
] | null | null | Vasya has got two number: *a* and *b*. However, Vasya finds number *a* too short. So he decided to repeat the operation of lengthening number *a* *n* times.
One operation of lengthening a number means adding exactly one digit to the number (in the decimal notation) to the right provided that the resulting number is di... | The first line contains three integers: *a*,<=*b*,<=*n* (1<=≤<=*a*,<=*b*,<=*n*<=≤<=105). | In a single line print the integer without leading zeros, which Vasya can get when he applies the lengthening operations to number *a* *n* times. If no such number exists, then print number -1. If there are multiple possible answers, print any of them. | [
"5 4 5\n",
"12 11 1\n",
"260 150 10\n"
] | [
"524848\n",
"121\n",
"-1\n"
] | none | 500 | [
{
"input": "5 4 5",
"output": "524848"
},
{
"input": "12 11 1",
"output": "121"
},
{
"input": "260 150 10",
"output": "-1"
},
{
"input": "78843 5684 42717",
"output": "-1"
},
{
"input": "93248 91435 1133",
"output": "-1"
},
{
"input": "100000 10 64479"... | 1,588,398,321 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 5 | 93 | 307,200 | a, b, n = map(int, input().split())
c = a
i = 0
result = a
output = 0
l1 = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
while i < n:
for j in l1:
a = int(str(a) + j)
if a % b == 0:
result = a
break
else:
a = result
if result == c:
... | Title: Adding Digits
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vasya has got two number: *a* and *b*. However, Vasya finds number *a* too short. So he decided to repeat the operation of lengthening number *a* *n* times.
One operation of lengthening a number means adding exactly one ... | ```python
a, b, n = map(int, input().split())
c = a
i = 0
result = a
output = 0
l1 = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
while i < n:
for j in l1:
a = int(str(a) + j)
if a % b == 0:
result = a
break
else:
a = result
if result ... | 0 | |
353 | A | Domino | PROGRAMMING | 1,200 | [
"implementation",
"math"
] | null | null | Valera has got *n* domino pieces in a row. Each piece consists of two halves — the upper one and the lower one. Each of the halves contains a number from 1 to 6. Valera loves even integers very much, so he wants the sum of the numbers on the upper halves and the sum of the numbers on the lower halves to be even.
To do... | The first line contains integer *n* (1<=≤<=*n*<=≤<=100), denoting the number of dominoes Valera has. Next *n* lines contain two space-separated integers *x**i*,<=*y**i* (1<=≤<=*x**i*,<=*y**i*<=≤<=6). Number *x**i* is initially written on the upper half of the *i*-th domino, *y**i* is initially written on the lower half... | Print a single number — the minimum required number of seconds. If Valera can't do the task in any time, print <=-<=1. | [
"2\n4 2\n6 4\n",
"1\n2 3\n",
"3\n1 4\n2 3\n4 4\n"
] | [
"0\n",
"-1\n",
"1\n"
] | In the first test case the sum of the numbers on the upper halves equals 10 and the sum of the numbers on the lower halves equals 6. Both numbers are even, so Valera doesn't required to do anything.
In the second sample Valera has only one piece of domino. It is written 3 on the one of its halves, therefore one of the... | 500 | [
{
"input": "2\n4 2\n6 4",
"output": "0"
},
{
"input": "1\n2 3",
"output": "-1"
},
{
"input": "3\n1 4\n2 3\n4 4",
"output": "1"
},
{
"input": "5\n5 4\n5 4\n1 5\n5 5\n3 3",
"output": "1"
},
{
"input": "20\n1 3\n5 2\n5 2\n2 6\n2 4\n1 1\n1 3\n1 4\n2 6\n4 2\n5 6\n2 2\n... | 1,615,047,385 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 10 | 186 | 1,331,200 | n=int(input())
arr_upper=[];arr_lower=[]
for i in range(n):
a,b=map(int,input().split())
arr_upper.append(a);arr_lower.append(b)
summ1,summ2=sum(arr_upper),sum(arr_lower)
if summ1%2==0 and summ2%2==0:print(0)
else:
for i in range(n):
for j in range(n):
#lower add and sub upper
summ11=summ1... | Title: Domino
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Valera has got *n* domino pieces in a row. Each piece consists of two halves — the upper one and the lower one. Each of the halves contains a number from 1 to 6. Valera loves even integers very much, so he wants the sum of the n... | ```python
n=int(input())
arr_upper=[];arr_lower=[]
for i in range(n):
a,b=map(int,input().split())
arr_upper.append(a);arr_lower.append(b)
summ1,summ2=sum(arr_upper),sum(arr_lower)
if summ1%2==0 and summ2%2==0:print(0)
else:
for i in range(n):
for j in range(n):
#lower add and sub upper
su... | 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,691,438,160 | 2,147,483,647 | Python 3 | OK | TESTS | 20 | 46 | 0 | testCase = int(input())
for i in range(0,testCase):
x = input()
l = len(x)
if l > 10:
print(str(x[0])+ str(l-2)+ str(x[-1]))
else:
print(x) | Title: Way Too Long Words
Time Limit: 1 seconds
Memory Limit: 256 megabytes
Problem Description:
Sometimes some words like "localization" or "internationalization" are so long that writing them many times in one text is quite tiresome.
Let's consider a word too long, if its length is strictly more than 10 character... | ```python
testCase = int(input())
for i in range(0,testCase):
x = input()
l = len(x)
if l > 10:
print(str(x[0])+ str(l-2)+ str(x[-1]))
else:
print(x)
``` | 3.977 |
66 | D | Petya and His Friends | PROGRAMMING | 1,700 | [
"constructive algorithms",
"math",
"number theory"
] | D. Petya and His Friends | 2 | 256 | Little Petya has a birthday soon. Due this wonderful event, Petya's friends decided to give him sweets. The total number of Petya's friends equals to *n*.
Let us remind you the definition of the greatest common divisor: *GCD*(*a*1,<=...,<=*a**k*)<==<=*d*, where *d* represents such a maximal positive number that each *... | The first line contains an integer *n* (2<=≤<=*n*<=≤<=50). | If there is no answer, print "-1" without quotes. Otherwise print a set of *n* distinct positive numbers *a*1,<=*a*2,<=...,<=*a**n*. Each line must contain one number. Each number must consist of not more than 100 digits, and must not contain any leading zeros. If there are several solutions to that problem, print any ... | [
"3\n",
"4\n"
] | [
"99\n55\n11115\n",
"385\n360\n792\n8360\n"
] | none | 2,000 | [
{
"input": "3",
"output": "15\n10\n6"
},
{
"input": "4",
"output": "105\n70\n42\n30"
},
{
"input": "5",
"output": "1155\n770\n462\n330\n210"
},
{
"input": "6",
"output": "15015\n10010\n6006\n4290\n2730\n2310"
},
{
"input": "7",
"output": "255255\n170170\n10210... | 1,678,710,436 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 49 | 154 | 2,355,200 | from functools import reduce
from itertools import combinations
from operator import mul
# https://prime-numbers.info/list/first-50-primes
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173,... | Title: Petya and His Friends
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Little Petya has a birthday soon. Due this wonderful event, Petya's friends decided to give him sweets. The total number of Petya's friends equals to *n*.
Let us remind you the definition of the greatest common divis... | ```python
from functools import reduce
from itertools import combinations
from operator import mul
# https://prime-numbers.info/list/first-50-primes
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163,... | 3.957113 |
545 | C | Woodcutters | PROGRAMMING | 1,500 | [
"dp",
"greedy"
] | null | null | Little Susie listens to fairy tales before bed every day. Today's fairy tale was about wood cutters and the little girl immediately started imagining the choppers cutting wood. She imagined the situation that is described below.
There are *n* trees located along the road at points with coordinates *x*1,<=*x*2,<=...,<=... | The first line contains integer *n* (1<=≤<=*n*<=≤<=105) — the number of trees.
Next *n* lines contain pairs of integers *x**i*,<=*h**i* (1<=≤<=*x**i*,<=*h**i*<=≤<=109) — the coordinate and the height of the *і*-th tree.
The pairs are given in the order of ascending *x**i*. No two trees are located at the point with t... | Print a single number — the maximum number of trees that you can cut down by the given rules. | [
"5\n1 2\n2 1\n5 10\n10 9\n19 1\n",
"5\n1 2\n2 1\n5 10\n10 9\n20 1\n"
] | [
"3\n",
"4\n"
] | In the first sample you can fell the trees like that:
- fell the 1-st tree to the left — now it occupies segment [ - 1;1] - fell the 2-nd tree to the right — now it occupies segment [2;3] - leave the 3-rd tree — it occupies point 5 - leave the 4-th tree — it occupies point 10 - fell the 5-th tree to the right — ... | 1,750 | [
{
"input": "5\n1 2\n2 1\n5 10\n10 9\n19 1",
"output": "3"
},
{
"input": "5\n1 2\n2 1\n5 10\n10 9\n20 1",
"output": "4"
},
{
"input": "4\n10 4\n15 1\n19 3\n20 1",
"output": "4"
},
{
"input": "35\n1 7\n3 11\n6 12\n7 6\n8 5\n9 11\n15 3\n16 10\n22 2\n23 3\n25 7\n27 3\n34 5\n35 10... | 1,668,344,312 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 4 | 327 | 9,625,600 | def cut_or_not(trees, i):
x_i_l, x_i, x_i_r = trees[i-1][0], trees[i][0], trees[i+1][0]
h_i = trees[i][1]
if x_i_r - x_i > h_i:
x_i = x_i + h_i
return 1
elif x_i - x_i_l > h_i:
x_i = x_i
return 1
else:
x_i = x_i
return 0
n = int(input()... | Title: Woodcutters
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Little Susie listens to fairy tales before bed every day. Today's fairy tale was about wood cutters and the little girl immediately started imagining the choppers cutting wood. She imagined the situation that is described b... | ```python
def cut_or_not(trees, i):
x_i_l, x_i, x_i_r = trees[i-1][0], trees[i][0], trees[i+1][0]
h_i = trees[i][1]
if x_i_r - x_i > h_i:
x_i = x_i + h_i
return 1
elif x_i - x_i_l > h_i:
x_i = x_i
return 1
else:
x_i = x_i
return 0
n = i... | 0 | |
11 | C | How Many Squares? | PROGRAMMING | 2,200 | [
"implementation"
] | C. How Many Squares? | 2 | 64 | You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2<=×<=2. We are only interested in two types of squares:
1. squares with each side parallel to a side of the matrix; 1. squares with each side... | The first line contains integer *t* (1<=≤<=*t*<=≤<=10000), where *t* is the number of test cases in the input. Then test cases follow. Each case starts with a line containing integers *n* and *m* (2<=≤<=*n*,<=*m*<=≤<=250), where *n* is the number of rows and *m* is the number of columns. The following *n* lines contain... | You should output exactly *t* lines, with the answer to the *i*-th test case on the *i*-th line. | [
"2\n8 8\n00010001\n00101000\n01000100\n10000010\n01000100\n00101000\n11010011\n11000011\n10 10\n1111111000\n1000001000\n1011001000\n1011001010\n1000001101\n1001001010\n1010101000\n1001001000\n1000001000\n1111111000\n",
"1\n12 11\n11111111111\n10000000001\n10111111101\n10100000101\n10101100101\n10101100101\n101000... | [
"1\n2\n",
"3\n"
] | none | 0 | [
{
"input": "2\n8 8\n00010001\n00101000\n01000100\n10000010\n01000100\n00101000\n11010011\n11000011\n10 10\n1111111000\n1000001000\n1011001000\n1011001010\n1000001101\n1001001010\n1010101000\n1001001000\n1000001000\n1111111000",
"output": "1\n2"
},
{
"input": "1\n12 11\n11111111111\n10000000001\n1011... | 1,593,099,209 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 12 | 2,000 | 6,963,200 | t = int(input())
for k in range(t):
n, m = list(map(int, input().split()))
arr = []
for i in range(n):
s = input()
c = []
for j in s:
c.append(j)
arr.append(c.copy())
dx = [0, 1, 0, -1, 1, 1, -1, -1]
dy = [1, 0, -1, 0, -1, 1, -1, 1]
ct ... | Title: How Many Squares?
Time Limit: 2 seconds
Memory Limit: 64 megabytes
Problem Description:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2<=×<=2. We are only interested in two types of ... | ```python
t = int(input())
for k in range(t):
n, m = list(map(int, input().split()))
arr = []
for i in range(n):
s = input()
c = []
for j in s:
c.append(j)
arr.append(c.copy())
dx = [0, 1, 0, -1, 1, 1, -1, -1]
dy = [1, 0, -1, 0, -1, 1, -1, 1]
... | 0 |
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,689,155,296 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 4 | 400 | 0 |
flag=0
houses,spleterss = map(int,input().split())
spleters_count=0
if houses==1:
print(0)
exit()
# print(type(spleterss))
forks=(spleterss*(spleterss+1)//2)-(spleterss-1)
if forks<houses:
print(-1)
exit()
while True:
if flag==0:
houses-=spleterss
flag=1
... | 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
flag=0
houses,spleterss = map(int,input().split())
spleters_count=0
if houses==1:
print(0)
exit()
# print(type(spleterss))
forks=(spleterss*(spleterss+1)//2)-(spleterss-1)
if forks<houses:
print(-1)
exit()
while True:
if flag==0:
houses-=spleterss
... | 0 | |
133 | A | HQ9+ | PROGRAMMING | 900 | [
"implementation"
] | null | null | HQ9+ is a joke programming language which has only four one-character instructions:
- "H" prints "Hello, World!",- "Q" prints the source code of the program itself,- "9" prints the lyrics of "99 Bottles of Beer" song, - "+" increments the value stored in the internal accumulator.
Instructions "H" and "Q" are case-s... | The input will consist of a single line *p* which will give a program in HQ9+. String *p* will contain between 1 and 100 characters, inclusive. ASCII-code of each character of *p* will be between 33 (exclamation mark) and 126 (tilde), inclusive. | Output "YES", if executing the program will produce any output, and "NO" otherwise. | [
"Hi!\n",
"Codeforces\n"
] | [
"YES\n",
"NO\n"
] | In the first case the program contains only one instruction — "H", which prints "Hello, World!".
In the second case none of the program characters are language instructions. | 500 | [
{
"input": "Hi!",
"output": "YES"
},
{
"input": "Codeforces",
"output": "NO"
},
{
"input": "a+b=c",
"output": "NO"
},
{
"input": "hq-lowercase",
"output": "NO"
},
{
"input": "Q",
"output": "YES"
},
{
"input": "9",
"output": "YES"
},
{
"inpu... | 1,686,245,173 | 2,147,483,647 | Python 3 | OK | TESTS | 85 | 92 | 0 | x=str(input())
if "H" in x or "Q" in x or "9" in x:
print("YES")
else:
print("NO") | Title: HQ9+
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
HQ9+ is a joke programming language which has only four one-character instructions:
- "H" prints "Hello, World!",- "Q" prints the source code of the program itself,- "9" prints the lyrics of "99 Bottles of Beer" song, - "+" in... | ```python
x=str(input())
if "H" in x or "Q" in x or "9" in x:
print("YES")
else:
print("NO")
``` | 3 | |
1,011 | A | Stages | PROGRAMMING | 900 | [
"greedy",
"implementation",
"sortings"
] | null | null | Natasha is going to fly to Mars. She needs to build a rocket, which consists of several stages in some order. Each of the stages is defined by a lowercase Latin letter. This way, the rocket can be described by the string — concatenation of letters, which correspond to the stages.
There are $n$ stages available. The ro... | The first line of input contains two integers — $n$ and $k$ ($1 \le k \le n \le 50$) – the number of available stages and the number of stages to use in the rocket.
The second line contains string $s$, which consists of exactly $n$ lowercase Latin letters. Each letter defines a new stage, which can be used to build th... | Print a single integer — the minimal total weight of the rocket or -1, if it is impossible to build the rocket at all. | [
"5 3\nxyabd\n",
"7 4\nproblem\n",
"2 2\nab\n",
"12 1\nabaabbaaabbb\n"
] | [
"29",
"34",
"-1",
"1"
] | In the first example, the following rockets satisfy the condition:
- "adx" (weight is $1+4+24=29$);- "ady" (weight is $1+4+25=30$);- "bdx" (weight is $2+4+24=30$);- "bdy" (weight is $2+4+25=31$).
Rocket "adx" has the minimal weight, so the answer is $29$.
In the second example, target rocket is "belo". Its weight ... | 500 | [
{
"input": "5 3\nxyabd",
"output": "29"
},
{
"input": "7 4\nproblem",
"output": "34"
},
{
"input": "2 2\nab",
"output": "-1"
},
{
"input": "12 1\nabaabbaaabbb",
"output": "1"
},
{
"input": "50 13\nqwertyuiopasdfghjklzxcvbnmaaaaaaaaaaaaaaaaaaaaaaaa",
"output": ... | 1,532,820,599 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 4 | 124 | 0 | n,k=map(int,input().split() )
alpha='abcdefghijklmnopqrstuvwxyz'
ch=str(input())
L=list(ch)
L.sort()
i=1
d={}
for x in alpha :
d[x]=i
i+=1
s=L[0]
m=d[L[0]]
l=1
while (len(s)<k) and (l<=n-1) :
if ( (d[L[l]] - d[L[l-1]] ) >=2 ):
s=s+(L[l])
m+=d[L[l]]
l+=1
if (m==0) or ... | Title: Stages
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Natasha is going to fly to Mars. She needs to build a rocket, which consists of several stages in some order. Each of the stages is defined by a lowercase Latin letter. This way, the rocket can be described by the string — conca... | ```python
n,k=map(int,input().split() )
alpha='abcdefghijklmnopqrstuvwxyz'
ch=str(input())
L=list(ch)
L.sort()
i=1
d={}
for x in alpha :
d[x]=i
i+=1
s=L[0]
m=d[L[0]]
l=1
while (len(s)<k) and (l<=n-1) :
if ( (d[L[l]] - d[L[l-1]] ) >=2 ):
s=s+(L[l])
m+=d[L[l]]
l+=1
if ... | 0 | |
898 | A | Rounding | PROGRAMMING | 800 | [
"implementation",
"math"
] | null | null | Vasya has a non-negative integer *n*. He wants to round it to nearest integer, which ends up with 0. If *n* already ends up with 0, Vasya considers it already rounded.
For example, if *n*<==<=4722 answer is 4720. If *n*<==<=5 Vasya can round it to 0 or to 10. Both ways are correct.
For given *n* find out to which int... | The first line contains single integer *n* (0<=≤<=*n*<=≤<=109) — number that Vasya has. | Print result of rounding *n*. Pay attention that in some cases answer isn't unique. In that case print any correct answer. | [
"5\n",
"113\n",
"1000000000\n",
"5432359\n"
] | [
"0\n",
"110\n",
"1000000000\n",
"5432360\n"
] | In the first example *n* = 5. Nearest integers, that ends up with zero are 0 and 10. Any of these answers is correct, so you can print 0 or 10. | 500 | [
{
"input": "5",
"output": "0"
},
{
"input": "113",
"output": "110"
},
{
"input": "1000000000",
"output": "1000000000"
},
{
"input": "5432359",
"output": "5432360"
},
{
"input": "999999994",
"output": "999999990"
},
{
"input": "10",
"output": "10"
... | 1,547,617,630 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 77 | 0 | n = int(input())
for i in range(n):
if n % 10 == 0:
print(n)
exit()
else:
n -= 1
| Title: Rounding
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vasya has a non-negative integer *n*. He wants to round it to nearest integer, which ends up with 0. If *n* already ends up with 0, Vasya considers it already rounded.
For example, if *n*<==<=4722 answer is 4720. If *n*<==<=5... | ```python
n = int(input())
for i in range(n):
if n % 10 == 0:
print(n)
exit()
else:
n -= 1
``` | 0 | |
112 | A | Petya and Strings | PROGRAMMING | 800 | [
"implementation",
"strings"
] | A. Petya and Strings | 2 | 256 | Little Petya loves presents. His mum bought him two strings of the same size for his birthday. The strings consist of uppercase and lowercase Latin letters. Now Petya wants to compare those two strings lexicographically. The letters' case does not matter, that is an uppercase letter is considered equivalent to the corr... | Each of the first two lines contains a bought string. The strings' lengths range from 1 to 100 inclusive. It is guaranteed that the strings are of the same length and also consist of uppercase and lowercase Latin letters. | If the first string is less than the second one, print "-1". If the second string is less than the first one, print "1". If the strings are equal, print "0". Note that the letters' case is not taken into consideration when the strings are compared. | [
"aaaa\naaaA\n",
"abs\nAbz\n",
"abcdefg\nAbCdEfF\n"
] | [
"0\n",
"-1\n",
"1\n"
] | If you want more formal information about the lexicographical order (also known as the "dictionary order" or "alphabetical order"), you can visit the following site:
- http://en.wikipedia.org/wiki/Lexicographical_order | 500 | [
{
"input": "aaaa\naaaA",
"output": "0"
},
{
"input": "abs\nAbz",
"output": "-1"
},
{
"input": "abcdefg\nAbCdEfF",
"output": "1"
},
{
"input": "asadasdasd\nasdwasdawd",
"output": "-1"
},
{
"input": "aslkjlkasdd\nasdlkjdajwi",
"output": "1"
},
{
"input":... | 1,696,004,946 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 53 | 124 | 0 | import sys
import bisect
input = sys.stdin.readline
def yes():
print("YES")
def no():
print("NO")
a = input().rstrip().lower()
b = input().rstrip().lower()
if a == b:
print(0)
elif a > b:
print(1)
else:
print(-1) | Title: Petya and Strings
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Little Petya loves presents. His mum bought him two strings of the same size for his birthday. The strings consist of uppercase and lowercase Latin letters. Now Petya wants to compare those two strings lexicographically. ... | ```python
import sys
import bisect
input = sys.stdin.readline
def yes():
print("YES")
def no():
print("NO")
a = input().rstrip().lower()
b = input().rstrip().lower()
if a == b:
print(0)
elif a > b:
print(1)
else:
print(-1)
``` | 3.969 |
542 | C | Idempotent functions | PROGRAMMING | 2,000 | [
"constructive algorithms",
"graphs",
"math"
] | null | null | Some time ago Leonid have known about idempotent functions. Idempotent function defined on a set {1,<=2,<=...,<=*n*} is such function , that for any the formula *g*(*g*(*x*))<==<=*g*(*x*) holds.
Let's denote as *f*(*k*)(*x*) the function *f* applied *k* times to the value *x*. More formally, *f*(1)(*x*)<==<=*f*(*x*),... | In the first line of the input there is a single integer *n* (1<=≤<=*n*<=≤<=200) — the size of function *f* domain.
In the second line follow *f*(1),<=*f*(2),<=...,<=*f*(*n*) (1<=≤<=*f*(*i*)<=≤<=*n* for each 1<=≤<=*i*<=≤<=*n*), the values of a function. | Output minimum *k* such that function *f*(*k*)(*x*) is idempotent. | [
"4\n1 2 2 4\n",
"3\n2 3 3\n",
"3\n2 3 1\n"
] | [
"1\n",
"2\n",
"3\n"
] | In the first sample test function *f*(*x*) = *f*<sup class="upper-index">(1)</sup>(*x*) is already idempotent since *f*(*f*(1)) = *f*(1) = 1, *f*(*f*(2)) = *f*(2) = 2, *f*(*f*(3)) = *f*(3) = 2, *f*(*f*(4)) = *f*(4) = 4.
In the second sample test:
- function *f*(*x*) = *f*<sup class="upper-index">(1)</sup>(*x*) isn'... | 750 | [
{
"input": "4\n1 2 2 4",
"output": "1"
},
{
"input": "3\n2 3 3",
"output": "2"
},
{
"input": "3\n2 3 1",
"output": "3"
},
{
"input": "1\n1",
"output": "1"
},
{
"input": "16\n1 4 13 9 11 16 14 6 5 12 7 8 15 2 3 10",
"output": "105"
},
{
"input": "20\n1 ... | 1,430,670,528 | 1,728 | Python 3 | WRONG_ANSWER | PRETESTS | 4 | 46 | 0 | n = int(input())
a = list(map(int, input().split()))
b = a
for i in range (1, 1000000):
ok = True
for j in range (1, n + 1):
if (b[j - 1] != b[b[j - 1] - 1]):
ok = False
break
if (ok):
print(i)
break
for j in range (1, n + 1):
b[j - 1]... | Title: Idempotent functions
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Some time ago Leonid have known about idempotent functions. Idempotent function defined on a set {1,<=2,<=...,<=*n*} is such function , that for any the formula *g*(*g*(*x*))<==<=*g*(*x*) holds.
Let's denote as *... | ```python
n = int(input())
a = list(map(int, input().split()))
b = a
for i in range (1, 1000000):
ok = True
for j in range (1, n + 1):
if (b[j - 1] != b[b[j - 1] - 1]):
ok = False
break
if (ok):
print(i)
break
for j in range (1, n + 1):
... | 0 | |
987 | A | Infinity Gauntlet | PROGRAMMING | 800 | [
"implementation"
] | null | null | You took a peek on Thanos wearing Infinity Gauntlet. In the Gauntlet there is a place for six Infinity Gems:
- the Power Gem of purple color, - the Time Gem of green color, - the Space Gem of blue color, - the Soul Gem of orange color, - the Reality Gem of red color, - the Mind Gem of yellow color.
Using colors... | In the first line of input there is one integer $n$ ($0 \le n \le 6$) — the number of Gems in Infinity Gauntlet.
In next $n$ lines there are colors of Gems you saw. Words used for colors are: purple, green, blue, orange, red, yellow. It is guaranteed that all the colors are distinct. All colors are given in lowercase ... | In the first line output one integer $m$ ($0 \le m \le 6$) — the number of absent Gems.
Then in $m$ lines print the names of absent Gems, each on its own line. Words used for names are: Power, Time, Space, Soul, Reality, Mind. Names can be printed in any order. Keep the first letter uppercase, others lowercase. | [
"4\nred\npurple\nyellow\norange\n",
"0\n"
] | [
"2\nSpace\nTime\n",
"6\nTime\nMind\nSoul\nPower\nReality\nSpace\n"
] | In the first sample Thanos already has Reality, Power, Mind and Soul Gems, so he needs two more: Time and Space.
In the second sample Thanos doesn't have any Gems, so he needs all six. | 500 | [
{
"input": "4\nred\npurple\nyellow\norange",
"output": "2\nSpace\nTime"
},
{
"input": "0",
"output": "6\nMind\nSpace\nPower\nTime\nReality\nSoul"
},
{
"input": "6\npurple\nblue\nyellow\nred\ngreen\norange",
"output": "0"
},
{
"input": "1\npurple",
"output": "5\nTime\nReal... | 1,616,170,799 | 299 | PyPy 3 | WRONG_ANSWER | TESTS | 0 | 61 | 0 | n=int(input())
m=6-n
s=set(["purple", "green", "blue", "orange", "red", "yellow"])
for _ in range(n):
st=input()
s.remove(st)
s=list(s)
print(m)
for j in s:
st=j[0].upper()+j[1:]
print(st) | Title: Infinity Gauntlet
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You took a peek on Thanos wearing Infinity Gauntlet. In the Gauntlet there is a place for six Infinity Gems:
- the Power Gem of purple color, - the Time Gem of green color, - the Space Gem of blue color, - the So... | ```python
n=int(input())
m=6-n
s=set(["purple", "green", "blue", "orange", "red", "yellow"])
for _ in range(n):
st=input()
s.remove(st)
s=list(s)
print(m)
for j in s:
st=j[0].upper()+j[1:]
print(st)
``` | 0 | |
427 | A | Police Recruits | PROGRAMMING | 800 | [
"implementation"
] | null | null | The police department of your city has just started its journey. Initially, they don’t have any manpower. So, they started hiring new recruits in groups.
Meanwhile, crimes keeps occurring within the city. One member of the police force can investigate only one crime during his/her lifetime.
If there is no police offi... | The first line of input will contain an integer *n* (1<=≤<=*n*<=≤<=105), the number of events. The next line will contain *n* space-separated integers.
If the integer is -1 then it means a crime has occurred. Otherwise, the integer will be positive, the number of officers recruited together at that time. No more than ... | Print a single integer, the number of crimes which will go untreated. | [
"3\n-1 -1 1\n",
"8\n1 -1 1 -1 -1 1 1 1\n",
"11\n-1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1\n"
] | [
"2\n",
"1\n",
"8\n"
] | Lets consider the second example:
1. Firstly one person is hired. 1. Then crime appears, the last hired person will investigate this crime. 1. One more person is hired. 1. One more crime appears, the last hired person will investigate this crime. 1. Crime appears. There is no free policeman at the time, so this c... | 500 | [
{
"input": "3\n-1 -1 1",
"output": "2"
},
{
"input": "8\n1 -1 1 -1 -1 1 1 1",
"output": "1"
},
{
"input": "11\n-1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1",
"output": "8"
},
{
"input": "7\n-1 -1 1 1 -1 -1 1",
"output": "2"
},
{
"input": "21\n-1 -1 -1 -1 -1 3 2 -1 6 -1 -1 2 1 ... | 1,689,824,595 | 2,147,483,647 | Python 3 | OK | TESTS | 63 | 61 | 10,547,200 | t = int(input())
ans = 0
a = list(map(int, input().split()))
police = 0
crime = 0
for i in range(len(a)):
if a[i] > 0:
police += a[i]
else:
if police < 1:
crime += 1
else:
police -= 1
print(crime)
| Title: Police Recruits
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The police department of your city has just started its journey. Initially, they don’t have any manpower. So, they started hiring new recruits in groups.
Meanwhile, crimes keeps occurring within the city. One member of... | ```python
t = int(input())
ans = 0
a = list(map(int, input().split()))
police = 0
crime = 0
for i in range(len(a)):
if a[i] > 0:
police += a[i]
else:
if police < 1:
crime += 1
else:
police -= 1
print(crime)
``` | 3 | |
493 | C | Vasya and Basketball | PROGRAMMING | 1,600 | [
"binary search",
"brute force",
"data structures",
"implementation",
"sortings",
"two pointers"
] | null | null | Vasya follows a basketball game and marks the distances from which each team makes a throw. He knows that each successful throw has value of either 2 or 3 points. A throw is worth 2 points if the distance it was made from doesn't exceed some value of *d* meters, and a throw is worth 3 points if the distance is larger t... | The first line contains integer *n* (1<=≤<=*n*<=≤<=2·105) — the number of throws of the first team. Then follow *n* integer numbers — the distances of throws *a**i* (1<=≤<=*a**i*<=≤<=2·109).
Then follows number *m* (1<=≤<=*m*<=≤<=2·105) — the number of the throws of the second team. Then follow *m* integer numbers — ... | Print two numbers in the format a:b — the score that is possible considering the problem conditions where the result of subtraction *a*<=-<=*b* is maximum. If there are several such scores, find the one in which number *a* is maximum. | [
"3\n1 2 3\n2\n5 6\n",
"5\n6 7 8 9 10\n5\n1 2 3 4 5\n"
] | [
"9:6\n",
"15:10\n"
] | none | 2,000 | [
{
"input": "3\n1 2 3\n2\n5 6",
"output": "9:6"
},
{
"input": "5\n6 7 8 9 10\n5\n1 2 3 4 5",
"output": "15:10"
},
{
"input": "5\n1 2 3 4 5\n5\n6 7 8 9 10",
"output": "15:15"
},
{
"input": "3\n1 2 3\n3\n6 4 5",
"output": "9:9"
},
{
"input": "10\n1 2 3 4 5 6 7 8 9 10... | 1,631,066,048 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 10 | 405 | 99,635,200 | import bisect
import collections
import copy
import functools
import heapq
import itertools
import math
import sys
import string
import random
from typing import List
sys.setrecursionlimit(99999)
n = int(input())
arr = list(map(int,input().split()))
m = int(input())
brr = list(map(int,input().split()))... | Title: Vasya and Basketball
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vasya follows a basketball game and marks the distances from which each team makes a throw. He knows that each successful throw has value of either 2 or 3 points. A throw is worth 2 points if the distance it was ma... | ```python
import bisect
import collections
import copy
import functools
import heapq
import itertools
import math
import sys
import string
import random
from typing import List
sys.setrecursionlimit(99999)
n = int(input())
arr = list(map(int,input().split()))
m = int(input())
brr = list(map(int,input()... | 0 | |
937 | A | Olympiad | PROGRAMMING | 800 | [
"implementation",
"sortings"
] | null | null | The recent All-Berland Olympiad in Informatics featured *n* participants with each scoring a certain amount of points.
As the head of the programming committee, you are to determine the set of participants to be awarded with diplomas with respect to the following criteria:
- At least one participant should get a di... | The first line contains a single integer *n* (1<=≤<=*n*<=≤<=100) — the number of participants.
The next line contains a sequence of *n* integers *a*1,<=*a*2,<=...,<=*a**n* (0<=≤<=*a**i*<=≤<=600) — participants' scores.
It's guaranteed that at least one participant has non-zero score. | Print a single integer — the desired number of ways. | [
"4\n1 3 3 2\n",
"3\n1 1 1\n",
"4\n42 0 0 42\n"
] | [
"3\n",
"1\n",
"1\n"
] | There are three ways to choose a subset in sample case one.
1. Only participants with 3 points will get diplomas. 1. Participants with 2 or 3 points will get diplomas. 1. Everyone will get a diploma!
The only option in sample case two is to award everyone.
Note that in sample case three participants with zero sco... | 500 | [
{
"input": "4\n1 3 3 2",
"output": "3"
},
{
"input": "3\n1 1 1",
"output": "1"
},
{
"input": "4\n42 0 0 42",
"output": "1"
},
{
"input": "10\n1 0 1 0 1 0 0 0 0 1",
"output": "1"
},
{
"input": "10\n572 471 540 163 50 30 561 510 43 200",
"output": "10"
},
{
... | 1,652,088,415 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 21 | 62 | 0 | import sys
input = lambda : sys.stdin.readline().strip()
'''
╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬
╬╬ ▓▓ ▓▓ ╬╬
╬╬ ▓▓ ▓▓ ╬╬
╬╬ ▓▓█████▓▓ ╬╬
╬╬ ▓▓ ▓▓ ╬╬
╬╬ ▓▓ ▓▓ ╬╬
╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬
'''
l = int(input())
list1 = list(map(int,input().s... | Title: Olympiad
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The recent All-Berland Olympiad in Informatics featured *n* participants with each scoring a certain amount of points.
As the head of the programming committee, you are to determine the set of participants to be awarded with ... | ```python
import sys
input = lambda : sys.stdin.readline().strip()
'''
╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬
╬╬ ▓▓ ▓▓ ╬╬
╬╬ ▓▓ ▓▓ ╬╬
╬╬ ▓▓█████▓▓ ╬╬
╬╬ ▓▓ ▓▓ ╬╬
╬╬ ▓▓ ▓▓ ╬╬
╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬
'''
l = int(input())
list1 = list(map(int... | 3 | |
224 | A | Parallelepiped | PROGRAMMING | 1,100 | [
"brute force",
"geometry",
"math"
] | null | null | You've got a rectangular parallelepiped with integer edge lengths. You know the areas of its three faces that have a common vertex. Your task is to find the sum of lengths of all 12 edges of this parallelepiped. | The first and the single line contains three space-separated integers — the areas of the parallelepiped's faces. The area's values are positive (<=><=0) and do not exceed 104. It is guaranteed that there exists at least one parallelepiped that satisfies the problem statement. | Print a single number — the sum of all edges of the parallelepiped. | [
"1 1 1\n",
"4 6 6\n"
] | [
"12\n",
"28\n"
] | In the first sample the parallelepiped has sizes 1 × 1 × 1, in the second one — 2 × 2 × 3. | 500 | [
{
"input": "1 1 1",
"output": "12"
},
{
"input": "4 6 6",
"output": "28"
},
{
"input": "20 10 50",
"output": "68"
},
{
"input": "9 4 36",
"output": "56"
},
{
"input": "324 9 36",
"output": "184"
},
{
"input": "1333 93 129",
"output": "308"
},
{... | 1,645,013,050 | 250 | PyPy 3 | WRONG_ANSWER | TESTS | 2 | 154 | 102,400 | import sys
import math
from collections import deque,Counter
from sys import stdin
#sys.setrecursionlimit(10**7)
int1=lambda x: int(x)-1
stinput=lambda :stdin.readline()[:-1]
ii=lambda :int(stinput())
mi=lambda :map(int, stdin.readline().split())
li=lambda :list(mi())
mi1=lambda :map(int1, stdin.readline().split())
l... | Title: Parallelepiped
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You've got a rectangular parallelepiped with integer edge lengths. You know the areas of its three faces that have a common vertex. Your task is to find the sum of lengths of all 12 edges of this parallelepiped.
Input S... | ```python
import sys
import math
from collections import deque,Counter
from sys import stdin
#sys.setrecursionlimit(10**7)
int1=lambda x: int(x)-1
stinput=lambda :stdin.readline()[:-1]
ii=lambda :int(stinput())
mi=lambda :map(int, stdin.readline().split())
li=lambda :list(mi())
mi1=lambda :map(int1, stdin.readline().... | 0 | |
729 | B | Spotlights | PROGRAMMING | 1,200 | [
"dp",
"implementation"
] | null | null | Theater stage is a rectangular field of size *n*<=×<=*m*. The director gave you the stage's plan which actors will follow. For each cell it is stated in the plan if there would be an actor in this cell or not.
You are to place a spotlight on the stage in some good position. The spotlight will project light in one of t... | The first line contains two positive integers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=1000) — the number of rows and the number of columns in the plan.
The next *n* lines contain *m* integers, 0 or 1 each — the description of the plan. Integer 1, means there will be an actor in the corresponding cell, while 0 means the cell ... | Print one integer — the number of good positions for placing the spotlight. | [
"2 4\n0 1 0 0\n1 0 1 0\n",
"4 4\n0 0 0 0\n1 0 0 1\n0 1 1 0\n0 1 0 0\n"
] | [
"9\n",
"20\n"
] | In the first example the following positions are good:
1. the (1, 1) cell and right direction; 1. the (1, 1) cell and down direction; 1. the (1, 3) cell and left direction; 1. the (1, 3) cell and down direction; 1. the (1, 4) cell and left direction; 1. the (2, 2) cell and left direction; 1. the (2, 2) cell and... | 1,000 | [
{
"input": "2 4\n0 1 0 0\n1 0 1 0",
"output": "9"
},
{
"input": "4 4\n0 0 0 0\n1 0 0 1\n0 1 1 0\n0 1 0 0",
"output": "20"
},
{
"input": "1 5\n1 1 0 0 0",
"output": "3"
},
{
"input": "2 10\n0 0 0 0 0 0 0 1 0 0\n1 0 0 0 0 0 0 0 0 0",
"output": "20"
},
{
"input": "3 ... | 1,538,483,141 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 78 | 307,200 | N = 4
M = 4
array = [[0, 0, 0, 0], [1, 0, 0, 1], [0, 1, 1, 0], [0, 1, 0, 0]]
# 0 1 0 0
# 1 0 1 0
tmpCountUp = 0
tmpCountDown = 0
tmpCountLeft = 0
tmpCountRight = 0
resultCount = 0
for n in range(N):
for m in range(M):
for up in range(1, n+1):
if(array[n-up][m] == 1 and array[n][m] != 1):
tmp... | Title: Spotlights
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Theater stage is a rectangular field of size *n*<=×<=*m*. The director gave you the stage's plan which actors will follow. For each cell it is stated in the plan if there would be an actor in this cell or not.
You are to pl... | ```python
N = 4
M = 4
array = [[0, 0, 0, 0], [1, 0, 0, 1], [0, 1, 1, 0], [0, 1, 0, 0]]
# 0 1 0 0
# 1 0 1 0
tmpCountUp = 0
tmpCountDown = 0
tmpCountLeft = 0
tmpCountRight = 0
resultCount = 0
for n in range(N):
for m in range(M):
for up in range(1, n+1):
if(array[n-up][m] == 1 and array[n][m] != 1)... | 0 | |
713 | A | Sonya and Queries | PROGRAMMING | 1,400 | [
"data structures",
"implementation"
] | 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. | 500 | [
{
"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,685,706,313 | 2,147,483,647 | PyPy 3-64 | RUNTIME_ERROR | TESTS | 0 | 77 | 4,198,400 | def count_matching_integers(queries):
counts = defaultdict(int) # Dictionary to store counts of integers in the multiset
pattern_counts = defaultdict(int) # Dictionary to store counts of integers matching each pattern
results = [] # List to store the results of type '?' queries
for query in... | Title: Sonya and Queries
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... | ```python
def count_matching_integers(queries):
counts = defaultdict(int) # Dictionary to store counts of integers in the multiset
pattern_counts = defaultdict(int) # Dictionary to store counts of integers matching each pattern
results = [] # List to store the results of type '?' queries
fo... | -1 | |
463 | B | Caisa and Pylons | PROGRAMMING | 1,100 | [
"brute force",
"implementation",
"math"
] | null | null | Caisa solved the problem with the sugar and now he is on the way back to home.
Caisa is playing a mobile game during his path. There are (*n*<=+<=1) pylons numbered from 0 to *n* in this game. The pylon with number 0 has zero height, the pylon with number *i* (*i*<=><=0) has height *h**i*. The goal of the game is ... | The first line contains integer *n* (1<=≤<=*n*<=≤<=105). The next line contains *n* integers *h*1, *h*2,<=..., *h**n* (1<=<=≤<=<=*h**i*<=<=≤<=<=105) representing the heights of the pylons. | Print a single number representing the minimum number of dollars paid by Caisa. | [
"5\n3 4 3 2 4\n",
"3\n4 4 4\n"
] | [
"4\n",
"4\n"
] | In the first sample he can pay 4 dollars and increase the height of pylon with number 0 by 4 units. Then he can safely pass to the last pylon. | 1,000 | [
{
"input": "5\n3 4 3 2 4",
"output": "4"
},
{
"input": "3\n4 4 4",
"output": "4"
},
{
"input": "99\n1401 2019 1748 3785 3236 3177 3443 3772 2138 1049 353 908 310 2388 1322 88 2160 2783 435 2248 1471 706 2468 2319 3156 3506 2794 1999 1983 2519 2597 3735 537 344 3519 3772 3872 2961 3895 20... | 1,697,998,076 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 31 | 0 | n = input()
l = map(int, input().split())
t=0
budget=0
curpy=0
for x in l:
if curpy>= x:
budget+= (curpy-x)
else:
price = x - curpy
if price >= budget:
price -= budget
budget = 0
t+=price
else:
budget-= price
... | Title: Caisa and Pylons
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Caisa solved the problem with the sugar and now he is on the way back to home.
Caisa is playing a mobile game during his path. There are (*n*<=+<=1) pylons numbered from 0 to *n* in this game. The pylon with number 0... | ```python
n = input()
l = map(int, input().split())
t=0
budget=0
curpy=0
for x in l:
if curpy>= x:
budget+= (curpy-x)
else:
price = x - curpy
if price >= budget:
price -= budget
budget = 0
t+=price
else:
budget-= pr... | 0 | |
706 | B | Interesting drink | PROGRAMMING | 1,100 | [
"binary search",
"dp",
"implementation"
] | null | null | Vasiliy likes to rest after a hard work, so you may often meet him in some bar nearby. As all programmers do, he loves the famous drink "Beecola", which can be bought in *n* different shops in the city. It's known that the price of one bottle in the shop *i* is equal to *x**i* coins.
Vasiliy plans to buy his favorite ... | The first line of the input contains a single integer *n* (1<=≤<=*n*<=≤<=100<=000) — the number of shops in the city that sell Vasiliy's favourite drink.
The second line contains *n* integers *x**i* (1<=≤<=*x**i*<=≤<=100<=000) — prices of the bottles of the drink in the *i*-th shop.
The third line contains a single i... | Print *q* integers. The *i*-th of them should be equal to the number of shops where Vasiliy will be able to buy a bottle of the drink on the *i*-th day. | [
"5\n3 10 8 6 11\n4\n1\n10\n3\n11\n"
] | [
"0\n4\n1\n5\n"
] | On the first day, Vasiliy won't be able to buy a drink in any of the shops.
On the second day, Vasiliy can buy a drink in the shops 1, 2, 3 and 4.
On the third day, Vasiliy can buy a drink only in the shop number 1.
Finally, on the last day Vasiliy can buy a drink in any shop. | 1,000 | [
{
"input": "5\n3 10 8 6 11\n4\n1\n10\n3\n11",
"output": "0\n4\n1\n5"
},
{
"input": "5\n868 987 714 168 123\n10\n424\n192\n795\n873\n117\n914\n735\n158\n631\n471",
"output": "2\n2\n3\n4\n0\n4\n3\n1\n2\n2"
},
{
"input": "3\n435 482 309\n7\n245\n241\n909\n745\n980\n29\n521",
"output": "... | 1,699,972,809 | 2,147,483,647 | Python 3 | OK | TESTS | 103 | 794 | 13,619,200 | import bisect as b
input()
x = sorted(map(int, input().split()))
for i in range(int(input())):
print(b.bisect_right(x, int(input()))) | Title: Interesting drink
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vasiliy likes to rest after a hard work, so you may often meet him in some bar nearby. As all programmers do, he loves the famous drink "Beecola", which can be bought in *n* different shops in the city. It's known tha... | ```python
import bisect as b
input()
x = sorted(map(int, input().split()))
for i in range(int(input())):
print(b.bisect_right(x, int(input())))
``` | 3 | |
776 | A | A Serial Killer | PROGRAMMING | 900 | [
"brute force",
"implementation",
"strings"
] | null | null | Our beloved detective, Sherlock is currently trying to catch a serial killer who kills a person each day. Using his powers of deduction, he came to know that the killer has a strategy for selecting his next victim.
The killer starts with two potential victims on his first day, selects one of these two, kills selected ... | First line of input contains two names (length of each of them doesn't exceed 10), the two initials potential victims. Next line contains integer *n* (1<=≤<=*n*<=≤<=1000), the number of days.
Next *n* lines contains two names (length of each of them doesn't exceed 10), first being the person murdered on this day and t... | Output *n*<=+<=1 lines, the *i*-th line should contain the two persons from which the killer selects for the *i*-th murder. The (*n*<=+<=1)-th line should contain the two persons from which the next victim is selected. In each line, the two names can be printed in any order. | [
"ross rachel\n4\nross joey\nrachel phoebe\nphoebe monica\nmonica chandler\n",
"icm codeforces\n1\ncodeforces technex\n"
] | [
"ross rachel\njoey rachel\njoey phoebe\njoey monica\njoey chandler\n",
"icm codeforces\nicm technex\n"
] | In first example, the killer starts with ross and rachel.
- After day 1, ross is killed and joey appears. - After day 2, rachel is killed and phoebe appears. - After day 3, phoebe is killed and monica appears. - After day 4, monica is killed and chandler appears. | 500 | [
{
"input": "ross rachel\n4\nross joey\nrachel phoebe\nphoebe monica\nmonica chandler",
"output": "ross rachel\njoey rachel\njoey phoebe\njoey monica\njoey chandler"
},
{
"input": "icm codeforces\n1\ncodeforces technex",
"output": "icm codeforces\nicm technex"
},
{
"input": "a b\n3\na c\n... | 1,679,518,619 | 2,147,483,647 | Python 3 | OK | TESTS | 57 | 46 | 0 | from sys import stdin
rd = stdin.readline
name1, name2 = rd().split()
n = int(rd())
print(name1, name2)
for _ in range(n):
mur, rep = rd().split()
if name1 == mur: name1 = rep
else: name2 = rep
print(name1, name2)
| Title: A Serial Killer
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Our beloved detective, Sherlock is currently trying to catch a serial killer who kills a person each day. Using his powers of deduction, he came to know that the killer has a strategy for selecting his next victim.
The... | ```python
from sys import stdin
rd = stdin.readline
name1, name2 = rd().split()
n = int(rd())
print(name1, name2)
for _ in range(n):
mur, rep = rd().split()
if name1 == mur: name1 = rep
else: name2 = rep
print(name1, name2)
``` | 3 | |
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,680,628,299 | 2,147,483,647 | Python 3 | OK | TESTS | 35 | 92 | 0 | n = input()
n = n.split()
l = int(n[0])*int(n[1])
plates = int(l / 2)
print(plates) | 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
n = input()
n = n.split()
l = int(n[0])*int(n[1])
plates = int(l / 2)
print(plates)
``` | 3.977 |
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.