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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
49 | A | Sleuth | PROGRAMMING | 800 | [
"implementation"
] | A. Sleuth | 2 | 256 | Vasya plays the sleuth with his friends. The rules of the game are as follows: those who play for the first time, that is Vasya is the sleuth, he should investigate a "crime" and find out what is happening. He can ask any questions whatsoever that can be answered with "Yes" or "No". All the rest agree beforehand to ans... | The single line contains a question represented by a non-empty line consisting of large and small Latin letters, spaces and a question mark. The line length does not exceed 100. It is guaranteed that the question mark occurs exactly once in the line — as the last symbol and that the line contains at least one letter. | Print answer for the question in a single line: YES if the answer is "Yes", NO if the answer is "No".
Remember that in the reply to the question the last letter, not the last character counts. I. e. the spaces and the question mark do not count as letters. | [
"Is it a melon?\n",
"Is it an apple?\n",
"Is it a banana ?\n",
"Is it an apple and a banana simultaneouSLY?\n"
] | [
"NO\n",
"YES\n",
"YES\n",
"YES\n"
] | none | 500 | [
{
"input": "Is it a melon?",
"output": "NO"
},
{
"input": "Is it an apple?",
"output": "YES"
},
{
"input": " Is it a banana ?",
"output": "YES"
},
{
"input": "Is it an apple and a banana simultaneouSLY?",
"output": "YES"
},
{
"input": "oHtSbDwzHb?",
... | 1,569,325,647 | 2,147,483,647 | Python 3 | OK | TESTS | 35 | 218 | 0 | a=input()
a=a.replace(' ','')
print("YES") if(a[len(a)-2]=='a' or a[len(a)-2]=='e' or a[len(a)-2]=='i' or a[len(a)-2]=='o' or a[len(a)-2]=='u' or a[len(a)-2]=='y' or a[len(a)-2]=='A' or a[len(a)-2]=='E' or a[len(a)-2]=='I' or a[len(a)-2]=='O' or a[len(a)-2]=='U' or a[len(a)-2]=='Y') else print("NO") | Title: Sleuth
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Vasya plays the sleuth with his friends. The rules of the game are as follows: those who play for the first time, that is Vasya is the sleuth, he should investigate a "crime" and find out what is happening. He can ask any questions ... | ```python
a=input()
a=a.replace(' ','')
print("YES") if(a[len(a)-2]=='a' or a[len(a)-2]=='e' or a[len(a)-2]=='i' or a[len(a)-2]=='o' or a[len(a)-2]=='u' or a[len(a)-2]=='y' or a[len(a)-2]=='A' or a[len(a)-2]=='E' or a[len(a)-2]=='I' or a[len(a)-2]=='O' or a[len(a)-2]=='U' or a[len(a)-2]=='Y') else print("NO")
``` | 3.9455 |
289 | A | Polo the Penguin and Segments | PROGRAMMING | 1,100 | [
"brute force",
"implementation"
] | null | null | Little penguin Polo adores integer segments, that is, pairs of integers [*l*; *r*] (*l*<=≤<=*r*).
He has a set that consists of *n* integer segments: [*l*1; *r*1],<=[*l*2; *r*2],<=...,<=[*l**n*; *r**n*]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 uni... | The first line contains two integers *n* and *k* (1<=≤<=*n*,<=*k*<=≤<=105). Each of the following *n* lines contain a segment as a pair of integers *l**i* and *r**i* (<=-<=105<=≤<=*l**i*<=≤<=*r**i*<=≤<=105), separated by a space.
It is guaranteed that no two segments intersect. In other words, for any two integers *i*... | In a single line print a single integer — the answer to the problem. | [
"2 3\n1 2\n3 4\n",
"3 7\n1 2\n3 3\n4 7\n"
] | [
"2\n",
"0\n"
] | none | 500 | [
{
"input": "2 3\n1 2\n3 4",
"output": "2"
},
{
"input": "3 7\n1 2\n3 3\n4 7",
"output": "0"
},
{
"input": "3 7\n1 10\n11 47\n74 128",
"output": "3"
},
{
"input": "5 4\n1 1\n2 2\n3 3\n4 4\n5 5",
"output": "3"
},
{
"input": "7 4\n2 2\n-1 -1\n0 1\n7 8\n-3 -2\n9 9\n4 ... | 1,661,797,407 | 2,147,483,647 | PyPy 3-64 | RUNTIME_ERROR | TESTS | 0 | 154 | 5,836,800 | n,k = map(int,input().split())
p = 0
for i in range(n):
l,r = map(int,input().split())
p += (r-l+1)
if p % k == 0: print(0)
else: print(k - (p%k))%k | Title: Polo the Penguin and Segments
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Little penguin Polo adores integer segments, that is, pairs of integers [*l*; *r*] (*l*<=≤<=*r*).
He has a set that consists of *n* integer segments: [*l*1; *r*1],<=[*l*2; *r*2],<=...,<=[*l**n*; *r**n*]... | ```python
n,k = map(int,input().split())
p = 0
for i in range(n):
l,r = map(int,input().split())
p += (r-l+1)
if p % k == 0: print(0)
else: print(k - (p%k))%k
``` | -1 | |
851 | A | Arpa and a research in Mexican wave | PROGRAMMING | 800 | [
"implementation",
"math"
] | null | null | Arpa is researching the Mexican wave.
There are *n* spectators in the stadium, labeled from 1 to *n*. They start the Mexican wave at time 0.
- At time 1, the first spectator stands. - At time 2, the second spectator stands. - ... - At time *k*, the *k*-th spectator stands. - At time *k*<=+<=1, the (*k*<=+<=1)-t... | The first line contains three integers *n*, *k*, *t* (1<=≤<=*n*<=≤<=109, 1<=≤<=*k*<=≤<=*n*, 1<=≤<=*t*<=<<=*n*<=+<=*k*). | Print single integer: how many spectators are standing at time *t*. | [
"10 5 3\n",
"10 5 7\n",
"10 5 12\n"
] | [
"3\n",
"5\n",
"3\n"
] | In the following a sitting spectator is represented as -, a standing spectator is represented as ^.
- At *t* = 0 ---------- <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/4d97e684117250a9afe9be022ab8a63653dd15aa.png" style="max-width: 100.0%;max-height: 100.0%;"/> number of standing spe... | 500 | [
{
"input": "10 5 3",
"output": "3"
},
{
"input": "10 5 7",
"output": "5"
},
{
"input": "10 5 12",
"output": "3"
},
{
"input": "840585600 770678331 788528791",
"output": "770678331"
},
{
"input": "25462281 23343504 8024619",
"output": "8024619"
},
{
"in... | 1,516,308,634 | 2,147,483,647 | Python 3 | OK | TESTS | 166 | 62 | 5,632,000 | n, k ,t = [int(i) for i in input().split()]
print(min(t, k, n + k - t)) | Title: Arpa and a research in Mexican wave
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Arpa is researching the Mexican wave.
There are *n* spectators in the stadium, labeled from 1 to *n*. They start the Mexican wave at time 0.
- At time 1, the first spectator stands. - At time 2,... | ```python
n, k ,t = [int(i) for i in input().split()]
print(min(t, k, n + k - t))
``` | 3 | |
855 | A | Tom Riddle's Diary | PROGRAMMING | 800 | [
"brute force",
"implementation",
"strings"
] | null | null | Harry Potter is on a mission to destroy You-Know-Who's Horcruxes. The first Horcrux that he encountered in the Chamber of Secrets is Tom Riddle's diary. The diary was with Ginny and it forced her to open the Chamber of Secrets. Harry wants to know the different people who had ever possessed the diary to make sure they ... | First line of input contains an integer *n* (1<=≤<=*n*<=≤<=100) — the number of names in the list.
Next *n* lines each contain a string *s**i*, consisting of lowercase English letters. The length of each string is between 1 and 100. | Output *n* lines each containing either "YES" or "NO" (without quotes), depending on whether this string was already present in the stream or not.
You can print each letter in any case (upper or lower). | [
"6\ntom\nlucius\nginny\nharry\nginny\nharry\n",
"3\na\na\na\n"
] | [
"NO\nNO\nNO\nNO\nYES\nYES\n",
"NO\nYES\nYES\n"
] | In test case 1, for *i* = 5 there exists *j* = 3 such that *s*<sub class="lower-index">*i*</sub> = *s*<sub class="lower-index">*j*</sub> and *j* < *i*, which means that answer for *i* = 5 is "YES". | 500 | [
{
"input": "6\ntom\nlucius\nginny\nharry\nginny\nharry",
"output": "NO\nNO\nNO\nNO\nYES\nYES"
},
{
"input": "3\na\na\na",
"output": "NO\nYES\nYES"
},
{
"input": "1\nzn",
"output": "NO"
},
{
"input": "9\nliyzmbjwnzryjokufuxcqtzwworjeoxkbaqrujrhdidqdvwdfzilwszgnzglnnbogaclckfnb... | 1,619,495,667 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 46 | 0 | x = int(input())
c = []
for i in range(x):
d = input()
c.append(d)
for i in range(x):
if(c[i] == c[i]):
print("NO")
else:
print("YES")
| Title: Tom Riddle's Diary
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Harry Potter is on a mission to destroy You-Know-Who's Horcruxes. The first Horcrux that he encountered in the Chamber of Secrets is Tom Riddle's diary. The diary was with Ginny and it forced her to open the Chamber ... | ```python
x = int(input())
c = []
for i in range(x):
d = input()
c.append(d)
for i in range(x):
if(c[i] == c[i]):
print("NO")
else:
print("YES")
``` | 0 | |
686 | A | Free Ice Cream | PROGRAMMING | 800 | [
"constructive algorithms",
"implementation"
] | null | null | After their adventure with the magic mirror Kay and Gerda have returned home and sometimes give free ice cream to kids in the summer.
At the start of the day they have *x* ice cream packs. Since the ice cream is free, people start standing in the queue before Kay and Gerda's house even in the night. Each person in the... | The first line contains two space-separated integers *n* and *x* (1<=≤<=*n*<=≤<=1000, 0<=≤<=*x*<=≤<=109).
Each of the next *n* lines contains a character '+' or '-', and an integer *d**i*, separated by a space (1<=≤<=*d**i*<=≤<=109). Record "+ *d**i*" in *i*-th line means that a carrier with *d**i* ice cream packs occ... | Print two space-separated integers — number of ice cream packs left after all operations, and number of kids that left the house in distress. | [
"5 7\n+ 5\n- 10\n- 20\n+ 40\n- 20\n",
"5 17\n- 16\n- 2\n- 98\n+ 100\n- 98\n"
] | [
"22 1\n",
"3 2\n"
] | Consider the first sample.
1. Initially Kay and Gerda have 7 packs of ice cream. 1. Carrier brings 5 more, so now they have 12 packs. 1. A kid asks for 10 packs and receives them. There are only 2 packs remaining. 1. Another kid asks for 20 packs. Kay and Gerda do not have them, so the kid goes away distressed. 1.... | 500 | [
{
"input": "5 7\n+ 5\n- 10\n- 20\n+ 40\n- 20",
"output": "22 1"
},
{
"input": "5 17\n- 16\n- 2\n- 98\n+ 100\n- 98",
"output": "3 2"
},
{
"input": "6 1000000000\n+ 1000000000\n+ 1000000000\n+ 1000000000\n+ 1000000000\n+ 1000000000\n+ 1000000000",
"output": "7000000000 0"
},
{
... | 1,689,601,935 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 0 | 61 | 0 | p = list(map(int, input().split()))
n, x = p
print(n,x)
z=list()
l=list()
rozcz = 0
for i in range(n):
s = list(input().split())
if s[0]=='-' and x>=int(s[1]):
x-=int(s[1])
elif s[0]=='-' and x<=int(s[1]):
rozcz+=1
elif s[0]=='+':
x+=int(s[1])
print(x, rozcz) | Title: Free Ice Cream
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
After their adventure with the magic mirror Kay and Gerda have returned home and sometimes give free ice cream to kids in the summer.
At the start of the day they have *x* ice cream packs. Since the ice cream is free, p... | ```python
p = list(map(int, input().split()))
n, x = p
print(n,x)
z=list()
l=list()
rozcz = 0
for i in range(n):
s = list(input().split())
if s[0]=='-' and x>=int(s[1]):
x-=int(s[1])
elif s[0]=='-' and x<=int(s[1]):
rozcz+=1
elif s[0]=='+':
x+=int(s[1])
print(x, roz... | 0 | |
1 | A | Theatre Square | PROGRAMMING | 1,000 | [
"math"
] | A. Theatre Square | 1 | 256 | Theatre Square in the capital city of Berland has a rectangular shape with the size *n*<=×<=*m* meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the size *a*<=×<=*a*.
What is the least number of flagstones needed to pave the... | The input contains three positive integer numbers in the first line: *n*,<=<=*m* and *a* (1<=≤<=<=*n*,<=*m*,<=*a*<=≤<=109). | Write the needed number of flagstones. | [
"6 6 4\n"
] | [
"4\n"
] | none | 0 | [
{
"input": "6 6 4",
"output": "4"
},
{
"input": "1 1 1",
"output": "1"
},
{
"input": "2 1 1",
"output": "2"
},
{
"input": "1 2 1",
"output": "2"
},
{
"input": "2 2 1",
"output": "4"
},
{
"input": "2 1 2",
"output": "1"
},
{
"input": "1 1 3"... | 1,682,368,875 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 31 | 0 | import math
x,y,z=input().split()
x,y,z=[int(x),int(y),int(z)]
print((math.ceil(x//z))*(math.ceil(y//z)))
| Title: Theatre Square
Time Limit: 1 seconds
Memory Limit: 256 megabytes
Problem Description:
Theatre Square in the capital city of Berland has a rectangular shape with the size *n*<=×<=*m* meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each ... | ```python
import math
x,y,z=input().split()
x,y,z=[int(x),int(y),int(z)]
print((math.ceil(x//z))*(math.ceil(y//z)))
``` | 0 |
218 | B | Airport | PROGRAMMING | 1,100 | [
"implementation"
] | null | null | Lolek and Bolek are about to travel abroad by plane. The local airport has a special "Choose Your Plane" offer. The offer's conditions are as follows:
- it is up to a passenger to choose a plane to fly on; - if the chosen plane has *x* (*x*<=><=0) empty seats at the given moment, then the ticket for such a plane ... | The first line contains two integers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=1000) — the number of passengers in the queue and the number of planes in the airport, correspondingly. The next line contains *m* integers *a*1,<=*a*2,<=...,<=*a**m* (1<=≤<=*a**i*<=≤<=1000) — *a**i* stands for the number of empty seats in the *i*-th... | Print two integers — the maximum and the minimum number of zlotys that the airport administration can earn, correspondingly. | [
"4 3\n2 1 1\n",
"4 3\n2 2 2\n"
] | [
"5 5\n",
"7 6\n"
] | In the first test sample the number of passengers is equal to the number of empty seats, so regardless of the way the planes are chosen, the administration will earn the same sum.
In the second sample the sum is maximized if the 1-st person in the queue buys a ticket to the 1-st plane, the 2-nd person — to the 2-nd pl... | 500 | [
{
"input": "4 3\n2 1 1",
"output": "5 5"
},
{
"input": "4 3\n2 2 2",
"output": "7 6"
},
{
"input": "10 5\n10 3 3 1 2",
"output": "58 26"
},
{
"input": "10 1\n10",
"output": "55 55"
},
{
"input": "10 1\n100",
"output": "955 955"
},
{
"input": "10 2\n4 7... | 1,665,380,304 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 2 | 92 | 0 | n,m = map(int, input().split())
seats = [int(s) for s in input().split(" ", m-1)]
seats.sort()
a=b=0
for s in seats:
if a==n:
break
b += s*(s+1)/2
a += s
seats.reverse()
i=j=0
while True:
if i==n:
break
for s in seats:
if i==n:
break
j += ... | Title: Airport
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Lolek and Bolek are about to travel abroad by plane. The local airport has a special "Choose Your Plane" offer. The offer's conditions are as follows:
- it is up to a passenger to choose a plane to fly on; - if the chosen pl... | ```python
n,m = map(int, input().split())
seats = [int(s) for s in input().split(" ", m-1)]
seats.sort()
a=b=0
for s in seats:
if a==n:
break
b += s*(s+1)/2
a += s
seats.reverse()
i=j=0
while True:
if i==n:
break
for s in seats:
if i==n:
break
... | -1 | |
0 | none | none | none | 0 | [
"none"
] | null | null | The main road in Bytecity is a straight line from south to north. Conveniently, there are coordinates measured in meters from the southernmost building in north direction.
At some points on the road there are *n* friends, and *i*-th of them is standing at the point *x**i* meters and can move with any speed no greater ... | The first line contains single integer *n* (2<=≤<=*n*<=≤<=60<=000) — the number of friends.
The second line contains *n* integers *x*1,<=*x*2,<=...,<=*x**n* (1<=≤<=*x**i*<=≤<=109) — the current coordinates of the friends, in meters.
The third line contains *n* integers *v*1,<=*v*2,<=...,<=*v**n* (1<=≤<=*v**i*<=≤<=109... | Print the minimum time (in seconds) needed for all the *n* friends to meet at some point on the road.
Your answer will be considered correct, if its absolute or relative error isn't greater than 10<=-<=6. Formally, let your answer be *a*, while jury's answer be *b*. Your answer will be considered correct if holds. | [
"3\n7 1 3\n1 2 1\n",
"4\n5 10 3 2\n2 3 2 4\n"
] | [
"2.000000000000\n",
"1.400000000000\n"
] | In the first sample, all friends can gather at the point 5 within 2 seconds. In order to achieve this, the first friend should go south all the time at his maximum speed, while the second and the third friends should go north at their maximum speeds. | 0 | [
{
"input": "3\n7 1 3\n1 2 1",
"output": "2.000000000000"
},
{
"input": "4\n5 10 3 2\n2 3 2 4",
"output": "1.400000000000"
},
{
"input": "3\n1 1000000000 2\n1 2 1000000000",
"output": "333333332.999999999971"
},
{
"input": "2\n4 5\n10 8",
"output": "0.055555555556"
},
... | 1,675,216,575 | 2,147,483,647 | Python 3 | OK | TESTS | 46 | 3,197 | 7,680,000 | def find_min_time(n, x, v):
l = -1
r = max(x) / 2 + 1
while r - l > 1e-6:
mid = l + (r - l) / 2
l1 = sorted(x[i] - mid*v[i] for i in range(len(x)))
r1 = sorted(x[i] + mid*v[i] for i in range(len(x)))
if r1[0] <= l1[-1]:
l = mid
else:
r = mid
return l
n = int(inp... | Title: none
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The main road in Bytecity is a straight line from south to north. Conveniently, there are coordinates measured in meters from the southernmost building in north direction.
At some points on the road there are *n* friends, and *i*... | ```python
def find_min_time(n, x, v):
l = -1
r = max(x) / 2 + 1
while r - l > 1e-6:
mid = l + (r - l) / 2
l1 = sorted(x[i] - mid*v[i] for i in range(len(x)))
r1 = sorted(x[i] + mid*v[i] for i in range(len(x)))
if r1[0] <= l1[-1]:
l = mid
else:
r = mid
return l
n... | 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,603,755,227 | 2,147,483,647 | PyPy 3 | OK | TESTS | 30 | 280 | 0 | s = input("")
capCount = 0
lowCount = 0
for l in s:
if l.islower():
lowCount += 1
elif l.isupper():
capCount += 1
if capCount == lowCount:
s = s.lower()
elif capCount > lowCount:
s = s.upper()
elif capCount < lowCount:
s = s.lower()
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("")
capCount = 0
lowCount = 0
for l in s:
if l.islower():
lowCount += 1
elif l.isupper():
capCount += 1
if capCount == lowCount:
s = s.lower()
elif capCount > lowCount:
s = s.upper()
elif capCount < lowCount:
s = s.lower()
print(s)
``` | 3.93 |
660 | D | Number of Parallelograms | PROGRAMMING | 1,900 | [
"geometry"
] | null | null | You are given *n* points on a plane. All the points are distinct and no three of them lie on the same line. Find the number of parallelograms with the vertices at the given points. | The first line of the input contains integer *n* (1<=≤<=*n*<=≤<=2000) — the number of points.
Each of the next *n* lines contains two integers (*x**i*,<=*y**i*) (0<=≤<=*x**i*,<=*y**i*<=≤<=109) — the coordinates of the *i*-th point. | Print the only integer *c* — the number of parallelograms with the vertices at the given points. | [
"4\n0 1\n1 0\n1 1\n2 0\n"
] | [
"1\n"
] | none | 0 | [
{
"input": "4\n0 1\n1 0\n1 1\n2 0",
"output": "1"
},
{
"input": "1\n0 0",
"output": "0"
},
{
"input": "1\n6 6",
"output": "0"
},
{
"input": "5\n1 5\n4 2\n4 4\n8 1\n8 2",
"output": "0"
},
{
"input": "10\n1 7\n2 14\n3 7\n3 13\n5 13\n13 10\n15 12\n17 1\n18 8\n19 0",
... | 1,616,630,811 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 61 | 204,800 | n = int(input())
a = []
for _ in range(n):
xy = list(map(int, input().split()))
a.append(xy)
slopes = {}
for i in range(n):
for j in range(i + 1, n):
slope = 0.0
x1, y1 = a[i][0], a[i][1]
x2, y2 = a[j][0], a[j][1]
if x2 - x1 != 0:
slope = (y2 - y1) / (x2 - x1)
... | Title: Number of Parallelograms
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given *n* points on a plane. All the points are distinct and no three of them lie on the same line. Find the number of parallelograms with the vertices at the given points.
Input Specification:
The fir... | ```python
n = int(input())
a = []
for _ in range(n):
xy = list(map(int, input().split()))
a.append(xy)
slopes = {}
for i in range(n):
for j in range(i + 1, n):
slope = 0.0
x1, y1 = a[i][0], a[i][1]
x2, y2 = a[j][0], a[j][1]
if x2 - x1 != 0:
slope = (y2 - y1) / (x2... | -1 | |
814 | A | An abandoned sentiment from past | PROGRAMMING | 900 | [
"constructive algorithms",
"greedy",
"implementation",
"sortings"
] | null | null | A few years ago, Hitagi encountered a giant crab, who stole the whole of her body weight. Ever since, she tried to avoid contact with others, for fear that this secret might be noticed.
To get rid of the oddity and recover her weight, a special integer sequence is needed. Hitagi's sequence has been broken for a long t... | The first line of input contains two space-separated positive integers *n* (2<=≤<=*n*<=≤<=100) and *k* (1<=≤<=*k*<=≤<=*n*) — the lengths of sequence *a* and *b* respectively.
The second line contains *n* space-separated integers *a*1,<=*a*2,<=...,<=*a**n* (0<=≤<=*a**i*<=≤<=200) — Hitagi's broken sequence with exactly ... | Output "Yes" if it's possible to replace zeros in *a* with elements in *b* and make the resulting sequence not increasing, and "No" otherwise. | [
"4 2\n11 0 0 14\n5 4\n",
"6 1\n2 3 0 8 9 10\n5\n",
"4 1\n8 94 0 4\n89\n",
"7 7\n0 0 0 0 0 0 0\n1 2 3 4 5 6 7\n"
] | [
"Yes\n",
"No\n",
"Yes\n",
"Yes\n"
] | In the first sample:
- Sequence *a* is 11, 0, 0, 14. - Two of the elements are lost, and the candidates in *b* are 5 and 4. - There are two possible resulting sequences: 11, 5, 4, 14 and 11, 4, 5, 14, both of which fulfill the requirements. Thus the answer is "Yes".
In the second sample, the only possible resulti... | 500 | [
{
"input": "4 2\n11 0 0 14\n5 4",
"output": "Yes"
},
{
"input": "6 1\n2 3 0 8 9 10\n5",
"output": "No"
},
{
"input": "4 1\n8 94 0 4\n89",
"output": "Yes"
},
{
"input": "7 7\n0 0 0 0 0 0 0\n1 2 3 4 5 6 7",
"output": "Yes"
},
{
"input": "40 1\n23 26 27 28 31 35 38 4... | 1,564,838,686 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 93 | 0 | n,m = map(int,input().split())
ln = list(map(int,input().split()))
lm = list(map(int,input().split()))
if m > 1:
print("YES")
else:
ln.sort()
if ln[1] > lm[0]:
print("NO")
else:
print("YES") | Title: An abandoned sentiment from past
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
A few years ago, Hitagi encountered a giant crab, who stole the whole of her body weight. Ever since, she tried to avoid contact with others, for fear that this secret might be noticed.
To get rid of t... | ```python
n,m = map(int,input().split())
ln = list(map(int,input().split()))
lm = list(map(int,input().split()))
if m > 1:
print("YES")
else:
ln.sort()
if ln[1] > lm[0]:
print("NO")
else:
print("YES")
``` | 0 | |
289 | A | Polo the Penguin and Segments | PROGRAMMING | 1,100 | [
"brute force",
"implementation"
] | null | null | Little penguin Polo adores integer segments, that is, pairs of integers [*l*; *r*] (*l*<=≤<=*r*).
He has a set that consists of *n* integer segments: [*l*1; *r*1],<=[*l*2; *r*2],<=...,<=[*l**n*; *r**n*]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 uni... | The first line contains two integers *n* and *k* (1<=≤<=*n*,<=*k*<=≤<=105). Each of the following *n* lines contain a segment as a pair of integers *l**i* and *r**i* (<=-<=105<=≤<=*l**i*<=≤<=*r**i*<=≤<=105), separated by a space.
It is guaranteed that no two segments intersect. In other words, for any two integers *i*... | In a single line print a single integer — the answer to the problem. | [
"2 3\n1 2\n3 4\n",
"3 7\n1 2\n3 3\n4 7\n"
] | [
"2\n",
"0\n"
] | none | 500 | [
{
"input": "2 3\n1 2\n3 4",
"output": "2"
},
{
"input": "3 7\n1 2\n3 3\n4 7",
"output": "0"
},
{
"input": "3 7\n1 10\n11 47\n74 128",
"output": "3"
},
{
"input": "5 4\n1 1\n2 2\n3 3\n4 4\n5 5",
"output": "3"
},
{
"input": "7 4\n2 2\n-1 -1\n0 1\n7 8\n-3 -2\n9 9\n4 ... | 1,628,000,790 | 2,147,483,647 | PyPy 3 | OK | TESTS | 28 | 1,652 | 28,364,800 | n,k = map(int, input().split())
s = 0
for _ in range(n):
a,b = map(int, input().split())
s += b - a + 1
print(0 if s % k == 0 else (k - s % k) % k) | Title: Polo the Penguin and Segments
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Little penguin Polo adores integer segments, that is, pairs of integers [*l*; *r*] (*l*<=≤<=*r*).
He has a set that consists of *n* integer segments: [*l*1; *r*1],<=[*l*2; *r*2],<=...,<=[*l**n*; *r**n*]... | ```python
n,k = map(int, input().split())
s = 0
for _ in range(n):
a,b = map(int, input().split())
s += b - a + 1
print(0 if s % k == 0 else (k - s % k) % k)
``` | 3 | |
340 | A | The Wall | PROGRAMMING | 1,200 | [
"math"
] | null | null | Iahub and his friend Floyd have started painting a wall. Iahub is painting the wall red and Floyd is painting it pink. You can consider the wall being made of a very large number of bricks, numbered 1, 2, 3 and so on.
Iahub has the following scheme of painting: he skips *x*<=-<=1 consecutive bricks, then he paints th... | The input will have a single line containing four integers in this order: *x*, *y*, *a*, *b*. (1<=≤<=*x*,<=*y*<=≤<=1000, 1<=≤<=*a*,<=*b*<=≤<=2·109, *a*<=≤<=*b*). | Output a single integer — the number of bricks numbered no less than *a* and no greater than *b* that are painted both red and pink. | [
"2 3 6 18\n"
] | [
"3"
] | Let's look at the bricks from *a* to *b* (*a* = 6, *b* = 18). The bricks colored in red are numbered 6, 8, 10, 12, 14, 16, 18. The bricks colored in pink are numbered 6, 9, 12, 15, 18. The bricks colored in both red and pink are numbered with 6, 12 and 18. | 500 | [
{
"input": "2 3 6 18",
"output": "3"
},
{
"input": "4 6 20 201",
"output": "15"
},
{
"input": "15 27 100 10000",
"output": "74"
},
{
"input": "105 60 3456 78910",
"output": "179"
},
{
"input": "1 1 1000 100000",
"output": "99001"
},
{
"input": "3 2 5 5... | 1,697,463,083 | 2,147,483,647 | PyPy 3 | RUNTIME_ERROR | TESTS | 0 | 124 | 2,048,000 | n1,n2,n3,n4=map(int,input().split())
def solve(n1,n2):
solution=n1*n2//math.gcd(n1,n2)
return solution
import math
solve1=solve(n1,n2)
answer=n4//solve1-(n3-1)//solve
print(answer)
| Title: The Wall
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Iahub and his friend Floyd have started painting a wall. Iahub is painting the wall red and Floyd is painting it pink. You can consider the wall being made of a very large number of bricks, numbered 1, 2, 3 and so on.
Iahub ... | ```python
n1,n2,n3,n4=map(int,input().split())
def solve(n1,n2):
solution=n1*n2//math.gcd(n1,n2)
return solution
import math
solve1=solve(n1,n2)
answer=n4//solve1-(n3-1)//solve
print(answer)
``` | -1 | |
0 | none | none | none | 0 | [
"none"
] | null | null | Young Teodor enjoys drawing. His favourite hobby is drawing segments with integer borders inside his huge [1;*m*] segment. One day Teodor noticed that picture he just drawn has one interesting feature: there doesn't exist an integer point, that belongs each of segments in the picture. Having discovered this fact, Teodo... | First line of input contains two integer numbers: *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=100<=000) — amount of segments of Teodor's picture and maximal coordinate of point that Sasha can ask about.
*i*th of next *n* lines contains two integer numbers *l**i* and *r**i* (1<=≤<=*l**i*<=≤<=*r**i*<=≤<=*m*) — left and right ends ... | Single line of output should contain one integer number *k* – size of largest set (*x**i*,<=*cnt*(*x**i*)) where all *x**i* are different, 1<=≤<=*x**i*<=≤<=*m*, and *cnt*(*x**i*) is amount of segments, containing point with coordinate *x**i*, such that one can't be sure that there doesn't exist point, belonging to all ... | [
"2 4\n1 2\n3 4\n",
"4 6\n1 3\n2 3\n4 6\n5 6\n"
] | [
"4\n",
"5\n"
] | First example shows situation where Sasha can never be sure that Teodor isn't lying to him, because even if one knows *cnt*(*x*<sub class="lower-index">*i*</sub>) for each point in segment [1;4], he can't distinguish this case from situation Teodor has drawn whole [1;4] segment.
In second example Sasha can ask about 5... | 0 | [] | 1,689,169,220 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 0 | 46 | 0 | print("_RANDOM_GUESS_1689169218.400044")# 1689169218.400059 | Title: none
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Young Teodor enjoys drawing. His favourite hobby is drawing segments with integer borders inside his huge [1;*m*] segment. One day Teodor noticed that picture he just drawn has one interesting feature: there doesn't exist an integ... | ```python
print("_RANDOM_GUESS_1689169218.400044")# 1689169218.400059
``` | 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,665,501,100 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 30 | 0 | n, m = map(int, input().split())
lis = []
open_set = set([_ for _ in range(m)])
for _ in range(n):
current_lis = [int(x) for x in input().split()]
current_lis.pop[0]
lis[len(lis):] = current_lis
if set(lis) == open_set:
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
n, m = map(int, input().split())
lis = []
open_set = set([_ for _ in range(m)])
for _ in range(n):
current_lis = [int(x) for x in input().split()]
current_lis.pop[0]
lis[len(lis):] = current_lis
if set(lis) == open_set:
print("YES")
else:
print("NO")
``` | -1 | |
476 | B | Dreamoon and WiFi | PROGRAMMING | 1,300 | [
"bitmasks",
"brute force",
"combinatorics",
"dp",
"math",
"probabilities"
] | null | null | Dreamoon is standing at the position 0 on a number line. Drazil is sending a list of commands through Wi-Fi to Dreamoon's smartphone and Dreamoon follows them.
Each command is one of the following two types:
1. Go 1 unit towards the positive direction, denoted as '+' 1. Go 1 unit towards the negative direction, de... | The first line contains a string *s*1 — the commands Drazil sends to Dreamoon, this string consists of only the characters in the set {'+', '-'}.
The second line contains a string *s*2 — the commands Dreamoon's smartphone recognizes, this string consists of only the characters in the set {'+', '-', '?'}. '?' denotes ... | Output a single real number corresponding to the probability. The answer will be considered correct if its relative or absolute error doesn't exceed 10<=-<=9. | [
"++-+-\n+-+-+\n",
"+-+-\n+-??\n",
"+++\n??-\n"
] | [
"1.000000000000\n",
"0.500000000000\n",
"0.000000000000\n"
] | For the first sample, both *s*<sub class="lower-index">1</sub> and *s*<sub class="lower-index">2</sub> will lead Dreamoon to finish at the same position + 1.
For the second sample, *s*<sub class="lower-index">1</sub> will lead Dreamoon to finish at position 0, while there are four possibilites for *s*<sub class="low... | 1,500 | [
{
"input": "++-+-\n+-+-+",
"output": "1.000000000000"
},
{
"input": "+-+-\n+-??",
"output": "0.500000000000"
},
{
"input": "+++\n??-",
"output": "0.000000000000"
},
{
"input": "++++++++++\n+++??++?++",
"output": "0.125000000000"
},
{
"input": "--+++---+-\n????????... | 1,655,723,971 | 2,147,483,647 | PyPy 3-64 | RUNTIME_ERROR | TESTS | 0 | 46 | 2,764,800 | import math
from collections import OrderedDict,Counter
import heapq
from collections import deque
import sys
def mpp():return map(int,inp().split())
def lis():return list(mpp())
def inp(): return input()
def fn(n,m):
d1=Counter(n)
d2=Counter(m)
n=d1["?"]
r=d1["+"]-d2["+"]
return 0 if n... | Title: Dreamoon and WiFi
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Dreamoon is standing at the position 0 on a number line. Drazil is sending a list of commands through Wi-Fi to Dreamoon's smartphone and Dreamoon follows them.
Each command is one of the following two types:
1. Go... | ```python
import math
from collections import OrderedDict,Counter
import heapq
from collections import deque
import sys
def mpp():return map(int,inp().split())
def lis():return list(mpp())
def inp(): return input()
def fn(n,m):
d1=Counter(n)
d2=Counter(m)
n=d1["?"]
r=d1["+"]-d2["+"]
ret... | -1 | |
46 | A | Ball Game | PROGRAMMING | 800 | [
"brute force",
"implementation"
] | A. Ball Game | 2 | 256 | A kindergarten teacher Natalia Pavlovna has invented a new ball game. This game not only develops the children's physique, but also teaches them how to count.
The game goes as follows. Kids stand in circle. Let's agree to think of the children as numbered with numbers from 1 to *n* clockwise and the child number 1 is... | The first line contains integer *n* (2<=≤<=*n*<=≤<=100) which indicates the number of kids in the circle. | In the single line print *n*<=-<=1 numbers which are the numbers of children who will get the ball after each throw. Separate the numbers by spaces. | [
"10\n",
"3\n"
] | [
"2 4 7 1 6 2 9 7 6\n",
"2 1\n"
] | none | 0 | [
{
"input": "10",
"output": "2 4 7 1 6 2 9 7 6"
},
{
"input": "3",
"output": "2 1"
},
{
"input": "4",
"output": "2 4 3"
},
{
"input": "5",
"output": "2 4 2 1"
},
{
"input": "6",
"output": "2 4 1 5 4"
},
{
"input": "7",
"output": "2 4 7 4 2 1"
},
... | 1,529,269,334 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 124 | 0 | for i in range(1, int(input())):
t = (t + i - 1) % n + 1
print(str(t), end=' ') | Title: Ball Game
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
A kindergarten teacher Natalia Pavlovna has invented a new ball game. This game not only develops the children's physique, but also teaches them how to count.
The game goes as follows. Kids stand in circle. Let's agree to think... | ```python
for i in range(1, int(input())):
t = (t + i - 1) % n + 1
print(str(t), end=' ')
``` | -1 |
14 | B | Young Photographer | PROGRAMMING | 1,000 | [
"implementation"
] | B. Young Photographer | 2 | 64 | Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position *x*0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, training at t... | The first line of the input file contains integers *n* and *x*0 (1<=≤<=*n*<=≤<=100; 0<=≤<=*x*0<=≤<=1000). The following *n* lines contain pairs of integers *a**i*,<=*b**i* (0<=≤<=*a**i*,<=*b**i*<=≤<=1000; *a**i*<=≠<=*b**i*). | Output the required minimum distance in the same units as the positions on the racetrack. If there is no such a position, output -1. | [
"3 3\n0 7\n14 2\n4 6\n"
] | [
"1\n"
] | none | 0 | [
{
"input": "3 3\n0 7\n14 2\n4 6",
"output": "1"
},
{
"input": "1 1\n0 10",
"output": "0"
},
{
"input": "2 2\n1 2\n3 2",
"output": "0"
},
{
"input": "3 2\n1 2\n2 3\n3 4",
"output": "-1"
},
{
"input": "2 4\n10 4\n1 5",
"output": "0"
},
{
"input": "1 10\n... | 1,677,234,519 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 62 | 0 | n, x0 = list(map(lambda num: int(num), input().split(" ")))
# n - number of sportsmen
# x0 - positions of photographer
sportsmens = []
# sportsmens p positions
for i in range(n):
sportsmen = list(map(lambda num: int(num), input().split(" ")))
if sportsmen[1] < sportsmen[0]:
sportsmen[0], sportsmen[1] ... | Title: Young Photographer
Time Limit: 2 seconds
Memory Limit: 64 megabytes
Problem Description:
Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position *x*0 of a long straight racetrack and got ready to take pictures. Bu... | ```python
n, x0 = list(map(lambda num: int(num), input().split(" ")))
# n - number of sportsmen
# x0 - positions of photographer
sportsmens = []
# sportsmens p positions
for i in range(n):
sportsmen = list(map(lambda num: int(num), input().split(" ")))
if sportsmen[1] < sportsmen[0]:
sportsmen[0], spo... | 0 |
3 | A | Shortest path of the king | PROGRAMMING | 1,000 | [
"greedy",
"shortest paths"
] | A. Shortest path of the king | 1 | 64 | The king is left alone on the chessboard. In spite of this loneliness, he doesn't lose heart, because he has business of national importance. For example, he has to pay an official visit to square *t*. As the king is not in habit of wasting his time, he wants to get from his current position *s* to square *t* in the le... | The first line contains the chessboard coordinates of square *s*, the second line — of square *t*.
Chessboard coordinates consist of two characters, the first one is a lowercase Latin letter (from a to h), the second one is a digit from 1 to 8. | In the first line print *n* — minimum number of the king's moves. Then in *n* lines print the moves themselves. Each move is described with one of the 8: L, R, U, D, LU, LD, RU or RD.
L, R, U, D stand respectively for moves left, right, up and down (according to the picture), and 2-letter combinations stand for diago... | [
"a8\nh1\n"
] | [
"7\nRD\nRD\nRD\nRD\nRD\nRD\nRD\n"
] | none | 0 | [
{
"input": "a8\nh1",
"output": "7\nRD\nRD\nRD\nRD\nRD\nRD\nRD"
},
{
"input": "b2\nb4",
"output": "2\nU\nU"
},
{
"input": "a5\na5",
"output": "0"
},
{
"input": "h1\nb2",
"output": "6\nLU\nL\nL\nL\nL\nL"
},
{
"input": "c5\nh2",
"output": "5\nRD\nRD\nRD\nR\nR"
... | 1,561,458,058 | 2,147,483,647 | Python 3 | OK | TESTS | 35 | 218 | 0 | tmp = input()
sx, sy = ord(tmp[0])-97, int(tmp[1])-1
tmp = input()
ex, ey = ord(tmp[0])-97, int(tmp[1])-1
dx, dy = ex-sx, ey-sy
h = [('R' if dx > 0 else 'L')]*max(dx, -dx)
v = [('U' if dy > 0 else 'D')]*max(dy, -dy)
r = max(len(h), len(v))
print(r)
for i in range(r):
s = ""
if len(h) > 0:
s += h.pop(0)... | Title: Shortest path of the king
Time Limit: 1 seconds
Memory Limit: 64 megabytes
Problem Description:
The king is left alone on the chessboard. In spite of this loneliness, he doesn't lose heart, because he has business of national importance. For example, he has to pay an official visit to square *t*. As the king ... | ```python
tmp = input()
sx, sy = ord(tmp[0])-97, int(tmp[1])-1
tmp = input()
ex, ey = ord(tmp[0])-97, int(tmp[1])-1
dx, dy = ex-sx, ey-sy
h = [('R' if dx > 0 else 'L')]*max(dx, -dx)
v = [('U' if dy > 0 else 'D')]*max(dy, -dy)
r = max(len(h), len(v))
print(r)
for i in range(r):
s = ""
if len(h) > 0:
s +... | 3.891 |
294 | A | Shaass and Oskols | PROGRAMMING | 800 | [
"implementation",
"math"
] | null | null | Shaass has decided to hunt some birds. There are *n* horizontal electricity wires aligned parallel to each other. Wires are numbered 1 to *n* from top to bottom. On each wire there are some oskols sitting next to each other. Oskol is the name of a delicious kind of birds in Shaass's territory. Supposed there are *a**i*... | The first line of the input contains an integer *n*, (1<=≤<=*n*<=≤<=100). The next line contains a list of space-separated integers *a*1,<=*a*2,<=...,<=*a**n*, (0<=≤<=*a**i*<=≤<=100).
The third line contains an integer *m*, (0<=≤<=*m*<=≤<=100). Each of the next *m* lines contains two integers *x**i* and *y**i*. The i... | On the *i*-th line of the output print the number of birds on the *i*-th wire. | [
"5\n10 10 10 10 10\n5\n2 5\n3 13\n2 12\n1 13\n4 6\n",
"3\n2 4 1\n1\n2 2\n"
] | [
"0\n12\n5\n0\n16\n",
"3\n0\n3\n"
] | none | 500 | [
{
"input": "5\n10 10 10 10 10\n5\n2 5\n3 13\n2 12\n1 13\n4 6",
"output": "0\n12\n5\n0\n16"
},
{
"input": "3\n2 4 1\n1\n2 2",
"output": "3\n0\n3"
},
{
"input": "5\n58 51 45 27 48\n5\n4 9\n5 15\n4 5\n5 8\n1 43",
"output": "0\n66\n57\n7\n0"
},
{
"input": "10\n48 53 10 28 91 56 8... | 1,596,467,256 | 2,147,483,647 | PyPy 3 | RUNTIME_ERROR | TESTS | 2 | 404 | 22,220,800 | n=int(input());l=list(map(int, input().split()))
for i in range(int(input())):
x,y = map(int, input().split())
if x-2>=0:l[x-2]+=y-1
if x<=n:l[x]+=l[x-1]-y
l[x-1]=0
print(*l) | Title: Shaass and Oskols
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Shaass has decided to hunt some birds. There are *n* horizontal electricity wires aligned parallel to each other. Wires are numbered 1 to *n* from top to bottom. On each wire there are some oskols sitting next to each... | ```python
n=int(input());l=list(map(int, input().split()))
for i in range(int(input())):
x,y = map(int, input().split())
if x-2>=0:l[x-2]+=y-1
if x<=n:l[x]+=l[x-1]-y
l[x-1]=0
print(*l)
``` | -1 | |
352 | B | Jeff and Periods | PROGRAMMING | 1,300 | [
"implementation",
"sortings"
] | null | null | One day Jeff got hold of an integer sequence *a*1, *a*2, ..., *a**n* of length *n*. The boy immediately decided to analyze the sequence. For that, he needs to find all values of *x*, for which these conditions hold:
- *x* occurs in sequence *a*. - Consider all positions of numbers *x* in the sequence *a* (such *i*, ... | The first line contains integer *n* (1<=≤<=*n*<=≤<=105). The next line contains integers *a*1, *a*2, ..., *a**n* (1<=≤<=*a**i*<=≤<=105). The numbers are separated by spaces. | In the first line print integer *t* — the number of valid *x*. On each of the next *t* lines print two integers *x* and *p**x*, where *x* is current suitable value, *p**x* is the common difference between numbers in the progression (if *x* occurs exactly once in the sequence, *p**x* must equal 0). Print the pairs in th... | [
"1\n2\n",
"8\n1 2 1 3 1 2 1 5\n"
] | [
"1\n2 0\n",
"4\n1 2\n2 4\n3 0\n5 0\n"
] | In the first test 2 occurs exactly once in the sequence, ergo *p*<sub class="lower-index">2</sub> = 0. | 1,000 | [
{
"input": "1\n2",
"output": "1\n2 0"
},
{
"input": "8\n1 2 1 3 1 2 1 5",
"output": "4\n1 2\n2 4\n3 0\n5 0"
},
{
"input": "3\n1 10 5",
"output": "3\n1 0\n5 0\n10 0"
},
{
"input": "4\n9 9 3 5",
"output": "3\n3 0\n5 0\n9 1"
},
{
"input": "6\n1 2 2 1 1 2",
"outpu... | 1,644,373,375 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 2 | 154 | 0 | n = int(input())
a = list(map(int, input().split()))
dict = {}
t = []
for i in range(n):
if a[i] not in dict:
dict[a[i]] = [i]
else :
dict[a[i]].append(i)
for x, y in dict.items():
ans = "YES"
cd = 0
if len(y) > 1:
cd = y[1] - y[0]
for i in range(1, len(y) - 1):
... | Title: Jeff and Periods
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
One day Jeff got hold of an integer sequence *a*1, *a*2, ..., *a**n* of length *n*. The boy immediately decided to analyze the sequence. For that, he needs to find all values of *x*, for which these conditions hold:
-... | ```python
n = int(input())
a = list(map(int, input().split()))
dict = {}
t = []
for i in range(n):
if a[i] not in dict:
dict[a[i]] = [i]
else :
dict[a[i]].append(i)
for x, y in dict.items():
ans = "YES"
cd = 0
if len(y) > 1:
cd = y[1] - y[0]
for i in range(1, len(y) -... | 0 | |
977 | A | Wrong Subtraction | PROGRAMMING | 800 | [
"implementation"
] | null | null | Little girl Tanya is learning how to decrease a number by one, but she does it wrong with a number consisting of two or more digits. Tanya subtracts one from a number by the following algorithm:
- if the last digit of the number is non-zero, she decreases the number by one; - if the last digit of the number is zero,... | The first line of the input contains two integer numbers $n$ and $k$ ($2 \le n \le 10^9$, $1 \le k \le 50$) — the number from which Tanya will subtract and the number of subtractions correspondingly. | Print one integer number — the result of the decreasing $n$ by one $k$ times.
It is guaranteed that the result will be positive integer number. | [
"512 4\n",
"1000000000 9\n"
] | [
"50\n",
"1\n"
] | The first example corresponds to the following sequence: $512 \rightarrow 511 \rightarrow 510 \rightarrow 51 \rightarrow 50$. | 0 | [
{
"input": "512 4",
"output": "50"
},
{
"input": "1000000000 9",
"output": "1"
},
{
"input": "131203 11",
"output": "12"
},
{
"input": "999999999 50",
"output": "9999"
},
{
"input": "999999999 49",
"output": "99990"
},
{
"input": "131203 9",
"outpu... | 1,697,821,540 | 2,147,483,647 | Python 3 | OK | TESTS | 11 | 46 | 0 | w,n = map(int,input().split())
for i in range(n):
if w%10 == 0:
w = w//10
else:
w-=1
print(w) | Title: Wrong Subtraction
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Little girl Tanya is learning how to decrease a number by one, but she does it wrong with a number consisting of two or more digits. Tanya subtracts one from a number by the following algorithm:
- if the last digit ... | ```python
w,n = map(int,input().split())
for i in range(n):
if w%10 == 0:
w = w//10
else:
w-=1
print(w)
``` | 3 | |
598 | A | Tricky Sum | PROGRAMMING | 900 | [
"math"
] | null | null | In this problem you are to calculate the sum of all integers from 1 to *n*, but you should take all powers of two with minus in the sum.
For example, for *n*<==<=4 the sum is equal to <=-<=1<=-<=2<=+<=3<=-<=4<==<=<=-<=4, because 1, 2 and 4 are 20, 21 and 22 respectively.
Calculate the answer for *t* values of *n*. | The first line of the input contains a single integer *t* (1<=≤<=*t*<=≤<=100) — the number of values of *n* to be processed.
Each of next *t* lines contains a single integer *n* (1<=≤<=*n*<=≤<=109). | Print the requested sum for each of *t* integers *n* given in the input. | [
"2\n4\n1000000000\n"
] | [
"-4\n499999998352516354\n"
] | The answer for the first sample is explained in the statement. | 0 | [
{
"input": "2\n4\n1000000000",
"output": "-4\n499999998352516354"
},
{
"input": "10\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10",
"output": "-1\n-3\n0\n-4\n1\n7\n14\n6\n15\n25"
},
{
"input": "10\n10\n9\n47\n33\n99\n83\n62\n1\n100\n53",
"output": "25\n15\n1002\n435\n4696\n3232\n1827\n-1\n4796\n130... | 1,631,939,118 | 2,147,483,647 | Python 3 | OK | TESTS | 21 | 77 | 6,758,400 | t = int(input())
for i in range(t):
n = int(input())
s = n*(n+1)//2
p = 1
while p <= n:
s = s - p * 2
p = p * 2
print(s)
| Title: Tricky Sum
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
In this problem you are to calculate the sum of all integers from 1 to *n*, but you should take all powers of two with minus in the sum.
For example, for *n*<==<=4 the sum is equal to <=-<=1<=-<=2<=+<=3<=-<=4<==<=<=-<=4, be... | ```python
t = int(input())
for i in range(t):
n = int(input())
s = n*(n+1)//2
p = 1
while p <= n:
s = s - p * 2
p = p * 2
print(s)
``` | 3 | |
122 | A | Lucky Division | PROGRAMMING | 1,000 | [
"brute force",
"number theory"
] | null | null | Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya calls a number almost lucky if it could be evenly divided by some lucky number. Help him find ... | The single line contains an integer *n* (1<=≤<=*n*<=≤<=1000) — the number that needs to be checked. | In the only line print "YES" (without the quotes), if number *n* is almost lucky. Otherwise, print "NO" (without the quotes). | [
"47\n",
"16\n",
"78\n"
] | [
"YES\n",
"YES\n",
"NO\n"
] | Note that all lucky numbers are almost lucky as any number is evenly divisible by itself.
In the first sample 47 is a lucky number. In the second sample 16 is divisible by 4. | 500 | [
{
"input": "47",
"output": "YES"
},
{
"input": "16",
"output": "YES"
},
{
"input": "78",
"output": "NO"
},
{
"input": "48",
"output": "YES"
},
{
"input": "100",
"output": "YES"
},
{
"input": "107",
"output": "NO"
},
{
"input": "77",
"ou... | 1,698,042,151 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 2 | 62 | 0 | s = int(input())
a = [47,744,4]
for i in a:
if s % i == 0:
bibi = True
if bibi == True:
print("YES")
else:
print("NO")
| Title: Lucky Division
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
... | ```python
s = int(input())
a = [47,744,4]
for i in a:
if s % i == 0:
bibi = True
if bibi == True:
print("YES")
else:
print("NO")
``` | -1 | |
5 | B | Center Alignment | PROGRAMMING | 1,200 | [
"implementation",
"strings"
] | B. Center Alignment | 1 | 64 | Almost every text editor has a built-in function of center text alignment. The developers of the popular in Berland text editor «Textpad» decided to introduce this functionality into the fourth release of the product.
You are to implement the alignment in the shortest possible time. Good luck! | The input file consists of one or more lines, each of the lines contains Latin letters, digits and/or spaces. The lines cannot start or end with a space. It is guaranteed that at least one of the lines has positive length. The length of each line and the total amount of the lines do not exceed 1000. | Format the given text, aligning it center. Frame the whole text with characters «*» of the minimum size. If a line cannot be aligned perfectly (for example, the line has even length, while the width of the block is uneven), you should place such lines rounding down the distance to the left or to the right edge and brin... | [
"This is\n\nCodeforces\nBeta\nRound\n5\n",
"welcome to the\nCodeforces\nBeta\nRound 5\n\nand\ngood luck\n"
] | [
"************\n* This is *\n* *\n*Codeforces*\n* Beta *\n* Round *\n* 5 *\n************\n",
"****************\n*welcome to the*\n* Codeforces *\n* Beta *\n* Round 5 *\n* *\n* and *\n* good luck *\n****************\n"
] | none | 0 | [
{
"input": "This is\n\nCodeforces\nBeta\nRound\n5",
"output": "************\n* This is *\n* *\n*Codeforces*\n* Beta *\n* Round *\n* 5 *\n************"
},
{
"input": "welcome to the\nCodeforces\nBeta\nRound 5\n\nand\ngood luck",
"output": "****************\n*welcome to th... | 1,583,268,308 | 2,147,483,647 | PyPy 3 | OK | TESTS | 19 | 498 | 4,505,600 | from math import floor, ceil
inputs = []
while True:
try:
inputs.append(input())
except:
break
s = max(map(len, inputs))
left = True
print('*' * (s+2))
for i in inputs:
l = len(i)
if (s-l) % 2 == 0:
print('*' + ' '*floor((s-l)/2) + i + ' '*ceil((s-l)/2) + '*')
... | Title: Center Alignment
Time Limit: 1 seconds
Memory Limit: 64 megabytes
Problem Description:
Almost every text editor has a built-in function of center text alignment. The developers of the popular in Berland text editor «Textpad» decided to introduce this functionality into the fourth release of the product.
You ... | ```python
from math import floor, ceil
inputs = []
while True:
try:
inputs.append(input())
except:
break
s = max(map(len, inputs))
left = True
print('*' * (s+2))
for i in inputs:
l = len(i)
if (s-l) % 2 == 0:
print('*' + ' '*floor((s-l)/2) + i + ' '*ceil((s-l)/2)... | 3.717431 |
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,692,493,714 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 15 | 0 | n = input()
if len(n) > 10:
print(n[-len(n)] + str(len(n) - 2) + n[-1])
else:
print(n) | Title: Way Too Long Words
Time Limit: 1 seconds
Memory Limit: 256 megabytes
Problem Description:
Sometimes some words like "localization" or "internationalization" are so long that writing them many times in one text is quite tiresome.
Let's consider a word too long, if its length is strictly more than 10 character... | ```python
n = input()
if len(n) > 10:
print(n[-len(n)] + str(len(n) - 2) + n[-1])
else:
print(n)
``` | 0 |
805 | A | Fake NP | PROGRAMMING | 1,000 | [
"greedy",
"math"
] | null | null | Tavak and Seyyed are good friends. Seyyed is very funny and he told Tavak to solve the following problem instead of longest-path.
You are given *l* and *r*. For all integers from *l* to *r*, inclusive, we wrote down all of their integer divisors except 1. Find the integer that we wrote down the maximum number of times... | The first line contains two integers *l* and *r* (2<=≤<=*l*<=≤<=*r*<=≤<=109). | Print single integer, the integer that appears maximum number of times in the divisors.
If there are multiple answers, print any of them. | [
"19 29\n",
"3 6\n"
] | [
"2\n",
"3\n"
] | Definition of a divisor: [https://www.mathsisfun.com/definitions/divisor-of-an-integer-.html](https://www.mathsisfun.com/definitions/divisor-of-an-integer-.html)
The first example: from 19 to 29 these numbers are divisible by 2: {20, 22, 24, 26, 28}.
The second example: from 3 to 6 these numbers are divisible by 3: {... | 500 | [
{
"input": "19 29",
"output": "2"
},
{
"input": "3 6",
"output": "2"
},
{
"input": "39 91",
"output": "2"
},
{
"input": "76 134",
"output": "2"
},
{
"input": "93 95",
"output": "2"
},
{
"input": "17 35",
"output": "2"
},
{
"input": "94 95",... | 1,621,533,081 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 24 | 108 | 0 | l,r = map(int,input().split())
div2 = 0
div3 = 0
print(2)
| Title: Fake NP
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Tavak and Seyyed are good friends. Seyyed is very funny and he told Tavak to solve the following problem instead of longest-path.
You are given *l* and *r*. For all integers from *l* to *r*, inclusive, we wrote down all of the... | ```python
l,r = map(int,input().split())
div2 = 0
div3 = 0
print(2)
``` | 0 | |
535 | B | Tavas and SaDDas | PROGRAMMING | 1,100 | [
"bitmasks",
"brute force",
"combinatorics",
"implementation"
] | null | null | Once again Tavas started eating coffee mix without water! Keione told him that it smells awful, but he didn't stop doing that. That's why Keione told his smart friend, SaDDas to punish him! SaDDas took Tavas' headphones and told him: "If you solve the following problem, I'll return it to you."
The problem is:
You ar... | The first and only line of input contains a lucky number *n* (1<=≤<=*n*<=≤<=109). | Print the index of *n* among all lucky numbers. | [
"4\n",
"7\n",
"77\n"
] | [
"1\n",
"2\n",
"6\n"
] | none | 1,000 | [
{
"input": "4",
"output": "1"
},
{
"input": "7",
"output": "2"
},
{
"input": "77",
"output": "6"
},
{
"input": "4",
"output": "1"
},
{
"input": "474744",
"output": "83"
},
{
"input": "777774",
"output": "125"
},
{
"input": "447",
"outpu... | 1,682,118,479 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 31 | 0 | n = int(input())
A =[]
a = 0
h = 0
d = 0
while n>0:
A.append(n%10)
n = n//10
h = h+1
A.reverse()
for i in range(len(A)):
if A[i] == 4:
d = 1
if A[i] == 4:
d = 2
if A[i] == 4 and A[i-1] == 4:
d = 2**i
if A[i] == 4 and A[i-1] == 7:
d = 2**i+1
... | Title: Tavas and SaDDas
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Once again Tavas started eating coffee mix without water! Keione told him that it smells awful, but he didn't stop doing that. That's why Keione told his smart friend, SaDDas to punish him! SaDDas took Tavas' headphone... | ```python
n = int(input())
A =[]
a = 0
h = 0
d = 0
while n>0:
A.append(n%10)
n = n//10
h = h+1
A.reverse()
for i in range(len(A)):
if A[i] == 4:
d = 1
if A[i] == 4:
d = 2
if A[i] == 4 and A[i-1] == 4:
d = 2**i
if A[i] == 4 and A[i-1] == 7:
d = 2... | 0 | |
424 | B | Megacity | PROGRAMMING | 1,200 | [
"binary search",
"greedy",
"implementation",
"sortings"
] | null | null | The administration of the Tomsk Region firmly believes that it's time to become a megacity (that is, get population of one million). Instead of improving the demographic situation, they decided to achieve its goal by expanding the boundaries of the city.
The city of Tomsk can be represented as point on the plane with ... | The first line of the input contains two integers *n* and *s* (1<=≤<=*n*<=≤<=103; 1<=≤<=*s*<=<<=106) — the number of locatons around Tomsk city and the population of the city. Then *n* lines follow. The *i*-th line contains three integers — the *x**i* and *y**i* coordinate values of the *i*-th location and the numbe... | In the output, print "-1" (without the quotes), if Tomsk won't be able to become a megacity. Otherwise, in the first line print a single real number — the minimum radius of the circle that the city needs to expand to in order to become a megacity.
The answer is considered correct if the absolute or relative error don'... | [
"4 999998\n1 1 1\n2 2 1\n3 3 1\n2 -2 1\n",
"4 999998\n1 1 2\n2 2 1\n3 3 1\n2 -2 1\n",
"2 1\n1 1 999997\n2 2 1\n"
] | [
"2.8284271\n",
"1.4142136\n",
"-1"
] | none | 1,000 | [
{
"input": "4 999998\n1 1 1\n2 2 1\n3 3 1\n2 -2 1",
"output": "2.8284271"
},
{
"input": "4 999998\n1 1 2\n2 2 1\n3 3 1\n2 -2 1",
"output": "1.4142136"
},
{
"input": "2 1\n1 1 999997\n2 2 1",
"output": "-1"
},
{
"input": "4 999998\n3 3 10\n-3 3 10\n3 -3 10\n-3 -3 10",
"out... | 1,573,408,542 | 2,147,483,647 | Python 3 | OK | TESTS | 54 | 124 | 307,200 | n, s = map(int, input().split())
l = []
for _ in range(n):
x, y, k = map(int, input().split())
l.append(((x**2+y**2)**0.5, k))
l.sort()
i = 0
dist = 0
while s < 10**6 and i < n:
s += l[i][1]
dist = l[i][0]
i += 1
if s < 10**6:
print("-1")
else:
print(("%.7f")%dist)
... | Title: Megacity
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The administration of the Tomsk Region firmly believes that it's time to become a megacity (that is, get population of one million). Instead of improving the demographic situation, they decided to achieve its goal by expanding... | ```python
n, s = map(int, input().split())
l = []
for _ in range(n):
x, y, k = map(int, input().split())
l.append(((x**2+y**2)**0.5, k))
l.sort()
i = 0
dist = 0
while s < 10**6 and i < n:
s += l[i][1]
dist = l[i][0]
i += 1
if s < 10**6:
print("-1")
else:
print(("%.7f")%d... | 3 | |
81 | A | Plug-in | PROGRAMMING | 1,400 | [
"implementation"
] | A. Plug-in | 1 | 256 | Polycarp thinks about the meaning of life very often. He does this constantly, even when typing in the editor. Every time he starts brooding he can no longer fully concentrate and repeatedly presses the keys that need to be pressed only once. For example, instead of the phrase "how are you" he can type "hhoow aaaare yy... | The input data consists of a single line to be processed. The length of the line is from 1 to 2·105 characters inclusive. The string contains only lowercase Latin letters. | Print the given string after it is processed. It is guaranteed that the result will contain at least one character. | [
"hhoowaaaareyyoouu\n",
"reallazy\n",
"abacabaabacabaa\n"
] | [
"wre",
"rezy",
"a"
] | none | 500 | [
{
"input": "hhoowaaaareyyoouu",
"output": "wre"
},
{
"input": "reallazy",
"output": "rezy"
},
{
"input": "abacabaabacabaa",
"output": "a"
},
{
"input": "xraccabccbry",
"output": "xy"
},
{
"input": "a",
"output": "a"
},
{
"input": "b",
"output": "b"... | 1,599,493,707 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 154 | 0 | p=[]
for i in input():
if not p or i==p[-1]:
p.pop()
else:
p.append(i)
print(''.join(r)) | Title: Plug-in
Time Limit: 1 seconds
Memory Limit: 256 megabytes
Problem Description:
Polycarp thinks about the meaning of life very often. He does this constantly, even when typing in the editor. Every time he starts brooding he can no longer fully concentrate and repeatedly presses the keys that need to be pressed... | ```python
p=[]
for i in input():
if not p or i==p[-1]:
p.pop()
else:
p.append(i)
print(''.join(r))
``` | -1 |
258 | A | Little Elephant and Bits | PROGRAMMING | 1,100 | [
"greedy",
"math"
] | null | null | The Little Elephant has an integer *a*, written in the binary notation. He wants to write this number on a piece of paper.
To make sure that the number *a* fits on the piece of paper, the Little Elephant ought to delete exactly one any digit from number *a* in the binary record. At that a new number appears. It consis... | The single line contains integer *a*, written in the binary notation without leading zeroes. This number contains more than 1 and at most 105 digits. | In the single line print the number that is written without leading zeroes in the binary notation — the answer to the problem. | [
"101\n",
"110010\n"
] | [
"11\n",
"11010\n"
] | In the first sample the best strategy is to delete the second digit. That results in number 11<sub class="lower-index">2</sub> = 3<sub class="lower-index">10</sub>.
In the second sample the best strategy is to delete the third or fourth digits — that results in number 11010<sub class="lower-index">2</sub> = 26<sub cla... | 500 | [
{
"input": "101",
"output": "11"
},
{
"input": "110010",
"output": "11010"
},
{
"input": "10000",
"output": "1000"
},
{
"input": "1111111110",
"output": "111111111"
},
{
"input": "10100101011110101",
"output": "1100101011110101"
},
{
"input": "11101001... | 1,591,439,082 | 2,147,483,647 | PyPy 3 | RUNTIME_ERROR | TESTS | 0 | 404 | 2,150,400 | n = [str(i) for i in input()]
if '0' in k:
n.remove('0')
print(''.join(i for i in n))
else:
n.remove('1')
print(''.join(i for i in n)) | Title: Little Elephant and Bits
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The Little Elephant has an integer *a*, written in the binary notation. He wants to write this number on a piece of paper.
To make sure that the number *a* fits on the piece of paper, the Little Elephant ought... | ```python
n = [str(i) for i in input()]
if '0' in k:
n.remove('0')
print(''.join(i for i in n))
else:
n.remove('1')
print(''.join(i for i in n))
``` | -1 | |
965 | C | Greedy Arkady | PROGRAMMING | 2,000 | [
"math"
] | null | null | $k$ people want to split $n$ candies between them. Each candy should be given to exactly one of them or be thrown away.
The people are numbered from $1$ to $k$, and Arkady is the first of them. To split the candies, Arkady will choose an integer $x$ and then give the first $x$ candies to himself, the next $x$ candies ... | The only line contains four integers $n$, $k$, $M$ and $D$ ($2 \le n \le 10^{18}$, $2 \le k \le n$, $1 \le M \le n$, $1 \le D \le \min{(n, 1000)}$, $M \cdot D \cdot k \ge n$) — the number of candies, the number of people, the maximum number of candies given to a person at once, the maximum number of times a person can ... | Print a single integer — the maximum possible number of candies Arkady can give to himself.
Note that it is always possible to choose some valid $x$. | [
"20 4 5 2\n",
"30 9 4 1\n"
] | [
"8\n",
"4\n"
] | In the first example Arkady should choose $x = 4$. He will give $4$ candies to himself, $4$ candies to the second person, $4$ candies to the third person, then $4$ candies to the fourth person and then again $4$ candies to himself. No person is given candies more than $2$ times, and Arkady receives $8$ candies in total... | 1,500 | [
{
"input": "20 4 5 2",
"output": "8"
},
{
"input": "30 9 4 1",
"output": "4"
},
{
"input": "2 2 1 1",
"output": "1"
},
{
"input": "42 20 5 29",
"output": "5"
},
{
"input": "1000000000000000000 135 1000000000000000 1000",
"output": "8325624421831635"
},
{
... | 1,542,813,302 | 5,222 | Python 3 | WRONG_ANSWER | TESTS | 3 | 109 | 0 | def calc(x, nn, kk):
ans = nn // (x * kk)
if nn % (x * kk) > 0:
ans += 1
return -ans * x
n, k, m, d = map(int, input().split())
l = 1
h = m
while l <= h:
mi = (l + h) // 2
each = mi * k
each_rec = n // each
if n % each > 0:
each_rec += 1
if each_rec <= d:
h = mi - 1
else:
l = mi + ... | Title: Greedy Arkady
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
$k$ people want to split $n$ candies between them. Each candy should be given to exactly one of them or be thrown away.
The people are numbered from $1$ to $k$, and Arkady is the first of them. To split the candies, Arka... | ```python
def calc(x, nn, kk):
ans = nn // (x * kk)
if nn % (x * kk) > 0:
ans += 1
return -ans * x
n, k, m, d = map(int, input().split())
l = 1
h = m
while l <= h:
mi = (l + h) // 2
each = mi * k
each_rec = n // each
if n % each > 0:
each_rec += 1
if each_rec <= d:
h = mi - 1
else:
... | 0 | |
96 | A | Football | PROGRAMMING | 900 | [
"implementation",
"strings"
] | A. Football | 2 | 256 | Petya loves football very much. One day, as he was watching a football match, he was writing the players' current positions on a piece of paper. To simplify the situation he depicted it as a string consisting of zeroes and ones. A zero corresponds to players of one team; a one corresponds to players of another team. If... | The first input line contains a non-empty string consisting of characters "0" and "1", which represents players. The length of the string does not exceed 100 characters. There's at least one player from each team present on the field. | Print "YES" if the situation is dangerous. Otherwise, print "NO". | [
"001001\n",
"1000000001\n"
] | [
"NO\n",
"YES\n"
] | none | 500 | [
{
"input": "001001",
"output": "NO"
},
{
"input": "1000000001",
"output": "YES"
},
{
"input": "00100110111111101",
"output": "YES"
},
{
"input": "11110111111111111",
"output": "YES"
},
{
"input": "01",
"output": "NO"
},
{
"input": "10100101",
"outp... | 1,686,600,087 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 40 | 92 | 0 | jugadores=str(input())
contParaCero=1
contParaUno=1
comprobar=False
for i in range(len(jugadores)-1):
if(jugadores[i]=="0"):
contParaUno=0
contParaCero+=1
if(contParaCero>=7):
comprobar=True
elif(jugadores[i]=="1"):
contParaCero=0
contParaUno+=1
if(contParaUno>=7):
... | Title: Football
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Petya loves football very much. One day, as he was watching a football match, he was writing the players' current positions on a piece of paper. To simplify the situation he depicted it as a string consisting of zeroes and ones. A... | ```python
jugadores=str(input())
contParaCero=1
contParaUno=1
comprobar=False
for i in range(len(jugadores)-1):
if(jugadores[i]=="0"):
contParaUno=0
contParaCero+=1
if(contParaCero>=7):
comprobar=True
elif(jugadores[i]=="1"):
contParaCero=0
contParaUno+=1
if(contParaUno>... | 0 |
139 | A | Petr and Book | PROGRAMMING | 1,000 | [
"implementation"
] | null | null | One Sunday Petr went to a bookshop and bought a new book on sports programming. The book had exactly *n* pages.
Petr decided to start reading it starting from the next day, that is, from Monday. Petr's got a very tight schedule and for each day of the week he knows how many pages he will be able to read on that day. S... | The first input line contains the single integer *n* (1<=≤<=*n*<=≤<=1000) — the number of pages in the book.
The second line contains seven non-negative space-separated integers that do not exceed 1000 — those integers represent how many pages Petr can read on Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and... | Print a single number — the number of the day of the week, when Petr will finish reading the book. The days of the week are numbered starting with one in the natural order: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday. | [
"100\n15 20 20 15 10 30 45\n",
"2\n1 0 0 0 0 0 0\n"
] | [
"6\n",
"1\n"
] | Note to the first sample:
By the end of Monday and therefore, by the beginning of Tuesday Petr has 85 pages left. He has 65 pages left by Wednesday, 45 by Thursday, 30 by Friday, 20 by Saturday and on Saturday Petr finishes reading the book (and he also has time to read 10 pages of something else).
Note to the second... | 500 | [
{
"input": "100\n15 20 20 15 10 30 45",
"output": "6"
},
{
"input": "2\n1 0 0 0 0 0 0",
"output": "1"
},
{
"input": "100\n100 200 100 200 300 400 500",
"output": "1"
},
{
"input": "3\n1 1 1 1 1 1 1",
"output": "3"
},
{
"input": "1\n1 1 1 1 1 1 1",
"output": "1... | 1,687,560,630 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 49 | 124 | 1,638,400 | n=int(input())
l=list(map(int,input().split()))
sum=0
count=0
while(True):
sum=sum+l[count]
if sum >= n:
print(count+1)
break
if count<6:
count+=1
else:
count=0
| Title: Petr and Book
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
One Sunday Petr went to a bookshop and bought a new book on sports programming. The book had exactly *n* pages.
Petr decided to start reading it starting from the next day, that is, from Monday. Petr's got a very tight s... | ```python
n=int(input())
l=list(map(int,input().split()))
sum=0
count=0
while(True):
sum=sum+l[count]
if sum >= n:
print(count+1)
break
if count<6:
count+=1
else:
count=0
``` | 3 | |
58 | A | Chat room | PROGRAMMING | 1,000 | [
"greedy",
"strings"
] | A. Chat room | 1 | 256 | Vasya has recently learned to type and log on to the Internet. He immediately entered a chat room and decided to say hello to everybody. Vasya typed the word *s*. It is considered that Vasya managed to say hello if several letters can be deleted from the typed word so that it resulted in the word "hello". For example, ... | The first and only line contains the word *s*, which Vasya typed. This word consisits of small Latin letters, its length is no less that 1 and no more than 100 letters. | If Vasya managed to say hello, print "YES", otherwise print "NO". | [
"ahhellllloou\n",
"hlelo\n"
] | [
"YES\n",
"NO\n"
] | none | 500 | [
{
"input": "ahhellllloou",
"output": "YES"
},
{
"input": "hlelo",
"output": "NO"
},
{
"input": "helhcludoo",
"output": "YES"
},
{
"input": "hehwelloho",
"output": "YES"
},
{
"input": "pnnepelqomhhheollvlo",
"output": "YES"
},
{
"input": "tymbzjyqhymeda... | 1,622,608,613 | 2,147,483,647 | PyPy 3 | OK | TESTS | 40 | 155 | 0 | def iscorrect(s,t):
i=0
j=0
while(j<len(s) and i<len(t)):
if(s[j]==t[i]):
i+=1
j+=1
return i==len(t)
s=input()
t='hello'
if(iscorrect(s,t)):
print("YES")
else:
print("NO") | Title: Chat room
Time Limit: 1 seconds
Memory Limit: 256 megabytes
Problem Description:
Vasya has recently learned to type and log on to the Internet. He immediately entered a chat room and decided to say hello to everybody. Vasya typed the word *s*. It is considered that Vasya managed to say hello if several letter... | ```python
def iscorrect(s,t):
i=0
j=0
while(j<len(s) and i<len(t)):
if(s[j]==t[i]):
i+=1
j+=1
return i==len(t)
s=input()
t='hello'
if(iscorrect(s,t)):
print("YES")
else:
print("NO")
``` | 3.9225 |
808 | B | Average Sleep Time | PROGRAMMING | 1,300 | [
"data structures",
"implementation",
"math"
] | null | null | It's been almost a week since Polycarp couldn't get rid of insomnia. And as you may already know, one week in Berland lasts *k* days!
When Polycarp went to a doctor with his problem, the doctor asked him about his sleeping schedule (more specifically, the average amount of hours of sleep per week). Luckily, Polycarp k... | The first line contains two integer numbers *n* and *k* (1<=≤<=*k*<=≤<=*n*<=≤<=2·105).
The second line contains *n* integer numbers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=105). | Output average sleeping time over all weeks.
The answer is considered to be correct if its absolute or relative error does not exceed 10<=-<=6. In particular, it is enough to output real number with at least 6 digits after the decimal point. | [
"3 2\n3 4 7\n",
"1 1\n10\n",
"8 2\n1 2 4 100000 123 456 789 1\n"
] | [
"9.0000000000\n",
"10.0000000000\n",
"28964.2857142857\n"
] | In the third example there are *n* - *k* + 1 = 7 weeks, so the answer is sums of all weeks divided by 7. | 0 | [
{
"input": "3 2\n3 4 7",
"output": "9.0000000000"
},
{
"input": "1 1\n10",
"output": "10.0000000000"
},
{
"input": "8 2\n1 2 4 100000 123 456 789 1",
"output": "28964.2857142857"
},
{
"input": "1 1\n1",
"output": "1.0000000000"
},
{
"input": "1 1\n100000",
"ou... | 1,496,500,402 | 2,147,483,647 | Python 3 | OK | TESTS | 29 | 202 | 14,233,600 | (n, k) = map(int, input().split())
A = list(map(int, input().split()))
S = sum(A[:k])
oper = S
for i in range(n-k):
oper -= A[i]
oper += A[i+k]
S += oper
#if n != 1:
# print(str((sum(S) / (n-k+1))*2)[:-2])
#else:
print(S / (n-k+1)) | Title: Average Sleep Time
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
It's been almost a week since Polycarp couldn't get rid of insomnia. And as you may already know, one week in Berland lasts *k* days!
When Polycarp went to a doctor with his problem, the doctor asked him about his s... | ```python
(n, k) = map(int, input().split())
A = list(map(int, input().split()))
S = sum(A[:k])
oper = S
for i in range(n-k):
oper -= A[i]
oper += A[i+k]
S += oper
#if n != 1:
# print(str((sum(S) / (n-k+1))*2)[:-2])
#else:
print(S / (n-k+1))
``` | 3 | |
1 | A | Theatre Square | PROGRAMMING | 1,000 | [
"math"
] | A. Theatre Square | 1 | 256 | Theatre Square in the capital city of Berland has a rectangular shape with the size *n*<=×<=*m* meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the size *a*<=×<=*a*.
What is the least number of flagstones needed to pave the... | The input contains three positive integer numbers in the first line: *n*,<=<=*m* and *a* (1<=≤<=<=*n*,<=*m*,<=*a*<=≤<=109). | Write the needed number of flagstones. | [
"6 6 4\n"
] | [
"4\n"
] | none | 0 | [
{
"input": "6 6 4",
"output": "4"
},
{
"input": "1 1 1",
"output": "1"
},
{
"input": "2 1 1",
"output": "2"
},
{
"input": "1 2 1",
"output": "2"
},
{
"input": "2 2 1",
"output": "4"
},
{
"input": "2 1 2",
"output": "1"
},
{
"input": "1 1 3"... | 1,696,441,300 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 15 | 0 | n,m,a=list(map(int, input().split()))
print((n/a)*(m/a))
| Title: Theatre Square
Time Limit: 1 seconds
Memory Limit: 256 megabytes
Problem Description:
Theatre Square in the capital city of Berland has a rectangular shape with the size *n*<=×<=*m* meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each ... | ```python
n,m,a=list(map(int, input().split()))
print((n/a)*(m/a))
``` | 0 |
268 | A | Games | PROGRAMMING | 800 | [
"brute force"
] | null | null | Manao works on a sports TV. He's spent much time watching the football games of some country. After a while he began to notice different patterns. For example, each team has two sets of uniforms: home uniform and guest uniform. When a team plays a game at home, the players put on the home uniform. When a team plays as ... | The first line contains an integer *n* (2<=≤<=*n*<=≤<=30). Each of the following *n* lines contains a pair of distinct space-separated integers *h**i*, *a**i* (1<=≤<=*h**i*,<=*a**i*<=≤<=100) — the colors of the *i*-th team's home and guest uniforms, respectively. | In a single line print the number of games where the host team is going to play in the guest uniform. | [
"3\n1 2\n2 4\n3 4\n",
"4\n100 42\n42 100\n5 42\n100 5\n",
"2\n1 2\n1 2\n"
] | [
"1\n",
"5\n",
"0\n"
] | In the first test case the championship consists of 6 games. The only game with the event in question is the game between teams 2 and 1 on the stadium of team 2.
In the second test sample the host team will have to wear guest uniform in the games between teams: 1 and 2, 2 and 1, 2 and 3, 3 and 4, 4 and 2 (the host tea... | 500 | [
{
"input": "3\n1 2\n2 4\n3 4",
"output": "1"
},
{
"input": "4\n100 42\n42 100\n5 42\n100 5",
"output": "5"
},
{
"input": "2\n1 2\n1 2",
"output": "0"
},
{
"input": "7\n4 7\n52 55\n16 4\n55 4\n20 99\n3 4\n7 52",
"output": "6"
},
{
"input": "10\n68 42\n1 35\n25 70\n... | 1,672,907,591 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 31 | 154 | 1,536,000 | n=int(input())
m=[]
k=0
for i in range(n):
h,a=map(int,input().split())
m.append(h)
m.append(a)
for i in range(0,len(m),2):
for w in range(len(m)):
if m[w]==m[i] and w%2!=0:
k+=1
print(k)
| Title: Games
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Manao works on a sports TV. He's spent much time watching the football games of some country. After a while he began to notice different patterns. For example, each team has two sets of uniforms: home uniform and guest uniform. W... | ```python
n=int(input())
m=[]
k=0
for i in range(n):
h,a=map(int,input().split())
m.append(h)
m.append(a)
for i in range(0,len(m),2):
for w in range(len(m)):
if m[w]==m[i] and w%2!=0:
k+=1
print(k)
``` | 3 | |
813 | A | The Contest | PROGRAMMING | 1,100 | [
"implementation"
] | null | null | Pasha is participating in a contest on one well-known website. This time he wants to win the contest and will do anything to get to the first place!
This contest consists of *n* problems, and Pasha solves *i*th problem in *a**i* time units (his solutions are always correct). At any moment of time he can be thinking ab... | The first line contains one integer *n* (1<=≤<=*n*<=≤<=1000) — the number of problems. The second line contains *n* integers *a**i* (1<=≤<=*a**i*<=≤<=105) — the time Pasha needs to solve *i*th problem.
The third line contains one integer *m* (0<=≤<=*m*<=≤<=1000) — the number of periods of time when the website is work... | If Pasha can solve and submit all the problems before the end of the contest, print the minimal moment of time by which he can have all the solutions submitted.
Otherwise print "-1" (without brackets). | [
"2\n3 4\n2\n1 4\n7 9\n",
"1\n5\n1\n1 4\n",
"1\n5\n1\n1 5\n"
] | [
"7\n",
"-1\n",
"5\n"
] | In the first example Pasha can act like this: he solves the second problem in 4 units of time and sends it immediately. Then he spends 3 time units to solve the first problem and sends it 7 time units after the contest starts, because at this moment the website starts working again.
In the second example Pasha invents... | 0 | [
{
"input": "2\n3 4\n2\n1 4\n7 9",
"output": "7"
},
{
"input": "1\n5\n1\n1 4",
"output": "-1"
},
{
"input": "1\n5\n1\n1 5",
"output": "5"
},
{
"input": "5\n100000 100000 100000 100000 100000\n0",
"output": "-1"
},
{
"input": "5\n886 524 128 4068 298\n3\n416 3755\n4... | 1,635,513,787 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 30 | 4,505,600 |
# Online Python - IDE, Editor, Compiler, Interpreter
def sum(a, b, c, d, e):
return (a + b + c + d + e)
a = int(input('Enter 1 number: '))
b = int(input('Enter 2 number: '))
c = int(input('Enter 3 number: '))
d = int(input('Enter 4 number: '))
e = int(input('Enter 5 number: '))
print(f'Sum of {a} and {b} and {c}... | Title: The Contest
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Pasha is participating in a contest on one well-known website. This time he wants to win the contest and will do anything to get to the first place!
This contest consists of *n* problems, and Pasha solves *i*th problem in ... | ```python
# Online Python - IDE, Editor, Compiler, Interpreter
def sum(a, b, c, d, e):
return (a + b + c + d + e)
a = int(input('Enter 1 number: '))
b = int(input('Enter 2 number: '))
c = int(input('Enter 3 number: '))
d = int(input('Enter 4 number: '))
e = int(input('Enter 5 number: '))
print(f'Sum of {a} and {... | -1 | |
556 | A | Case of the Zeros and Ones | PROGRAMMING | 900 | [
"greedy"
] | null | null | Andrewid the Android is a galaxy-famous detective. In his free time he likes to think about strings containing zeros and ones.
Once he thought about a string of length *n* consisting of zeroes and ones. Consider the following operation: we choose any two adjacent positions in the string, and if one them contains 0, an... | First line of the input contains a single integer *n* (1<=≤<=*n*<=≤<=2·105), the length of the string that Andreid has.
The second line contains the string of length *n* consisting only from zeros and ones. | Output the minimum length of the string that may remain after applying the described operations several times. | [
"4\n1100\n",
"5\n01010\n",
"8\n11101111\n"
] | [
"0\n",
"1\n",
"6\n"
] | In the first sample test it is possible to change the string like the following: <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/10df55364c21c6e8d5da31b6ab6f6294c4fc26b3.png" style="max-width: 100.0%;max-height: 100.0%;"/>.
In the second sample test it is possible to change the string like... | 250 | [
{
"input": "4\n1100",
"output": "0"
},
{
"input": "5\n01010",
"output": "1"
},
{
"input": "8\n11101111",
"output": "6"
},
{
"input": "1\n0",
"output": "1"
},
{
"input": "1\n1",
"output": "1"
},
{
"input": "2\n00",
"output": "2"
},
{
"input"... | 1,662,401,892 | 2,147,483,647 | Python 3 | OK | TESTS | 49 | 78 | 512,000 | zero = 0
one = 0
sz = int(input())
string = input()
for char in string:
if char == '0':
zero += 1
else:
one += 1
print(abs(one - zero))
| Title: Case of the Zeros and Ones
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Andrewid the Android is a galaxy-famous detective. In his free time he likes to think about strings containing zeros and ones.
Once he thought about a string of length *n* consisting of zeroes and ones. Cons... | ```python
zero = 0
one = 0
sz = int(input())
string = input()
for char in string:
if char == '0':
zero += 1
else:
one += 1
print(abs(one - zero))
``` | 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,655,225,182 | 2,147,483,647 | Python 3 | OK | TESTS | 30 | 92 | 0 | a=input()
s=a.upper()
d=list(s)
w=0
r=0
for i in range(len(a)):
if d[i]==a[i]:
w=w+1
else:
r=r+1
if w>r:
print(a.upper())
else:
print(a.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
a=input()
s=a.upper()
d=list(s)
w=0
r=0
for i in range(len(a)):
if d[i]==a[i]:
w=w+1
else:
r=r+1
if w>r:
print(a.upper())
else:
print(a.lower())
``` | 3.977 |
37 | A | Towers | PROGRAMMING | 1,000 | [
"sortings"
] | A. Towers | 2 | 256 | Little Vasya has received a young builder’s kit. The kit consists of several wooden bars, the lengths of all of them are known. The bars can be put one on the top of the other if their lengths are the same.
Vasya wants to construct the minimal number of towers from the bars. Help Vasya to use the bars in the best way ... | The first line contains an integer *N* (1<=≤<=*N*<=≤<=1000) — the number of bars at Vasya’s disposal. The second line contains *N* space-separated integers *l**i* — the lengths of the bars. All the lengths are natural numbers not exceeding 1000. | In one line output two numbers — the height of the largest tower and their total number. Remember that Vasya should use all the bars. | [
"3\n1 2 3\n",
"4\n6 5 6 7\n"
] | [
"1 3\n",
"2 3\n"
] | none | 500 | [
{
"input": "3\n1 2 3",
"output": "1 3"
},
{
"input": "4\n6 5 6 7",
"output": "2 3"
},
{
"input": "4\n3 2 1 1",
"output": "2 3"
},
{
"input": "4\n1 2 3 3",
"output": "2 3"
},
{
"input": "3\n20 22 36",
"output": "1 3"
},
{
"input": "25\n47 30 94 41 45 20... | 1,516,731,756 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 5 | 122 | 5,632,000 | n=int(input(""))
ch=input("")
l=ch.split(" ")
def rechlist(l,x):
index=0
for j in range(i+1,n):
if l[j]==l[i]:
index=1
break
return(index)
for i in range(0,n):
l[i]=int(l[i])
hitower=1
nbtrowr=0
for i in range(0,n) :
if rechlist(l,i)==1:
hitowe... | Title: Towers
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Little Vasya has received a young builder’s kit. The kit consists of several wooden bars, the lengths of all of them are known. The bars can be put one on the top of the other if their lengths are the same.
Vasya wants to construct... | ```python
n=int(input(""))
ch=input("")
l=ch.split(" ")
def rechlist(l,x):
index=0
for j in range(i+1,n):
if l[j]==l[i]:
index=1
break
return(index)
for i in range(0,n):
l[i]=int(l[i])
hitower=1
nbtrowr=0
for i in range(0,n) :
if rechlist(l,i)==1:
... | 0 |
287 | A | IQ Test | PROGRAMMING | 1,100 | [
"brute force",
"implementation"
] | null | null | In the city of Ultima Thule job applicants are often offered an IQ test.
The test is as follows: the person gets a piece of squared paper with a 4<=×<=4 square painted on it. Some of the square's cells are painted black and others are painted white. Your task is to repaint at most one cell the other color so that the... | Four lines contain four characters each: the *j*-th character of the *i*-th line equals "." if the cell in the *i*-th row and the *j*-th column of the square is painted white, and "#", if the cell is black. | Print "YES" (without the quotes), if the test can be passed and "NO" (without the quotes) otherwise. | [
"####\n.#..\n####\n....\n",
"####\n....\n####\n....\n"
] | [
"YES\n",
"NO\n"
] | In the first test sample it is enough to repaint the first cell in the second row. After such repainting the required 2 × 2 square is on the intersection of the 1-st and 2-nd row with the 1-st and 2-nd column. | 500 | [
{
"input": "###.\n...#\n###.\n...#",
"output": "NO"
},
{
"input": ".##.\n#..#\n.##.\n#..#",
"output": "NO"
},
{
"input": ".#.#\n#.#.\n.#.#\n#.#.",
"output": "NO"
},
{
"input": "##..\n..##\n##..\n..##",
"output": "NO"
},
{
"input": "#.#.\n#.#.\n.#.#\n.#.#",
"ou... | 1,666,533,101 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 31 | 0 | s=''
s1=''
s2=''
s3=''
for i in range(4):
o=input()
s+=o
for u in s[12:]:
if u==".":
s3+="#"
else:
s3+="."
for j in s[4:8]:
if j==".":
s1+="#"
else:
s1+="."
for k in s[12:]:
if k==".":
s2+="#"
else:
s2+="."
... | Title: IQ Test
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
In the city of Ultima Thule job applicants are often offered an IQ test.
The test is as follows: the person gets a piece of squared paper with a 4<=×<=4 square painted on it. Some of the square's cells are painted black and o... | ```python
s=''
s1=''
s2=''
s3=''
for i in range(4):
o=input()
s+=o
for u in s[12:]:
if u==".":
s3+="#"
else:
s3+="."
for j in s[4:8]:
if j==".":
s1+="#"
else:
s1+="."
for k in s[12:]:
if k==".":
s2+="#"
else:
s2+=... | 0 | |
20 | C | Dijkstra? | PROGRAMMING | 1,900 | [
"graphs",
"shortest paths"
] | C. Dijkstra? | 1 | 64 | You are given a weighted undirected graph. The vertices are enumerated from 1 to *n*. Your task is to find the shortest path between the vertex 1 and the vertex *n*. | The first line contains two integers *n* and *m* (2<=≤<=*n*<=≤<=105,<=0<=≤<=*m*<=≤<=105), where *n* is the number of vertices and *m* is the number of edges. Following *m* lines contain one edge each in form *a**i*, *b**i* and *w**i* (1<=≤<=*a**i*,<=*b**i*<=≤<=*n*,<=1<=≤<=*w**i*<=≤<=106), where *a**i*,<=*b**i* are edge... | Write the only integer -1 in case of no path. Write the shortest path in opposite case. If there are many solutions, print any of them. | [
"5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1\n",
"5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1\n"
] | [
"1 4 3 5 ",
"1 4 3 5 "
] | none | 1,500 | [
{
"input": "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1",
"output": "1 4 3 5 "
},
{
"input": "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1",
"output": "1 4 3 5 "
},
{
"input": "2 1\n1 2 1",
"output": "1 2 "
},
{
"input": "3 1\n1 2 1",
"output": "-1"
},
{
"input... | 1,558,457,565 | 2,147,483,647 | PyPy 3 | RUNTIME_ERROR | TESTS | 23 | 390 | 9,318,400 | from collections import deque
from heapq import heappush, heappop
a = [int(x) for x in input().split()]
m = a[0]
pq = []
dist = [10**12] * m
visited = [False]* m
graf = [[] for i in range(m)]
#graf2 = [[0]*m for i in range(m)]
suly = []
start = 0
dist[start] = 0
prev = [0] * m
prev[start] = -1
mo = []
... | Title: Dijkstra?
Time Limit: 1 seconds
Memory Limit: 64 megabytes
Problem Description:
You are given a weighted undirected graph. The vertices are enumerated from 1 to *n*. Your task is to find the shortest path between the vertex 1 and the vertex *n*.
Input Specification:
The first line contains two integers *n* a... | ```python
from collections import deque
from heapq import heappush, heappop
a = [int(x) for x in input().split()]
m = a[0]
pq = []
dist = [10**12] * m
visited = [False]* m
graf = [[] for i in range(m)]
#graf2 = [[0]*m for i in range(m)]
suly = []
start = 0
dist[start] = 0
prev = [0] * m
prev[start] = -1
... | -1 |
264 | B | Good Sequences | PROGRAMMING | 1,500 | [
"dp",
"number theory"
] | null | null | Squirrel Liss is interested in sequences. She also has preferences of integers. She thinks *n* integers *a*1,<=*a*2,<=...,<=*a**n* are good.
Now she is interested in good sequences. A sequence *x*1,<=*x*2,<=...,<=*x**k* is called good if it satisfies the following three conditions:
- The sequence is strictly increas... | The input consists of two lines. The first line contains a single integer *n* (1<=≤<=*n*<=≤<=105) — the number of good integers. The second line contains a single-space separated list of good integers *a*1,<=*a*2,<=...,<=*a**n* in strictly increasing order (1<=≤<=*a**i*<=≤<=105; *a**i*<=<<=*a**i*<=+<=1). | Print a single integer — the length of the longest good sequence. | [
"5\n2 3 4 6 9\n",
"9\n1 2 3 5 6 7 8 9 10\n"
] | [
"4\n",
"4\n"
] | In the first example, the following sequences are examples of good sequences: [2; 4; 6; 9], [2; 4; 6], [3; 9], [6]. The length of the longest good sequence is 4. | 1,000 | [
{
"input": "5\n2 3 4 6 9",
"output": "4"
},
{
"input": "9\n1 2 3 5 6 7 8 9 10",
"output": "4"
},
{
"input": "4\n1 2 4 6",
"output": "3"
},
{
"input": "7\n1 2 3 4 7 9 10",
"output": "3"
},
{
"input": "1\n1",
"output": "1"
},
{
"input": "8\n3 4 5 6 7 8 9... | 1,633,262,796 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 10 | 186 | 21,606,400 | from math import gcd
n = int(input())
a = list(map(int,input().split()))
dp = [1]*n
for i in range(n):
for j in range(i):
if a[i] > a[j] and gcd(a[i],a[j]) > 1:
dp[i] = dp[j]+1
print(max(dp)) | Title: Good Sequences
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Squirrel Liss is interested in sequences. She also has preferences of integers. She thinks *n* integers *a*1,<=*a*2,<=...,<=*a**n* are good.
Now she is interested in good sequences. A sequence *x*1,<=*x*2,<=...,<=*x**k*... | ```python
from math import gcd
n = int(input())
a = list(map(int,input().split()))
dp = [1]*n
for i in range(n):
for j in range(i):
if a[i] > a[j] and gcd(a[i],a[j]) > 1:
dp[i] = dp[j]+1
print(max(dp))
``` | 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,691,106,680 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 3 | 46 | 0 | v=int(input())
v1=list(map(int,input().split()))
v1.sort()
e=0
c=0
for _ in range(v):
if e==v:
break
for i in v1:
if max(v1)==min(v1):
e+=1
print(c)
else:
a=max(v1)-v1[e]
e+=1
c+=a
print(c)
| 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
v=int(input())
v1=list(map(int,input().split()))
v1.sort()
e=0
c=0
for _ in range(v):
if e==v:
break
for i in v1:
if max(v1)==min(v1):
e+=1
print(c)
else:
a=max(v1)-v1[e]
e+=1
c+=a
print(c)
``` | 0 | |
479 | A | Expression | PROGRAMMING | 1,000 | [
"brute force",
"math"
] | null | null | Petya studies in a school and he adores Maths. His class has been studying arithmetic expressions. On the last class the teacher wrote three positive integers *a*, *b*, *c* on the blackboard. The task was to insert signs of operations '+' and '*', and probably brackets between the numbers so that the value of the resul... | The input contains three integers *a*, *b* and *c*, each on a single line (1<=≤<=*a*,<=*b*,<=*c*<=≤<=10). | Print the maximum value of the expression that you can obtain. | [
"1\n2\n3\n",
"2\n10\n3\n"
] | [
"9\n",
"60\n"
] | none | 500 | [
{
"input": "1\n2\n3",
"output": "9"
},
{
"input": "2\n10\n3",
"output": "60"
},
{
"input": "1\n1\n1",
"output": "3"
},
{
"input": "1\n2\n1",
"output": "4"
},
{
"input": "10\n10\n10",
"output": "1000"
},
{
"input": "5\n1\n3",
"output": "20"
},
{... | 1,694,754,071 | 2,147,483,647 | Python 3 | OK | TESTS | 29 | 46 | 0 | # Read input values
firstInteger = int(input())
secondInteger = int(input())
thirdInteger = int(input())
# Calculate and print the maximum value of the expression
maxValue = max(firstInteger + secondInteger + thirdInteger, firstInteger * secondInteger * thirdInteger, (firstInteger + secondInteger) * thirdInteger, firs... | Title: Expression
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Petya studies in a school and he adores Maths. His class has been studying arithmetic expressions. On the last class the teacher wrote three positive integers *a*, *b*, *c* on the blackboard. The task was to insert signs of ... | ```python
# Read input values
firstInteger = int(input())
secondInteger = int(input())
thirdInteger = int(input())
# Calculate and print the maximum value of the expression
maxValue = max(firstInteger + secondInteger + thirdInteger, firstInteger * secondInteger * thirdInteger, (firstInteger + secondInteger) * thirdInt... | 3 | |
12 | B | Correct Solution? | PROGRAMMING | 1,100 | [
"implementation",
"sortings"
] | B. Correct Solution? | 2 | 256 | One cold winter evening Alice and her older brother Bob was sitting at home near the fireplace and giving each other interesting problems to solve. When it was Alice's turn, she told the number *n* to Bob and said:
—Shuffle the digits in this number in order to obtain the smallest possible number without leading zeroe... | The first line contains one integer *n* (0<=≤<=*n*<=≤<=109) without leading zeroes. The second lines contains one integer *m* (0<=≤<=*m*<=≤<=109) — Bob's answer, possibly with leading zeroes. | Print OK if Bob's answer is correct and WRONG_ANSWER otherwise. | [
"3310\n1033\n",
"4\n5\n"
] | [
"OK\n",
"WRONG_ANSWER\n"
] | none | 0 | [
{
"input": "3310\n1033",
"output": "OK"
},
{
"input": "4\n5",
"output": "WRONG_ANSWER"
},
{
"input": "40\n04",
"output": "WRONG_ANSWER"
},
{
"input": "12\n12",
"output": "OK"
},
{
"input": "432\n234",
"output": "OK"
},
{
"input": "17109\n01179",
"o... | 1,687,496,435 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 30 | 92 | 0 | a, b, c, m = input(), input(),[0]*10, 9
for i in a:
i = int(i)
c[i]+=1
if 0 < i < m:
m = i
c[m]-=1
d = str(m)
for i in range(10):
d+=str(i)*c[i]
print('OK' if d == b else 'WRONG_ANSWER') | Title: Correct Solution?
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
One cold winter evening Alice and her older brother Bob was sitting at home near the fireplace and giving each other interesting problems to solve. When it was Alice's turn, she told the number *n* to Bob and said:
—Shuf... | ```python
a, b, c, m = input(), input(),[0]*10, 9
for i in a:
i = int(i)
c[i]+=1
if 0 < i < m:
m = i
c[m]-=1
d = str(m)
for i in range(10):
d+=str(i)*c[i]
print('OK' if d == b else 'WRONG_ANSWER')
``` | 0 |
271 | A | Beautiful Year | PROGRAMMING | 800 | [
"brute force"
] | null | null | It seems like the year of 2013 came only yesterday. Do you know a curious fact? The year of 2013 is the first year after the old 1987 with only distinct digits.
Now you are suggested to solve the following problem: given a year number, find the minimum year number which is strictly larger than the given one and has on... | The single line contains integer *y* (1000<=≤<=*y*<=≤<=9000) — the year number. | Print a single integer — the minimum year number that is strictly larger than *y* and all it's digits are distinct. It is guaranteed that the answer exists. | [
"1987\n",
"2013\n"
] | [
"2013\n",
"2014\n"
] | none | 500 | [
{
"input": "1987",
"output": "2013"
},
{
"input": "2013",
"output": "2014"
},
{
"input": "1000",
"output": "1023"
},
{
"input": "1001",
"output": "1023"
},
{
"input": "1234",
"output": "1235"
},
{
"input": "5555",
"output": "5601"
},
{
"inp... | 1,696,862,771 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 6 | 62 | 0 | n = input()
x = int(n)
for i in range(x + 1, 9000):
i = str(i)
if i[0] != i[1] and i[0] != i[2] and i[0] != i[3] \
and i[1] != i[2] and i[1] != i[3] and i[2] != i[3]:
x = i
break
print(int(x))
| Title: Beautiful Year
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
It seems like the year of 2013 came only yesterday. Do you know a curious fact? The year of 2013 is the first year after the old 1987 with only distinct digits.
Now you are suggested to solve the following problem: give... | ```python
n = input()
x = int(n)
for i in range(x + 1, 9000):
i = str(i)
if i[0] != i[1] and i[0] != i[2] and i[0] != i[3] \
and i[1] != i[2] and i[1] != i[3] and i[2] != i[3]:
x = i
break
print(int(x))
``` | 0 | |
1,004 | C | Sonya and Robots | PROGRAMMING | 1,400 | [
"constructive algorithms",
"implementation"
] | null | null | Since Sonya is interested in robotics too, she decided to construct robots that will read and recognize numbers.
Sonya has drawn $n$ numbers in a row, $a_i$ is located in the $i$-th position. She also has put a robot at each end of the row (to the left of the first number and to the right of the last number). Sonya wi... | The first line contains a single integer $n$ ($1\leq n\leq 10^5$) — the number of numbers in a row.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1\leq a_i\leq 10^5$) — the numbers in a row. | Print one number — the number of possible pairs that Sonya can give to robots so that they will not meet. | [
"5\n1 5 4 1 3\n",
"7\n1 2 1 1 1 3 2\n"
] | [
"9\n",
"7\n"
] | In the first example, Sonya can give pairs ($1$, $1$), ($1$, $3$), ($1$, $4$), ($1$, $5$), ($4$, $1$), ($4$, $3$), ($5$, $1$), ($5$, $3$), and ($5$, $4$).
In the second example, Sonya can give pairs ($1$, $1$), ($1$, $2$), ($1$, $3$), ($2$, $1$), ($2$, $2$), ($2$, $3$), and ($3$, $2$). | 1,500 | [
{
"input": "5\n1 5 4 1 3",
"output": "9"
},
{
"input": "7\n1 2 1 1 1 3 2",
"output": "7"
},
{
"input": "10\n2 2 4 4 3 1 1 2 3 2",
"output": "14"
},
{
"input": "15\n1 2 2 1 2 4 2 1 1 6 6 4 2 5 4",
"output": "20"
},
{
"input": "1\n1",
"output": "0"
}
] | 1,617,877,724 | 2,147,483,647 | PyPy 3 | OK | TESTS | 42 | 202 | 14,745,600 | n=int(input())
arr=list(map(int,input().split()))
d={}
for i in arr:
d[i]=d.get(i,0)+1
ans=0;s=set()
for i in arr:
d[i]=d.get(i,0)-1
if d[i]==0:del d[i]
if i not in s:
ans+=len(d)
s.add(i)
print(ans)
| Title: Sonya and Robots
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Since Sonya is interested in robotics too, she decided to construct robots that will read and recognize numbers.
Sonya has drawn $n$ numbers in a row, $a_i$ is located in the $i$-th position. She also has put a robot ... | ```python
n=int(input())
arr=list(map(int,input().split()))
d={}
for i in arr:
d[i]=d.get(i,0)+1
ans=0;s=set()
for i in arr:
d[i]=d.get(i,0)-1
if d[i]==0:del d[i]
if i not in s:
ans+=len(d)
s.add(i)
print(ans)
``` | 3 | |
707 | A | Brain's Photos | PROGRAMMING | 800 | [
"implementation"
] | null | null | Small, but very brave, mouse Brain was not accepted to summer school of young villains. He was upset and decided to postpone his plans of taking over the world, but to become a photographer instead.
As you may know, the coolest photos are on the film (because you can specify the hashtag #film for such).
Brain took a ... | The first line of the input contains two integers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=100) — the number of photo pixel matrix rows and columns respectively.
Then *n* lines describing matrix rows follow. Each of them contains *m* space-separated characters describing colors of pixels in a row. Each character in the line i... | Print the "#Black&White" (without quotes), if the photo is black-and-white and "#Color" (without quotes), if it is colored, in the only line. | [
"2 2\nC M\nY Y\n",
"3 2\nW W\nW W\nB B\n",
"1 1\nW\n"
] | [
"#Color",
"#Black&White",
"#Black&White"
] | none | 500 | [
{
"input": "2 2\nC M\nY Y",
"output": "#Color"
},
{
"input": "3 2\nW W\nW W\nB B",
"output": "#Black&White"
},
{
"input": "1 1\nW",
"output": "#Black&White"
},
{
"input": "2 3\nW W W\nB G Y",
"output": "#Color"
},
{
"input": "1 1\nW",
"output": "#Black&White"
... | 1,653,593,937 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 50 | 62 | 2,355,200 |
n, m = list(map(int, input().split()))
col = []
a = []
for i in range(n):
st = input().split()
for i in st:
a.append(i)
if 'C' in a or 'M' in a or 'Y' in a:
print("#Color")
else:
print('#Black&White')
| Title: Brain's Photos
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Small, but very brave, mouse Brain was not accepted to summer school of young villains. He was upset and decided to postpone his plans of taking over the world, but to become a photographer instead.
As you may know, the... | ```python
n, m = list(map(int, input().split()))
col = []
a = []
for i in range(n):
st = input().split()
for i in st:
a.append(i)
if 'C' in a or 'M' in a or 'Y' in a:
print("#Color")
else:
print('#Black&White')
``` | 3 | |
32 | B | Borze | PROGRAMMING | 800 | [
"expression parsing",
"implementation"
] | B. Borze | 2 | 256 | Ternary numeric notation is quite popular in Berland. To telegraph the ternary number the Borze alphabet is used. Digit 0 is transmitted as «.», 1 as «-.» and 2 as «--». You are to decode the Borze code, i.e. to find out the ternary number given its representation in Borze alphabet. | The first line contains a number in Borze code. The length of the string is between 1 and 200 characters. It's guaranteed that the given string is a valid Borze code of some ternary number (this number can have leading zeroes). | Output the decoded ternary number. It can have leading zeroes. | [
".-.--\n",
"--.\n",
"-..-.--\n"
] | [
"012",
"20",
"1012"
] | none | 1,000 | [
{
"input": ".-.--",
"output": "012"
},
{
"input": "--.",
"output": "20"
},
{
"input": "-..-.--",
"output": "1012"
},
{
"input": "---..",
"output": "210"
},
{
"input": "..--.---..",
"output": "0020210"
},
{
"input": "-.....----.",
"output": "1000022... | 1,685,055,561 | 2,147,483,647 | Python 3 | OK | TESTS | 30 | 92 | 0 | s=input()
k=""
j=0
while j<len(s) :
if s[j]=="." :
k+="0"
j+=1
elif s[j]=="-" and s[j+1]=="." :
k+="1"
j+=2
elif s[j]=="-" and s[j+1]=="-" :
k+="2"
j+=2
print(k)
| Title: Borze
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Ternary numeric notation is quite popular in Berland. To telegraph the ternary number the Borze alphabet is used. Digit 0 is transmitted as «.», 1 as «-.» and 2 as «--». You are to decode the Borze code, i.e. to find out the ternary ... | ```python
s=input()
k=""
j=0
while j<len(s) :
if s[j]=="." :
k+="0"
j+=1
elif s[j]=="-" and s[j+1]=="." :
k+="1"
j+=2
elif s[j]=="-" and s[j+1]=="-" :
k+="2"
j+=2
print(k)
``` | 3.977 |
78 | A | Haiku | PROGRAMMING | 800 | [
"implementation",
"strings"
] | A. Haiku | 2 | 256 | Haiku is a genre of Japanese traditional poetry.
A haiku poem consists of 17 syllables split into three phrases, containing 5, 7 and 5 syllables correspondingly (the first phrase should contain exactly 5 syllables, the second phrase should contain exactly 7 syllables, and the third phrase should contain exactly 5 syll... | The input data consists of three lines. The length of each line is between 1 and 100, inclusive. The *i*-th line contains the *i*-th phrase of the poem. Each phrase consists of one or more words, which are separated by one or more spaces. A word is a non-empty sequence of lowercase Latin letters. Leading and/or trailin... | Print "YES" (without the quotes) if the poem is a haiku. Otherwise, print "NO" (also without the quotes). | [
"on codeforces \nbeta round is running\n a rustling of keys \n",
"how many gallons\nof edo s rain did you drink\n cuckoo\n"
] | [
"YES",
"NO"
] | none | 500 | [
{
"input": "on codeforces \nbeta round is running\n a rustling of keys ",
"output": "YES"
},
{
"input": "how many gallons\nof edo s rain did you drink\n cuckoo",
"output": "NO"
},
{
"input": " hatsu shigure\n saru mo komino wo\nhoshige nari",
... | 1,473,660,707 | 2,147,483,647 | Python 3 | OK | TESTS | 40 | 124 | 0 | import sys
s, t, r = input().strip(), input().strip(), input().strip()
vowel = set('aeiou')
s_counter = t_counter = r_counter = 0
for _ in s:
if _ in vowel:
s_counter += 1
if s_counter != 5:
print('NO')
sys.exit()
for _ in t:
if _ in vowel:
t_counter += 1
if t_counter !=... | Title: Haiku
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Haiku is a genre of Japanese traditional poetry.
A haiku poem consists of 17 syllables split into three phrases, containing 5, 7 and 5 syllables correspondingly (the first phrase should contain exactly 5 syllables, the second phrase... | ```python
import sys
s, t, r = input().strip(), input().strip(), input().strip()
vowel = set('aeiou')
s_counter = t_counter = r_counter = 0
for _ in s:
if _ in vowel:
s_counter += 1
if s_counter != 5:
print('NO')
sys.exit()
for _ in t:
if _ in vowel:
t_counter += 1
if t_... | 3.969 |
43 | A | Football | PROGRAMMING | 1,000 | [
"strings"
] | A. Football | 2 | 256 | One day Vasya decided to have a look at the results of Berland 1910 Football Championship’s finals. Unfortunately he didn't find the overall score of the match; however, he got hold of a profound description of the match's process. On the whole there are *n* lines in that description each of which described one goal. E... | The first line contains an integer *n* (1<=≤<=*n*<=≤<=100) — the number of lines in the description. Then follow *n* lines — for each goal the names of the teams that scored it. The names are non-empty lines consisting of uppercase Latin letters whose lengths do not exceed 10 symbols. It is guaranteed that the match di... | Print the name of the winning team. We remind you that in football the team that scores more goals is considered the winner. | [
"1\nABC\n",
"5\nA\nABA\nABA\nA\nA\n"
] | [
"ABC\n",
"A\n"
] | none | 500 | [
{
"input": "1\nABC",
"output": "ABC"
},
{
"input": "5\nA\nABA\nABA\nA\nA",
"output": "A"
},
{
"input": "2\nXTSJEP\nXTSJEP",
"output": "XTSJEP"
},
{
"input": "3\nXZYDJAEDZ\nXZYDJAEDZ\nXZYDJAEDZ",
"output": "XZYDJAEDZ"
},
{
"input": "3\nQCCYXL\nQCCYXL\nAXGLFQDD",
... | 1,637,948,076 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 60 | 0 | n=int(input('Number of lines: '))
for i in range(0,n):
a=[]
x=0
x=input()
a.append(x)
counter1=a.count(x)
counter2=len(a)-counter1
list2=[]
for r in a:
if r != x:
list2.append(r)
if counter1 >counter2:
print (x)
else:
print (list2[0])
| Title: Football
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
One day Vasya decided to have a look at the results of Berland 1910 Football Championship’s finals. Unfortunately he didn't find the overall score of the match; however, he got hold of a profound description of the match's process... | ```python
n=int(input('Number of lines: '))
for i in range(0,n):
a=[]
x=0
x=input()
a.append(x)
counter1=a.count(x)
counter2=len(a)-counter1
list2=[]
for r in a:
if r != x:
list2.append(r)
if counter1 >counter2:
print (x)
else:
print (list2[0])
``` | 0 |
1 | A | Theatre Square | PROGRAMMING | 1,000 | [
"math"
] | A. Theatre Square | 1 | 256 | Theatre Square in the capital city of Berland has a rectangular shape with the size *n*<=×<=*m* meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the size *a*<=×<=*a*.
What is the least number of flagstones needed to pave the... | The input contains three positive integer numbers in the first line: *n*,<=<=*m* and *a* (1<=≤<=<=*n*,<=*m*,<=*a*<=≤<=109). | Write the needed number of flagstones. | [
"6 6 4\n"
] | [
"4\n"
] | none | 0 | [
{
"input": "6 6 4",
"output": "4"
},
{
"input": "1 1 1",
"output": "1"
},
{
"input": "2 1 1",
"output": "2"
},
{
"input": "1 2 1",
"output": "2"
},
{
"input": "2 2 1",
"output": "4"
},
{
"input": "2 1 2",
"output": "1"
},
{
"input": "1 1 3"... | 1,686,681,488 | 2,147,483,647 | Python 3 | OK | TESTS | 20 | 46 | 0 | n,m,a= input().split()
n=int(n)
m=int(m)
a=int(a)
print(-n//a*(-m//a)) | Title: Theatre Square
Time Limit: 1 seconds
Memory Limit: 256 megabytes
Problem Description:
Theatre Square in the capital city of Berland has a rectangular shape with the size *n*<=×<=*m* meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each ... | ```python
n,m,a= input().split()
n=int(n)
m=int(m)
a=int(a)
print(-n//a*(-m//a))
``` | 3.977 |
581 | C | Developing Skills | PROGRAMMING | 1,400 | [
"implementation",
"math",
"sortings"
] | null | null | Petya loves computer games. Finally a game that he's been waiting for so long came out!
The main character of this game has *n* different skills, each of which is characterized by an integer *a**i* from 0 to 100. The higher the number *a**i* is, the higher is the *i*-th skill of the character. The total rating of the ... | The first line of the input contains two positive integers *n* and *k* (1<=≤<=*n*<=≤<=105, 0<=≤<=*k*<=≤<=107) — the number of skills of the character and the number of units of improvements at Petya's disposal.
The second line of the input contains a sequence of *n* integers *a**i* (0<=≤<=*a**i*<=≤<=100), where *a**i*... | The first line of the output should contain a single non-negative integer — the maximum total rating of the character that Petya can get using *k* or less improvement units. | [
"2 4\n7 9\n",
"3 8\n17 15 19\n",
"2 2\n99 100\n"
] | [
"2\n",
"5\n",
"20\n"
] | In the first test case the optimal strategy is as follows. Petya has to improve the first skill to 10 by spending 3 improvement units, and the second skill to 10, by spending one improvement unit. Thus, Petya spends all his improvement units and the total rating of the character becomes equal to *lfloor* *frac*{100}{1... | 1,500 | [
{
"input": "2 4\n7 9",
"output": "2"
},
{
"input": "3 8\n17 15 19",
"output": "5"
},
{
"input": "2 2\n99 100",
"output": "20"
},
{
"input": "100 10000\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... | 1,678,250,027 | 2,147,483,647 | PyPy 3-64 | COMPILATION_ERROR | TESTS | 0 | 0 | 0 | # 3 8
# 17 15 19
from heapq import*
n,k=map(int,input().split())
a=[*map(int,input().split()]
l=[(-(10-v%10), v) for v in a]
heapify(l)
ans=sum(v//10 for v in a)
while l:
d,v=heappop(l)
d=-d
x=min(k,d)
v+=x
k-=x
ans+=x==d
if v<100:
heappush(l,(-(10-v%10), v))
if ... | Title: Developing Skills
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Petya loves computer games. Finally a game that he's been waiting for so long came out!
The main character of this game has *n* different skills, each of which is characterized by an integer *a**i* from 0 to 100. The... | ```python
# 3 8
# 17 15 19
from heapq import*
n,k=map(int,input().split())
a=[*map(int,input().split()]
l=[(-(10-v%10), v) for v in a]
heapify(l)
ans=sum(v//10 for v in a)
while l:
d,v=heappop(l)
d=-d
x=min(k,d)
v+=x
k-=x
ans+=x==d
if v<100:
heappush(l,(-(10-v%10), v)... | -1 | |
501 | A | Contest | PROGRAMMING | 900 | [
"implementation"
] | null | null | Misha and Vasya participated in a Codeforces contest. Unfortunately, each of them solved only one problem, though successfully submitted it at the first attempt. Misha solved the problem that costs *a* points and Vasya solved the problem that costs *b* points. Besides, Misha submitted the problem *c* minutes after the ... | The first line contains four integers *a*, *b*, *c*, *d* (250<=≤<=*a*,<=*b*<=≤<=3500, 0<=≤<=*c*,<=*d*<=≤<=180).
It is guaranteed that numbers *a* and *b* are divisible by 250 (just like on any real Codeforces round). | Output on a single line:
"Misha" (without the quotes), if Misha got more points than Vasya.
"Vasya" (without the quotes), if Vasya got more points than Misha.
"Tie" (without the quotes), if both of them got the same number of points. | [
"500 1000 20 30\n",
"1000 1000 1 1\n",
"1500 1000 176 177\n"
] | [
"Vasya\n",
"Tie\n",
"Misha\n"
] | none | 500 | [
{
"input": "500 1000 20 30",
"output": "Vasya"
},
{
"input": "1000 1000 1 1",
"output": "Tie"
},
{
"input": "1500 1000 176 177",
"output": "Misha"
},
{
"input": "1500 1000 74 177",
"output": "Misha"
},
{
"input": "750 2500 175 178",
"output": "Vasya"
},
{
... | 1,560,681,192 | 2,147,483,647 | Python 3 | OK | TESTS | 40 | 109 | 0 | # import sys
# sys.stdin=open("input.in",'r')
# sys.stdout=open("out.out",'w')
a,b,c,d=map(int,input().split())
m=max(3*a//10,a-(a//250)*c)
v=max(3*b//10,b-(b//250)*d)
if m==v:
print("Tie")
elif m>v:
print("Misha")
else:
print("Vasya")
| Title: Contest
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Misha and Vasya participated in a Codeforces contest. Unfortunately, each of them solved only one problem, though successfully submitted it at the first attempt. Misha solved the problem that costs *a* points and Vasya solved t... | ```python
# import sys
# sys.stdin=open("input.in",'r')
# sys.stdout=open("out.out",'w')
a,b,c,d=map(int,input().split())
m=max(3*a//10,a-(a//250)*c)
v=max(3*b//10,b-(b//250)*d)
if m==v:
print("Tie")
elif m>v:
print("Misha")
else:
print("Vasya")
``` | 3 | |
371 | C | Hamburgers | PROGRAMMING | 1,600 | [
"binary search",
"brute force"
] | null | null | Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (... | The first line of the input contains a non-empty string that describes the recipe of "Le Hamburger de Polycarpus". The length of the string doesn't exceed 100, the string contains only letters 'B' (uppercase English B), 'S' (uppercase English S) and 'C' (uppercase English C).
The second line contains three integers *n... | Print the maximum number of hamburgers Polycarpus can make. If he can't make any hamburger, print 0. | [
"BBBSSC\n6 4 1\n1 2 3\n4\n",
"BBC\n1 10 1\n1 10 1\n21\n",
"BSC\n1 1 1\n1 1 3\n1000000000000\n"
] | [
"2\n",
"7\n",
"200000000001\n"
] | none | 1,500 | [
{
"input": "BBBSSC\n6 4 1\n1 2 3\n4",
"output": "2"
},
{
"input": "BBC\n1 10 1\n1 10 1\n21",
"output": "7"
},
{
"input": "BSC\n1 1 1\n1 1 3\n1000000000000",
"output": "200000000001"
},
{
"input": "B\n1 1 1\n1 1 1\n381",
"output": "382"
},
{
"input": "BSC\n3 5 6\n7... | 1,639,235,956 | 2,147,483,647 | PyPy 3 | OK | TESTS | 31 | 93 | 0 | import sys
input = sys.stdin.readline;
req = [0 for _ in range(3)]
def binarysearch(low:int,high:int):
ans = 0
while(low <= high):
mid = low + (high - low)//2
required_amount = 0
for i in range(0,3):
required_amount += max(0,req[i]*mi... | Title: Hamburgers
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He ... | ```python
import sys
input = sys.stdin.readline;
req = [0 for _ in range(3)]
def binarysearch(low:int,high:int):
ans = 0
while(low <= high):
mid = low + (high - low)//2
required_amount = 0
for i in range(0,3):
required_amount += max(0... | 3 | |
710 | A | King Moves | PROGRAMMING | 800 | [
"implementation"
] | null | null | The only king stands on the standard chess board. You are given his position in format "cd", where *c* is the column from 'a' to 'h' and *d* is the row from '1' to '8'. Find the number of moves permitted for the king.
Check the king's moves here [https://en.wikipedia.org/wiki/King_(chess)](https://en.wikipedia.org/wik... | The only line contains the king's position in the format "cd", where 'c' is the column from 'a' to 'h' and 'd' is the row from '1' to '8'. | Print the only integer *x* — the number of moves permitted for the king. | [
"e4\n"
] | [
"8\n"
] | none | 0 | [
{
"input": "e4",
"output": "8"
},
{
"input": "a1",
"output": "3"
},
{
"input": "h8",
"output": "3"
},
{
"input": "a4",
"output": "5"
},
{
"input": "g7",
"output": "8"
},
{
"input": "e1",
"output": "5"
},
{
"input": "b2",
"output": "8"
... | 1,472,048,696 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 31 | 4,608,000 | s=input()
b=s[0]
n=int(s[1])
print(b,n)
if b!="a" and b!="h":
if n!=1 and n!=8:
print(8)
else:
print(5)
else:
if n!=1 and n!=8:
print(5)
else:
print(3) | Title: King Moves
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The only king stands on the standard chess board. You are given his position in format "cd", where *c* is the column from 'a' to 'h' and *d* is the row from '1' to '8'. Find the number of moves permitted for the king.
Check... | ```python
s=input()
b=s[0]
n=int(s[1])
print(b,n)
if b!="a" and b!="h":
if n!=1 and n!=8:
print(8)
else:
print(5)
else:
if n!=1 and n!=8:
print(5)
else:
print(3)
``` | 0 | |
234 | B | Reading | PROGRAMMING | 1,000 | [
"sortings"
] | null | null | Vasya is going to the Olympics in the city Ntown by train. The boy wants to read the textbook to prepare for the Olympics. He counted that he needed *k* hours for this. He also found that the light in the train changes every hour. The light is measured on a scale from 0 to 100, where 0 is very dark, and 100 is very lig... | The first input line contains two integers *n* and *k* (1<=≤<=*n*<=≤<=1000,<=1<=≤<=*k*<=≤<=*n*) — the number of hours on the train and the number of hours to read, correspondingly. The second line contains *n* space-separated integers *a**i* (0<=≤<=*a**i*<=≤<=100), *a**i* is the light level at the *i*-th hour. | In the first output line print the minimum light level Vasya will read at. In the second line print *k* distinct space-separated integers *b*1,<=*b*2,<=...,<=*b**k*, — the indexes of hours Vasya will read at (1<=≤<=*b**i*<=≤<=*n*). The hours are indexed starting from 1. If there are multiple optimal solutions, print an... | [
"5 3\n20 10 30 40 10\n",
"6 5\n90 20 35 40 60 100\n"
] | [
"20\n1 3 4 \n",
"35\n1 3 4 5 6 \n"
] | In the first sample Vasya should read at the first hour (light 20), third hour (light 30) and at the fourth hour (light 40). The minimum light Vasya will have to read at is 20. | 0 | [
{
"input": "5 3\n20 10 30 40 10",
"output": "20\n1 3 4 "
},
{
"input": "6 5\n90 20 35 40 60 100",
"output": "35\n1 3 4 5 6 "
},
{
"input": "100 7\n85 66 9 91 50 46 61 12 55 65 95 1 25 97 95 4 59 59 52 34 94 30 60 11 68 36 17 84 87 68 72 87 46 99 24 66 75 77 75 2 19 3 33 19 7 20 22 3 71 2... | 1,677,266,228 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 60 | 0 | n, k = list(map(int,input().split()))
a = list(map(int,input().split()))
b = a.copy()
b.sort()
b = b[-k:]
c = list()
print(min(b))
for i in range(len(b)):
c.append(a.index(b[i]) + 1)
numbers = sorted(c)
print(*numbers, sep = ' ') | Title: Reading
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vasya is going to the Olympics in the city Ntown by train. The boy wants to read the textbook to prepare for the Olympics. He counted that he needed *k* hours for this. He also found that the light in the train changes every ho... | ```python
n, k = list(map(int,input().split()))
a = list(map(int,input().split()))
b = a.copy()
b.sort()
b = b[-k:]
c = list()
print(min(b))
for i in range(len(b)):
c.append(a.index(b[i]) + 1)
numbers = sorted(c)
print(*numbers, sep = ' ')
``` | -1 | |
916 | A | Jamie and Alarm Snooze | PROGRAMMING | 900 | [
"brute force",
"implementation",
"math"
] | null | null | Jamie loves sleeping. One day, he decides that he needs to wake up at exactly *hh*:<=*mm*. However, he hates waking up, so he wants to make waking up less painful by setting the alarm at a lucky time. He will then press the snooze button every *x* minutes until *hh*:<=*mm* is reached, and only then he will wake up. He ... | The first line contains a single integer *x* (1<=≤<=*x*<=≤<=60).
The second line contains two two-digit integers, *hh* and *mm* (00<=≤<=*hh*<=≤<=23,<=00<=≤<=*mm*<=≤<=59). | Print the minimum number of times he needs to press the button. | [
"3\n11 23\n",
"5\n01 07\n"
] | [
"2\n",
"0\n"
] | In the first sample, Jamie needs to wake up at 11:23. So, he can set his alarm at 11:17. He would press the snooze button when the alarm rings at 11:17 and at 11:20.
In the second sample, Jamie can set his alarm at exactly at 01:07 which is lucky. | 500 | [
{
"input": "3\n11 23",
"output": "2"
},
{
"input": "5\n01 07",
"output": "0"
},
{
"input": "34\n09 24",
"output": "3"
},
{
"input": "2\n14 37",
"output": "0"
},
{
"input": "14\n19 54",
"output": "9"
},
{
"input": "42\n15 44",
"output": "12"
},
... | 1,691,239,849 | 2,147,483,647 | Python 3 | OK | TESTS | 254 | 46 | 0 | x = int(input())
h, m = map(int, input().split())
M, c = 60*h + m, 0
while '7' not in str(M//60) + str(M%60):
c += 1; M -= x
if M < 0: M += 1440
print(c) | Title: Jamie and Alarm Snooze
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Jamie loves sleeping. One day, he decides that he needs to wake up at exactly *hh*:<=*mm*. However, he hates waking up, so he wants to make waking up less painful by setting the alarm at a lucky time. He will the... | ```python
x = int(input())
h, m = map(int, input().split())
M, c = 60*h + m, 0
while '7' not in str(M//60) + str(M%60):
c += 1; M -= x
if M < 0: M += 1440
print(c)
``` | 3 | |
386 | A | Second-Price Auction | PROGRAMMING | 800 | [
"implementation"
] | null | null | In this problem we consider a special type of an auction, which is called the second-price auction. As in regular auction *n* bidders place a bid which is price a bidder ready to pay. The auction is closed, that is, each bidder secretly informs the organizer of the auction price he is willing to pay. After that, the au... | The first line of the input contains *n* (2<=≤<=*n*<=≤<=1000) — number of bidders. The second line contains *n* distinct integer numbers *p*1,<=*p*2,<=... *p**n*, separated by single spaces (1<=≤<=*p**i*<=≤<=10000), where *p**i* stands for the price offered by the *i*-th bidder. | The single output line should contain two integers: index of the winner and the price he will pay. Indices are 1-based. | [
"2\n5 7\n",
"3\n10 2 8\n",
"6\n3 8 2 9 4 14\n"
] | [
"2 5\n",
"1 8\n",
"6 9\n"
] | none | 500 | [
{
"input": "2\n5 7",
"output": "2 5"
},
{
"input": "3\n10 2 8",
"output": "1 8"
},
{
"input": "6\n3 8 2 9 4 14",
"output": "6 9"
},
{
"input": "4\n4707 7586 4221 5842",
"output": "2 5842"
},
{
"input": "5\n3304 4227 4869 6937 6002",
"output": "4 6002"
},
{... | 1,639,247,054 | 2,147,483,647 | Python 3 | OK | TESTS | 42 | 46 | 0 | c=int(input())
g=[int(c) for c in input().split(' ')]
m=g.index(max(g))
g.sort()
g.pop()
print(m+1,max(g))
| Title: Second-Price Auction
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
In this problem we consider a special type of an auction, which is called the second-price auction. As in regular auction *n* bidders place a bid which is price a bidder ready to pay. The auction is closed, that is... | ```python
c=int(input())
g=[int(c) for c in input().split(' ')]
m=g.index(max(g))
g.sort()
g.pop()
print(m+1,max(g))
``` | 3 | |
265 | A | Colorful Stones (Simplified Edition) | PROGRAMMING | 800 | [
"implementation"
] | null | null | There is a sequence of colorful stones. The color of each stone is one of red, green, or blue. You are given a string *s*. The *i*-th (1-based) character of *s* represents the color of the *i*-th stone. If the character is "R", "G", or "B", the color of the corresponding stone is red, green, or blue, respectively.
Ini... | The input contains two lines. The first line contains the string *s* (1<=≤<=|*s*|<=≤<=50). The second line contains the string *t* (1<=≤<=|*t*|<=≤<=50). The characters of each string will be one of "R", "G", or "B". It is guaranteed that Liss don't move out of the sequence. | Print the final 1-based position of Liss in a single line. | [
"RGB\nRRR\n",
"RRRBGBRBBB\nBBBRR\n",
"BRRBGBRGRBGRGRRGGBGBGBRGBRGRGGGRBRRRBRBBBGRRRGGBBB\nBBRBGGRGRGBBBRBGRBRBBBBRBRRRBGBBGBBRRBBGGRBRRBRGRB\n"
] | [
"2\n",
"3\n",
"15\n"
] | none | 500 | [
{
"input": "RGB\nRRR",
"output": "2"
},
{
"input": "RRRBGBRBBB\nBBBRR",
"output": "3"
},
{
"input": "BRRBGBRGRBGRGRRGGBGBGBRGBRGRGGGRBRRRBRBBBGRRRGGBBB\nBBRBGGRGRGBBBRBGRBRBBBBRBRRRBGBBGBBRRBBGGRBRRBRGRB",
"output": "15"
},
{
"input": "G\nRRBBRBRRBR",
"output": "1"
},
... | 1,690,774,271 | 2,147,483,647 | Python 3 | OK | TESTS | 19 | 92 | 0 | # RRRBGBRBBB
# BBBRR
s = input()
t = input()
step = 0
for i in range(len(t)):
if t[i] == s[step]:
step+=1
print(step+1)
| Title: Colorful Stones (Simplified Edition)
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
There is a sequence of colorful stones. The color of each stone is one of red, green, or blue. You are given a string *s*. The *i*-th (1-based) character of *s* represents the color of the *i*-th st... | ```python
# RRRBGBRBBB
# BBBRR
s = input()
t = input()
step = 0
for i in range(len(t)):
if t[i] == s[step]:
step+=1
print(step+1)
``` | 3 | |
656 | G | You're a Professional | PROGRAMMING | 1,900 | [
"*special"
] | null | null | A simple recommendation system would recommend a user things liked by a certain number of their friends. In this problem you will implement part of such a system.
You are given user's friends' opinions about a list of items. You are also given a threshold *T* — the minimal number of "likes" necessary for an item to be... | The first line of the input will contain three space-separated integers: the number of friends *F* (1<=≤<=*F*<=≤<=10), the number of items *I* (1<=≤<=*I*<=≤<=10) and the threshold *T* (1<=≤<=*T*<=≤<=*F*).
The following *F* lines of input contain user's friends' opinions. *j*-th character of *i*-th line is 'Y' if *i*-t... | Output an integer — the number of items liked by at least *T* of user's friends. | [
"3 3 2\nYYY\nNNN\nYNY\n",
"4 4 1\nNNNY\nNNYN\nNYNN\nYNNN\n"
] | [
"2\n",
"4\n"
] | none | 0 | [
{
"input": "3 3 2\nYYY\nNNN\nYNY",
"output": "2"
},
{
"input": "4 4 1\nNNNY\nNNYN\nNYNN\nYNNN",
"output": "4"
},
{
"input": "3 5 2\nNYNNY\nYNNNN\nNNYYN",
"output": "0"
},
{
"input": "1 10 1\nYYYNYNNYNN",
"output": "5"
},
{
"input": "10 1 5\nY\nN\nN\nN\nY\nN\nN\nY\... | 1,463,671,245 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 0 | 0 | F, I, T = map(int, input().split(" "))
A = []
for i in range(F):
A.append(input())
res = 0
for i in range(I):
s = 0
for j in range(F):
if A[j][i] == 'Y': s += 1
if s >= T: res += 1
print(res)
| Title: You're a Professional
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
A simple recommendation system would recommend a user things liked by a certain number of their friends. In this problem you will implement part of such a system.
You are given user's friends' opinions about a li... | ```python
F, I, T = map(int, input().split(" "))
A = []
for i in range(F):
A.append(input())
res = 0
for i in range(I):
s = 0
for j in range(F):
if A[j][i] == 'Y': s += 1
if s >= T: res += 1
print(res)
``` | 0 | |
318 | A | Even Odds | PROGRAMMING | 900 | [
"math"
] | null | null | Being a nonconformist, Volodya is displeased with the current state of things, particularly with the order of natural numbers (natural number is positive integer number). He is determined to rearrange them. But there are too many natural numbers, so Volodya decided to start with the first *n*. He writes down the follow... | The only line of input contains integers *n* and *k* (1<=≤<=*k*<=≤<=*n*<=≤<=1012).
Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier. | Print the number that will stand at the position number *k* after Volodya's manipulations. | [
"10 3\n",
"7 7\n"
] | [
"5",
"6"
] | In the first sample Volodya's sequence will look like this: {1, 3, 5, 7, 9, 2, 4, 6, 8, 10}. The third place in the sequence is therefore occupied by the number 5. | 500 | [
{
"input": "10 3",
"output": "5"
},
{
"input": "7 7",
"output": "6"
},
{
"input": "7 1",
"output": "1"
},
{
"input": "7 2",
"output": "3"
},
{
"input": "8 5",
"output": "2"
},
{
"input": "8 3",
"output": "5"
},
{
"input": "8 4",
"output... | 1,698,608,248 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 30 | 0 | end=int(input())
start=int(input())
numbers = []
if start == end:
for i in range(start,end-1):
if i%1 ==0:
numbers.append(i)
print(numbers[2])
elif i%2 ==0:
numbers.append(i)
print(numbers[2])
else:
for i in range(start,end):
if i%1 ==0:
numbers.append(i)
elif i... | Title: Even Odds
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Being a nonconformist, Volodya is displeased with the current state of things, particularly with the order of natural numbers (natural number is positive integer number). He is determined to rearrange them. But there are too ... | ```python
end=int(input())
start=int(input())
numbers = []
if start == end:
for i in range(start,end-1):
if i%1 ==0:
numbers.append(i)
print(numbers[2])
elif i%2 ==0:
numbers.append(i)
print(numbers[2])
else:
for i in range(start,end):
if i%1 ==0:
numbers.append(i)
... | -1 | |
863 | F | Almost Permutation | PROGRAMMING | 2,200 | [
"flows"
] | null | null | Recently Ivan noticed an array *a* while debugging his code. Now Ivan can't remember this array, but the bug he was trying to fix didn't go away, so Ivan thinks that the data from this array might help him to reproduce the bug.
Ivan clearly remembers that there were *n* elements in the array, and each element was not ... | The first line contains two integer numbers *n* and *q* (1<=≤<=*n*<=≤<=50, 0<=≤<=*q*<=≤<=100).
Then *q* lines follow, each representing a fact about the array. *i*-th line contains the numbers *t**i*, *l**i*, *r**i* and *v**i* for *i*-th fact (1<=≤<=*t**i*<=≤<=2, 1<=≤<=*l**i*<=≤<=*r**i*<=≤<=*n*, 1<=≤<=*v**i*<=≤<=*n*, ... | If the facts are controversial and there is no array that corresponds to them, print -1. Otherwise, print minimum possible *cost* of the array. | [
"3 0\n",
"3 1\n1 1 3 2\n",
"3 2\n1 1 3 2\n2 1 3 2\n",
"3 2\n1 1 3 2\n2 1 3 1\n"
] | [
"3\n",
"5\n",
"9\n",
"-1\n"
] | none | 0 | [
{
"input": "3 0",
"output": "3"
},
{
"input": "3 1\n1 1 3 2",
"output": "5"
},
{
"input": "3 2\n1 1 3 2\n2 1 3 2",
"output": "9"
},
{
"input": "3 2\n1 1 3 2\n2 1 3 1",
"output": "-1"
},
{
"input": "50 0",
"output": "50"
},
{
"input": "50 1\n2 31 38 25"... | 1,648,505,756 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 28 | 93 | 1,331,200 | def process(n, Q):
maxes = [n for i in range(n+1)]
mins = [1 for i in range(n+1)]
for t, l, r, v in Q:
if t==1:
for i in range(l, r+1):
mins[i] = max(mins[i], v)
else:
for i in range(l, r+1):
maxes[i] = min(maxes[i], v)
L... | Title: Almost Permutation
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Recently Ivan noticed an array *a* while debugging his code. Now Ivan can't remember this array, but the bug he was trying to fix didn't go away, so Ivan thinks that the data from this array might help him to reprodu... | ```python
def process(n, Q):
maxes = [n for i in range(n+1)]
mins = [1 for i in range(n+1)]
for t, l, r, v in Q:
if t==1:
for i in range(l, r+1):
mins[i] = max(mins[i], v)
else:
for i in range(l, r+1):
maxes[i] = min(maxes[i],... | 0 | |
688 | B | Lovely Palindromes | PROGRAMMING | 1,000 | [
"constructive algorithms",
"math"
] | null | null | Pari has a friend who loves palindrome numbers. A palindrome number is a number that reads the same forward or backward. For example 12321, 100001 and 1 are palindrome numbers, while 112 and 1021 are not.
Pari is trying to love them too, but only very special and gifted people can understand the beauty behind palindro... | The only line of the input contains a single integer *n* (1<=≤<=*n*<=≤<=10100<=000). | Print the *n*-th even-length palindrome number. | [
"1\n",
"10\n"
] | [
"11\n",
"1001\n"
] | The first 10 even-length palindrome numbers are 11, 22, 33, ... , 88, 99 and 1001. | 1,000 | [
{
"input": "1",
"output": "11"
},
{
"input": "10",
"output": "1001"
},
{
"input": "11",
"output": "1111"
},
{
"input": "12",
"output": "1221"
},
{
"input": "100",
"output": "100001"
},
{
"input": "1321",
"output": "13211231"
},
{
"input": "... | 1,632,645,240 | 2,147,483,647 | Python 3 | OK | TESTS | 40 | 62 | 7,372,800 |
a = input()
print( a + a[::-1] )
| Title: Lovely Palindromes
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Pari has a friend who loves palindrome numbers. A palindrome number is a number that reads the same forward or backward. For example 12321, 100001 and 1 are palindrome numbers, while 112 and 1021 are not.
Pari is tr... | ```python
a = input()
print( a + a[::-1] )
``` | 3 | |
486 | A | Calculating Function | PROGRAMMING | 800 | [
"implementation",
"math"
] | null | null | For a positive integer *n* let's define a function *f*:
*f*(*n*)<==<=<=-<=1<=+<=2<=-<=3<=+<=..<=+<=(<=-<=1)*n**n*
Your task is to calculate *f*(*n*) for a given integer *n*. | The single line contains the positive integer *n* (1<=≤<=*n*<=≤<=1015). | Print *f*(*n*) in a single line. | [
"4\n",
"5\n"
] | [
"2\n",
"-3\n"
] | *f*(4) = - 1 + 2 - 3 + 4 = 2
*f*(5) = - 1 + 2 - 3 + 4 - 5 = - 3 | 500 | [
{
"input": "4",
"output": "2"
},
{
"input": "5",
"output": "-3"
},
{
"input": "1000000000",
"output": "500000000"
},
{
"input": "1000000001",
"output": "-500000001"
},
{
"input": "1000000000000000",
"output": "500000000000000"
},
{
"input": "100",
... | 1,693,718,749 | 2,147,483,647 | Python 3 | OK | TESTS | 39 | 31 | 0 | n=int(input())
k=n//2
if n%2==1:
k=(n+1)//2
print(-k)
else:
print(k)
| Title: Calculating Function
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
For a positive integer *n* let's define a function *f*:
*f*(*n*)<==<=<=-<=1<=+<=2<=-<=3<=+<=..<=+<=(<=-<=1)*n**n*
Your task is to calculate *f*(*n*) for a given integer *n*.
Input Specification:
The single line... | ```python
n=int(input())
k=n//2
if n%2==1:
k=(n+1)//2
print(-k)
else:
print(k)
``` | 3 | |
670 | B | Game of Robots | PROGRAMMING | 1,000 | [
"implementation"
] | null | null | In late autumn evening *n* robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.
At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. A... | The first line contains two positive integers *n* and *k* (1<=≤<=*n*<=≤<=100<=000, 1<=≤<=*k*<=≤<=*min*(2·109,<=*n*·(*n*<=+<=1)<=/<=2).
The second line contains the sequence *id*1,<=*id*2,<=...,<=*id**n* (1<=≤<=*id**i*<=≤<=109) — identifiers of roborts. It is guaranteed that all identifiers are different. | Print the *k*-th pronounced identifier (assume that the numeration starts from 1). | [
"2 2\n1 2\n",
"4 5\n10 4 18 3\n"
] | [
"1\n",
"4\n"
] | In the first sample identifiers of robots will be pronounced in the following order: 1, 1, 2. As *k* = 2, the answer equals to 1.
In the second test case identifiers of robots will be pronounced in the following order: 10, 10, 4, 10, 4, 18, 10, 4, 18, 3. As *k* = 5, the answer equals to 4. | 750 | [
{
"input": "2 2\n1 2",
"output": "1"
},
{
"input": "4 5\n10 4 18 3",
"output": "4"
},
{
"input": "1 1\n4",
"output": "4"
},
{
"input": "2 1\n5 1",
"output": "5"
},
{
"input": "2 2\n1 4",
"output": "1"
},
{
"input": "2 3\n6 7",
"output": "7"
},
... | 1,649,598,251 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 3 | 31 | 0 | n, k = map(int, input().split())
identifiers = list(map(int, input().split()))
i = 0
while True:
if (1 + i) * i // 2 > k:
z = i - 1
break
else:
i += 1
x = k - ((1 + z) * z // 2) - 1
print(identifiers[x])
| Title: Game of Robots
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
In late autumn evening *n* robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.
At some moment, robots decided to play the game "Snowball". Below there are t... | ```python
n, k = map(int, input().split())
identifiers = list(map(int, input().split()))
i = 0
while True:
if (1 + i) * i // 2 > k:
z = i - 1
break
else:
i += 1
x = k - ((1 + z) * z // 2) - 1
print(identifiers[x])
``` | 0 | |
519 | B | A and B and Compilation Errors | PROGRAMMING | 1,100 | [
"data structures",
"implementation",
"sortings"
] | null | null | A and B are preparing themselves for programming contests.
B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code.
Initially, the compiler displayed *n* compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix... | The first line of the input contains integer *n* (3<=≤<=*n*<=≤<=105) — the initial number of compilation errors.
The second line contains *n* space-separated integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=109) — the errors the compiler displayed for the first time.
The third line contains *n*<=-<=1 space-sepa... | Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively. | [
"5\n1 5 8 123 7\n123 7 5 1\n5 1 7\n",
"6\n1 4 3 3 5 7\n3 7 5 4 3\n4 3 7 5\n"
] | [
"8\n123\n",
"1\n3\n"
] | In the first test sample B first corrects the error number 8, then the error number 123.
In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. | 1,000 | [
{
"input": "5\n1 5 8 123 7\n123 7 5 1\n5 1 7",
"output": "8\n123"
},
{
"input": "6\n1 4 3 3 5 7\n3 7 5 4 3\n4 3 7 5",
"output": "1\n3"
},
{
"input": "3\n1 2 3\n3 2\n2",
"output": "1\n3"
},
{
"input": "10\n460626451 802090732 277246428 661369649 388684428 784303821 376287098 6... | 1,635,261,382 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 7 | 2,000 | 19,968,000 | a=int(input())
b=list(input().split())
c=list(input().split())
d=list(input().split())
i=0
while i<len(c):
if c[i] in b:
b.remove(c[i])
i+=1
i=0
while i<len(d):
if d[i] in c:
c.remove(d[i])
i+=1
print(b[0])
print(c[0])
| Title: A and B and Compilation Errors
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
A and B are preparing themselves for programming contests.
B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code.
Initially, the compiler disp... | ```python
a=int(input())
b=list(input().split())
c=list(input().split())
d=list(input().split())
i=0
while i<len(c):
if c[i] in b:
b.remove(c[i])
i+=1
i=0
while i<len(d):
if d[i] in c:
c.remove(d[i])
i+=1
print(b[0])
print(c[0])
``` | 0 | |
27 | C | Unordered Subsequence | PROGRAMMING | 1,900 | [
"constructive algorithms",
"greedy"
] | C. Unordered Subsequence | 2 | 256 | The sequence is called ordered if it is non-decreasing or non-increasing. For example, sequnces [3, 1, 1, 0] and [1, 2, 3, 100] are ordered, but the sequence [1, 3, 3, 1] is not. You are given a sequence of numbers. You are to find it's shortest subsequence which is not ordered.
A subsequence is a sequence that can be... | The first line of the input contains one integer *n* (1<=≤<=*n*<=≤<=105). The second line contains *n* space-separated integers — the given sequence. All numbers in this sequence do not exceed 106 by absolute value. | If the given sequence does not contain any unordered subsequences, output 0. Otherwise, output the length *k* of the shortest such subsequence. Then output *k* integers from the range [1..*n*] — indexes of the elements of this subsequence. If there are several solutions, output any of them. | [
"5\n67 499 600 42 23\n",
"3\n1 2 3\n",
"3\n2 3 1\n"
] | [
"3\n1 3 5\n",
"0\n",
"3\n1 2 3\n"
] | none | 1,500 | [
{
"input": "3\n3 1 2",
"output": "3\n1 2 3"
},
{
"input": "1\n-895376",
"output": "0"
},
{
"input": "2\n166442 61629",
"output": "0"
},
{
"input": "3\n-771740 -255752 -300809",
"output": "3\n1 2 3"
},
{
"input": "4\n-227347 -573134 -671045 11011",
"output": "3... | 1,531,513,392 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 186 | 0 | n = int(input())
a = list(map(int,input().split(' ')))
z = []
d = {}
for i in range(n):
d.update({a[i]:i+1})
def check(l,m,h):
temp = a[m]
f = []
for i in range(l,m):
if a[i]<a[m]:
f.append(a[i])
break
f.append(a[m])
for j in range(m+1,h):
... | Title: Unordered Subsequence
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
The sequence is called ordered if it is non-decreasing or non-increasing. For example, sequnces [3, 1, 1, 0] and [1, 2, 3, 100] are ordered, but the sequence [1, 3, 3, 1] is not. You are given a sequence of numbers. Y... | ```python
n = int(input())
a = list(map(int,input().split(' ')))
z = []
d = {}
for i in range(n):
d.update({a[i]:i+1})
def check(l,m,h):
temp = a[m]
f = []
for i in range(l,m):
if a[i]<a[m]:
f.append(a[i])
break
f.append(a[m])
for j in range(m+1,h)... | 0 |
197 | A | Plate Game | PROGRAMMING | 1,600 | [
"constructive algorithms",
"games",
"math"
] | null | null | You've got a rectangular table with length *a* and width *b* and the infinite number of plates of radius *r*. Two players play the following game: they take turns to put the plates on the table so that the plates don't lie on each other (but they can touch each other), and so that any point on any plate is located with... | A single line contains three space-separated integers *a*, *b*, *r* (1<=≤<=*a*,<=*b*,<=*r*<=≤<=100) — the table sides and the plates' radius, correspondingly. | If wins the player who moves first, print "First" (without the quotes). Otherwise print "Second" (without the quotes). | [
"5 5 2\n",
"6 7 4\n"
] | [
"First\n",
"Second\n"
] | In the first sample the table has place for only one plate. The first player puts a plate on the table, the second player can't do that and loses.
In the second sample the table is so small that it doesn't have enough place even for one plate. So the first player loses without making a single move. | 1,000 | [
{
"input": "5 5 2",
"output": "First"
},
{
"input": "6 7 4",
"output": "Second"
},
{
"input": "100 100 1",
"output": "First"
},
{
"input": "1 1 100",
"output": "Second"
},
{
"input": "13 7 3",
"output": "First"
},
{
"input": "23 7 3",
"output": "Fi... | 1,572,680,308 | 2,147,483,647 | Python 3 | OK | TESTS | 95 | 248 | 0 | a, b, c = map(int, input().split())
if a < c * 2 or b < c * 2:
print("Second")
else :
print("First") | Title: Plate Game
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You've got a rectangular table with length *a* and width *b* and the infinite number of plates of radius *r*. Two players play the following game: they take turns to put the plates on the table so that the plates don't lie o... | ```python
a, b, c = map(int, input().split())
if a < c * 2 or b < c * 2:
print("Second")
else :
print("First")
``` | 3 | |
171 | E | MYSTERIOUS LANGUAGE | PROGRAMMING | 2,000 | [
"*special"
] | null | null | You are given a mysterious language (codenamed "Secret") available in "Custom Test" tab. Find out what this language is and write a program which outputs its name. Note that the program must be written in this language. | This program has only one test, and it's empty (it doesn't give your program anything to read). | Output the name of the mysterious language. | [] | [] | none | 0 | [
{
"input": "1",
"output": "INTERCAL"
}
] | 1,612,342,610 | 2,147,483,647 | Python 3 | OK | TESTS | 1 | 92 | 0 | print("INTERCAL"); | Title: MYSTERIOUS LANGUAGE
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given a mysterious language (codenamed "Secret") available in "Custom Test" tab. Find out what this language is and write a program which outputs its name. Note that the program must be written in this langu... | ```python
print("INTERCAL");
``` | 3 | |
251 | D | Two Sets | PROGRAMMING | 2,700 | [
"bitmasks",
"math"
] | null | null | Little Petya likes numbers a lot. Recently his mother has presented him a collection of *n* non-negative integers. There's only one thing Petya likes more than numbers: playing with little Masha. He immediately decided to give a part of his new collection to her. To make the game even more interesting, Petya decided to... | The first line contains integer *n* (1<=≤<=*n*<=≤<=105), showing how many numbers Petya's mother gave him. The second line contains the actual space-separated numbers. They are all integer, non-negative and do not exceed 1018. | Print *n* space-separated integers, the *i*-th of them should equal either 1, if Petya keeps the number that follows *i*-th in his collection, or it should equal 2, if Petya gives the corresponding number to Masha. The numbers are indexed in the order in which they are given in the input. | [
"6\n1 2 3 4 5 6\n",
"3\n1000000000000 1000000000000 1000000000000\n",
"8\n1 1 2 2 3 3 4 4\n"
] | [
"2 2 2 2 2 2\n",
"2 2 2\n",
"1 2 1 2 2 2 1 2\n"
] | none | 2,000 | [] | 1,689,603,311 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 0 | 30 | 0 | print("_RANDOM_GUESS_1689603311.8876774")# 1689603311.8876994 | Title: Two Sets
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Little Petya likes numbers a lot. Recently his mother has presented him a collection of *n* non-negative integers. There's only one thing Petya likes more than numbers: playing with little Masha. He immediately decided to give... | ```python
print("_RANDOM_GUESS_1689603311.8876774")# 1689603311.8876994
``` | 0 | |
701 | A | Cards | PROGRAMMING | 800 | [
"greedy",
"implementation"
] | null | null | There are *n* cards (*n* is even) in the deck. Each card has a positive integer written on it. *n*<=/<=2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards ... | The first line of the input contains integer *n* (2<=≤<=*n*<=≤<=100) — the number of cards in the deck. It is guaranteed that *n* is even.
The second line contains the sequence of *n* positive integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=100), where *a**i* is equal to the number written on the *i*-th card. | Print *n*<=/<=2 pairs of integers, the *i*-th pair denote the cards that should be given to the *i*-th player. Each card should be given to exactly one player. Cards are numbered in the order they appear in the input.
It is guaranteed that solution exists. If there are several correct answers, you are allowed to print... | [
"6\n1 5 7 4 4 3\n",
"4\n10 10 10 10\n"
] | [
"1 3\n6 2\n4 5\n",
"1 2\n3 4\n"
] | In the first sample, cards are distributed in such a way that each player has the sum of numbers written on his cards equal to 8.
In the second sample, all values *a*<sub class="lower-index">*i*</sub> are equal. Thus, any distribution is acceptable. | 500 | [
{
"input": "6\n1 5 7 4 4 3",
"output": "1 3\n6 2\n4 5"
},
{
"input": "4\n10 10 10 10",
"output": "1 4\n2 3"
},
{
"input": "100\n2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ... | 1,644,167,351 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 46 | 0 | n = int(input())
a = [int(x) for x in input().split()]
b = []
sum = 0
for i in a:
sum += i
k = int(sum / (n / 2))
for i in range(n):
if a[i] > 0:
v = k - a[i]
a[i] = -1
for j in range(n):
if a[j] == v:
print(i + 1, j + 1)
a[j] = -... | Title: Cards
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
There are *n* cards (*n* is even) in the deck. Each card has a positive integer written on it. *n*<=/<=2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one p... | ```python
n = int(input())
a = [int(x) for x in input().split()]
b = []
sum = 0
for i in a:
sum += i
k = int(sum / (n / 2))
for i in range(n):
if a[i] > 0:
v = k - a[i]
a[i] = -1
for j in range(n):
if a[j] == v:
print(i + 1, j + 1)
... | 0 | |
931 | A | Friends Meeting | PROGRAMMING | 800 | [
"brute force",
"greedy",
"implementation",
"math"
] | null | null | Two friends are on the coordinate axis *Ox* in points with integer coordinates. One of them is in the point *x*1<==<=*a*, another one is in the point *x*2<==<=*b*.
Each of the friends can move by one along the line in any direction unlimited number of times. When a friend moves, the tiredness of a friend changes acco... | The first line contains a single integer *a* (1<=≤<=*a*<=≤<=1000) — the initial position of the first friend.
The second line contains a single integer *b* (1<=≤<=*b*<=≤<=1000) — the initial position of the second friend.
It is guaranteed that *a*<=≠<=*b*. | Print the minimum possible total tiredness if the friends meet in the same point. | [
"3\n4\n",
"101\n99\n",
"5\n10\n"
] | [
"1\n",
"2\n",
"9\n"
] | In the first example the first friend should move by one to the right (then the meeting happens at point 4), or the second friend should move by one to the left (then the meeting happens at point 3). In both cases, the total tiredness becomes 1.
In the second example the first friend should move by one to the left, an... | 500 | [
{
"input": "3\n4",
"output": "1"
},
{
"input": "101\n99",
"output": "2"
},
{
"input": "5\n10",
"output": "9"
},
{
"input": "1\n2",
"output": "1"
},
{
"input": "1\n1000",
"output": "250000"
},
{
"input": "999\n1000",
"output": "1"
},
{
"inpu... | 1,587,391,233 | 2,147,483,647 | PyPy 3 | OK | TESTS | 40 | 156 | 0 | x=int(input())
y=int(input())
d=abs(x-y)
c=d//2
r=c*(c+1)
if(d%2==0):
print(r)
else:
print(r+(d+1)//2)
| Title: Friends Meeting
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Two friends are on the coordinate axis *Ox* in points with integer coordinates. One of them is in the point *x*1<==<=*a*, another one is in the point *x*2<==<=*b*.
Each of the friends can move by one along the line in... | ```python
x=int(input())
y=int(input())
d=abs(x-y)
c=d//2
r=c*(c+1)
if(d%2==0):
print(r)
else:
print(r+(d+1)//2)
``` | 3 | |
669 | A | Little Artem and Presents | PROGRAMMING | 800 | [
"math"
] | null | null | Little Artem got *n* stones on his birthday and now wants to give some of them to Masha. He knows that Masha cares more about the fact of receiving the present, rather than the value of that present, so he wants to give her stones as many times as possible. However, Masha remembers the last present she received, so Art... | The only line of the input contains a single integer *n* (1<=≤<=*n*<=≤<=109) — number of stones Artem received on his birthday. | Print the maximum possible number of times Artem can give presents to Masha. | [
"1\n",
"2\n",
"3\n",
"4\n"
] | [
"1\n",
"1\n",
"2\n",
"3\n"
] | In the first sample, Artem can only give 1 stone to Masha.
In the second sample, Atrem can give Masha 1 or 2 stones, though he can't give her 1 stone two times.
In the third sample, Atrem can first give Masha 2 stones, a then 1 more stone.
In the fourth sample, Atrem can first give Masha 1 stone, then 2 stones, and ... | 500 | [
{
"input": "1",
"output": "1"
},
{
"input": "2",
"output": "1"
},
{
"input": "3",
"output": "2"
},
{
"input": "4",
"output": "3"
},
{
"input": "100",
"output": "67"
},
{
"input": "101",
"output": "67"
},
{
"input": "102",
"output": "68"... | 1,690,045,615 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 46 | 0 | def max_gifts(n):
if n <= 2:
return n
dp = [0] * (n + 1)
dp[1] = 1
dp[2] = 2
for i in range(3, n + 1):
dp[i] = dp[i - 1] + dp[i - 2]
print(dp[n])
n = int(input())
result = max_gifts(n)
print(result)
| Title: Little Artem and Presents
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Little Artem got *n* stones on his birthday and now wants to give some of them to Masha. He knows that Masha cares more about the fact of receiving the present, rather than the value of that present, so he wan... | ```python
def max_gifts(n):
if n <= 2:
return n
dp = [0] * (n + 1)
dp[1] = 1
dp[2] = 2
for i in range(3, n + 1):
dp[i] = dp[i - 1] + dp[i - 2]
print(dp[n])
n = int(input())
result = max_gifts(n)
print(result)
``` | 0 | |
448 | B | Suffix Structures | PROGRAMMING | 1,400 | [
"implementation",
"strings"
] | null | null | Bizon the Champion isn't just a bison. He also is a favorite of the "Bizons" team.
At a competition the "Bizons" got the following problem: "You are given two distinct words (strings of English letters), *s* and *t*. You need to transform word *s* into word *t*". The task looked simple to the guys because they know th... | The first line contains a non-empty word *s*. The second line contains a non-empty word *t*. Words *s* and *t* are different. Each word consists only of lowercase English letters. Each word contains at most 100 letters. | In the single line print the answer to the problem. Print "need tree" (without the quotes) if word *s* cannot be transformed into word *t* even with use of both suffix array and suffix automaton. Print "automaton" (without the quotes) if you need only the suffix automaton to solve the problem. Print "array" (without th... | [
"automaton\ntomat\n",
"array\narary\n",
"both\nhot\n",
"need\ntree\n"
] | [
"automaton\n",
"array\n",
"both\n",
"need tree\n"
] | In the third sample you can act like that: first transform "both" into "oth" by removing the first character using the suffix automaton and then make two swaps of the string using the suffix array and get "hot". | 1,000 | [
{
"input": "automaton\ntomat",
"output": "automaton"
},
{
"input": "array\narary",
"output": "array"
},
{
"input": "both\nhot",
"output": "both"
},
{
"input": "need\ntree",
"output": "need tree"
},
{
"input": "abacaba\naaaa",
"output": "automaton"
},
{
... | 1,619,410,202 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 4 | 108 | 0 | s = input()
t = input()
if (t in s) and len(s) != len(t):
print('automaton')
elif len(s) == len(t) and sorted(s) == sorted(t):
print('array')
else:
f = 1
for i in t:
if i not in s:
f = 0
break
else:
s.replace(i, '1', 1)
if f == 1:
... | Title: Suffix Structures
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Bizon the Champion isn't just a bison. He also is a favorite of the "Bizons" team.
At a competition the "Bizons" got the following problem: "You are given two distinct words (strings of English letters), *s* and *t*.... | ```python
s = input()
t = input()
if (t in s) and len(s) != len(t):
print('automaton')
elif len(s) == len(t) and sorted(s) == sorted(t):
print('array')
else:
f = 1
for i in t:
if i not in s:
f = 0
break
else:
s.replace(i, '1', 1)
if f... | 0 | |
336 | A | Vasily the Bear and Triangle | PROGRAMMING | 1,000 | [
"implementation",
"math"
] | null | null | Vasily the bear has a favorite rectangle, it has one vertex at point (0,<=0), and the opposite vertex at point (*x*,<=*y*). Of course, the sides of Vasya's favorite rectangle are parallel to the coordinate axes.
Vasya also loves triangles, if the triangles have one vertex at point *B*<==<=(0,<=0). That's why today he... | The first line contains two integers *x*,<=*y* (<=-<=109<=≤<=*x*,<=*y*<=≤<=109,<=*x*<=≠<=0,<=*y*<=≠<=0). | Print in the single line four integers *x*1,<=*y*1,<=*x*2,<=*y*2 — the coordinates of the required points. | [
"10 5\n",
"-10 5\n"
] | [
"0 15 15 0\n",
"-15 0 0 15\n"
] | <img class="tex-graphics" src="https://espresso.codeforces.com/a9ea2088c4294ce8f23801562fda36b830df2c3f.png" style="max-width: 100.0%;max-height: 100.0%;"/>
Figure to the first sample | 500 | [
{
"input": "10 5",
"output": "0 15 15 0"
},
{
"input": "-10 5",
"output": "-15 0 0 15"
},
{
"input": "20 -10",
"output": "0 -30 30 0"
},
{
"input": "-10 -1000000000",
"output": "-1000000010 0 0 -1000000010"
},
{
"input": "-1000000000 -1000000000",
"output": "-... | 1,622,959,399 | 2,147,483,647 | Python 3 | OK | TESTS | 30 | 186 | 0 | a,b=map(int,input().split())
if a>0 and b>0:
c=abs(b)+abs(a)
print(0,c,c,0)
elif a<0 and b>0:
c=abs(b)+abs(a)
print(-c,0, 0,c)
elif a<0 and b<0:
c=abs(b)+abs(a)
print(-c,0,0,-c)
elif a>0 and b<0:
c=abs(b)+abs(a)
print(0,-c,c,0) | Title: Vasily the Bear and Triangle
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vasily the bear has a favorite rectangle, it has one vertex at point (0,<=0), and the opposite vertex at point (*x*,<=*y*). Of course, the sides of Vasya's favorite rectangle are parallel to the coordinate ... | ```python
a,b=map(int,input().split())
if a>0 and b>0:
c=abs(b)+abs(a)
print(0,c,c,0)
elif a<0 and b>0:
c=abs(b)+abs(a)
print(-c,0, 0,c)
elif a<0 and b<0:
c=abs(b)+abs(a)
print(-c,0,0,-c)
elif a>0 and b<0:
c=abs(b)+abs(a)
print(0,-c,c,0)
``` | 3 | |
474 | B | Worms | PROGRAMMING | 1,200 | [
"binary search",
"implementation"
] | null | null | It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.
Marmot brought Mole *n* ordered piles of worms such that *i*-th pile contains *a**i* worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to *a*1, worms in second pile are labeled w... | The first line contains a single integer *n* (1<=≤<=*n*<=≤<=105), the number of piles.
The second line contains *n* integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=103, *a*1<=+<=*a*2<=+<=...<=+<=*a**n*<=≤<=106), where *a**i* is the number of worms in the *i*-th pile.
The third line contains single integer *m* (... | Print *m* lines to the standard output. The *i*-th line should contain an integer, representing the number of the pile where the worm labeled with the number *q**i* is. | [
"5\n2 7 3 4 9\n3\n1 25 11\n"
] | [
"1\n5\n3\n"
] | For the sample input:
- The worms with labels from [1, 2] are in the first pile. - The worms with labels from [3, 9] are in the second pile. - The worms with labels from [10, 12] are in the third pile. - The worms with labels from [13, 16] are in the fourth pile. - The worms with labels from [17, 25] are in the f... | 1,000 | [
{
"input": "5\n2 7 3 4 9\n3\n1 25 11",
"output": "1\n5\n3"
}
] | 1,689,216,090 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 2 | 1,000 | 2,048,000 | #How works, if a1==1, range is 1 to a1 else, range is a1 + 1 to a1 + a2, etc...
#int(input())
#[int(x) for x in (input().split())]
#int(input())
#[int(y) for y in (input().split())]
n = int(input())
a = [int(x) for x in (input().split())]
m = int(input())
q = [int(x) for x in (input().split()... | Title: Worms
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.
Marmot brought Mole *n* ordered piles of worms such that *i*-th pile contains *a**i* worms. He labeled all these worms with consecutive integers:... | ```python
#How works, if a1==1, range is 1 to a1 else, range is a1 + 1 to a1 + a2, etc...
#int(input())
#[int(x) for x in (input().split())]
#int(input())
#[int(y) for y in (input().split())]
n = int(input())
a = [int(x) for x in (input().split())]
m = int(input())
q = [int(x) for x in (input... | 0 | |
214 | A | System of Equations | PROGRAMMING | 800 | [
"brute force"
] | null | null | Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you?
You are given a system of equations:
You should count, how many there are pairs of int... | A single line contains two integers *n*,<=*m* (1<=≤<=*n*,<=*m*<=≤<=1000) — the parameters of the system. The numbers on the line are separated by a space. | On a single line print the answer to the problem. | [
"9 3\n",
"14 28\n",
"4 20\n"
] | [
"1\n",
"1\n",
"0\n"
] | In the first sample the suitable pair is integers (3, 0). In the second sample the suitable pair is integers (3, 5). In the third sample there is no suitable pair. | 500 | [
{
"input": "9 3",
"output": "1"
},
{
"input": "14 28",
"output": "1"
},
{
"input": "4 20",
"output": "0"
},
{
"input": "18 198",
"output": "1"
},
{
"input": "22 326",
"output": "1"
},
{
"input": "26 104",
"output": "1"
},
{
"input": "14 10"... | 1,634,074,086 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 11 | 92 | 6,758,400 | n,m=map(int,input().split())
s=0
for a in range (n):
for b in range(m):
if (a*a+b==n and a+b*b==m):
s=s+1
print(s) | Title: System of Equations
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immedi... | ```python
n,m=map(int,input().split())
s=0
for a in range (n):
for b in range(m):
if (a*a+b==n and a+b*b==m):
s=s+1
print(s)
``` | 0 | |
80 | A | Panoramix's Prediction | PROGRAMMING | 800 | [
"brute force"
] | A. Panoramix's Prediction | 2 | 256 | A prime number is a number which has exactly two distinct divisors: one and itself. For example, numbers 2, 7, 3 are prime, and 1, 6, 4 are not.
The next prime number after *x* is the smallest prime number greater than *x*. For example, the next prime number after 2 is 3, and the next prime number after 3 is 5. Note t... | The first and only input line contains two positive integers — *n* and *m* (2<=≤<=*n*<=<<=*m*<=≤<=50). It is guaranteed that *n* is prime.
Pretests contain all the cases with restrictions 2<=≤<=*n*<=<<=*m*<=≤<=4. | Print YES, if *m* is the next prime number after *n*, or NO otherwise. | [
"3 5\n",
"7 11\n",
"7 9\n"
] | [
"YES",
"YES",
"NO"
] | none | 500 | [
{
"input": "3 5",
"output": "YES"
},
{
"input": "7 11",
"output": "YES"
},
{
"input": "7 9",
"output": "NO"
},
{
"input": "2 3",
"output": "YES"
},
{
"input": "2 4",
"output": "NO"
},
{
"input": "3 4",
"output": "NO"
},
{
"input": "3 5",
... | 1,525,339,498 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 18 | 154 | 7,065,600 | n,m=map(int,input().split())
p=[2,3,5,7,11,13,17,19,23,29,31,37,41,43]
for i in range(len(p)):
if p[i]==n:
break
if m==p[i+1]:
print("YES")
else:
print("NO")
| Title: Panoramix's Prediction
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
A prime number is a number which has exactly two distinct divisors: one and itself. For example, numbers 2, 7, 3 are prime, and 1, 6, 4 are not.
The next prime number after *x* is the smallest prime number greater t... | ```python
n,m=map(int,input().split())
p=[2,3,5,7,11,13,17,19,23,29,31,37,41,43]
for i in range(len(p)):
if p[i]==n:
break
if m==p[i+1]:
print("YES")
else:
print("NO")
``` | -1 |
514 | A | Chewbaсca and Number | PROGRAMMING | 1,200 | [
"greedy",
"implementation"
] | null | null | Luke Skywalker gave Chewbacca an integer number *x*. Chewbacca isn't good at numbers but he loves inverting digits in them. Inverting digit *t* means replacing it with digit 9<=-<=*t*.
Help Chewbacca to transform the initial number *x* to the minimum possible positive number by inverting some (possibly, zero) digits.... | The first line contains a single integer *x* (1<=≤<=*x*<=≤<=1018) — the number that Luke Skywalker gave to Chewbacca. | Print the minimum possible positive number that Chewbacca can obtain after inverting some digits. The number shouldn't contain leading zeroes. | [
"27\n",
"4545\n"
] | [
"22\n",
"4444\n"
] | none | 500 | [
{
"input": "27",
"output": "22"
},
{
"input": "4545",
"output": "4444"
},
{
"input": "1",
"output": "1"
},
{
"input": "9",
"output": "9"
},
{
"input": "8772",
"output": "1222"
},
{
"input": "81",
"output": "11"
},
{
"input": "71723447",
... | 1,694,796,921 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 4 | 31 | 0 | num = list(map(int, input()))
# 如果第一位是9,那么不改变,否则根据上述规则转换
num = [num[0]] + [(9 - x if x >= 5 else x) for x in num[1:]]
# 将数字列表转回字符串并输出
print(''.join(map(str, num)))
| Title: Chewbaсca and Number
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Luke Skywalker gave Chewbacca an integer number *x*. Chewbacca isn't good at numbers but he loves inverting digits in them. Inverting digit *t* means replacing it with digit 9<=-<=*t*.
Help Chewbacca to transform... | ```python
num = list(map(int, input()))
# 如果第一位是9,那么不改变,否则根据上述规则转换
num = [num[0]] + [(9 - x if x >= 5 else x) for x in num[1:]]
# 将数字列表转回字符串并输出
print(''.join(map(str, num)))
``` | 0 | |
579 | A | Raising Bacteria | PROGRAMMING | 1,000 | [
"bitmasks"
] | null | null | You are a lover of bacteria. You want to raise some bacteria in a box.
Initially, the box is empty. Each morning, you can put any number of bacteria into the box. And each night, every bacterium in the box will split into two bacteria. You hope to see exactly *x* bacteria in the box at some moment.
What is the mini... | The only line containing one integer *x* (1<=≤<=*x*<=≤<=109). | The only line containing one integer: the answer. | [
"5\n",
"8\n"
] | [
"2\n",
"1\n"
] | For the first sample, we can add one bacterium in the box in the first day morning and at the third morning there will be 4 bacteria in the box. Now we put one more resulting 5 in the box. We added 2 bacteria in the process so the answer is 2.
For the second sample, we can put one in the first morning and in the 4-th ... | 250 | [
{
"input": "5",
"output": "2"
},
{
"input": "8",
"output": "1"
},
{
"input": "536870911",
"output": "29"
},
{
"input": "1",
"output": "1"
},
{
"input": "343000816",
"output": "14"
},
{
"input": "559980448",
"output": "12"
},
{
"input": "697... | 1,672,267,083 | 2,147,483,647 | Python 3 | OK | TESTS | 36 | 46 | 0 | ans = str(bin(int(input())))
total = 0
for i in range(len(ans)):
if ans[i] == "1":
total += 1
print(total) | Title: Raising Bacteria
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are a lover of bacteria. You want to raise some bacteria in a box.
Initially, the box is empty. Each morning, you can put any number of bacteria into the box. And each night, every bacterium in the box will split... | ```python
ans = str(bin(int(input())))
total = 0
for i in range(len(ans)):
if ans[i] == "1":
total += 1
print(total)
``` | 3 | |
0 | none | none | none | 0 | [
"none"
] | null | null | Qwerty the Ranger took up a government job and arrived on planet Mars. He should stay in the secret lab and conduct some experiments on bacteria that have funny and abnormal properties. The job isn't difficult, but the salary is high.
At the beginning of the first experiment there is a single bacterium in the test tub... | The first line contains four space-separated integers *k*, *b*, *n* and *t* (1<=≤<=*k*,<=*b*,<=*n*,<=*t*<=≤<=106) — the parameters of bacterial growth, the time Qwerty needed to grow *z* bacteria in the first experiment and the initial number of bacteria in the second experiment, correspondingly. | Print a single number — the minimum number of seconds Qwerty needs to grow at least *z* bacteria in the tube. | [
"3 1 3 5\n",
"1 4 4 7\n",
"2 2 4 100\n"
] | [
"2",
"3",
"0"
] | none | 0 | [
{
"input": "3 1 3 5",
"output": "2"
},
{
"input": "1 4 4 7",
"output": "3"
},
{
"input": "2 2 4 100",
"output": "0"
},
{
"input": "1 2 3 100",
"output": "0"
},
{
"input": "10 10 10 123456",
"output": "6"
},
{
"input": "847 374 283 485756",
"output"... | 1,625,754,096 | 3,996 | PyPy 3 | TIME_LIMIT_EXCEEDED | TESTS | 6 | 2,000 | 9,113,600 | k, b, n, t = list(map(int, input().split()))
pierwsza = 1
for x in range(n):
pierwsza = pierwsza*k + b
sekundy = 0
druga = t
while druga < pierwsza:
druga = druga*k + b
sekundy = sekundy + 1
print(sekundy) | Title: none
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Qwerty the Ranger took up a government job and arrived on planet Mars. He should stay in the secret lab and conduct some experiments on bacteria that have funny and abnormal properties. The job isn't difficult, but the salary is h... | ```python
k, b, n, t = list(map(int, input().split()))
pierwsza = 1
for x in range(n):
pierwsza = pierwsza*k + b
sekundy = 0
druga = t
while druga < pierwsza:
druga = druga*k + b
sekundy = sekundy + 1
print(sekundy)
``` | 0 | |
58 | A | Chat room | PROGRAMMING | 1,000 | [
"greedy",
"strings"
] | A. Chat room | 1 | 256 | Vasya has recently learned to type and log on to the Internet. He immediately entered a chat room and decided to say hello to everybody. Vasya typed the word *s*. It is considered that Vasya managed to say hello if several letters can be deleted from the typed word so that it resulted in the word "hello". For example, ... | The first and only line contains the word *s*, which Vasya typed. This word consisits of small Latin letters, its length is no less that 1 and no more than 100 letters. | If Vasya managed to say hello, print "YES", otherwise print "NO". | [
"ahhellllloou\n",
"hlelo\n"
] | [
"YES\n",
"NO\n"
] | none | 500 | [
{
"input": "ahhellllloou",
"output": "YES"
},
{
"input": "hlelo",
"output": "NO"
},
{
"input": "helhcludoo",
"output": "YES"
},
{
"input": "hehwelloho",
"output": "YES"
},
{
"input": "pnnepelqomhhheollvlo",
"output": "YES"
},
{
"input": "tymbzjyqhymeda... | 1,679,487,207 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 34 | 46 | 0 | s = "hello"
a = input()
def look():
i = 0
j = 0
while i != 5:
if j == len(a):
return False
if i == 4:
return True
elif s[i] == a[j]:
i += 1
j += 1
else:
j += 1
if look():
print("YES")
els... | Title: Chat room
Time Limit: 1 seconds
Memory Limit: 256 megabytes
Problem Description:
Vasya has recently learned to type and log on to the Internet. He immediately entered a chat room and decided to say hello to everybody. Vasya typed the word *s*. It is considered that Vasya managed to say hello if several letter... | ```python
s = "hello"
a = input()
def look():
i = 0
j = 0
while i != 5:
if j == len(a):
return False
if i == 4:
return True
elif s[i] == a[j]:
i += 1
j += 1
else:
j += 1
if look():
print("... | 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,639,582,282 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 4 | 62 | 0 | i=input()
i=int(i[:2])
if i==23:
print('00:00')
else:
if i<5:
print(f"0{i+1}:{i+1}0")
elif i<9:
print("10:01")
elif i>=15 and i<19:
print("20:02")
else:
print(f"{i+1}:{str(i+1)[::-1]}") | 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
i=input()
i=int(i[:2])
if i==23:
print('00:00')
else:
if i<5:
print(f"0{i+1}:{i+1}0")
elif i<9:
print("10:01")
elif i>=15 and i<19:
print("20:02")
else:
print(f"{i+1}:{str(i+1)[::-1]}")
``` | 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,633,347,689 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 15 | 0 | n,m=[int(x) for x in input().split()]
a=[0]*m
for i in range(n):
k=input().split()
for j in range(1,int(k[0])):
a[j]=1
if sum(a)==m:
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
n,m=[int(x) for x in input().split()]
a=[0]*m
for i in range(n):
k=input().split()
for j in range(1,int(k[0])):
a[j]=1
if sum(a)==m:
print('YES')
else:
print('NO')
``` | 0 | |
884 | D | Boxes And Balls | PROGRAMMING | 2,300 | [
"data structures",
"greedy"
] | null | null | Ivan has *n* different boxes. The first of them contains some balls of *n* different colors.
Ivan wants to play a strange game. He wants to distribute the balls into boxes in such a way that for every *i* (1<=≤<=*i*<=≤<=*n*) *i*-th box will contain all balls with color *i*.
In order to do this, Ivan will make some tu... | The first line contains one integer number *n* (1<=≤<=*n*<=≤<=200000) — the number of boxes and colors.
The second line contains *n* integer numbers *a*1, *a*2, ..., *a**n* (1<=≤<=*a**i*<=≤<=109), where *a**i* is the number of balls with color *i*. | Print one number — the minimum possible penalty of the game. | [
"3\n1 2 3\n",
"4\n2 3 4 5\n"
] | [
"6\n",
"19\n"
] | In the first example you take all the balls from the first box, choose *k* = 3 and sort all colors to corresponding boxes. Penalty is 6.
In the second example you make two turns:
1. Take all the balls from the first box, choose *k* = 3, put balls of color 3 to the third box, of color 4 — to the fourth box and the r... | 0 | [
{
"input": "3\n1 2 3",
"output": "6"
},
{
"input": "4\n2 3 4 5",
"output": "19"
},
{
"input": "6\n1 4 4 4 4 4",
"output": "38"
},
{
"input": "8\n821407370 380061316 428719552 90851747 825473738 704702117 845629927 245820158",
"output": "8176373828"
},
{
"input": "... | 1,509,122,564 | 2,147,483,647 | Python 3 | OK | TESTS | 32 | 467 | 16,486,400 | import heapq
ip = lambda: map(int,input().split())
n = ip()
l = list(ip())
if (len(l)%2==0): l.append(0)
heapq.heapify(l)
pen = 0
while len(l) > 1:
x = heapq.heappop(l)
y = heapq.heappop(l)
z = heapq.heappop(l)
pen = pen + x + y + z
heapq.heappush(l, x + y + z)
print(pen) | Title: Boxes And Balls
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Ivan has *n* different boxes. The first of them contains some balls of *n* different colors.
Ivan wants to play a strange game. He wants to distribute the balls into boxes in such a way that for every *i* (1<=≤<=*i*<=≤... | ```python
import heapq
ip = lambda: map(int,input().split())
n = ip()
l = list(ip())
if (len(l)%2==0): l.append(0)
heapq.heapify(l)
pen = 0
while len(l) > 1:
x = heapq.heappop(l)
y = heapq.heappop(l)
z = heapq.heappop(l)
pen = pen + x + y + z
heapq.heappush(l, x + y + z)
print(pen)
``` | 3 | |
834 | B | The Festive Evening | PROGRAMMING | 1,100 | [
"data structures",
"implementation"
] | null | null | It's the end of July – the time when a festive evening is held at Jelly Castle! Guests from all over the kingdom gather here to discuss new trends in the world of confectionery. Yet some of the things discussed here are not supposed to be disclosed to the general public: the information can cause discord in the kingdom... | Two integers are given in the first string: the number of guests *n* and the number of guards *k* (1<=≤<=*n*<=≤<=106, 1<=≤<=*k*<=≤<=26).
In the second string, *n* uppercase English letters *s*1*s*2... *s**n* are given, where *s**i* is the entrance used by the *i*-th guest. | Output «YES» if at least one door was unguarded during some time, and «NO» otherwise.
You can output each letter in arbitrary case (upper or lower). | [
"5 1\nAABBB\n",
"5 1\nABABB\n"
] | [
"NO\n",
"YES\n"
] | In the first sample case, the door A is opened right before the first guest's arrival and closed when the second guest enters the castle. The door B is opened right before the arrival of the third guest, and closed after the fifth one arrives. One guard can handle both doors, as the first one is closed before the secon... | 1,000 | [
{
"input": "5 1\nAABBB",
"output": "NO"
},
{
"input": "5 1\nABABB",
"output": "YES"
},
{
"input": "26 1\nABCDEFGHIJKLMNOPQRSTUVWXYZ",
"output": "NO"
},
{
"input": "27 1\nABCDEFGHIJKLMNOPQRSTUVWXYZA",
"output": "YES"
},
{
"input": "5 2\nABACA",
"output": "NO"
... | 1,568,351,039 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 4 | 108 | 0 | # -*- coding: utf-8 -*-
"""
Created on Fri Sep 13 10:27:06 2019
@author: avina
"""
n,k = map(int, input().split())
st = input()
st2 = st[::-1]
t = False
for i in range(n):
a = n - st2.index(st[i]) -1
s = len(set(st[i:a]))
if s > k:
t = True
break
if t:
print('YES')
e... | Title: The Festive Evening
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
It's the end of July – the time when a festive evening is held at Jelly Castle! Guests from all over the kingdom gather here to discuss new trends in the world of confectionery. Yet some of the things discussed here... | ```python
# -*- coding: utf-8 -*-
"""
Created on Fri Sep 13 10:27:06 2019
@author: avina
"""
n,k = map(int, input().split())
st = input()
st2 = st[::-1]
t = False
for i in range(n):
a = n - st2.index(st[i]) -1
s = len(set(st[i:a]))
if s > k:
t = True
break
if t:
print... | 0 | |
794 | B | Cutting Carrot | PROGRAMMING | 1,200 | [
"geometry",
"math"
] | null | null | Igor the analyst has adopted *n* little bunnies. As we all know, bunnies love carrots. Thus, Igor has bought a carrot to be shared between his bunnies. Igor wants to treat all the bunnies equally, and thus he wants to cut the carrot into *n* pieces of equal area.
Formally, the carrot can be viewed as an isosceles tri... | The first and only line of input contains two space-separated integers, *n* and *h* (2<=≤<=*n*<=≤<=1000, 1<=≤<=*h*<=≤<=105). | The output should contain *n*<=-<=1 real numbers *x*1,<=*x*2,<=...,<=*x**n*<=-<=1. The number *x**i* denotes that the *i*-th cut must be made *x**i* units away from the apex of the carrot. In addition, 0<=<<=*x*1<=<<=*x*2<=<<=...<=<<=*x**n*<=-<=1<=<<=*h* must hold.
Your output will be considered correc... | [
"3 2\n",
"2 100000\n"
] | [
"1.154700538379 1.632993161855\n",
"70710.678118654752\n"
] | Definition of isosceles triangle: [https://en.wikipedia.org/wiki/Isosceles_triangle](https://en.wikipedia.org/wiki/Isosceles_triangle). | 1,000 | [
{
"input": "3 2",
"output": "1.154700538379 1.632993161855"
},
{
"input": "2 100000",
"output": "70710.678118654752"
},
{
"input": "1000 100000",
"output": "3162.277660168379 4472.135954999579 5477.225575051661 6324.555320336759 7071.067811865475 7745.966692414834 8366.600265340755 8... | 1,494,673,691 | 5,591 | Python 3 | RUNTIME_ERROR | PRETESTS | 0 | 46 | 0 | n = int(input())
h = int(input())
def tarea(v):
return ((v/h)*v)/2
def area(prev_h, curr_h):
return tarea(curr_h) - tarea(prev_h)
P = h/2
Pn = P/n
prev_cut = 0
for i in range(n - 1):
lo = prev_cut
hi = h
while abs(lo - hi) > 1e-6:
mid = (hi + lo)/2
a = area(prev_cut, mid)
... | Title: Cutting Carrot
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Igor the analyst has adopted *n* little bunnies. As we all know, bunnies love carrots. Thus, Igor has bought a carrot to be shared between his bunnies. Igor wants to treat all the bunnies equally, and thus he wants to cu... | ```python
n = int(input())
h = int(input())
def tarea(v):
return ((v/h)*v)/2
def area(prev_h, curr_h):
return tarea(curr_h) - tarea(prev_h)
P = h/2
Pn = P/n
prev_cut = 0
for i in range(n - 1):
lo = prev_cut
hi = h
while abs(lo - hi) > 1e-6:
mid = (hi + lo)/2
a = area(prev_cut, mi... | -1 | |
985 | B | Switches and Lamps | PROGRAMMING | 1,200 | [
"implementation"
] | null | null | You are given *n* switches and *m* lamps. The *i*-th switch turns on some subset of the lamps. This information is given as the matrix *a* consisting of *n* rows and *m* columns where *a**i*,<=*j*<==<=1 if the *i*-th switch turns on the *j*-th lamp and *a**i*,<=*j*<==<=0 if the *i*-th switch is not connected to the *j*... | The first line of the input contains two integers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=2000) — the number of the switches and the number of the lamps.
The following *n* lines contain *m* characters each. The character *a**i*,<=*j* is equal to '1' if the *i*-th switch turns on the *j*-th lamp and '0' otherwise.
It is guar... | Print "YES" if there is a switch that if you will ignore it and press all the other *n*<=-<=1 switches then all *m* lamps will be turned on. Print "NO" if there is no such switch. | [
"4 5\n10101\n01000\n00111\n10000\n",
"4 5\n10100\n01000\n00110\n00101\n"
] | [
"YES\n",
"NO\n"
] | none | 0 | [
{
"input": "4 5\n10101\n01000\n00111\n10000",
"output": "YES"
},
{
"input": "4 5\n10100\n01000\n00110\n00101",
"output": "NO"
},
{
"input": "1 5\n11111",
"output": "NO"
},
{
"input": "10 1\n1\n0\n0\n0\n0\n0\n0\n0\n0\n1",
"output": "YES"
},
{
"input": "1 1\n1",
... | 1,529,483,325 | 2,147,483,647 | PyPy 3 | OK | TESTS | 67 | 467 | 28,876,800 | n,m=(int(i) for i in input().split())
a=[[] for i in range(n)]
s=[input() for i in range(n)]
b=[0]*m
f=[True]*n
for i in range(n):
for j in range(m):
if s[i][j]=='1':
a[i].append(j)
b[j]+=1
for i in range(n):
for j in a[i]:
if b[j]==1:
f[i]=False
... | Title: Switches and Lamps
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given *n* switches and *m* lamps. The *i*-th switch turns on some subset of the lamps. This information is given as the matrix *a* consisting of *n* rows and *m* columns where *a**i*,<=*j*<==<=1 if the *i*-th... | ```python
n,m=(int(i) for i in input().split())
a=[[] for i in range(n)]
s=[input() for i in range(n)]
b=[0]*m
f=[True]*n
for i in range(n):
for j in range(m):
if s[i][j]=='1':
a[i].append(j)
b[j]+=1
for i in range(n):
for j in a[i]:
if b[j]==1:
f... | 3 | |
839 | A | Arya and Bran | PROGRAMMING | 900 | [
"implementation"
] | null | null | Bran and his older sister Arya are from the same house. Bran like candies so much, so Arya is going to give him some Candies.
At first, Arya and Bran have 0 Candies. There are *n* days, at the *i*-th day, Arya finds *a**i* candies in a box, that is given by the Many-Faced God. Every day she can give Bran at most 8 of ... | The first line contains two integers *n* and *k* (1<=≤<=*n*<=≤<=100, 1<=≤<=*k*<=≤<=10000).
The second line contains *n* integers *a*1,<=*a*2,<=*a*3,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=100). | If it is impossible for Arya to give Bran *k* candies within *n* days, print -1.
Otherwise print a single integer — the minimum number of days Arya needs to give Bran *k* candies before the end of the *n*-th day. | [
"2 3\n1 2\n",
"3 17\n10 10 10\n",
"1 9\n10\n"
] | [
"2",
"3",
"-1"
] | In the first sample, Arya can give Bran 3 candies in 2 days.
In the second sample, Arya can give Bran 17 candies in 3 days, because she can give him at most 8 candies per day.
In the third sample, Arya can't give Bran 9 candies, because she can give him at most 8 candies per day and she must give him the candies with... | 500 | [
{
"input": "2 3\n1 2",
"output": "2"
},
{
"input": "3 17\n10 10 10",
"output": "3"
},
{
"input": "1 9\n10",
"output": "-1"
},
{
"input": "10 70\n6 5 2 3 3 2 1 4 3 2",
"output": "-1"
},
{
"input": "20 140\n40 4 81 40 10 54 34 50 84 60 16 1 90 78 38 93 99 60 81 99",... | 1,594,236,636 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 93 | 6,656,000 | n,k=map(int,input().split())
l=list(map(int,input().split()))
for i in range(n):
t=t+l[i]
k=k-min(8,t)
t=t-min(8,t)
if(k<=0):
print(i+1)
else:
print('-1')
| Title: Arya and Bran
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Bran and his older sister Arya are from the same house. Bran like candies so much, so Arya is going to give him some Candies.
At first, Arya and Bran have 0 Candies. There are *n* days, at the *i*-th day, Arya finds *a**... | ```python
n,k=map(int,input().split())
l=list(map(int,input().split()))
for i in range(n):
t=t+l[i]
k=k-min(8,t)
t=t-min(8,t)
if(k<=0):
print(i+1)
else:
print('-1')
``` | -1 | |
17 | D | Notepad | PROGRAMMING | 2,400 | [
"number theory"
] | D. Notepad | 2 | 64 | Nick is attracted by everything unconventional. He doesn't like decimal number system any more, and he decided to study other number systems. A number system with base *b* caught his attention. Before he starts studying it, he wants to write in his notepad all the numbers of length *n* without leading zeros in this num... | The only input line contains three space-separated integers *b*, *n* and *c* (2<=≤<=*b*<=<<=10106, 1<=≤<=*n*<=<<=10106, 1<=≤<=*c*<=≤<=109). You may consider that Nick has infinite patience, endless amount of paper and representations of digits as characters. The numbers doesn't contain leading zeros. | In the only line output the amount of numbers written on the same page as the last number. | [
"2 3 3\n",
"2 3 4\n"
] | [
"1",
"4"
] | In both samples there are exactly 4 numbers of length 3 in binary number system. In the first sample Nick writes 3 numbers on the first page and 1 on the second page. In the second sample all the 4 numbers can be written on the first page. | 0 | [
{
"input": "2 3 3",
"output": "1"
},
{
"input": "2 3 4",
"output": "4"
},
{
"input": "9 1 79",
"output": "8"
},
{
"input": "9 1 345",
"output": "8"
},
{
"input": "9 9 999982045",
"output": "344373768"
},
{
"input": "4 42 44",
"output": "12"
},
... | 1,596,874,539 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 6 | 216 | 6,656,000 | import math
b,n,c = [int(i) for i in input().split()]
result = math.pow(b,n)-math.pow(b,n-1)
res = int(result%c)
if res==0:
print(c)
else:
print(res) | Title: Notepad
Time Limit: 2 seconds
Memory Limit: 64 megabytes
Problem Description:
Nick is attracted by everything unconventional. He doesn't like decimal number system any more, and he decided to study other number systems. A number system with base *b* caught his attention. Before he starts studying it, he wants... | ```python
import math
b,n,c = [int(i) for i in input().split()]
result = math.pow(b,n)-math.pow(b,n-1)
res = int(result%c)
if res==0:
print(c)
else:
print(res)
``` | 0 |
236 | A | Boy or Girl | PROGRAMMING | 800 | [
"brute force",
"implementation",
"strings"
] | null | null | Those days, many boys use beautiful girls' photos as avatars in forums. So it is pretty hard to tell the gender of a user at the first glance. Last year, our hero went to a forum and had a nice chat with a beauty (he thought so). After that they talked very often and eventually they became a couple in the network.
Bu... | The first line contains a non-empty string, that contains only lowercase English letters — the user name. This string contains at most 100 letters. | If it is a female by our hero's method, print "CHAT WITH HER!" (without the quotes), otherwise, print "IGNORE HIM!" (without the quotes). | [
"wjmzbmr\n",
"xiaodao\n",
"sevenkplus\n"
] | [
"CHAT WITH HER!\n",
"IGNORE HIM!\n",
"CHAT WITH HER!\n"
] | For the first example. There are 6 distinct characters in "wjmzbmr". These characters are: "w", "j", "m", "z", "b", "r". So wjmzbmr is a female and you should print "CHAT WITH HER!". | 500 | [
{
"input": "wjmzbmr",
"output": "CHAT WITH HER!"
},
{
"input": "xiaodao",
"output": "IGNORE HIM!"
},
{
"input": "sevenkplus",
"output": "CHAT WITH HER!"
},
{
"input": "pezu",
"output": "CHAT WITH HER!"
},
{
"input": "wnemlgppy",
"output": "CHAT WITH HER!"
},... | 1,694,763,754 | 2,147,483,647 | PyPy 3-64 | RUNTIME_ERROR | TESTS | 0 | 186 | 3,379,200 | username = input()
seen = set()
result = ''
for c in username:
if seen.count(c) == 0:
seen.append(c)
result.append(c)
print("CHAT WITH HER!" if len(result) % 2 == 0 else "IGNORE HIM!")
| Title: Boy or Girl
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Those days, many boys use beautiful girls' photos as avatars in forums. So it is pretty hard to tell the gender of a user at the first glance. Last year, our hero went to a forum and had a nice chat with a beauty (he though... | ```python
username = input()
seen = set()
result = ''
for c in username:
if seen.count(c) == 0:
seen.append(c)
result.append(c)
print("CHAT WITH HER!" if len(result) % 2 == 0 else "IGNORE HIM!")
``` | -1 | |
859 | B | Lazy Security Guard | PROGRAMMING | 1,000 | [
"brute force",
"geometry",
"math"
] | null | null | Your security guard friend recently got a new job at a new security company. The company requires him to patrol an area of the city encompassing exactly *N* city blocks, but they let him choose which blocks. That is, your friend must walk the perimeter of a region whose area is exactly *N* blocks. Your friend is quite ... | Input will consist of a single integer *N* (1<=≤<=*N*<=≤<=106), the number of city blocks that must be enclosed by the route. | Print the minimum perimeter that can be achieved. | [
"4\n",
"11\n",
"22\n"
] | [
"8\n",
"14\n",
"20\n"
] | Here are some possible shapes for the examples:
<img class="tex-graphics" src="https://espresso.codeforces.com/e11bef2cf82b55dd583cfc97d12b5aee5e483a65.png" style="max-width: 100.0%;max-height: 100.0%;"/> | 750 | [
{
"input": "4",
"output": "8"
},
{
"input": "11",
"output": "14"
},
{
"input": "22",
"output": "20"
},
{
"input": "3",
"output": "8"
},
{
"input": "1024",
"output": "128"
},
{
"input": "101",
"output": "42"
},
{
"input": "30",
"output":... | 1,505,590,331 | 7,031 | Python 3 | OK | TESTS | 35 | 62 | 0 | import math
x = int(input().strip())
root = int(round(math.sqrt(x)))
rem = x - root * root
perim = root * 4
s1, s2 = root, rem - root
if (rem < root):
s1 = rem
s2 = 0
if s1 > 0:
perim += 2
if s2 > 0:
perim += 2
print(perim) | Title: Lazy Security Guard
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Your security guard friend recently got a new job at a new security company. The company requires him to patrol an area of the city encompassing exactly *N* city blocks, but they let him choose which blocks. That is... | ```python
import math
x = int(input().strip())
root = int(round(math.sqrt(x)))
rem = x - root * root
perim = root * 4
s1, s2 = root, rem - root
if (rem < root):
s1 = rem
s2 = 0
if s1 > 0:
perim += 2
if s2 > 0:
perim += 2
print(perim)
``` | 3 | |
719 | A | Vitya in the Countryside | PROGRAMMING | 1,100 | [
"implementation"
] | null | null | Every summer Vitya comes to visit his grandmother in the countryside. This summer, he got a huge wart. Every grandma knows that one should treat warts when the moon goes down. Thus, Vitya has to catch the moment when the moon is down.
Moon cycle lasts 30 days. The size of the visible part of the moon (in Vitya's units... | The first line of the input contains a single integer *n* (1<=≤<=*n*<=≤<=92) — the number of consecutive days Vitya was watching the size of the visible part of the moon.
The second line contains *n* integers *a**i* (0<=≤<=*a**i*<=≤<=15) — Vitya's records.
It's guaranteed that the input data is consistent. | If Vitya can be sure that the size of visible part of the moon on day *n*<=+<=1 will be less than the size of the visible part on day *n*, then print "DOWN" at the only line of the output. If he might be sure that the size of the visible part will increase, then print "UP". If it's impossible to determine what exactly ... | [
"5\n3 4 5 6 7\n",
"7\n12 13 14 15 14 13 12\n",
"1\n8\n"
] | [
"UP\n",
"DOWN\n",
"-1\n"
] | In the first sample, the size of the moon on the next day will be equal to 8, thus the answer is "UP".
In the second sample, the size of the moon on the next day will be 11, thus the answer is "DOWN".
In the third sample, there is no way to determine whether the size of the moon on the next day will be 7 or 9, thus t... | 500 | [
{
"input": "5\n3 4 5 6 7",
"output": "UP"
},
{
"input": "7\n12 13 14 15 14 13 12",
"output": "DOWN"
},
{
"input": "1\n8",
"output": "-1"
},
{
"input": "44\n7 8 9 10 11 12 13 14 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 14 13 12 11 10",
"out... | 1,614,935,374 | 2,147,483,647 | Python 3 | COMPILATION_ERROR | TESTS | 0 | 0 | 0 | t = int(input())
a = list(map(int, input().split()))
if len(a) == 1:
if a[0] == 0:
print('UP')
elif a[0] == 15:
print('DOWN')
else:
print(-1)
quit()
last = a[-1]
prev = a[-2]
if last == 0 or (last > prev and last != 15):
print('UP')
else
print('DOWN')... | Title: Vitya in the Countryside
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Every summer Vitya comes to visit his grandmother in the countryside. This summer, he got a huge wart. Every grandma knows that one should treat warts when the moon goes down. Thus, Vitya has to catch the momen... | ```python
t = int(input())
a = list(map(int, input().split()))
if len(a) == 1:
if a[0] == 0:
print('UP')
elif a[0] == 15:
print('DOWN')
else:
print(-1)
quit()
last = a[-1]
prev = a[-2]
if last == 0 or (last > prev and last != 15):
print('UP')
else
pri... | -1 | |
996 | A | Hit the Lottery | PROGRAMMING | 800 | [
"dp",
"greedy"
] | null | null | Allen has a LOT of money. He has $n$ dollars in the bank. For security reasons, he wants to withdraw it in cash (we will not disclose the reasons here). The denominations for dollar bills are $1$, $5$, $10$, $20$, $100$. What is the minimum number of bills Allen could receive after withdrawing his entire balance? | The first and only line of input contains a single integer $n$ ($1 \le n \le 10^9$). | Output the minimum number of bills that Allen could receive. | [
"125\n",
"43\n",
"1000000000\n"
] | [
"3\n",
"5\n",
"10000000\n"
] | In the first sample case, Allen can withdraw this with a $100$ dollar bill, a $20$ dollar bill, and a $5$ dollar bill. There is no way for Allen to receive $125$ dollars in one or two bills.
In the second sample case, Allen can withdraw two $20$ dollar bills and three $1$ dollar bills.
In the third sample case, Allen... | 500 | [
{
"input": "125",
"output": "3"
},
{
"input": "43",
"output": "5"
},
{
"input": "1000000000",
"output": "10000000"
},
{
"input": "4",
"output": "4"
},
{
"input": "5",
"output": "1"
},
{
"input": "1",
"output": "1"
},
{
"input": "74",
"o... | 1,694,832,939 | 2,147,483,647 | Python 3 | OK | TESTS | 49 | 46 | 0 | n = int(input())
count = 0
denominations = [100, 20, 10, 5, 1]
for denomination in denominations:
count += n // denomination # Calculate the number of bills of this denomination
n %= denomination # Update the remaining amount after using the bills
print(count)
| Title: Hit the Lottery
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Allen has a LOT of money. He has $n$ dollars in the bank. For security reasons, he wants to withdraw it in cash (we will not disclose the reasons here). The denominations for dollar bills are $1$, $5$, $10$, $20$, $100$... | ```python
n = int(input())
count = 0
denominations = [100, 20, 10, 5, 1]
for denomination in denominations:
count += n // denomination # Calculate the number of bills of this denomination
n %= denomination # Update the remaining amount after using the bills
print(count)
``` | 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,655,632,758 | 2,147,483,647 | PyPy 3 | OK | TESTS | 32 | 154 | 0 | t=int(input())
L=[int(i) for i in input().split()]
D={}
first1=-1
first2=-1
for i in range(len(L)):
if L[i]%2==0:
if first2==-1:
first2=i
else:
if first1==-1:
first1=i
c=0
for i in range(3):
if(L[i]%2==0):
c+=1;
if c>=2:
print(first1+1)
e... | 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
t=int(input())
L=[int(i) for i in input().split()]
D={}
first1=-1
first2=-1
for i in range(len(L)):
if L[i]%2==0:
if first2==-1:
first2=i
else:
if first1==-1:
first1=i
c=0
for i in range(3):
if(L[i]%2==0):
c+=1;
if c>=2:
print(fi... | 3.9615 |
514 | B | Han Solo and Lazer Gun | PROGRAMMING | 1,400 | [
"brute force",
"data structures",
"geometry",
"implementation",
"math"
] | null | null | There are *n* Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (*x*,<=*y*) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (*x*0,<=*y*0). In one shot... | The first line contains three integers *n*, *x*0 и *y*0 (1<=≤<=*n*<=≤<=1000, <=-<=104<=≤<=*x*0,<=*y*0<=≤<=104) — the number of stormtroopers on the battle field and the coordinates of your gun.
Next *n* lines contain two integers each *x**i*, *y**i* (<=-<=104<=≤<=*x**i*,<=*y**i*<=≤<=104) — the coordinates of the storm... | Print a single integer — the minimum number of shots Han Solo needs to destroy all the stormtroopers. | [
"4 0 0\n1 1\n2 2\n2 0\n-1 -1\n",
"2 1 2\n1 1\n1 0\n"
] | [
"2\n",
"1\n"
] | Explanation to the first and second samples from the statement, respectively: | 1,000 | [
{
"input": "4 0 0\n1 1\n2 2\n2 0\n-1 -1",
"output": "2"
},
{
"input": "2 1 2\n1 1\n1 0",
"output": "1"
},
{
"input": "1 1 1\n0 0",
"output": "1"
},
{
"input": "2 0 0\n10000 -10000\n-10000 10000",
"output": "1"
},
{
"input": "2 0 0\n10000 -10000\n10000 10000",
... | 1,675,098,517 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 29 | 108 | 5,529,600 | def online(x,a,p):
if x[0]*(a[1]-p[1])+x[1]*(p[0]-a[0])+a[0]*p[1]-a[1]*p[0]==0:
return True
return False
n,x,y=map(int,input().split())
c=1
l=[x,y]
lines=[list(map(int,input().split()))]
for _ in range(n-1):
nl=list(map(int,input().split()))
chk=True
for i in lines:
if on... | Title: Han Solo and Lazer Gun
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
There are *n* Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (*x*,<=*y*) on this plane.
Han Solo has the ... | ```python
def online(x,a,p):
if x[0]*(a[1]-p[1])+x[1]*(p[0]-a[0])+a[0]*p[1]-a[1]*p[0]==0:
return True
return False
n,x,y=map(int,input().split())
c=1
l=[x,y]
lines=[list(map(int,input().split()))]
for _ in range(n-1):
nl=list(map(int,input().split()))
chk=True
for i in lines:
... | 3 |
Subsets and Splits
Successful Python Submissions
Retrieves all records from the train dataset where the verdict is 'OK', providing basic filtering but limited analytical value.
SQL Console for MatrixStudio/Codeforces-Python-Submissions
Retrieves records of users with a rating of 1600 or higher and a verdict of 'OK', providing basic filtering but limited analytical value.
SQL Console for MatrixStudio/Codeforces-Python-Submissions
Counts the number of entries with a rating above 2000 and a verdict of 'OK', providing basic filtering but limited analytical value.
SQL Console for MatrixStudio/Codeforces-Python-Submissions
Counts the number of entries with a 'OK' verdict, providing a basic overview of a specific category within the dataset.