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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
483 | A | Counterexample | PROGRAMMING | 1,100 | [
"brute force",
"implementation",
"math",
"number theory"
] | null | null | Your friend has recently learned about coprime numbers. A pair of numbers {*a*,<=*b*} is called coprime if the maximum number that divides both *a* and *b* is equal to one.
Your friend often comes up with different statements. He has recently supposed that if the pair (*a*,<=*b*) is coprime and the pair (*b*,<=*c*) i... | The single line contains two positive space-separated integers *l*, *r* (1<=≤<=*l*<=≤<=*r*<=≤<=1018; *r*<=-<=*l*<=≤<=50). | Print three positive space-separated integers *a*, *b*, *c* — three distinct numbers (*a*,<=*b*,<=*c*) that form the counterexample. If there are several solutions, you are allowed to print any of them. The numbers must be printed in ascending order.
If the counterexample does not exist, print the single number -1. | [
"2 4\n",
"10 11\n",
"900000000000000009 900000000000000029\n"
] | [
"2 3 4\n",
"-1\n",
"900000000000000009 900000000000000010 900000000000000021\n"
] | In the first sample pair (2, 4) is not coprime and pairs (2, 3) and (3, 4) are.
In the second sample you cannot form a group of three distinct integers, so the answer is -1.
In the third sample it is easy to see that numbers 900000000000000009 and 900000000000000021 are divisible by three. | 500 | [
{
"input": "2 4",
"output": "2 3 4"
},
{
"input": "10 11",
"output": "-1"
},
{
"input": "900000000000000009 900000000000000029",
"output": "900000000000000009 900000000000000010 900000000000000021"
},
{
"input": "640097987171091791 640097987171091835",
"output": "64009798... | 1,595,851,777 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 109 | 6,656,000 | import sys
import math
input = sys.stdin.readline
l, r = map(int, input().strip().split())
for i in range(l, r + 1):
for j in range(i + 1, r + 1):
if math.gcd(i, j) != 1:
print(i, i + 1, j)
exit(0)
print(-1)
| Title: Counterexample
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Your friend has recently learned about coprime numbers. A pair of numbers {*a*,<=*b*} is called coprime if the maximum number that divides both *a* and *b* is equal to one.
Your friend often comes up with different st... | ```python
import sys
import math
input = sys.stdin.readline
l, r = map(int, input().strip().split())
for i in range(l, r + 1):
for j in range(i + 1, r + 1):
if math.gcd(i, j) != 1:
print(i, i + 1, j)
exit(0)
print(-1)
``` | 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,672,305,272 | 2,147,483,647 | Python 3 | OK | TESTS | 20 | 46 | 0 | from math import ceil
p,q,a=map(int,input().split())
M=ceil(p/a)
N=ceil(q/a)
print(int(M*N)) | 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
from math import ceil
p,q,a=map(int,input().split())
M=ceil(p/a)
N=ceil(q/a)
print(int(M*N))
``` | 3.977 |
711 | A | Bus to Udayland | PROGRAMMING | 800 | [
"brute force",
"implementation"
] | null | null | ZS the Coder and Chris the Baboon are travelling to Udayland! To get there, they have to get on the special IOI bus. The IOI bus has *n* rows of seats. There are 4 seats in each row, and the seats are separated into pairs by a walkway. When ZS and Chris came, some places in the bus was already occupied.
ZS and Chris a... | The first line of the input contains a single integer *n* (1<=≤<=*n*<=≤<=1000) — the number of rows of seats in the bus.
Then, *n* lines follow. Each line contains exactly 5 characters, the first two of them denote the first pair of seats in the row, the third character denotes the walkway (it always equals '|') and t... | If it is possible for Chris and ZS to sit at neighbouring empty seats, print "YES" (without quotes) in the first line. In the next *n* lines print the bus configuration, where the characters in the pair of seats for Chris and ZS is changed with characters '+'. Thus the configuration should differ from the input one by ... | [
"6\nOO|OX\nXO|XX\nOX|OO\nXX|OX\nOO|OO\nOO|XX\n",
"4\nXO|OX\nXO|XX\nOX|OX\nXX|OX\n",
"5\nXX|XX\nXX|XX\nXO|OX\nXO|OO\nOX|XO\n"
] | [
"YES\n++|OX\nXO|XX\nOX|OO\nXX|OX\nOO|OO\nOO|XX\n",
"NO\n",
"YES\nXX|XX\nXX|XX\nXO|OX\nXO|++\nOX|XO\n"
] | Note that the following is an incorrect configuration for the first sample case because the seats must be in the same pair.
O+|+X
XO|XX
OX|OO
XX|OX
OO|OO
OO|XX | 500 | [
{
"input": "6\nOO|OX\nXO|XX\nOX|OO\nXX|OX\nOO|OO\nOO|XX",
"output": "YES\n++|OX\nXO|XX\nOX|OO\nXX|OX\nOO|OO\nOO|XX"
},
{
"input": "4\nXO|OX\nXO|XX\nOX|OX\nXX|OX",
"output": "NO"
},
{
"input": "5\nXX|XX\nXX|XX\nXO|OX\nXO|OO\nOX|XO",
"output": "YES\nXX|XX\nXX|XX\nXO|OX\nXO|++\nOX|XO"
... | 1,646,275,581 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 31 | 0 | n = int(input())
lista = []
flag = 0
for i in range (n):
s = input()
if s[0] == 'O'and s[1] == 'O' and flag == 0:
s = s.replace('OO', '++')
flag = 1
if s[3] == 'O'and s[4] == 'O' and flag == 0:
s = s.replace('OO', '++')
flag = 1
lista.appe... | Title: Bus to Udayland
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
ZS the Coder and Chris the Baboon are travelling to Udayland! To get there, they have to get on the special IOI bus. The IOI bus has *n* rows of seats. There are 4 seats in each row, and the seats are separated into pai... | ```python
n = int(input())
lista = []
flag = 0
for i in range (n):
s = input()
if s[0] == 'O'and s[1] == 'O' and flag == 0:
s = s.replace('OO', '++')
flag = 1
if s[3] == 'O'and s[4] == 'O' and flag == 0:
s = s.replace('OO', '++')
flag = 1
... | 0 | |
588 | A | Duff and Meat | PROGRAMMING | 900 | [
"greedy"
] | null | null | Duff is addicted to meat! Malek wants to keep her happy for *n* days. In order to be happy in *i*-th day, she needs to eat exactly *a**i* kilograms of meat.
There is a big shop uptown and Malek wants to buy meat for her from there. In *i*-th day, they sell meat for *p**i* dollars per kilogram. Malek knows all numbers ... | The first line of input contains integer *n* (1<=≤<=*n*<=≤<=105), the number of days.
In the next *n* lines, *i*-th line contains two integers *a**i* and *p**i* (1<=≤<=*a**i*,<=*p**i*<=≤<=100), the amount of meat Duff needs and the cost of meat in that day. | Print the minimum money needed to keep Duff happy for *n* days, in one line. | [
"3\n1 3\n2 2\n3 1\n",
"3\n1 3\n2 1\n3 2\n"
] | [
"10\n",
"8\n"
] | In the first sample case: An optimal way would be to buy 1 kg on the first day, 2 kg on the second day and 3 kg on the third day.
In the second sample case: An optimal way would be to buy 1 kg on the first day and 5 kg (needed meat for the second and third day) on the second day. | 750 | [
{
"input": "3\n1 3\n2 2\n3 1",
"output": "10"
},
{
"input": "3\n1 3\n2 1\n3 2",
"output": "8"
},
{
"input": "1\n39 52",
"output": "2028"
},
{
"input": "2\n25 56\n94 17",
"output": "2998"
},
{
"input": "5\n39 21\n95 89\n73 90\n9 55\n85 32",
"output": "6321"
}... | 1,594,541,579 | 2,147,483,647 | Python 3 | OK | TESTS | 30 | 420 | 7,782,400 | n = int(input())
k = [0] * 2 * n
j = 0
for i in range(n):
a, p = map(int, input().split())
k[j], k[j + 1] = a, p
j += 2
z = 0
s = k[1]
for i in range(0, len(k), 2):
s = min(k[i + 1], s)
if s < k[i + 1]:
z += k[i] * s
else:
z += k[i] * k[i + 1]
print(z) | Title: Duff and Meat
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Duff is addicted to meat! Malek wants to keep her happy for *n* days. In order to be happy in *i*-th day, she needs to eat exactly *a**i* kilograms of meat.
There is a big shop uptown and Malek wants to buy meat for her ... | ```python
n = int(input())
k = [0] * 2 * n
j = 0
for i in range(n):
a, p = map(int, input().split())
k[j], k[j + 1] = a, p
j += 2
z = 0
s = k[1]
for i in range(0, len(k), 2):
s = min(k[i + 1], s)
if s < k[i + 1]:
z += k[i] * s
else:
z += k[i] * k[i + 1]
print(z)
``... | 3 | |
818 | G | Four Melodies | PROGRAMMING | 2,600 | [
"flows",
"graphs"
] | null | null | Author note: I think some of you might remember the problem "Two Melodies" from Eductational Codeforces Round 22. Now it's time to make it a bit more difficult!
Alice is a composer, and recently she had recorded two tracks that became very popular. Now she has got a lot of fans who are waiting for new tracks.
This t... | The first line contains one integer number *n* (4<=≤<=*n*<=≤<=3000).
The second line contains *n* integer numbers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=105) — notes written on a sheet. | Print maximum sum of lengths of such four non-empty non-intersecting subsequences that all of them form a melody. | [
"5\n1 3 5 7 9\n",
"5\n1 3 5 7 2\n"
] | [
"4\n",
"5\n"
] | In the first example it is possible to compose 4 melodies by choosing any 4 notes (and each melody will consist of only one note).
In the second example it is possible to compose one melody with 2 notes — {1, 2}. Remaining notes are used in other three melodies (one note per each melody). | 0 | [
{
"input": "5\n1 3 5 7 9",
"output": "4"
},
{
"input": "5\n1 3 5 7 2",
"output": "5"
},
{
"input": "4\n1 3 5 7",
"output": "4"
},
{
"input": "4\n1 1 1 1",
"output": "4"
},
{
"input": "4\n1 1 2 1",
"output": "4"
},
{
"input": "4\n3 2 3 1",
"output":... | 1,689,369,141 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 0 | 31 | 0 | print("_RANDOM_GUESS_1689369141.109539")# 1689369141.1095538 | Title: Four Melodies
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Author note: I think some of you might remember the problem "Two Melodies" from Eductational Codeforces Round 22. Now it's time to make it a bit more difficult!
Alice is a composer, and recently she had recorded two trac... | ```python
print("_RANDOM_GUESS_1689369141.109539")# 1689369141.1095538
``` | 0 | |
372 | A | Counting Kangaroos is Fun | PROGRAMMING | 1,600 | [
"binary search",
"greedy",
"sortings",
"two pointers"
] | null | null | There are *n* kangaroos with pockets. Each kangaroo has a size (integer number). A kangaroo can go into another kangaroo's pocket if and only if the size of kangaroo who hold the kangaroo is at least twice as large as the size of kangaroo who is held.
Each kangaroo can hold at most one kangaroo, and the kangaroo who i... | The first line contains a single integer — *n* (1<=≤<=*n*<=≤<=5·105). Each of the next *n* lines contains an integer *s**i* — the size of the *i*-th kangaroo (1<=≤<=*s**i*<=≤<=105). | Output a single integer — the optimal number of visible kangaroos. | [
"8\n2\n5\n7\n6\n9\n8\n4\n2\n",
"8\n9\n1\n6\n2\n6\n5\n8\n3\n"
] | [
"5\n",
"5\n"
] | none | 500 | [
{
"input": "8\n2\n5\n7\n6\n9\n8\n4\n2",
"output": "5"
},
{
"input": "8\n9\n1\n6\n2\n6\n5\n8\n3",
"output": "5"
},
{
"input": "12\n3\n99\n24\n46\n75\n63\n57\n55\n10\n62\n34\n52",
"output": "7"
},
{
"input": "12\n55\n75\n1\n98\n63\n64\n9\n39\n82\n18\n47\n9",
"output": "6"
... | 1,606,317,275 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 5 | 155 | 0 | n = int(input())
l = []
for _ in range(n):
l.append(int(input()))
l.sort()
i,j = 0,1
cnt = 0
while j<n:
while j<n and l[j]<2*l[i]:
j+=1
if j<n and l[j]>= 2*l[i]:
cnt+=1
i+=1
print(n-cnt)
| Title: Counting Kangaroos is Fun
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
There are *n* kangaroos with pockets. Each kangaroo has a size (integer number). A kangaroo can go into another kangaroo's pocket if and only if the size of kangaroo who hold the kangaroo is at least twice as ... | ```python
n = int(input())
l = []
for _ in range(n):
l.append(int(input()))
l.sort()
i,j = 0,1
cnt = 0
while j<n:
while j<n and l[j]<2*l[i]:
j+=1
if j<n and l[j]>= 2*l[i]:
cnt+=1
i+=1
print(n-cnt)
``` | 0 | |
507 | A | Amr and Music | PROGRAMMING | 1,000 | [
"greedy",
"implementation",
"sortings"
] | null | null | Amr is a young coder who likes music a lot. He always wanted to learn how to play music but he was busy coding so he got an idea.
Amr has *n* instruments, it takes *a**i* days to learn *i*-th instrument. Being busy, Amr dedicated *k* days to learn how to play the maximum possible number of instruments.
Amr asked for ... | The first line contains two numbers *n*, *k* (1<=≤<=*n*<=≤<=100, 0<=≤<=*k*<=≤<=10<=000), the number of instruments and number of days respectively.
The second line contains *n* integers *a**i* (1<=≤<=*a**i*<=≤<=100), representing number of days required to learn the *i*-th instrument. | In the first line output one integer *m* representing the maximum number of instruments Amr can learn.
In the second line output *m* space-separated integers: the indices of instruments to be learnt. You may output indices in any order.
if there are multiple optimal solutions output any. It is not necessary to use al... | [
"4 10\n4 3 1 2\n",
"5 6\n4 3 1 1 2\n",
"1 3\n4\n"
] | [
"4\n1 2 3 4",
"3\n1 3 4",
"0\n"
] | In the first test Amr can learn all 4 instruments.
In the second test other possible solutions are: {2, 3, 5} or {3, 4, 5}.
In the third test Amr doesn't have enough time to learn the only presented instrument. | 500 | [
{
"input": "4 10\n4 3 1 2",
"output": "4\n1 2 3 4"
},
{
"input": "5 6\n4 3 1 1 2",
"output": "3\n3 4 5"
},
{
"input": "1 3\n4",
"output": "0"
},
{
"input": "2 100\n100 100",
"output": "1\n1"
},
{
"input": "3 150\n50 50 50",
"output": "3\n1 2 3"
},
{
"i... | 1,587,813,862 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 0 | 108 | 0 | n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
tot=a[0]
i=1
ins=0
b=[]
while tot<=k and i<n:
tot+=a[i]
b.append(a[i])
ins+=1
i+=1
if ins ==0:
print(0)
else:
print(ins)
print(*b) | Title: Amr and Music
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Amr is a young coder who likes music a lot. He always wanted to learn how to play music but he was busy coding so he got an idea.
Amr has *n* instruments, it takes *a**i* days to learn *i*-th instrument. Being busy, Amr ... | ```python
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
tot=a[0]
i=1
ins=0
b=[]
while tot<=k and i<n:
tot+=a[i]
b.append(a[i])
ins+=1
i+=1
if ins ==0:
print(0)
else:
print(ins)
print(*b)
``` | 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,592,637,113 | 2,147,483,647 | Python 3 | OK | TESTS | 34 | 109 | 307,200 | def answer():
n1=[int(x) for x in input().split()]
n = n1[0]
d = n1[1]
dis=0
while n:
a = input().split()
a[1]=int(a[1])
if a[0]=="+":
d+=a[1]
else:
if d-a[1]<0:
dis+=1
else:
d... | 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
def answer():
n1=[int(x) for x in input().split()]
n = n1[0]
d = n1[1]
dis=0
while n:
a = input().split()
a[1]=int(a[1])
if a[0]=="+":
d+=a[1]
else:
if d-a[1]<0:
dis+=1
else:
... | 3 | |
617 | A | Elephant | PROGRAMMING | 800 | [
"math"
] | null | null | An elephant decided to visit his friend. It turned out that the elephant's house is located at point 0 and his friend's house is located at point *x*(*x*<=><=0) of the coordinate line. In one step the elephant can move 1, 2, 3, 4 or 5 positions forward. Determine, what is the minimum number of steps he need to make ... | The first line of the input contains an integer *x* (1<=≤<=*x*<=≤<=1<=000<=000) — The coordinate of the friend's house. | Print the minimum number of steps that elephant needs to make to get from point 0 to point *x*. | [
"5\n",
"12\n"
] | [
"1\n",
"3\n"
] | In the first sample the elephant needs to make one step of length 5 to reach the point *x*.
In the second sample the elephant can get to point *x* if he moves by 3, 5 and 4. There are other ways to get the optimal answer but the elephant cannot reach *x* in less than three moves. | 500 | [
{
"input": "5",
"output": "1"
},
{
"input": "12",
"output": "3"
},
{
"input": "999999",
"output": "200000"
},
{
"input": "41",
"output": "9"
},
{
"input": "1000000",
"output": "200000"
},
{
"input": "1",
"output": "1"
},
{
"input": "2",
... | 1,696,168,385 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 0 | 30 | 0 | x = int(input())
steps = 0
while x != 1:
if x % 5 == 0:
steps += (x / 5)
x = x / 5
elif x % 4 == 0:
steps += (x / 4)
x = x / 4
elif x % 3 == 0:
steps += (x / 3)
x = x / 3
elif x % 2 == 0:
steps += (... | Title: Elephant
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
An elephant decided to visit his friend. It turned out that the elephant's house is located at point 0 and his friend's house is located at point *x*(*x*<=><=0) of the coordinate line. In one step the elephant can move 1, 2... | ```python
x = int(input())
steps = 0
while x != 1:
if x % 5 == 0:
steps += (x / 5)
x = x / 5
elif x % 4 == 0:
steps += (x / 4)
x = x / 4
elif x % 3 == 0:
steps += (x / 3)
x = x / 3
elif x % 2 == 0:
... | 0 | |
223 | A | Bracket Sequence | PROGRAMMING | 1,700 | [
"data structures",
"expression parsing",
"implementation"
] | null | null | A bracket sequence is a string, containing only characters "(", ")", "[" and "]".
A correct bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters "1" and "+" between the original characters of the sequence. For example, bracket sequences "()[]", "([... | The first and the only line contains the bracket sequence as a string, consisting only of characters "(", ")", "[" and "]". It is guaranteed that the string is non-empty and its length doesn't exceed 105 characters. | In the first line print a single integer — the number of brackets «[» in the required bracket sequence. In the second line print the optimal sequence. If there are more than one optimal solutions print any of them. | [
"([])\n",
"(((\n"
] | [
"1\n([])\n",
"0\n\n"
] | none | 500 | [
{
"input": "([])",
"output": "1\n([])"
},
{
"input": "(((",
"output": "0"
},
{
"input": "(][)",
"output": "0"
},
{
"input": "(()[))()[]",
"output": "1\n()[]"
},
{
"input": "(][](](][[(][",
"output": "1\n[]"
},
{
"input": "((])(]]))(](((()[[()[[[)([]()]... | 1,622,629,602 | 2,147,483,647 | PyPy 3 | COMPILATION_ERROR | TESTS | 0 | 0 | 0 | class Element():
def __init__(self,val):
self.val=val
self.next=None
self.prev=None
class Stack():
def __init__(self):
self.last=None
def push(self,val):
new_ele = Element(val)
if self.last is None: self.last=new_ele
else:
self.... | Title: Bracket Sequence
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
A bracket sequence is a string, containing only characters "(", ")", "[" and "]".
A correct bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters "... | ```python
class Element():
def __init__(self,val):
self.val=val
self.next=None
self.prev=None
class Stack():
def __init__(self):
self.last=None
def push(self,val):
new_ele = Element(val)
if self.last is None: self.last=new_ele
else:
... | -1 | |
66 | D | Petya and His Friends | PROGRAMMING | 1,700 | [
"constructive algorithms",
"math",
"number theory"
] | D. Petya and His Friends | 2 | 256 | Little Petya has a birthday soon. Due this wonderful event, Petya's friends decided to give him sweets. The total number of Petya's friends equals to *n*.
Let us remind you the definition of the greatest common divisor: *GCD*(*a*1,<=...,<=*a**k*)<==<=*d*, where *d* represents such a maximal positive number that each *... | The first line contains an integer *n* (2<=≤<=*n*<=≤<=50). | If there is no answer, print "-1" without quotes. Otherwise print a set of *n* distinct positive numbers *a*1,<=*a*2,<=...,<=*a**n*. Each line must contain one number. Each number must consist of not more than 100 digits, and must not contain any leading zeros. If there are several solutions to that problem, print any ... | [
"3\n",
"4\n"
] | [
"99\n55\n11115\n",
"385\n360\n792\n8360\n"
] | none | 2,000 | [
{
"input": "3",
"output": "15\n10\n6"
},
{
"input": "4",
"output": "105\n70\n42\n30"
},
{
"input": "5",
"output": "1155\n770\n462\n330\n210"
},
{
"input": "6",
"output": "15015\n10010\n6006\n4290\n2730\n2310"
},
{
"input": "7",
"output": "255255\n170170\n10210... | 1,693,218,512 | 2,147,483,647 | PyPy 3 | OK | TESTS | 49 | 186 | 1,228,800 |
primes = []
def is_prime(x):
f = 2
while f*f <= x:
if x % f == 0:
return False
f += 1
return True
for i in range(2, 250 + 1):
if is_prime(i):
primes.append(i)
n = int(input())
if n == 2:
print(-1)
elif n == 3:
print(3*5)
print(7*5)
... | Title: Petya and His Friends
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Little Petya has a birthday soon. Due this wonderful event, Petya's friends decided to give him sweets. The total number of Petya's friends equals to *n*.
Let us remind you the definition of the greatest common divis... | ```python
primes = []
def is_prime(x):
f = 2
while f*f <= x:
if x % f == 0:
return False
f += 1
return True
for i in range(2, 250 + 1):
if is_prime(i):
primes.append(i)
n = int(input())
if n == 2:
print(-1)
elif n == 3:
print(3*5)
p... | 3.951211 |
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,529,537,227 | 2,147,483,647 | PyPy 3 | OK | TESTS | 40 | 108 | 0 | from sys import stdin
lines, line_index = stdin.readlines(), -1
def get_line():
global lines, line_index
line_index += 1
return lines[line_index]
def main():
s = get_line().strip()
pattern = 'hello'
i, c = 0, 0
while i < len(s) and c < len(pattern):
if s[i] == pattern[c]:
c += 1
i += 1... | 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
from sys import stdin
lines, line_index = stdin.readlines(), -1
def get_line():
global lines, line_index
line_index += 1
return lines[line_index]
def main():
s = get_line().strip()
pattern = 'hello'
i, c = 0, 0
while i < len(s) and c < len(pattern):
if s[i] == pattern[c]:
c += 1
... | 3.946 |
399 | B | Red and Blue Balls | PROGRAMMING | 0 | [] | null | null | User ainta has a stack of *n* red and blue balls. He can apply a certain operation which changes the colors of the balls inside the stack.
- While the top ball inside the stack is red, pop the ball from the top of the stack. - Then replace the blue ball on the top with a red ball. - And finally push some blue balls... | The first line contains an integer *n* (1<=≤<=*n*<=≤<=50) — the number of balls inside the stack.
The second line contains a string *s* (|*s*|<==<=*n*) describing the initial state of the stack. The *i*-th character of the string *s* denotes the color of the *i*-th ball (we'll number the balls from top to bottom of th... | Print the maximum number of operations ainta can repeatedly apply.
Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. | [
"3\nRBR\n",
"4\nRBBR\n",
"5\nRBBRR\n"
] | [
"2\n",
"6\n",
"6\n"
] | The first example is depicted below.
The explanation how user ainta applies the first operation. He pops out one red ball, changes the color of the ball in the middle from blue to red, and pushes one blue ball.
The explanation how user ainta applies the second operation. He will not pop out red balls, he simply chang... | 1,000 | [
{
"input": "3\nRBR",
"output": "2"
},
{
"input": "4\nRBBR",
"output": "6"
},
{
"input": "5\nRBBRR",
"output": "6"
},
{
"input": "5\nRBRBR",
"output": "10"
},
{
"input": "10\nRRBRRBBRRR",
"output": "100"
},
{
"input": "10\nBRBRRRRRRR",
"output": "5"... | 1,556,337,048 | 2,147,483,647 | Python 3 | OK | TESTS | 34 | 109 | 0 | n, s = int(input()), input()
print(sum(2 ** i for i in range(n) if s[i] == 'B')) | Title: Red and Blue Balls
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
User ainta has a stack of *n* red and blue balls. He can apply a certain operation which changes the colors of the balls inside the stack.
- While the top ball inside the stack is red, pop the ball from the top of ... | ```python
n, s = int(input()), input()
print(sum(2 ** i for i in range(n) if s[i] == 'B'))
``` | 3 | |
721 | B | Passwords | PROGRAMMING | 1,100 | [
"implementation",
"math",
"sortings",
"strings"
] | null | null | Vanya is managed to enter his favourite site Codehorses. Vanya uses *n* distinct passwords for sites at all, however he can't remember which one exactly he specified during Codehorses registration.
Vanya will enter passwords in order of non-decreasing their lengths, and he will enter passwords of same length in arbitr... | The first line of the input contains two integers *n* and *k* (1<=≤<=*n*,<=*k*<=≤<=100) — the number of Vanya's passwords and the number of failed tries, after which the access to the site is blocked for 5 seconds.
The next *n* lines contains passwords, one per line — pairwise distinct non-empty strings consisting of ... | Print two integers — time (in seconds), Vanya needs to be authorized to Codehorses in the best case for him and in the worst case respectively. | [
"5 2\ncba\nabc\nbb1\nabC\nABC\nabc\n",
"4 100\n11\n22\n1\n2\n22\n"
] | [
"1 15\n",
"3 4\n"
] | Consider the first sample case. As soon as all passwords have the same length, Vanya can enter the right password at the first try as well as at the last try. If he enters it at the first try, he spends exactly 1 second. Thus in the best case the answer is 1. If, at the other hand, he enters it at the last try, he ente... | 1,000 | [
{
"input": "5 2\ncba\nabc\nbb1\nabC\nABC\nabc",
"output": "1 15"
},
{
"input": "4 100\n11\n22\n1\n2\n22",
"output": "3 4"
},
{
"input": "1 1\na1\na1",
"output": "1 1"
},
{
"input": "1 100\na1\na1",
"output": "1 1"
},
{
"input": "2 1\nabc\nAbc\nAbc",
"output": ... | 1,638,208,158 | 2,147,483,647 | Python 3 | OK | TESTS | 66 | 61 | 0 | def ints_get():
return map(int, input().strip().split())
n,k = ints_get()
arr=[]
for i in range(n):
arr.append(input())
arr.sort(key = len)
psd = input()
l = len(psd)
lmo = 0
eql = 0
p,q= None, None
for i in range(n):
if len(arr[i]) <l:
lmo += 1
elif len(arr[i]) == l:
... | Title: Passwords
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vanya is managed to enter his favourite site Codehorses. Vanya uses *n* distinct passwords for sites at all, however he can't remember which one exactly he specified during Codehorses registration.
Vanya will enter passwords... | ```python
def ints_get():
return map(int, input().strip().split())
n,k = ints_get()
arr=[]
for i in range(n):
arr.append(input())
arr.sort(key = len)
psd = input()
l = len(psd)
lmo = 0
eql = 0
p,q= None, None
for i in range(n):
if len(arr[i]) <l:
lmo += 1
elif len(arr[i]) == l... | 3 | |
583 | B | Robot's Task | PROGRAMMING | 1,200 | [
"greedy",
"implementation"
] | null | null | Robot Doc is located in the hall, with *n* computers stand in a line, numbered from left to right from 1 to *n*. Each computer contains exactly one piece of information, each of which Doc wants to get eventually. The computers are equipped with a security system, so to crack the *i*-th of them, the robot needs to colle... | The first line contains number *n* (1<=≤<=*n*<=≤<=1000). The second line contains *n* non-negative integers *a*1,<=*a*2,<=...,<=*a**n* (0<=≤<=*a**i*<=<<=*n*), separated by a space. It is guaranteed that there exists a way for robot to collect all pieces of the information. | Print a single number — the minimum number of changes in direction that the robot will have to make in order to collect all *n* parts of information. | [
"3\n0 2 0\n",
"5\n4 2 3 0 1\n",
"7\n0 3 1 0 5 2 6\n"
] | [
"1\n",
"3\n",
"2\n"
] | In the first sample you can assemble all the pieces of information in the optimal manner by assembling first the piece of information in the first computer, then in the third one, then change direction and move to the second one, and then, having 2 pieces of information, collect the last piece.
In the second sample to... | 1,000 | [
{
"input": "3\n0 2 0",
"output": "1"
},
{
"input": "5\n4 2 3 0 1",
"output": "3"
},
{
"input": "7\n0 3 1 0 5 2 6",
"output": "2"
},
{
"input": "1\n0",
"output": "0"
},
{
"input": "2\n0 1",
"output": "0"
},
{
"input": "10\n0 0 0 0 0 0 0 0 0 0",
"out... | 1,572,600,480 | 2,147,483,647 | PyPy 3 | OK | TESTS | 56 | 155 | 1,945,600 | #RAVENS
#TEAM_2
#ESSI-DAYI_MOHSEN-LORENZO
import sys
input=sys.stdin.readline
n = int(input())
a = list(map(int,input().split()))
Power = 0
res = -1
E = [0]*n
while Power != n:
res+=1
for i in range(n):
if E[i] == 0 and Power >= a[i]:
Power+=1
E[i] = 1
if Power !... | Title: Robot's Task
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Robot Doc is located in the hall, with *n* computers stand in a line, numbered from left to right from 1 to *n*. Each computer contains exactly one piece of information, each of which Doc wants to get eventually. The compu... | ```python
#RAVENS
#TEAM_2
#ESSI-DAYI_MOHSEN-LORENZO
import sys
input=sys.stdin.readline
n = int(input())
a = list(map(int,input().split()))
Power = 0
res = -1
E = [0]*n
while Power != n:
res+=1
for i in range(n):
if E[i] == 0 and Power >= a[i]:
Power+=1
E[i] = 1
... | 3 | |
731 | A | Night at the Museum | PROGRAMMING | 800 | [
"implementation",
"strings"
] | null | null | Grigoriy, like the hero of one famous comedy film, found a job as a night security guard at the museum. At first night he received embosser and was to take stock of the whole exposition.
Embosser is a special devise that allows to "print" the text of a plastic tape. Text is printed sequentially, character by character... | The only line of input contains the name of some exhibit — the non-empty string consisting of no more than 100 characters. It's guaranteed that the string consists of only lowercase English letters. | Print one integer — the minimum number of rotations of the wheel, required to print the name given in the input. | [
"zeus\n",
"map\n",
"ares\n"
] | [
"18\n",
"35\n",
"34\n"
] | To print the string from the first sample it would be optimal to perform the following sequence of rotations:
1. from 'a' to 'z' (1 rotation counterclockwise), 1. from 'z' to 'e' (5 clockwise rotations), 1. from 'e' to 'u' (10 rotations counterclockwise), 1. from 'u' to 's' (2 counterclockwise rotations). | 500 | [
{
"input": "zeus",
"output": "18"
},
{
"input": "map",
"output": "35"
},
{
"input": "ares",
"output": "34"
},
{
"input": "l",
"output": "11"
},
{
"input": "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuv",
"... | 1,671,056,640 | 2,147,483,647 | Python 3 | OK | TESTS | 44 | 46 | 0 | Alphapit =['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
word = input()
count = 0
curent = 'a'
for i in word:
if (26 - abs(Alphapit.index(i)- Alphapit.index(curent))) >=(abs(Alphapit.index(i)- Alphapit.index(curent))):... | Title: Night at the Museum
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Grigoriy, like the hero of one famous comedy film, found a job as a night security guard at the museum. At first night he received embosser and was to take stock of the whole exposition.
Embosser is a special devis... | ```python
Alphapit =['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
word = input()
count = 0
curent = 'a'
for i in word:
if (26 - abs(Alphapit.index(i)- Alphapit.index(curent))) >=(abs(Alphapit.index(i)- Alphapit.index(... | 3 | |
677 | A | Vanya and Fence | PROGRAMMING | 800 | [
"implementation"
] | null | null | Vanya and his friends are walking along the fence of height *h* and they do not want the guard to notice them. In order to achieve this the height of each of the friends should not exceed *h*. If the height of some person is greater than *h* he can bend down and then he surely won't be noticed by the guard. The height ... | The first line of the input contains two integers *n* and *h* (1<=≤<=*n*<=≤<=1000, 1<=≤<=*h*<=≤<=1000) — the number of friends and the height of the fence, respectively.
The second line contains *n* integers *a**i* (1<=≤<=*a**i*<=≤<=2*h*), the *i*-th of them is equal to the height of the *i*-th person. | Print a single integer — the minimum possible valid width of the road. | [
"3 7\n4 5 14\n",
"6 1\n1 1 1 1 1 1\n",
"6 5\n7 6 8 9 10 5\n"
] | [
"4\n",
"6\n",
"11\n"
] | In the first sample, only person number 3 must bend down, so the required width is equal to 1 + 1 + 2 = 4.
In the second sample, all friends are short enough and no one has to bend, so the width 1 + 1 + 1 + 1 + 1 + 1 = 6 is enough.
In the third sample, all the persons have to bend, except the last one. The required m... | 500 | [
{
"input": "3 7\n4 5 14",
"output": "4"
},
{
"input": "6 1\n1 1 1 1 1 1",
"output": "6"
},
{
"input": "6 5\n7 6 8 9 10 5",
"output": "11"
},
{
"input": "10 420\n214 614 297 675 82 740 174 23 255 15",
"output": "13"
},
{
"input": "10 561\n657 23 1096 487 785 66 481... | 1,694,712,440 | 2,147,483,647 | Python 3 | OK | TESTS | 29 | 46 | 0 | n11, h11 = map(int, input().split())
friends_heights11 = list(map(int, input().split()))
min_width11 = sum(2 if height11 > h11 else 1 for height11 in friends_heights11)
print(min_width11)
| Title: Vanya and Fence
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vanya and his friends are walking along the fence of height *h* and they do not want the guard to notice them. In order to achieve this the height of each of the friends should not exceed *h*. If the height of some pers... | ```python
n11, h11 = map(int, input().split())
friends_heights11 = list(map(int, input().split()))
min_width11 = sum(2 if height11 > h11 else 1 for height11 in friends_heights11)
print(min_width11)
``` | 3 | |
676 | C | Vasya and String | PROGRAMMING | 1,500 | [
"binary search",
"dp",
"strings",
"two pointers"
] | null | null | High school student Vasya got a string of length *n* as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than *k* characters of the original strin... | The first line of the input contains two integers *n* and *k* (1<=≤<=*n*<=≤<=100<=000,<=0<=≤<=*k*<=≤<=*n*) — the length of the string and the maximum number of characters to change.
The second line contains the string, consisting of letters 'a' and 'b' only. | Print the only integer — the maximum beauty of the string Vasya can achieve by changing no more than *k* characters. | [
"4 2\nabba\n",
"8 1\naabaabaa\n"
] | [
"4\n",
"5\n"
] | In the first sample, Vasya can obtain both strings "aaaa" and "bbbb".
In the second sample, the optimal answer is obtained with the string "aaaaabaa" or with the string "aabaaaaa". | 1,500 | [
{
"input": "4 2\nabba",
"output": "4"
},
{
"input": "8 1\naabaabaa",
"output": "5"
},
{
"input": "1 0\na",
"output": "1"
},
{
"input": "1 1\nb",
"output": "1"
},
{
"input": "1 0\nb",
"output": "1"
},
{
"input": "1 1\na",
"output": "1"
},
{
... | 1,613,206,273 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 2 | 108 | 0 | n,k=map(int,input().split())
s = input()
i = 0
ans = -1
prev = 0
flag = False
while i < n:
x = k
j=i+1
curr = 1
while j<n and x>-1:
if s[j]==s[i]:
j+=1
curr+=1
elif s[j]!=s[i] and x>0:
x-=1
j+=1
curr+=1
if not flag:
... | Title: Vasya and String
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
High school student Vasya got a string of length *n* as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequ... | ```python
n,k=map(int,input().split())
s = input()
i = 0
ans = -1
prev = 0
flag = False
while i < n:
x = k
j=i+1
curr = 1
while j<n and x>-1:
if s[j]==s[i]:
j+=1
curr+=1
elif s[j]!=s[i] and x>0:
x-=1
j+=1
curr+=1
if ... | 0 | |
56 | A | Bar | PROGRAMMING | 1,000 | [
"implementation"
] | A. Bar | 2 | 256 | According to Berland laws it is only allowed to sell alcohol to people not younger than 18 years. Vasya's job is to monitor the law's enforcement. Tonight he entered a bar and saw *n* people sitting there. For every one of them Vasya happened to determine either the age or the drink the person is having. Vasya can chec... | The first line contains an integer *n* (1<=≤<=*n*<=≤<=100) which is the number of the bar's clients. Then follow *n* lines, each describing one visitor. A line either contains his age (an integer from 0 to 1000) or his drink (a string of capital Latin letters from 1 to 100 in length). It is guaranteed that the input da... | Print a single number which is the number of people Vasya should check to guarantee the law enforcement. | [
"5\n18\nVODKA\nCOKE\n19\n17\n"
] | [
"2\n"
] | In the sample test the second and fifth clients should be checked. | 500 | [
{
"input": "5\n18\nVODKA\nCOKE\n19\n17",
"output": "2"
},
{
"input": "2\n2\nGIN",
"output": "2"
},
{
"input": "3\nWHISKEY\n3\nGIN",
"output": "3"
},
{
"input": "4\n813\nIORBQITQXMPTFAEMEQDQIKFGKGOTNKTOSZCBRPXJLUKVLVHJYNRUJXK\nRUM\nRHVRWGODYWWTYZFLFYKCVUFFRTQDINKNWPKFHZBFWBHWI... | 1,633,868,805 | 2,147,483,647 | Python 3 | OK | TESTS | 28 | 92 | 6,963,200 | def func(arr):
alc = ['ABSINTH', 'BEER', 'BRANDY', 'CHAMPAGNE', 'GIN', 'RUM', 'SAKE', 'TEQUILA', 'VODKA', 'WHISKEY', 'WINE']
c = 0
for _ in arr:
if _.isdigit():
if int(_) < 18:
c += 1
else:
if _.upper() in alc:
c += 1
retu... | Title: Bar
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
According to Berland laws it is only allowed to sell alcohol to people not younger than 18 years. Vasya's job is to monitor the law's enforcement. Tonight he entered a bar and saw *n* people sitting there. For every one of them Vasya h... | ```python
def func(arr):
alc = ['ABSINTH', 'BEER', 'BRANDY', 'CHAMPAGNE', 'GIN', 'RUM', 'SAKE', 'TEQUILA', 'VODKA', 'WHISKEY', 'WINE']
c = 0
for _ in arr:
if _.isdigit():
if int(_) < 18:
c += 1
else:
if _.upper() in alc:
c += 1... | 3.96403 |
792 | B | Counting-out Rhyme | PROGRAMMING | 1,300 | [
"implementation"
] | null | null | *n* children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to *n*. In the beginning, the first child is considered the leader. The game is played in *k* steps. In the *i*-th step the leader counts out *a**i* people in clockwise order, starting from the next person. T... | The first line contains two integer numbers *n* and *k* (2<=≤<=*n*<=≤<=100, 1<=≤<=*k*<=≤<=*n*<=-<=1).
The next line contains *k* integer numbers *a*1,<=*a*2,<=...,<=*a**k* (1<=≤<=*a**i*<=≤<=109). | Print *k* numbers, the *i*-th one corresponds to the number of child to be eliminated at the *i*-th step. | [
"7 5\n10 4 11 4 1\n",
"3 2\n2 5\n"
] | [
"4 2 5 6 1 \n",
"3 2 \n"
] | Let's consider first example:
- In the first step child 4 is eliminated, child 5 becomes the leader. - In the second step child 2 is eliminated, child 3 becomes the leader. - In the third step child 5 is eliminated, child 6 becomes the leader. - In the fourth step child 6 is eliminated, child 7 becomes the leader... | 0 | [
{
"input": "7 5\n10 4 11 4 1",
"output": "4 2 5 6 1 "
},
{
"input": "3 2\n2 5",
"output": "3 2 "
},
{
"input": "2 1\n1",
"output": "2 "
},
{
"input": "2 1\n2",
"output": "1 "
},
{
"input": "2 1\n3",
"output": "2 "
},
{
"input": "10 7\n5 10 4 3 8 10 6",... | 1,490,627,122 | 1,822 | Python 3 | OK | TESTS | 22 | 62 | 5,529,600 | n, _ = [int(i) for i in input().strip().split(' ')]
ak = [int(i) for i in input().strip().split(' ')]
people = list(range(1, n + 1))
current = 0
leaved = []
for k in ak:
pos = ((current + k) % len(people))
leave = people.pop(pos)
leaved.append(leave)
if pos >= len(people):
current = 0
... | Title: Counting-out Rhyme
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
*n* children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to *n*. In the beginning, the first child is considered the leader. The game is played in *k* steps. In ... | ```python
n, _ = [int(i) for i in input().strip().split(' ')]
ak = [int(i) for i in input().strip().split(' ')]
people = list(range(1, n + 1))
current = 0
leaved = []
for k in ak:
pos = ((current + k) % len(people))
leave = people.pop(pos)
leaved.append(leave)
if pos >= len(people):
curren... | 3 | |
2 | A | Winner | PROGRAMMING | 1,500 | [
"hashing",
"implementation"
] | A. Winner | 1 | 64 | The winner of the card game popular in Berland "Berlogging" is determined according to the following rules. If at the end of the game there is only one player with the maximum number of points, he is the winner. The situation becomes more difficult if the number of such players is more than one. During each round a pla... | The first line contains an integer number *n* (1<=<=≤<=<=*n*<=<=≤<=<=1000), *n* is the number of rounds played. Then follow *n* lines, containing the information about the rounds in "name score" format in chronological order, where name is a string of lower-case Latin letters with the length from 1 to 32, and score is ... | Print the name of the winner. | [
"3\nmike 3\nandrew 5\nmike 2\n",
"3\nandrew 3\nandrew 2\nmike 5\n"
] | [
"andrew\n",
"andrew\n"
] | none | 0 | [
{
"input": "3\nmike 3\nandrew 5\nmike 2",
"output": "andrew"
},
{
"input": "3\nandrew 3\nandrew 2\nmike 5",
"output": "andrew"
},
{
"input": "5\nkaxqybeultn -352\nmgochgrmeyieyskhuourfg -910\nkaxqybeultn 691\nmgochgrmeyieyskhuourfg -76\nkaxqybeultn -303",
"output": "kaxqybeultn"
},... | 1,679,081,497 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 9 | 92 | 0 | import sys
rounds = int(input())
playercards = {}
bar = {
"a" : 0,
}
for round in range(rounds):
value = list(input().split())
name = str(value[0])
score = int(value[1])
# print("round number :", round, "----------------")
if name not in playercards:
# print(f"adding {name} to the playercards")
playercards... | Title: Winner
Time Limit: 1 seconds
Memory Limit: 64 megabytes
Problem Description:
The winner of the card game popular in Berland "Berlogging" is determined according to the following rules. If at the end of the game there is only one player with the maximum number of points, he is the winner. The situation becomes... | ```python
import sys
rounds = int(input())
playercards = {}
bar = {
"a" : 0,
}
for round in range(rounds):
value = list(input().split())
name = str(value[0])
score = int(value[1])
# print("round number :", round, "----------------")
if name not in playercards:
# print(f"adding {name} to the playercards")
p... | 0 |
401 | A | Vanya and Cards | PROGRAMMING | 800 | [
"implementation",
"math"
] | null | null | Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed *x* in the absolute value.
Natasha doesn't like when Vanya spends a long time p... | The first line contains two integers: *n* (1<=≤<=*n*<=≤<=1000) — the number of found cards and *x* (1<=≤<=*x*<=≤<=1000) — the maximum absolute value of the number on a card. The second line contains *n* space-separated integers — the numbers on found cards. It is guaranteed that the numbers do not exceed *x* in their a... | Print a single number — the answer to the problem. | [
"3 2\n-1 1 2\n",
"2 3\n-2 -2\n"
] | [
"1\n",
"2\n"
] | In the first sample, Vanya needs to find a single card with number -2.
In the second sample, Vanya needs to find two cards with number 2. He can't find a single card with the required number as the numbers on the lost cards do not exceed 3 in their absolute value. | 500 | [
{
"input": "3 2\n-1 1 2",
"output": "1"
},
{
"input": "2 3\n-2 -2",
"output": "2"
},
{
"input": "4 4\n1 2 3 4",
"output": "3"
},
{
"input": "2 2\n-1 -1",
"output": "1"
},
{
"input": "15 5\n-2 -1 2 -4 -3 4 -4 -2 -2 2 -2 -1 1 -4 -2",
"output": "4"
},
{
"... | 1,577,979,712 | 2,147,483,647 | Python 3 | OK | TESTS | 47 | 109 | 307,200 | def solve(n, x, a):
k = sum(a)
if k == 0: return 0
else: return abs(k)//x + (1 if abs(k) % x != 0 else 0)
def main():
n, x = list(map(int, input().split()))
a = list(map(int, input().split()))
print(solve(n, x, a))
main()
| Title: Vanya and Cards
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each... | ```python
def solve(n, x, a):
k = sum(a)
if k == 0: return 0
else: return abs(k)//x + (1 if abs(k) % x != 0 else 0)
def main():
n, x = list(map(int, input().split()))
a = list(map(int, input().split()))
print(solve(n, x, a))
main()
``` | 3 | |
639 | A | Bear and Displayed Friends | PROGRAMMING | 1,200 | [
"implementation"
] | null | null | Limak is a little polar bear. He loves connecting with other bears via social networks. He has *n* friends and his relation with the *i*-th of them is described by a unique integer *t**i*. The bigger this value is, the better the friendship is. No two friends have the same value *t**i*.
Spring is starting and the Wint... | The first line contains three integers *n*, *k* and *q* (1<=≤<=*n*,<=*q*<=≤<=150<=000,<=1<=≤<=*k*<=≤<=*min*(6,<=*n*)) — the number of friends, the maximum number of displayed online friends and the number of queries, respectively.
The second line contains *n* integers *t*1,<=*t*2,<=...,<=*t**n* (1<=≤<=*t**i*<=≤<=109) ... | For each query of the second type print one line with the answer — "YES" (without quotes) if the given friend is displayed and "NO" (without quotes) otherwise. | [
"4 2 8\n300 950 500 200\n1 3\n2 4\n2 3\n1 1\n1 2\n2 1\n2 2\n2 3\n",
"6 3 9\n50 20 51 17 99 24\n1 3\n1 4\n1 5\n1 2\n2 4\n2 2\n1 1\n2 4\n2 3\n"
] | [
"NO\nYES\nNO\nYES\nYES\n",
"NO\nYES\nNO\nYES\n"
] | In the first sample, Limak has 4 friends who all sleep initially. At first, the system displays nobody because nobody is online. There are the following 8 queries:
1. "1 3" — Friend 3 becomes online. 1. "2 4" — We should check if friend 4 is displayed. He isn't even online and thus we print "NO". 1. "2 3" — We shou... | 500 | [
{
"input": "4 2 8\n300 950 500 200\n1 3\n2 4\n2 3\n1 1\n1 2\n2 1\n2 2\n2 3",
"output": "NO\nYES\nNO\nYES\nYES"
},
{
"input": "6 3 9\n50 20 51 17 99 24\n1 3\n1 4\n1 5\n1 2\n2 4\n2 2\n1 1\n2 4\n2 3",
"output": "NO\nYES\nNO\nYES"
},
{
"input": "6 3 10\n62417580 78150524 410053501 582708235 ... | 1,679,761,879 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 0 | 61 | 0 | numbersAmount, windowHeight, requestsAmount = map(int, input().split())
friendCoefficents = list(map(int, input().split()))
class FriendWindows:
def __init__(self, height) -> None:
self.Height = height
self.Windows = []
def CreateNewPosition(self, rating: int):
ratings = ... | Title: Bear and Displayed Friends
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Limak is a little polar bear. He loves connecting with other bears via social networks. He has *n* friends and his relation with the *i*-th of them is described by a unique integer *t**i*. The bigger this val... | ```python
numbersAmount, windowHeight, requestsAmount = map(int, input().split())
friendCoefficents = list(map(int, input().split()))
class FriendWindows:
def __init__(self, height) -> None:
self.Height = height
self.Windows = []
def CreateNewPosition(self, rating: int):
... | 0 | |
550 | A | Two Substrings | PROGRAMMING | 1,500 | [
"brute force",
"dp",
"greedy",
"implementation",
"strings"
] | null | null | You are given string *s*. Your task is to determine if the given string *s* contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). | The only line of input contains a string *s* of length between 1 and 105 consisting of uppercase Latin letters. | Print "YES" (without the quotes), if string *s* contains two non-overlapping substrings "AB" and "BA", and "NO" otherwise. | [
"ABA\n",
"BACFAB\n",
"AXBYBXA\n"
] | [
"NO\n",
"YES\n",
"NO\n"
] | In the first sample test, despite the fact that there are substrings "AB" and "BA", their occurrences overlap, so the answer is "NO".
In the second sample test there are the following occurrences of the substrings: BACFAB.
In the third sample test there is no substring "AB" nor substring "BA". | 1,000 | [
{
"input": "ABA",
"output": "NO"
},
{
"input": "BACFAB",
"output": "YES"
},
{
"input": "AXBYBXA",
"output": "NO"
},
{
"input": "ABABAB",
"output": "YES"
},
{
"input": "BBBBBBBBBB",
"output": "NO"
},
{
"input": "ABBA",
"output": "YES"
},
{
"... | 1,694,441,307 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 3 | 46 | 0 | s = input()
ab = s.find('AB')
ba = s.find('BA')
if (ab != -1 and ba != -1) and (ba != ab + 1):
print('YES')
else:
print('NO')
| Title: Two Substrings
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given string *s*. Your task is to determine if the given string *s* contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
Input Specification:
The only line of input contain... | ```python
s = input()
ab = s.find('AB')
ba = s.find('BA')
if (ab != -1 and ba != -1) and (ba != ab + 1):
print('YES')
else:
print('NO')
``` | 0 | |
675 | A | Infinite Sequence | PROGRAMMING | 1,100 | [
"math"
] | null | null | Vasya likes everything infinite. Now he is studying the properties of a sequence *s*, such that its first element is equal to *a* (*s*1<==<=*a*), and the difference between any two neighbouring elements is equal to *c* (*s**i*<=-<=*s**i*<=-<=1<==<=*c*). In particular, Vasya wonders if his favourite integer *b* appears ... | The first line of the input contain three integers *a*, *b* and *c* (<=-<=109<=≤<=*a*,<=*b*,<=*c*<=≤<=109) — the first element of the sequence, Vasya's favorite number and the difference between any two neighbouring elements of the sequence, respectively. | If *b* appears in the sequence *s* print "YES" (without quotes), otherwise print "NO" (without quotes). | [
"1 7 3\n",
"10 10 0\n",
"1 -4 5\n",
"0 60 50\n"
] | [
"YES\n",
"YES\n",
"NO\n",
"NO\n"
] | In the first sample, the sequence starts from integers 1, 4, 7, so 7 is its element.
In the second sample, the favorite integer of Vasya is equal to the first element of the sequence.
In the third sample all elements of the sequence are greater than Vasya's favorite integer.
In the fourth sample, the sequence starts... | 500 | [
{
"input": "1 7 3",
"output": "YES"
},
{
"input": "10 10 0",
"output": "YES"
},
{
"input": "1 -4 5",
"output": "NO"
},
{
"input": "0 60 50",
"output": "NO"
},
{
"input": "1 -4 -5",
"output": "YES"
},
{
"input": "0 1 0",
"output": "NO"
},
{
... | 1,559,056,202 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 9 | 140 | 0 | a,b,c = map(int,input().split())
l = 0
while(abs(b)>=abs(a)):
if(a==b):
print('YES')
exit()
a+=c
l+=1
if(l==1000000):
break
print('NO')
| Title: Infinite Sequence
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vasya likes everything infinite. Now he is studying the properties of a sequence *s*, such that its first element is equal to *a* (*s*1<==<=*a*), and the difference between any two neighbouring elements is equal to *c... | ```python
a,b,c = map(int,input().split())
l = 0
while(abs(b)>=abs(a)):
if(a==b):
print('YES')
exit()
a+=c
l+=1
if(l==1000000):
break
print('NO')
``` | 0 | |
980 | C | Posterized | PROGRAMMING | 1,700 | [
"games",
"greedy"
] | null | null | Professor Ibrahim has prepared the final homework for his algorithm’s class. He asked his students to implement the Posterization Image Filter.
Their algorithm will be tested on an array of integers, where the $i$-th integer represents the color of the $i$-th pixel in the image. The image is in black and white, theref... | The first line of input contains two integers $n$ and $k$ ($1 \leq n \leq 10^5$, $1 \leq k \leq 256$), the number of pixels in the image, and the maximum size of a group, respectively.
The second line contains $n$ integers $p_1, p_2, \dots, p_n$ ($0 \leq p_i \leq 255$), where $p_i$ is the color of the $i$-th pixel. | Print $n$ space-separated integers; the lexicographically smallest possible array that represents the image after applying the Posterization filter. | [
"4 3\n2 14 3 4\n",
"5 2\n0 2 1 255 254\n"
] | [
"0 12 3 3\n",
"0 1 1 254 254\n"
] | One possible way to group colors and assign keys for the first sample:
Color $2$ belongs to the group $[0,2]$, with group key $0$.
Color $14$ belongs to the group $[12,14]$, with group key $12$.
Colors $3$ and $4$ belong to group $[3, 5]$, with group key $3$.
Other groups won't affect the result so they are not lis... | 1,500 | [
{
"input": "4 3\n2 14 3 4",
"output": "0 12 3 3"
},
{
"input": "5 2\n0 2 1 255 254",
"output": "0 1 1 254 254"
},
{
"input": "10 3\n112 184 161 156 118 231 191 128 91 229",
"output": "110 182 159 154 116 229 189 126 89 229"
},
{
"input": "9 3\n174 149 118 124 166 146 219 233 ... | 1,541,627,608 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 9 | 108 | 102,400 | def read():
return [int(v) for v in input().split()]
def main():
n, k = read()
a = read()
cache = {}
for i in range(n):
if a[i] not in cache:
for v in range(1, k):
value = a[i] - v
if value in cache:
if a[i] - cache[value] < ... | Title: Posterized
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Professor Ibrahim has prepared the final homework for his algorithm’s class. He asked his students to implement the Posterization Image Filter.
Their algorithm will be tested on an array of integers, where the $i$-th intege... | ```python
def read():
return [int(v) for v in input().split()]
def main():
n, k = read()
a = read()
cache = {}
for i in range(n):
if a[i] not in cache:
for v in range(1, k):
value = a[i] - v
if value in cache:
if a[i] - cache... | 0 | |
344 | A | Magnets | PROGRAMMING | 800 | [
"implementation"
] | null | null | Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together at a close distance, then the like poles will repel each other and the oppo... | The first line of the input contains an integer *n* (1<=≤<=*n*<=≤<=100000) — the number of magnets. Then *n* lines follow. The *i*-th line (1<=≤<=*i*<=≤<=*n*) contains either characters "01", if Mike put the *i*-th magnet in the "plus-minus" position, or characters "10", if Mike put the magnet in the "minus-plus" posit... | On the single line of the output print the number of groups of magnets. | [
"6\n10\n10\n10\n01\n10\n10\n",
"4\n01\n01\n10\n10\n"
] | [
"3\n",
"2\n"
] | The first testcase corresponds to the figure. The testcase has three groups consisting of three, one and two magnets.
The second testcase has two groups, each consisting of two magnets. | 500 | [
{
"input": "6\n10\n10\n10\n01\n10\n10",
"output": "3"
},
{
"input": "4\n01\n01\n10\n10",
"output": "2"
},
{
"input": "1\n10",
"output": "1"
},
{
"input": "2\n01\n10",
"output": "2"
},
{
"input": "2\n10\n10",
"output": "1"
},
{
"input": "3\n10\n01\n10",... | 1,697,230,481 | 2,147,483,647 | Python 3 | OK | TESTS | 31 | 248 | 0 | a = int(input())
b = input()
chk = b[1]
cnt = 1
for i in range(1,a):
k = input()
if k[0] == chk:
cnt = cnt + 1
chk = k[1]
print(cnt)
| Title: Magnets
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets... | ```python
a = int(input())
b = input()
chk = b[1]
cnt = 1
for i in range(1,a):
k = input()
if k[0] == chk:
cnt = cnt + 1
chk = k[1]
print(cnt)
``` | 3 | |
237 | A | Free Cash | PROGRAMMING | 1,000 | [
"implementation"
] | null | null | Valera runs a 24/7 fast food cafe. He magically learned that next day *n* people will visit his cafe. For each person we know the arrival time: the *i*-th person comes exactly at *h**i* hours *m**i* minutes. The cafe spends less than a minute to serve each client, but if a client comes in and sees that there is no free... | The first line contains a single integer *n* (1<=≤<=*n*<=≤<=105), that is the number of cafe visitors.
Each of the following *n* lines has two space-separated integers *h**i* and *m**i* (0<=≤<=*h**i*<=≤<=23; 0<=≤<=*m**i*<=≤<=59), representing the time when the *i*-th person comes into the cafe.
Note that the time is... | Print a single integer — the minimum number of cashes, needed to serve all clients next day. | [
"4\n8 0\n8 10\n8 10\n8 45\n",
"3\n0 12\n10 11\n22 22\n"
] | [
"2\n",
"1\n"
] | In the first sample it is not enough one cash to serve all clients, because two visitors will come into cafe in 8:10. Therefore, if there will be one cash in cafe, then one customer will be served by it, and another one will not wait and will go away.
In the second sample all visitors will come in different times, so ... | 500 | [
{
"input": "4\n8 0\n8 10\n8 10\n8 45",
"output": "2"
},
{
"input": "3\n0 12\n10 11\n22 22",
"output": "1"
},
{
"input": "5\n12 8\n15 27\n15 27\n16 2\n19 52",
"output": "2"
},
{
"input": "7\n5 6\n7 34\n7 34\n7 34\n12 29\n15 19\n20 23",
"output": "3"
},
{
"input": "... | 1,610,636,599 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 6 | 154 | 0 | m1=-1
h1=-1
l=1
#c=[]
for _ in range(int(input())):
c=0
h,m=map(int,input().split())
if m==m1 and h==h1 and l>c:
#l=l+1
c=c+1
l=l+c
#c.append(l)
m1=m
h1=h
print(l)
| Title: Free Cash
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Valera runs a 24/7 fast food cafe. He magically learned that next day *n* people will visit his cafe. For each person we know the arrival time: the *i*-th person comes exactly at *h**i* hours *m**i* minutes. The cafe spends l... | ```python
m1=-1
h1=-1
l=1
#c=[]
for _ in range(int(input())):
c=0
h,m=map(int,input().split())
if m==m1 and h==h1 and l>c:
#l=l+1
c=c+1
l=l+c
#c.append(l)
m1=m
h1=h
print(l)
``` | 0 | |
45 | A | Codecraft III | PROGRAMMING | 900 | [
"implementation"
] | A. Codecraft III | 2 | 256 | Today Vasya visited a widely known site and learned that the continuation of his favourite game Codecraft II will appear after exactly *k* months. He looked at the calendar and learned that at the moment is the month number *s*. Vasya immediately got interested in what month Codecraft III will appear. Help him understa... | The first input line contains the name of the current month. It is guaranteed that it is a proper English name of one of twelve months. The first letter is uppercase, the rest are lowercase. The second line contains integer *k* (0<=≤<=*k*<=≤<=100) — the number of months left till the appearance of Codecraft III. | Print starting from an uppercase letter the name of the month in which the continuation of Codeforces II will appear. The printed name must be contained in the list January, February, March, April, May, June, July, August, September, October, November, December. | [
"November\n3\n",
"May\n24\n"
] | [
"February\n",
"May\n"
] | none | 0 | [
{
"input": "November\n3",
"output": "February"
},
{
"input": "May\n24",
"output": "May"
},
{
"input": "April\n0",
"output": "April"
},
{
"input": "September\n0",
"output": "September"
},
{
"input": "August\n0",
"output": "August"
},
{
"input": "June\n1... | 1,592,399,260 | 2,147,483,647 | PyPy 3 | OK | TESTS | 25 | 310 | 0 | month={1:'January',2:'February',3:'March',4:'April',5:'May',6:'June',7:'July',8:'August',9:'September',10:'October',11:'November',12:'December',13:'January',14:'February',15:'March',16:'April',17:'May',18:'June',19:'July',20:'August',21:'September',22:'October',21:'November'}
s=str(input())
n=int(input())
for key,it... | Title: Codecraft III
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Today Vasya visited a widely known site and learned that the continuation of his favourite game Codecraft II will appear after exactly *k* months. He looked at the calendar and learned that at the moment is the month number *... | ```python
month={1:'January',2:'February',3:'March',4:'April',5:'May',6:'June',7:'July',8:'August',9:'September',10:'October',11:'November',12:'December',13:'January',14:'February',15:'March',16:'April',17:'May',18:'June',19:'July',20:'August',21:'September',22:'October',21:'November'}
s=str(input())
n=int(input())
... | 3.9225 |
820 | B | Mister B and Angle in Polygon | PROGRAMMING | 1,300 | [
"constructive algorithms",
"geometry",
"math"
] | null | null | On one quiet day all of sudden Mister B decided to draw angle *a* on his field. Aliens have already visited his field and left many different geometric figures on it. One of the figures is regular convex *n*-gon (regular convex polygon with *n* sides).
That's why Mister B decided to use this polygon. Now Mister B must... | First and only line contains two space-separated integers *n* and *a* (3<=≤<=*n*<=≤<=105, 1<=≤<=*a*<=≤<=180) — the number of vertices in the polygon and the needed angle, in degrees. | Print three space-separated integers: the vertices *v*1, *v*2, *v*3, which form . If there are multiple optimal solutions, print any of them. The vertices are numbered from 1 to *n* in clockwise order. | [
"3 15\n",
"4 67\n",
"4 68\n"
] | [
"1 2 3\n",
"2 1 3\n",
"4 1 2\n"
] | In first sample test vertices of regular triangle can create only angle of 60 degrees, that's why every possible angle is correct.
Vertices of square can create 45 or 90 degrees angles only. That's why in second sample test the angle of 45 degrees was chosen, since |45 - 67| < |90 - 67|. Other correct answers are: ... | 1,000 | [
{
"input": "3 15",
"output": "2 1 3"
},
{
"input": "4 67",
"output": "2 1 3"
},
{
"input": "4 68",
"output": "2 1 4"
},
{
"input": "3 1",
"output": "2 1 3"
},
{
"input": "3 180",
"output": "2 1 3"
},
{
"input": "100000 1",
"output": "2 1 558"
},
... | 1,700,086,703 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 46 | 62 | 7,065,600 | n,a=map(int,input().split())
ll=[]
alfa=(n-2)*180/n
beta=(180-alfa)/2
x=beta
while x<alfa:
ll.append(x)
x+=beta
ll.append(alfa)
t=190
f=0
for i in range(n-2):
if abs(a-ll[i])<t:
t=abs(a-ll[i])
f=i
print(2,1,3+f) | Title: Mister B and Angle in Polygon
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
On one quiet day all of sudden Mister B decided to draw angle *a* on his field. Aliens have already visited his field and left many different geometric figures on it. One of the figures is regular convex *... | ```python
n,a=map(int,input().split())
ll=[]
alfa=(n-2)*180/n
beta=(180-alfa)/2
x=beta
while x<alfa:
ll.append(x)
x+=beta
ll.append(alfa)
t=190
f=0
for i in range(n-2):
if abs(a-ll[i])<t:
t=abs(a-ll[i])
f=i
print(2,1,3+f)
``` | 3 | |
134 | A | Average Numbers | PROGRAMMING | 1,200 | [
"brute force",
"implementation"
] | null | null | You are given a sequence of positive integers *a*1,<=*a*2,<=...,<=*a**n*. Find all such indices *i*, that the *i*-th element equals the arithmetic mean of all other elements (that is all elements except for this one). | The first line contains the integer *n* (2<=≤<=*n*<=≤<=2·105). The second line contains elements of the sequence *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=1000). All the elements are positive integers. | Print on the first line the number of the sought indices. Print on the second line the sought indices in the increasing order. All indices are integers from 1 to *n*.
If the sought elements do not exist, then the first output line should contain number 0. In this case you may either not print the second line or print ... | [
"5\n1 2 3 4 5\n",
"4\n50 50 50 50\n"
] | [
"1\n3 ",
"4\n1 2 3 4 "
] | none | 500 | [
{
"input": "5\n1 2 3 4 5",
"output": "1\n3 "
},
{
"input": "4\n50 50 50 50",
"output": "4\n1 2 3 4 "
},
{
"input": "3\n2 3 1",
"output": "1\n1 "
},
{
"input": "2\n4 2",
"output": "0"
},
{
"input": "2\n1 1",
"output": "2\n1 2 "
},
{
"input": "10\n3 3 3 ... | 1,605,433,586 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 0 | 482 | 10,956,800 | import random
name = ["amir" , 'mahdi' , 'hamid' , 'fateme' , 'mohammad' , 'mohsen']
family = ["majidi" , "ahmadi" , "amiri" , 'anvari' , 'mirzaei' , 'jamali']
a = range(1,10)
for num in range(1,50) :
print (f'{random.choice(name)} {random.choice(family)} {random.choice(a)}{random.choice(a)}{random.choice(a)}{ra... | Title: Average Numbers
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given a sequence of positive integers *a*1,<=*a*2,<=...,<=*a**n*. Find all such indices *i*, that the *i*-th element equals the arithmetic mean of all other elements (that is all elements except for this one).
... | ```python
import random
name = ["amir" , 'mahdi' , 'hamid' , 'fateme' , 'mohammad' , 'mohsen']
family = ["majidi" , "ahmadi" , "amiri" , 'anvari' , 'mirzaei' , 'jamali']
a = range(1,10)
for num in range(1,50) :
print (f'{random.choice(name)} {random.choice(family)} {random.choice(a)}{random.choice(a)}{random.cho... | 0 | |
810 | B | Summer sell-off | PROGRAMMING | 1,300 | [
"greedy",
"sortings"
] | null | null | Summer holidays! Someone is going on trips, someone is visiting grandparents, but someone is trying to get a part-time job. This summer Noora decided that she wants to earn some money, and took a job in a shop as an assistant.
Shop, where Noora is working, has a plan on the following *n* days. For each day sales manag... | The first line contains two integers *n* and *f* (1<=≤<=*n*<=≤<=105,<=0<=≤<=*f*<=≤<=*n*) denoting the number of days in shop's plan and the number of days that Noora has to choose for sell-out.
Each line of the following *n* subsequent lines contains two integers *k**i*,<=*l**i* (0<=≤<=*k**i*,<=*l**i*<=≤<=109) denotin... | Print a single integer denoting the maximal number of products that shop can sell. | [
"4 2\n2 1\n3 5\n2 3\n1 5\n",
"4 1\n0 2\n0 3\n3 5\n0 6\n"
] | [
"10",
"5"
] | In the first example we can choose days with numbers 2 and 4 for sell-out. In this case new numbers of products for sale would be equal to [2, 6, 2, 2] respectively. So on the first day shop will sell 1 product, on the second — 5, on the third — 2, on the fourth — 2. In total 1 + 5 + 2 + 2 = 10 product units.
In the s... | 1,000 | [
{
"input": "4 2\n2 1\n3 5\n2 3\n1 5",
"output": "10"
},
{
"input": "4 1\n0 2\n0 3\n3 5\n0 6",
"output": "5"
},
{
"input": "1 1\n5 8",
"output": "8"
},
{
"input": "2 1\n8 12\n6 11",
"output": "19"
},
{
"input": "2 1\n6 7\n5 7",
"output": "13"
},
{
"inpu... | 1,496,716,169 | 2,147,483,647 | Python 3 | OK | TESTS | 159 | 655 | 13,004,800 | n,f = map(int,input().split())
days = []
for i in range(n):
prod , peo = map(int,input().split())
sold = min(prod,peo)
max_sold = min(2*prod,peo)
gain = max_sold-sold
days.append([gain,max_sold,sold])
days.sort()
days.reverse()
ans =0
for i in range(n):
if f>0:
f-=1
ans += days[i][1]
else:
... | Title: Summer sell-off
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Summer holidays! Someone is going on trips, someone is visiting grandparents, but someone is trying to get a part-time job. This summer Noora decided that she wants to earn some money, and took a job in a shop as an ass... | ```python
n,f = map(int,input().split())
days = []
for i in range(n):
prod , peo = map(int,input().split())
sold = min(prod,peo)
max_sold = min(2*prod,peo)
gain = max_sold-sold
days.append([gain,max_sold,sold])
days.sort()
days.reverse()
ans =0
for i in range(n):
if f>0:
f-=1
ans += days[i][1]
... | 3 | |
340 | D | Bubble Sort Graph | PROGRAMMING | 1,500 | [
"binary search",
"data structures",
"dp"
] | null | null | Iahub recently has learned Bubble Sort, an algorithm that is used to sort a permutation with *n* elements *a*1, *a*2, ..., *a**n* in ascending order. He is bored of this so simple algorithm, so he invents his own graph. The graph (let's call it *G*) initially has *n* vertices and 0 edges. During Bubble Sort execution, ... | The first line of the input contains an integer *n* (2<=≤<=*n*<=≤<=105). The next line contains *n* distinct integers *a*1, *a*2, ..., *a**n* (1<=≤<=*a**i*<=≤<=*n*). | Output a single integer — the answer to the problem. | [
"3\n3 1 2\n"
] | [
"2\n"
] | Consider the first example. Bubble sort swaps elements 3 and 1. We add edge (1, 3). Permutation is now [1, 3, 2]. Then bubble sort swaps elements 3 and 2. We add edge (2, 3). Permutation is now sorted. We have a graph with 3 vertices and 2 edges (1, 3) and (2, 3). Its maximal independent set is [1, 2]. | 2,000 | [
{
"input": "3\n3 1 2",
"output": "2"
},
{
"input": "5\n4 2 1 3 5",
"output": "3"
},
{
"input": "10\n1 9 8 10 2 3 4 6 5 7",
"output": "6"
},
{
"input": "50\n12 24 42 43 36 3 40 29 7 34 10 13 28 9 35 23 25 21 19 4 20 18 11 38 41 48 6 46 33 17 31 37 2 30 32 44 45 5 47 49 16 15 5... | 1,582,060,901 | 2,147,483,647 | Python 3 | OK | TESTS | 54 | 810 | 7,168,000 | def CeilIndex(A, l, r, key):
while (r - l > 1):
m = l + (r - l)//2
if (A[m] >= key):
r = m
else:
l = m
return r
def LIS(A, size):
tailTable = [0 for i in range(size + 1)]
len = 0
tailTable[0] = A[0]
len ... | Title: Bubble Sort Graph
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Iahub recently has learned Bubble Sort, an algorithm that is used to sort a permutation with *n* elements *a*1, *a*2, ..., *a**n* in ascending order. He is bored of this so simple algorithm, so he invents his own grap... | ```python
def CeilIndex(A, l, r, key):
while (r - l > 1):
m = l + (r - l)//2
if (A[m] >= key):
r = m
else:
l = m
return r
def LIS(A, size):
tailTable = [0 for i in range(size + 1)]
len = 0
tailTable[0] = A[0] ... | 3 | |
369 | B | Valera and Contest | PROGRAMMING | 1,400 | [
"constructive algorithms",
"implementation",
"math"
] | null | null | Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of *n* students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.
After the contest was over, Valer... | The first line of the input contains exactly six integers *n*,<=*k*,<=*l*,<=*r*,<=*s**all*,<=*s**k* (1<=≤<=*n*,<=*k*,<=*l*,<=*r*<=≤<=1000; *l*<=≤<=*r*; *k*<=≤<=*n*; 1<=≤<=*s**k*<=≤<=*s**all*<=≤<=106).
It's guaranteed that the input is such that the answer exists. | Print exactly *n* integers *a*1,<=*a*2,<=...,<=*a**n* — the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order. | [
"5 3 1 3 13 9\n",
"5 3 1 3 15 9\n"
] | [
"2 3 2 3 3 ",
"3 3 3 3 3 "
] | none | 1,000 | [
{
"input": "5 3 1 3 13 9",
"output": "2 3 2 3 3 "
},
{
"input": "5 3 1 3 15 9",
"output": "3 3 3 3 3 "
},
{
"input": "50 25 1 1 50 25",
"output": "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 "
},
{
"input": "1000 700 782... | 1,602,435,468 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 3 | 155 | 1,843,200 |
from collections import deque
n , k , l , r , st , sk = map(int,input().split())
#n , k , sk = map(int,input().split())
d = deque()
rem = sk % k
for i in range(k):
if (i == 0 and rem > 0 ):
d.append(rem + sk//k)
else:
d.append(sk//k)
#print(d)
if (n != k):
sm = st... | Title: Valera and Contest
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of *n* students (including Valera). This contest was an individual c... | ```python
from collections import deque
n , k , l , r , st , sk = map(int,input().split())
#n , k , sk = map(int,input().split())
d = deque()
rem = sk % k
for i in range(k):
if (i == 0 and rem > 0 ):
d.append(rem + sk//k)
else:
d.append(sk//k)
#print(d)
if (n != k):
... | 0 | |
981 | A | Antipalindrome | PROGRAMMING | 900 | [
"brute force",
"implementation",
"strings"
] | null | null | A string is a palindrome if it reads the same from the left to the right and from the right to the left. For example, the strings "kek", "abacaba", "r" and "papicipap" are palindromes, while the strings "abb" and "iq" are not.
A substring $s[l \ldots r]$ ($1<=\leq<=l<=\leq<=r<=\leq<=|s|$) of a string $s<==<=s_{1}s_{2}... | The first line contains a non-empty string $s$ with length at most $50$ characters, containing lowercase English letters only. | If there is such a substring in $s$ that is not a palindrome, print the maximum length of such a substring. Otherwise print $0$.
Note that there can be multiple longest substrings that are not palindromes, but their length is unique. | [
"mew\n",
"wuffuw\n",
"qqqqqqqq\n"
] | [
"3\n",
"5\n",
"0\n"
] | "mew" is not a palindrome, so the longest substring of it that is not a palindrome, is the string "mew" itself. Thus, the answer for the first example is $3$.
The string "uffuw" is one of the longest non-palindrome substrings (of length $5$) of the string "wuffuw", so the answer for the second example is $5$.
All sub... | 500 | [
{
"input": "mew",
"output": "3"
},
{
"input": "wuffuw",
"output": "5"
},
{
"input": "qqqqqqqq",
"output": "0"
},
{
"input": "ijvji",
"output": "4"
},
{
"input": "iiiiiii",
"output": "0"
},
{
"input": "wobervhvvkihcuyjtmqhaaigvvgiaahqmtjyuchikvvhvrebow"... | 1,527,433,401 | 801 | Python 3 | OK | TESTS | 133 | 93 | 0 | def is_palindrome(S):
length = len(S)
result = True
for i in range(len(S) // 2):
if S[i] != S[length - i - 1]:
result = False
break
return result
s = input()
n = len(s)
yes = False
for i in range(n):
for j in range(n-1, i, -1):
if not is_palin... | Title: Antipalindrome
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
A string is a palindrome if it reads the same from the left to the right and from the right to the left. For example, the strings "kek", "abacaba", "r" and "papicipap" are palindromes, while the strings "abb" and "iq" ar... | ```python
def is_palindrome(S):
length = len(S)
result = True
for i in range(len(S) // 2):
if S[i] != S[length - i - 1]:
result = False
break
return result
s = input()
n = len(s)
yes = False
for i in range(n):
for j in range(n-1, i, -1):
if no... | 3 | |
119 | A | Epic Game | PROGRAMMING | 800 | [
"implementation"
] | null | null | Simon and Antisimon play a game. Initially each player receives one fixed positive integer that doesn't change throughout the game. Simon receives number *a* and Antisimon receives number *b*. They also have a heap of *n* stones. The players take turns to make a move and Simon starts. During a move a player should take... | The only string contains space-separated integers *a*, *b* and *n* (1<=≤<=*a*,<=*b*,<=*n*<=≤<=100) — the fixed numbers Simon and Antisimon have received correspondingly and the initial number of stones in the pile. | If Simon wins, print "0" (without the quotes), otherwise print "1" (without the quotes). | [
"3 5 9\n",
"1 1 100\n"
] | [
"0",
"1"
] | The greatest common divisor of two non-negative integers *a* and *b* is such maximum positive integer *k*, that *a* is divisible by *k* without remainder and similarly, *b* is divisible by *k* without remainder. Let *gcd*(*a*, *b*) represent the operation of calculating the greatest common divisor of numbers *a* and *b... | 500 | [
{
"input": "3 5 9",
"output": "0"
},
{
"input": "1 1 100",
"output": "1"
},
{
"input": "23 12 16",
"output": "1"
},
{
"input": "95 26 29",
"output": "1"
},
{
"input": "73 32 99",
"output": "1"
},
{
"input": "1 1 1",
"output": "0"
},
{
"inpu... | 1,697,900,006 | 2,147,483,647 | Python 3 | OK | TESTS | 45 | 92 | 0 | import math
a,b,c = map(int, input().split())
d=0
while(c!=0):
d += 1
if d%2 == 1:
c -= math.gcd(a, c)
elif d%2 == 0:
c -= math.gcd(b, c)
if d%2 == 1:
print("0")
elif d%2 == 0 :
print("1")
| Title: Epic Game
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Simon and Antisimon play a game. Initially each player receives one fixed positive integer that doesn't change throughout the game. Simon receives number *a* and Antisimon receives number *b*. They also have a heap of *n* sto... | ```python
import math
a,b,c = map(int, input().split())
d=0
while(c!=0):
d += 1
if d%2 == 1:
c -= math.gcd(a, c)
elif d%2 == 0:
c -= math.gcd(b, c)
if d%2 == 1:
print("0")
elif d%2 == 0 :
print("1")
``` | 3 | |
991 | B | Getting an A | PROGRAMMING | 900 | [
"greedy",
"sortings"
] | null | null | Translator's note: in Russia's most widespread grading system, there are four grades: 5, 4, 3, 2, the higher the better, roughly corresponding to A, B, C and F respectively in American grading system.
The term is coming to an end and students start thinking about their grades. Today, a professor told his students that... | The first line contains a single integer $n$ — the number of Vasya's grades ($1 \leq n \leq 100$).
The second line contains $n$ integers from $2$ to $5$ — Vasya's grades for his lab works. | Output a single integer — the minimum amount of lab works that Vasya has to redo. It can be shown that Vasya can always redo enough lab works to get a $5$. | [
"3\n4 4 4\n",
"4\n5 4 5 5\n",
"4\n5 3 3 5\n"
] | [
"2\n",
"0\n",
"1\n"
] | In the first sample, it is enough to redo two lab works to make two $4$s into $5$s.
In the second sample, Vasya's average is already $4.75$ so he doesn't have to redo anything to get a $5$.
In the second sample Vasya has to redo one lab work to get rid of one of the $3$s, that will make the average exactly $4.5$ so t... | 1,000 | [
{
"input": "3\n4 4 4",
"output": "2"
},
{
"input": "4\n5 4 5 5",
"output": "0"
},
{
"input": "4\n5 3 3 5",
"output": "1"
},
{
"input": "1\n5",
"output": "0"
},
{
"input": "4\n3 2 5 4",
"output": "2"
},
{
"input": "5\n5 4 3 2 5",
"output": "2"
},
... | 1,678,044,401 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 5 | 31 | 0 | n = int(input())
*a, = map(int, input().split())
c2 = a.count(2)
c3 = a.count(3)
c4 = a.count(4)
c5 = a.count(5)
cnt = c2 * 3 + c3 * 2 + c4
ans = 0
while cnt > c5:
if c2:
c2 -= 1
cnt -= 3
elif c3:
c3 -= 1
cnt -= 2
else:
c4 -= 1
cnt -= 1
c... | Title: Getting an A
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Translator's note: in Russia's most widespread grading system, there are four grades: 5, 4, 3, 2, the higher the better, roughly corresponding to A, B, C and F respectively in American grading system.
The term is coming t... | ```python
n = int(input())
*a, = map(int, input().split())
c2 = a.count(2)
c3 = a.count(3)
c4 = a.count(4)
c5 = a.count(5)
cnt = c2 * 3 + c3 * 2 + c4
ans = 0
while cnt > c5:
if c2:
c2 -= 1
cnt -= 3
elif c3:
c3 -= 1
cnt -= 2
else:
c4 -= 1
cnt -... | 0 | |
378 | A | Playing with Dice | PROGRAMMING | 800 | [
"brute force"
] | null | null | Two players are playing a game. First each of them writes an integer from 1 to 6, and then a dice is thrown. The player whose written number got closer to the number on the dice wins. If both payers have the same difference, it's a draw.
The first player wrote number *a*, the second player wrote number *b*. How many w... | The single line contains two integers *a* and *b* (1<=≤<=*a*,<=*b*<=≤<=6) — the numbers written on the paper by the first and second player, correspondingly. | Print three integers: the number of ways to throw the dice at which the first player wins, the game ends with a draw or the second player wins, correspondingly. | [
"2 5\n",
"2 4\n"
] | [
"3 0 3\n",
"2 1 3\n"
] | The dice is a standard cube-shaped six-sided object with each side containing a number from 1 to 6, and where all numbers on all sides are distinct.
You can assume that number *a* is closer to number *x* than number *b*, if |*a* - *x*| < |*b* - *x*|. | 500 | [
{
"input": "2 5",
"output": "3 0 3"
},
{
"input": "2 4",
"output": "2 1 3"
},
{
"input": "5 3",
"output": "2 1 3"
},
{
"input": "1 6",
"output": "3 0 3"
},
{
"input": "5 1",
"output": "3 1 2"
},
{
"input": "6 3",
"output": "2 0 4"
},
{
"inp... | 1,567,809,217 | 2,147,483,647 | Python 3 | OK | TESTS | 38 | 109 | 0 | number = input('')
a = int(number[0])
b = int(number[2])
def dice(a, b):
a_win = 0
b_win = 0
draw = 0
for x in range(1,7):
if abs(a-x) < abs(b-x):
a_win += 1
elif abs(a-x) > abs(b-x):
b_win += 1
else:
draw += 1
return a_win, draw, b_win
res... | Title: Playing with Dice
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Two players are playing a game. First each of them writes an integer from 1 to 6, and then a dice is thrown. The player whose written number got closer to the number on the dice wins. If both payers have the same diff... | ```python
number = input('')
a = int(number[0])
b = int(number[2])
def dice(a, b):
a_win = 0
b_win = 0
draw = 0
for x in range(1,7):
if abs(a-x) < abs(b-x):
a_win += 1
elif abs(a-x) > abs(b-x):
b_win += 1
else:
draw += 1
return a_win, draw,... | 3 | |
77 | B | Falling Anvils | PROGRAMMING | 1,800 | [
"math",
"probabilities"
] | B. Falling Anvils | 2 | 256 | For some reason in many American cartoons anvils fall from time to time onto heroes' heads. Of course, safes, wardrobes, cruisers, planes fall sometimes too... But anvils do so most of all.
Anvils come in different sizes and shapes. Quite often they get the hero stuck deep in the ground. But have you ever thought who ... | The first line contains integer *t* (1<=≤<=*t*<=≤<=10000) — amount of testcases.
Each of the following *t* lines contain two space-separated integers *a* and *b* (0<=≤<=*a*,<=*b*<=≤<=106).
Pretests contain all the tests with 0<=<<=*a*<=<<=10,<=0<=≤<=*b*<=<<=10. | Print *t* lines — the probability of a successful anvil hit for each testcase. The absolute or relative error of the answer should not exceed 10<=-<=6. | [
"2\n4 2\n1 2\n"
] | [
"0.6250000000\n0.5312500000\n"
] | none | 1,000 | [
{
"input": "2\n4 2\n1 2",
"output": "0.6250000000\n0.5312500000"
},
{
"input": "90\n1 1\n2 1\n3 1\n4 1\n5 1\n6 1\n7 1\n8 1\n9 1\n1 2\n2 2\n3 2\n4 2\n5 2\n6 2\n7 2\n8 2\n9 2\n1 3\n2 3\n3 3\n4 3\n5 3\n6 3\n7 3\n8 3\n9 3\n1 4\n2 4\n3 4\n4 4\n5 4\n6 4\n7 4\n8 4\n9 4\n1 5\n2 5\n3 5\n4 5\n5 5\n6 5\n7 5\n8... | 1,579,952,050 | 2,147,483,647 | PyPy 3 | OK | TESTS | 7 | 716 | 6,041,600 | t = int(input())
for _ in range(t):
a, b = map(float, input().split())
if b == 0.0:
print(1.0)
elif a == 0.0:
print(0.5)
elif a / 4.0 <= b:
print((a + 8.0 * b) / 16.0 / b)
else:
print(1.0 - b / a)
| Title: Falling Anvils
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
For some reason in many American cartoons anvils fall from time to time onto heroes' heads. Of course, safes, wardrobes, cruisers, planes fall sometimes too... But anvils do so most of all.
Anvils come in different sizes an... | ```python
t = int(input())
for _ in range(t):
a, b = map(float, input().split())
if b == 0.0:
print(1.0)
elif a == 0.0:
print(0.5)
elif a / 4.0 <= b:
print((a + 8.0 * b) / 16.0 / b)
else:
print(1.0 - b / a)
``` | 3.809747 |
411 | A | Password Check | PROGRAMMING | 800 | [
"*special",
"implementation"
] | null | null | You have probably registered on Internet sites many times. And each time you should enter your invented password. Usually the registration form automatically checks the password's crypt resistance. If the user's password isn't complex enough, a message is displayed. Today your task is to implement such an automatic che... | The first line contains a non-empty sequence of characters (at most 100 characters). Each character is either a large English letter, or a small English letter, or a digit, or one of characters: "!", "?", ".", ",", "_". | If the password is complex enough, print message "Correct" (without the quotes), otherwise print message "Too weak" (without the quotes). | [
"abacaba\n",
"X12345\n",
"CONTEST_is_STARTED!!11\n"
] | [
"Too weak\n",
"Too weak\n",
"Correct\n"
] | none | 0 | [
{
"input": "abacaba",
"output": "Too weak"
},
{
"input": "X12345",
"output": "Too weak"
},
{
"input": "CONTEST_is_STARTED!!11",
"output": "Correct"
},
{
"input": "1zA__",
"output": "Correct"
},
{
"input": "1zA_",
"output": "Too weak"
},
{
"input": "zA_... | 1,697,232,867 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 3 | 46 | 0 | def containsUpper(s):
for c in s:
if c in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
return True
return False
def containsLower(s):
for c in s:
if c in 'abcdefghijklmnopqrstuvwxyz':
return True
return False
def containsDigit(s):
for c in s:
if c in '0123456789':
... | Title: Password Check
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You have probably registered on Internet sites many times. And each time you should enter your invented password. Usually the registration form automatically checks the password's crypt resistance. If the user's password... | ```python
def containsUpper(s):
for c in s:
if c in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
return True
return False
def containsLower(s):
for c in s:
if c in 'abcdefghijklmnopqrstuvwxyz':
return True
return False
def containsDigit(s):
for c in s:
if c in '012... | 0 | |
1,003 | F | Abbreviation | PROGRAMMING | 2,200 | [
"dp",
"hashing",
"strings"
] | null | null | You are given a text consisting of $n$ space-separated words. There is exactly one space character between any pair of adjacent words. There are no spaces before the first word and no spaces after the last word. The length of text is the number of letters and spaces in it. $w_i$ is the $i$-th word of text. All words co... | The first line of the input contains one integer $n$ ($1 \le n \le 300$) — the number of words in the text.
The next line contains $n$ space-separated words of the text $w_1, w_2, \dots, w_n$. Each word consists only of lowercase Latin letters.
It is guaranteed that the length of text does not exceed $10^5$. | Print one integer — the minimum length of the text after at most one abbreviation. | [
"6\nto be or not to be\n",
"10\na ab a a b ab a a b c\n",
"6\naa bb aa aa bb bb\n"
] | [
"12\n",
"13\n",
"11\n"
] | In the first example you can obtain the text "TB or not TB".
In the second example you can obtain the text "a AAAB AAAB c".
In the third example you can obtain the text "AB aa AB bb". | 0 | [
{
"input": "6\nto be or not to be",
"output": "12"
},
{
"input": "10\na ab a a b ab a a b c",
"output": "13"
},
{
"input": "6\naa bb aa aa bb bb",
"output": "11"
},
{
"input": "45\nxr l pl sx c c u py sv j f x h u y w w bs u cp e ad ib b tz gy lm e s n ln kg fs rd ln v f sh t... | 1,594,154,519 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 3 | 140 | 22,118,400 | # Author: S Mahesh Raju
# Username: maheshraju2020
# Date: 07/07/2020
from sys import stdin,stdout
from math import gcd, ceil, sqrt
from collections import Counter
ii1 = lambda: int(stdin.readline().strip())
is1 = lambda: stdin.readline().strip()
iia = lambda: list(map(int, stdin.readline().strip().split()))
... | Title: Abbreviation
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given a text consisting of $n$ space-separated words. There is exactly one space character between any pair of adjacent words. There are no spaces before the first word and no spaces after the last word. The length... | ```python
# Author: S Mahesh Raju
# Username: maheshraju2020
# Date: 07/07/2020
from sys import stdin,stdout
from math import gcd, ceil, sqrt
from collections import Counter
ii1 = lambda: int(stdin.readline().strip())
is1 = lambda: stdin.readline().strip()
iia = lambda: list(map(int, stdin.readline().strip().... | 0 | |
226 | A | Flying Saucer Segments | PROGRAMMING | 1,400 | [
"math"
] | null | null | An expedition group flew from planet ACM-1 to Earth in order to study the bipedal species (its representatives don't even have antennas on their heads!).
The flying saucer, on which the brave pioneers set off, consists of three sections. These sections are connected by a chain: the 1-st section is adjacent only to the... | The first line contains two space-separated integers: *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=109) — the number of aliens on the saucer and the number, modulo which you should print the answer, correspondingly. | Print a single number — the answer to the problem modulo *m*. | [
"1 10\n",
"3 8\n"
] | [
"2\n",
"2\n"
] | In the first sample the only crew member moves from segment 3 to segment 2, and then from segment 2 to segment 1 without any problems. Thus, the whole moving will take two minutes.
To briefly describe the movements in the second sample we will use value <img align="middle" class="tex-formula" src="https://espresso.cod... | 500 | [
{
"input": "1 10",
"output": "2"
},
{
"input": "3 8",
"output": "2"
},
{
"input": "8 12",
"output": "8"
},
{
"input": "4 84",
"output": "80"
},
{
"input": "9 95",
"output": "17"
},
{
"input": "331358794 820674098",
"output": "2619146"
},
{
... | 1,564,056,651 | 2,147,483,647 | Python 3 | OK | TESTS | 78 | 248 | 0 | # -*- coding: utf-8 -*-
"""
Created on Tue Jul 16 19:44:48 2019
@author: asus
"""
def pows(a,b,mod):
ret = 1;
while(b):
if(b & 1):
ret = (ret * a) % mod
a = (a * a) % mod
b >>= 1
return ret;
if __name__ == '__main__':
n,m=map(int,input().split())
k=(pows(3,n,m)%m-1+m)... | Title: Flying Saucer Segments
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
An expedition group flew from planet ACM-1 to Earth in order to study the bipedal species (its representatives don't even have antennas on their heads!).
The flying saucer, on which the brave pioneers set off, c... | ```python
# -*- coding: utf-8 -*-
"""
Created on Tue Jul 16 19:44:48 2019
@author: asus
"""
def pows(a,b,mod):
ret = 1;
while(b):
if(b & 1):
ret = (ret * a) % mod
a = (a * a) % mod
b >>= 1
return ret;
if __name__ == '__main__':
n,m=map(int,input().split())
k=(pows(3,n... | 3 | |
691 | A | Fashion in Berland | PROGRAMMING | 1,000 | [
"implementation"
] | null | null | According to rules of the Berland fashion, a jacket should be fastened by all the buttons except only one, but not necessarily it should be the last one. Also if the jacket has only one button, it should be fastened, so the jacket will not swinging open.
You are given a jacket with *n* buttons. Determine if it is fast... | The first line contains integer *n* (1<=≤<=*n*<=≤<=1000) — the number of buttons on the jacket.
The second line contains *n* integers *a**i* (0<=≤<=*a**i*<=≤<=1). The number *a**i*<==<=0 if the *i*-th button is not fastened. Otherwise *a**i*<==<=1. | In the only line print the word "YES" if the jacket is fastened in a right way. Otherwise print the word "NO". | [
"3\n1 0 1\n",
"3\n1 0 0\n"
] | [
"YES\n",
"NO\n"
] | none | 0 | [
{
"input": "3\n1 0 1",
"output": "YES"
},
{
"input": "3\n1 0 0",
"output": "NO"
},
{
"input": "3\n1 1 0",
"output": "YES"
},
{
"input": "3\n1 1 1",
"output": "NO"
},
{
"input": "3\n0 0 1",
"output": "NO"
},
{
"input": "3\n0 0 0",
"output": "NO"
}... | 1,568,208,759 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 3 | 108 | 0 | n = int(input())
l = list(map(int,input().split()))
zeros = l.count(0)
if zeros == 1:
if n == 1:
print("NO")
else:
print("YES")
elif zeros == 0:
print("YES")
else:
print("NO") | Title: Fashion in Berland
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
According to rules of the Berland fashion, a jacket should be fastened by all the buttons except only one, but not necessarily it should be the last one. Also if the jacket has only one button, it should be fastened,... | ```python
n = int(input())
l = list(map(int,input().split()))
zeros = l.count(0)
if zeros == 1:
if n == 1:
print("NO")
else:
print("YES")
elif zeros == 0:
print("YES")
else:
print("NO")
``` | 0 | |
220 | A | Little Elephant and Problem | PROGRAMMING | 1,300 | [
"implementation",
"sortings"
] | null | null | The Little Elephant has got a problem — somebody has been touching his sorted by non-decreasing array *a* of length *n* and possibly swapped some elements of the array.
The Little Elephant doesn't want to call the police until he understands if he could have accidentally changed the array himself. He thinks that he co... | The first line contains a single integer *n* (2<=≤<=*n*<=≤<=105) — the size of array *a*. The next line contains *n* positive integers, separated by single spaces and not exceeding 109, — array *a*.
Note that the elements of the array are not necessarily distinct numbers. | In a single line print "YES" (without the quotes) if the Little Elephant could have accidentally changed the array himself, and "NO" (without the quotes) otherwise. | [
"2\n1 2\n",
"3\n3 2 1\n",
"4\n4 3 2 1\n"
] | [
"YES\n",
"YES\n",
"NO\n"
] | In the first sample the array has already been sorted, so to sort it, we need 0 swap operations, that is not more than 1. Thus, the answer is "YES".
In the second sample we can sort the array if we swap elements 1 and 3, so we need 1 swap operation to sort the array. Thus, the answer is "YES".
In the third sample we ... | 500 | [
{
"input": "2\n1 2",
"output": "YES"
},
{
"input": "3\n3 2 1",
"output": "YES"
},
{
"input": "4\n4 3 2 1",
"output": "NO"
},
{
"input": "3\n1 3 2",
"output": "YES"
},
{
"input": "2\n2 1",
"output": "YES"
},
{
"input": "9\n7 7 8 8 10 10 10 10 1000000000... | 1,585,910,812 | 2,147,483,647 | Python 3 | OK | TESTS | 96 | 171 | 8,192,000 | n = int(input())
nums = [int(i) for i in input().split()]
snums = sorted(nums)
l = len(nums)
count = 0
for i in range(n):
if nums[i] != snums[i]:
count += 1
if count > 2:
print("NO")
break
else:
print("YES")
| Title: Little Elephant and Problem
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The Little Elephant has got a problem — somebody has been touching his sorted by non-decreasing array *a* of length *n* and possibly swapped some elements of the array.
The Little Elephant doesn't want to c... | ```python
n = int(input())
nums = [int(i) for i in input().split()]
snums = sorted(nums)
l = len(nums)
count = 0
for i in range(n):
if nums[i] != snums[i]:
count += 1
if count > 2:
print("NO")
break
else:
print("YES")
``` | 3 | |
975 | C | Valhalla Siege | PROGRAMMING | 1,400 | [
"binary search"
] | null | null | Ivar the Boneless is a great leader. He is trying to capture Kattegat from Lagertha. The war has begun and wave after wave Ivar's warriors are falling in battle.
Ivar has $n$ warriors, he places them on a straight line in front of the main gate, in a way that the $i$-th warrior stands right after $(i-1)$-th warrior. T... | The first line contains two integers $n$ and $q$ ($1 \le n, q \leq 200\,000$) — the number of warriors and the number of minutes in the battle.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \leq a_i \leq 10^9$) that represent the warriors' strengths.
The third line contains $q$ integers $k_1, k_2,... | Output $q$ lines, the $i$-th of them is the number of standing warriors after the $i$-th minute. | [
"5 5\n1 2 1 2 1\n3 10 1 1 1\n",
"4 4\n1 2 3 4\n9 1 10 6\n"
] | [
"3\n5\n4\n4\n3\n",
"1\n4\n4\n1\n"
] | In the first example:
- after the 1-st minute, the 1-st and 2-nd warriors die. - after the 2-nd minute all warriors die (and all arrows left over are wasted), then they will be revived thus answer is 5 — all warriors are alive. - after the 3-rd minute, the 1-st warrior dies. - after the 4-th minute, the 2-nd warr... | 1,500 | [
{
"input": "5 5\n1 2 1 2 1\n3 10 1 1 1",
"output": "3\n5\n4\n4\n3"
},
{
"input": "4 4\n1 2 3 4\n9 1 10 6",
"output": "1\n4\n4\n1"
},
{
"input": "10 3\n1 1 1 1 1 1 1 1 1 1\n10 10 5",
"output": "10\n10\n5"
},
{
"input": "1 1\n56563128\n897699770",
"output": "1"
},
{
... | 1,525,185,579 | 2,079 | Python 3 | OK | TESTS | 35 | 1,294 | 35,020,800 | import sys
import math
import bisect
import itertools
n,q = list(map(int,sys.stdin.readline().strip().split(' ')))
a = list(map(int,sys.stdin.readline().strip().split(' ')))
prefix_sum = list(itertools.accumulate(a))
k = list(map(int,sys.stdin.readline().strip().split(' ')))
k_sum = 0
for q0 in range(q):
k_sum += k[... | Title: Valhalla Siege
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Ivar the Boneless is a great leader. He is trying to capture Kattegat from Lagertha. The war has begun and wave after wave Ivar's warriors are falling in battle.
Ivar has $n$ warriors, he places them on a straight line ... | ```python
import sys
import math
import bisect
import itertools
n,q = list(map(int,sys.stdin.readline().strip().split(' ')))
a = list(map(int,sys.stdin.readline().strip().split(' ')))
prefix_sum = list(itertools.accumulate(a))
k = list(map(int,sys.stdin.readline().strip().split(' ')))
k_sum = 0
for q0 in range(q):
k... | 3 | |
0 | none | none | none | 0 | [
"none"
] | null | null | Oleg writes down the history of the days he lived. For each day he decides if it was good or bad. Oleg calls a non-empty sequence of days a zebra, if it starts with a bad day, ends with a bad day, and good and bad days are alternating in it. Let us denote bad days as 0 and good days as 1. Then, for example, sequences o... | In the only line of input data there is a non-empty string *s* consisting of characters 0 and 1, which describes the history of Oleg's life. Its length (denoted as |*s*|) does not exceed 200<=000 characters. | If there is a way to divide history into zebra subsequences, in the first line of output you should print an integer *k* (1<=≤<=*k*<=≤<=|*s*|), the resulting number of subsequences. In the *i*-th of following *k* lines first print the integer *l**i* (1<=≤<=*l**i*<=≤<=|*s*|), which is the length of the *i*-th subsequenc... | [
"0010100\n",
"111\n"
] | [
"3\n3 1 3 4\n3 2 5 6\n1 7\n",
"-1\n"
] | none | 0 | [
{
"input": "0010100",
"output": "3\n1 1\n5 2 3 4 5 6\n1 7"
},
{
"input": "111",
"output": "-1"
},
{
"input": "0",
"output": "1\n1 1"
},
{
"input": "1",
"output": "-1"
},
{
"input": "0101010101",
"output": "-1"
},
{
"input": "010100001",
"output": "... | 1,684,732,055 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 15 | 307,200 | from collections import deque
def solve():
s = input().strip()
n = len(s)
bad = deque()
good = deque()
zebra = [[] for _ in range(n)]
for i, c in enumerate(s):
if c == '0':
if len(good) > 0:
z = good.pop()
zebra[z].append(i+1)
... | Title: none
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Oleg writes down the history of the days he lived. For each day he decides if it was good or bad. Oleg calls a non-empty sequence of days a zebra, if it starts with a bad day, ends with a bad day, and good and bad days are alterna... | ```python
from collections import deque
def solve():
s = input().strip()
n = len(s)
bad = deque()
good = deque()
zebra = [[] for _ in range(n)]
for i, c in enumerate(s):
if c == '0':
if len(good) > 0:
z = good.pop()
zebra[z].ap... | 0 | |
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,613,590,224 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 1 | 186 | 0 | import sys
arr = list(map(int, sys.stdin.readline().rstrip().split(" ")))
t = arr[0]
c = arr[1]
tr = list()
while t > 0:
arr2 = list(map(int, sys.stdin.readline().rstrip().split(" ")))
#print(arr2)
l = len(arr2)
for i in range(0, l):
tr.append(arr2[i])
t = t-1
l2 = len(tr)
mx = 0
mi = 0
for ... | 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
import sys
arr = list(map(int, sys.stdin.readline().rstrip().split(" ")))
t = arr[0]
c = arr[1]
tr = list()
while t > 0:
arr2 = list(map(int, sys.stdin.readline().rstrip().split(" ")))
#print(arr2)
l = len(arr2)
for i in range(0, l):
tr.append(arr2[i])
t = t-1
l2 = len(tr)
mx = 0
m... | 0 |
242 | D | Dispute | PROGRAMMING | 2,100 | [
"dfs and similar",
"graphs",
"greedy"
] | null | null | Valera has *n* counters numbered from 1 to *n*. Some of them are connected by wires, and each of the counters has a special button.
Initially, all the counters contain number 0. When you press a button on a certain counter, the value it has increases by one. Also, the values recorded in all the counters, directly conn... | The first line contains two space-separated integers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=105), that denote the number of counters Valera has and the number of pairs of counters connected by wires.
Each of the following *m* lines contains two space-separated integers *u**i* and *v**i* (1<=≤<=*u**i*,<=*v**i*<=≤<=*n*,<=*u**... | If Valera can't win the dispute print in the first line -1.
Otherwise, print in the first line integer *k* (0<=≤<=*k*<=≤<=*n*). In the second line print *k* distinct space-separated integers — the numbers of the counters, where Valera should push buttons to win the dispute, in arbitrary order.
If there exists multipl... | [
"5 5\n2 3\n4 1\n1 5\n5 3\n2 1\n1 1 2 0 2\n",
"4 2\n1 2\n3 4\n0 0 0 0\n"
] | [
"2\n1 2\n",
"3\n1 3 4\n"
] | none | 2,000 | [
{
"input": "5 5\n2 3\n4 1\n1 5\n5 3\n2 1\n1 1 2 0 2",
"output": "2\n1 2"
},
{
"input": "4 2\n1 2\n3 4\n0 0 0 0",
"output": "3\n1 3 4"
},
{
"input": "3 3\n2 3\n1 3\n1 2\n1 1 3",
"output": "0"
},
{
"input": "4 6\n3 4\n2 3\n2 4\n1 2\n1 3\n4 1\n4 0 2 3",
"output": "1\n2 "
}... | 1,605,386,412 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 248 | 921,600 | from queue import Queue
n,m = map(int,input().split())
e = [[]for i in range(n+1)]
b = [0]*n
for i in range(m):
u,v = map(int,input().split())
e[u-1].append(v-1)
e[v-1].append(u-1)
ans = 0
q = Queue()
a = input().split()
ai = [-1]*n
c=0
mask = [False]*n
for i in a:
inti = int(i)
ai[c... | Title: Dispute
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Valera has *n* counters numbered from 1 to *n*. Some of them are connected by wires, and each of the counters has a special button.
Initially, all the counters contain number 0. When you press a button on a certain counter, th... | ```python
from queue import Queue
n,m = map(int,input().split())
e = [[]for i in range(n+1)]
b = [0]*n
for i in range(m):
u,v = map(int,input().split())
e[u-1].append(v-1)
e[v-1].append(u-1)
ans = 0
q = Queue()
a = input().split()
ai = [-1]*n
c=0
mask = [False]*n
for i in a:
inti = int(i)... | 0 | |
876 | A | Trip For Meal | PROGRAMMING | 900 | [
"math"
] | null | null | Winnie-the-Pooh likes honey very much! That is why he decided to visit his friends. Winnie has got three best friends: Rabbit, Owl and Eeyore, each of them lives in his own house. There are winding paths between each pair of houses. The length of a path between Rabbit's and Owl's houses is *a* meters, between Rabbit's ... | First line contains an integer *n* (1<=≤<=*n*<=≤<=100) — number of visits.
Second line contains an integer *a* (1<=≤<=*a*<=≤<=100) — distance between Rabbit's and Owl's houses.
Third line contains an integer *b* (1<=≤<=*b*<=≤<=100) — distance between Rabbit's and Eeyore's houses.
Fourth line contains an integer *c* ... | Output one number — minimum distance in meters Winnie must go through to have a meal *n* times. | [
"3\n2\n3\n1\n",
"1\n2\n3\n5\n"
] | [
"3\n",
"0\n"
] | In the first test case the optimal path for Winnie is the following: first have a meal in Rabbit's house, then in Owl's house, then in Eeyore's house. Thus he will pass the distance 2 + 1 = 3.
In the second test case Winnie has a meal in Rabbit's house and that is for him. So he doesn't have to walk anywhere at all. | 500 | [
{
"input": "3\n2\n3\n1",
"output": "3"
},
{
"input": "1\n2\n3\n5",
"output": "0"
},
{
"input": "10\n1\n8\n3",
"output": "9"
},
{
"input": "7\n10\n5\n6",
"output": "30"
},
{
"input": "9\n9\n7\n5",
"output": "42"
},
{
"input": "9\n37\n85\n76",
"outpu... | 1,509,011,260 | 2,147,483,647 | Python 3 | OK | TESTS | 48 | 62 | 0 |
n = int(input())
a = int(input())
b = int(input())
c = int(input())
mx = max(a, b, c)
mn = min(a, b, c)
print(0 if n == 1 else min(a, b) + (n - 2) * mn)
| Title: Trip For Meal
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Winnie-the-Pooh likes honey very much! That is why he decided to visit his friends. Winnie has got three best friends: Rabbit, Owl and Eeyore, each of them lives in his own house. There are winding paths between each pair... | ```python
n = int(input())
a = int(input())
b = int(input())
c = int(input())
mx = max(a, b, c)
mn = min(a, b, c)
print(0 if n == 1 else min(a, b) + (n - 2) * mn)
``` | 3 | |
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,565,602,629 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 6 | 109 | 0 | a,b,c,d=map(int,input().split())
p1=a-((a/250)*c)
p2=b-((b/250)*d)
if(p1>p2):
print("Misha")
elif(p1==p2):
print("Tie")
elif(p2>p1):
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
a,b,c,d=map(int,input().split())
p1=a-((a/250)*c)
p2=b-((b/250)*d)
if(p1>p2):
print("Misha")
elif(p1==p2):
print("Tie")
elif(p2>p1):
print("Vasya")
``` | 0 | |
957 | A | Tritonic Iridescence | PROGRAMMING | 1,300 | [
"implementation"
] | null | null | Overlooking the captivating blend of myriads of vernal hues, Arkady the painter lays out a long, long canvas.
Arkady has a sufficiently large amount of paint of three colours: cyan, magenta, and yellow. On the one-dimensional canvas split into *n* consecutive segments, each segment needs to be painted in one of the co... | The first line contains a single positive integer *n* (1<=≤<=*n*<=≤<=100) — the length of the canvas.
The second line contains a string *s* of *n* characters, the *i*-th of which is either 'C' (denoting a segment painted in cyan), 'M' (denoting one painted in magenta), 'Y' (one painted in yellow), or '?' (an unpainted... | If there are at least two different ways of painting, output "Yes"; otherwise output "No" (both without quotes).
You can print each character in any case (upper or lower). | [
"5\nCY??Y\n",
"5\nC?C?Y\n",
"5\n?CYC?\n",
"5\nC??MM\n",
"3\nMMY\n"
] | [
"Yes\n",
"Yes\n",
"Yes\n",
"No\n",
"No\n"
] | For the first example, there are exactly two different ways of colouring: CYCMY and CYMCY.
For the second example, there are also exactly two different ways of colouring: CMCMY and CYCMY.
For the third example, there are four ways of colouring: MCYCM, MCYCY, YCYCM, and YCYCY.
For the fourth example, no matter how th... | 500 | [
{
"input": "5\nCY??Y",
"output": "Yes"
},
{
"input": "5\nC?C?Y",
"output": "Yes"
},
{
"input": "5\n?CYC?",
"output": "Yes"
},
{
"input": "5\nC??MM",
"output": "No"
},
{
"input": "3\nMMY",
"output": "No"
},
{
"input": "15\n??YYYYYY??YYYY?",
"output"... | 1,621,257,873 | 2,147,483,647 | PyPy 3 | TIME_LIMIT_EXCEEDED | TESTS | 25 | 1,000 | 10,240,000 | def bf(i,x):
global r
if i < len(l):
if x != kk:
if l[i] == "?":
for c in "CYM":
if l[i-1] != c and l[i] != c:
l[i]=c
bf(i+1,x+1)
l[i]="?"
else:
... | Title: Tritonic Iridescence
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Overlooking the captivating blend of myriads of vernal hues, Arkady the painter lays out a long, long canvas.
Arkady has a sufficiently large amount of paint of three colours: cyan, magenta, and yellow. On the one... | ```python
def bf(i,x):
global r
if i < len(l):
if x != kk:
if l[i] == "?":
for c in "CYM":
if l[i-1] != c and l[i] != c:
l[i]=c
bf(i+1,x+1)
l[i]="?"
else:
... | 0 | |
856 | A | Set Theory | PROGRAMMING | 1,600 | [
"brute force",
"constructive algorithms"
] | null | null | Masha and Grisha like studying sets of positive integers.
One day Grisha has written a set *A* containing *n* different integers *a**i* on a blackboard. Now he asks Masha to create a set *B* containing *n* different integers *b**j* such that all *n*2 integers that can be obtained by summing up *a**i* and *b**j* for al... | Input data contains multiple test cases. The first line contains an integer *t* — the number of test cases (1<=≤<=*t*<=≤<=100).
Each test case is described in the following way: the first line of the description contains one integer *n* — the number of elements in *A* (1<=≤<=*n*<=≤<=100).
The second line contains *n*... | For each test first print the answer:
- NO, if Masha's task is impossible to solve, there is no way to create the required set *B*. - YES, if there is the way to create the required set. In this case the second line must contain *n* different positive integers *b**j* — elements of *B* (1<=≤<=*b**j*<=≤<=106). If the... | [
"3\n3\n1 10 100\n1\n1\n2\n2 4\n"
] | [
"YES\n1 2 3 \nYES\n1 \nYES\n1 2 \n"
] | none | 0 | [
{
"input": "3\n3\n1 10 100\n1\n1\n2\n2 4",
"output": "YES\n1 2 3 \nYES\n1 \nYES\n1 2 "
},
{
"input": "1\n100\n74 14 24 45 22 9 49 78 79 20 60 1 31 91 32 39 90 5 42 57 30 58 64 68 12 11 86 8 3 38 76 17 98 26 85 92 56 65 89 66 36 87 23 67 13 48 15 47 81 73 63 50 34 93 82 44 77 69 96 100 41 19 35 16 88... | 1,656,079,424 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 30 | 0 | #!/usr/bin/python3
def main():
with open("input.txt", "r") as file:
n = int(file.readline().strip())
max_square = 0
state = [0] * n
for i in range(n):
counter = 0
for j, e in enumerate(file.readline().strip()):
if e != "#":
... | Title: Set Theory
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Masha and Grisha like studying sets of positive integers.
One day Grisha has written a set *A* containing *n* different integers *a**i* on a blackboard. Now he asks Masha to create a set *B* containing *n* different integer... | ```python
#!/usr/bin/python3
def main():
with open("input.txt", "r") as file:
n = int(file.readline().strip())
max_square = 0
state = [0] * n
for i in range(n):
counter = 0
for j, e in enumerate(file.readline().strip()):
if e != "#":
... | -1 | |
991 | B | Getting an A | PROGRAMMING | 900 | [
"greedy",
"sortings"
] | null | null | Translator's note: in Russia's most widespread grading system, there are four grades: 5, 4, 3, 2, the higher the better, roughly corresponding to A, B, C and F respectively in American grading system.
The term is coming to an end and students start thinking about their grades. Today, a professor told his students that... | The first line contains a single integer $n$ — the number of Vasya's grades ($1 \leq n \leq 100$).
The second line contains $n$ integers from $2$ to $5$ — Vasya's grades for his lab works. | Output a single integer — the minimum amount of lab works that Vasya has to redo. It can be shown that Vasya can always redo enough lab works to get a $5$. | [
"3\n4 4 4\n",
"4\n5 4 5 5\n",
"4\n5 3 3 5\n"
] | [
"2\n",
"0\n",
"1\n"
] | In the first sample, it is enough to redo two lab works to make two $4$s into $5$s.
In the second sample, Vasya's average is already $4.75$ so he doesn't have to redo anything to get a $5$.
In the second sample Vasya has to redo one lab work to get rid of one of the $3$s, that will make the average exactly $4.5$ so t... | 1,000 | [
{
"input": "3\n4 4 4",
"output": "2"
},
{
"input": "4\n5 4 5 5",
"output": "0"
},
{
"input": "4\n5 3 3 5",
"output": "1"
},
{
"input": "1\n5",
"output": "0"
},
{
"input": "4\n3 2 5 4",
"output": "2"
},
{
"input": "5\n5 4 3 2 5",
"output": "2"
},
... | 1,628,941,943 | 2,147,483,647 | Python 3 | OK | TESTS | 61 | 77 | 6,963,200 | import math
n=int(input())
l=list(map(int,input().split()))
l.sort()
z=math.ceil(4.5*n)
z1=z-sum(l)
x=0
for i in range(n):
if z1>0:
z1=z1-(5-l[i])
l[i]=5
x+=1
else:
break
print(x) | Title: Getting an A
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Translator's note: in Russia's most widespread grading system, there are four grades: 5, 4, 3, 2, the higher the better, roughly corresponding to A, B, C and F respectively in American grading system.
The term is coming t... | ```python
import math
n=int(input())
l=list(map(int,input().split()))
l.sort()
z=math.ceil(4.5*n)
z1=z-sum(l)
x=0
for i in range(n):
if z1>0:
z1=z1-(5-l[i])
l[i]=5
x+=1
else:
break
print(x)
``` | 3 | |
833 | A | The Meaningless Game | PROGRAMMING | 1,700 | [
"math",
"number theory"
] | null | null | Slastyona and her loyal dog Pushok are playing a meaningless game that is indeed very interesting.
The game consists of multiple rounds. Its rules are very simple: in each round, a natural number *k* is chosen. Then, the one who says (or barks) it faster than the other wins the round. After that, the winner's score is... | In the first string, the number of games *n* (1<=≤<=*n*<=≤<=350000) is given.
Each game is represented by a pair of scores *a*, *b* (1<=≤<=*a*,<=*b*<=≤<=109) – the results of Slastyona and Pushok, correspondingly. | For each pair of scores, answer "Yes" if it's possible for a game to finish with given score, and "No" otherwise.
You can output each letter in arbitrary case (upper or lower). | [
"6\n2 4\n75 45\n8 8\n16 16\n247 994\n1000000000 1000000\n"
] | [
"Yes\nYes\nYes\nNo\nNo\nYes\n"
] | First game might have been consisted of one round, in which the number 2 would have been chosen and Pushok would have won.
The second game needs exactly two rounds to finish with such result: in the first one, Slastyona would have said the number 5, and in the second one, Pushok would have barked the number 3. | 500 | [
{
"input": "6\n2 4\n75 45\n8 8\n16 16\n247 994\n1000000000 1000000",
"output": "Yes\nYes\nYes\nNo\nNo\nYes"
},
{
"input": "3\n1 1\n8 27\n1000 1331",
"output": "Yes\nNo\nNo"
},
{
"input": "1\n12004 18012002",
"output": "Yes"
},
{
"input": "1\n3331 11095561",
"output": "Yes... | 1,676,979,022 | 2,147,483,647 | PyPy 3 | TIME_LIMIT_EXCEEDED | TESTS | 7 | 1,000 | 12,288,000 | def GCD(a,b):
if a<b:
a,b=b,a
if b==0:
return a
return GCD(b,a%b)
def ss(a,b):
l=GCD(a,b)
r=(a//l)*(b//l)
x=l//r
p=1
while p*p*p<=x:
if p*p*p==x:
return "Yes"
p+=1
return "No"
for _ in range(int(in... | Title: The Meaningless Game
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Slastyona and her loyal dog Pushok are playing a meaningless game that is indeed very interesting.
The game consists of multiple rounds. Its rules are very simple: in each round, a natural number *k* is chosen. Th... | ```python
def GCD(a,b):
if a<b:
a,b=b,a
if b==0:
return a
return GCD(b,a%b)
def ss(a,b):
l=GCD(a,b)
r=(a//l)*(b//l)
x=l//r
p=1
while p*p*p<=x:
if p*p*p==x:
return "Yes"
p+=1
return "No"
for _ in ra... | 0 | |
770 | A | New Password | PROGRAMMING | 800 | [
"*special",
"implementation"
] | null | null | Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help.
Innokentiy decides that new password should satisfy the following conditions:
- the length of the password must be equal to *n*, - the password should cons... | The first line contains two positive integers *n* and *k* (2<=≤<=*n*<=≤<=100, 2<=≤<=*k*<=≤<=*min*(*n*,<=26)) — the length of the password and the number of distinct symbols in it.
Pay attention that a desired new password always exists. | Print any password which satisfies all conditions given by Innokentiy. | [
"4 3\n",
"6 6\n",
"5 2\n"
] | [
"java\n",
"python\n",
"phphp\n"
] | In the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.
In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letter... | 500 | [
{
"input": "4 3",
"output": "abca"
},
{
"input": "6 6",
"output": "abcdef"
},
{
"input": "5 2",
"output": "ababa"
},
{
"input": "3 2",
"output": "aba"
},
{
"input": "10 2",
"output": "ababababab"
},
{
"input": "26 13",
"output": "abcdefghijklmabcde... | 1,648,041,531 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 46 | 409,600 | import string
import random
n, k = list(map(int, input().strip().split()))[:2]
letters = list(string.ascii_lowercase)
password = []
while len(set(password)) != k:
password = ''.join(random.choice(letters) for i in range(n))
print(password) | Title: New Password
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help.
Innokentiy decides that new password should satisfy the foll... | ```python
import string
import random
n, k = list(map(int, input().strip().split()))[:2]
letters = list(string.ascii_lowercase)
password = []
while len(set(password)) != k:
password = ''.join(random.choice(letters) for i in range(n))
print(password)
``` | 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,671,907 | 3,807 | Python 3 | OK | TESTS | 31 | 62 | 102,400 | n,h=map(int,input().split())
ss=h/2
H=[0]*n
for i in range(n):
x=ss/n
k=(x*(i+1)/ss)**(1/2)
H[i]=x*(i+1)/k*2
for i in range(n-1):
print(H[i],end=" ") | 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,h=map(int,input().split())
ss=h/2
H=[0]*n
for i in range(n):
x=ss/n
k=(x*(i+1)/ss)**(1/2)
H[i]=x*(i+1)/k*2
for i in range(n-1):
print(H[i],end=" ")
``` | 3 | |
486 | B | OR in Matrix | PROGRAMMING | 1,300 | [
"greedy",
"hashing",
"implementation"
] | null | null | Let's define logical *OR* as an operation on two logical values (i. e. values that belong to the set {0,<=1}) that is equal to 1 if either or both of the logical values is set to 1, otherwise it is 0. We can define logical *OR* of three or more logical values in the same manner:
where is equal to 1 if some *a**i*<==... | The first line contains two integer *m* and *n* (1<=≤<=*m*,<=*n*<=≤<=100), number of rows and number of columns of matrices respectively.
The next *m* lines each contain *n* integers separated by spaces describing rows of matrix *B* (each element of *B* is either 0 or 1). | In the first line, print "NO" if Nam has made a mistake when calculating *B*, otherwise print "YES". If the first line is "YES", then also print *m* rows consisting of *n* integers representing matrix *A* that can produce given matrix *B*. If there are several solutions print any one. | [
"2 2\n1 0\n0 0\n",
"2 3\n1 1 1\n1 1 1\n",
"2 3\n0 1 0\n1 1 1\n"
] | [
"NO\n",
"YES\n1 1 1\n1 1 1\n",
"YES\n0 0 0\n0 1 0\n"
] | none | 1,000 | [
{
"input": "2 2\n1 0\n0 0",
"output": "NO"
},
{
"input": "2 3\n1 1 1\n1 1 1",
"output": "YES\n1 1 1\n1 1 1"
},
{
"input": "2 3\n0 1 0\n1 1 1",
"output": "YES\n0 0 0\n0 1 0"
},
{
"input": "5 5\n1 1 1 1 1\n1 0 0 0 0\n1 0 0 0 0\n1 0 0 0 0\n1 0 0 0 0",
"output": "YES\n1 0 0 0... | 1,695,254,937 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 2 | 46 | 0 | l1 = input()
m,n = int(l1.split()[0]), int(l1.split()[1])
B = []
for i in range(m):
row = [int(x) for x in input().split()]
B.append(row)
A = [[-1]*n for i in range(m)]
visit_r = set()
visit_c = set()
for r in range(m):
for c in range(n):
if B[r][c] == 0 and r not in visit_r and c... | Title: OR in Matrix
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Let's define logical *OR* as an operation on two logical values (i. e. values that belong to the set {0,<=1}) that is equal to 1 if either or both of the logical values is set to 1, otherwise it is 0. We can define logical... | ```python
l1 = input()
m,n = int(l1.split()[0]), int(l1.split()[1])
B = []
for i in range(m):
row = [int(x) for x in input().split()]
B.append(row)
A = [[-1]*n for i in range(m)]
visit_r = set()
visit_c = set()
for r in range(m):
for c in range(n):
if B[r][c] == 0 and r not in vis... | 0 | |
275 | A | Lights Out | PROGRAMMING | 900 | [
"implementation"
] | null | null | Lenny is playing a game on a 3<=×<=3 grid of lights. In the beginning of the game all lights are switched on. Pressing any of the lights will toggle it and all side-adjacent lights. The goal of the game is to switch all the lights off. We consider the toggling as follows: if the light was switched on then it will be sw... | The input consists of three rows. Each row contains three integers each between 0 to 100 inclusive. The *j*-th number in the *i*-th row is the number of times the *j*-th light of the *i*-th row of the grid is pressed. | Print three lines, each containing three characters. The *j*-th character of the *i*-th line is "1" if and only if the corresponding light is switched on, otherwise it's "0". | [
"1 0 0\n0 0 0\n0 0 1\n",
"1 0 1\n8 8 8\n2 0 3\n"
] | [
"001\n010\n100\n",
"010\n011\n100\n"
] | none | 500 | [
{
"input": "1 0 0\n0 0 0\n0 0 1",
"output": "001\n010\n100"
},
{
"input": "1 0 1\n8 8 8\n2 0 3",
"output": "010\n011\n100"
},
{
"input": "13 85 77\n25 50 45\n65 79 9",
"output": "000\n010\n000"
},
{
"input": "96 95 5\n8 84 74\n67 31 61",
"output": "011\n011\n101"
},
{... | 1,669,831,578 | 2,147,483,647 | Python 3 | OK | TESTS | 33 | 46 | 0 | mat=[]
for _ in range(3):
arr=list(map(int,(input().split())))
mat.append(arr)
lights=[[1]*3 for _ in range(3)]
for i in range(3):
for j in range(3):
x=mat[i][j]
x+=mat[i-1][j] if i-1>=0 else 0
x+=mat[i+1][j] if i+1<3 else 0
x+=mat[i][j-1] if j-1>=0 else 0
... | Title: Lights Out
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Lenny is playing a game on a 3<=×<=3 grid of lights. In the beginning of the game all lights are switched on. Pressing any of the lights will toggle it and all side-adjacent lights. The goal of the game is to switch all the ... | ```python
mat=[]
for _ in range(3):
arr=list(map(int,(input().split())))
mat.append(arr)
lights=[[1]*3 for _ in range(3)]
for i in range(3):
for j in range(3):
x=mat[i][j]
x+=mat[i-1][j] if i-1>=0 else 0
x+=mat[i+1][j] if i+1<3 else 0
x+=mat[i][j-1] if j-1>=0 ... | 3 | |
802 | G | Fake News (easy) | PROGRAMMING | 800 | [
"implementation",
"strings"
] | null | null | As it's the first of April, Heidi is suspecting that the news she reads today are fake, and she does not want to look silly in front of all the contestants. She knows that a newspiece is fake if it contains heidi as a subsequence. Help Heidi assess whether the given piece is true, but please be discreet about it... | The first and only line of input contains a single nonempty string *s* of length at most 1000 composed of lowercase letters (a-z). | Output YES if the string *s* contains heidi as a subsequence and NO otherwise. | [
"abcheaibcdi\n",
"hiedi\n"
] | [
"YES",
"NO"
] | A string *s* contains another string *p* as a subsequence if it is possible to delete some characters from *s* and obtain *p*. | 0 | [
{
"input": "abcheaibcdi",
"output": "YES"
},
{
"input": "hiedi",
"output": "NO"
},
{
"input": "ihied",
"output": "NO"
},
{
"input": "diehi",
"output": "NO"
},
{
"input": "deiih",
"output": "NO"
},
{
"input": "iheid",
"output": "NO"
},
{
"in... | 1,607,681,750 | 2,147,483,647 | Python 3 | OK | TESTS | 58 | 109 | 0 | news=input() #input-abcheaibcdi
def check_subsequence(fakenews):
subsequence = 'heidi'
k = 0
i=0
while i<len(fakenews) and k<len(subsequence):
if fakenews[i]==subsequence[k]:
k += 1
if k==len(subsequence):
return '... | Title: Fake News (easy)
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
As it's the first of April, Heidi is suspecting that the news she reads today are fake, and she does not want to look silly in front of all the contestants. She knows that a newspiece is fake if it contains heidi as a ... | ```python
news=input() #input-abcheaibcdi
def check_subsequence(fakenews):
subsequence = 'heidi'
k = 0
i=0
while i<len(fakenews) and k<len(subsequence):
if fakenews[i]==subsequence[k]:
k += 1
if k==len(subsequence):
... | 3 | |
976 | A | Minimum Binary Number | PROGRAMMING | 800 | [
"implementation"
] | null | null | String can be called correct if it consists of characters "0" and "1" and there are no redundant leading zeroes. Here are some examples: "0", "10", "1001".
You are given a correct string *s*.
You can perform two different operations on this string:
1. swap any pair of adjacent characters (for example, "101" "110"... | The first line contains integer number *n* (1<=≤<=*n*<=≤<=100) — the length of string *s*.
The second line contains the string *s* consisting of characters "0" and "1". It is guaranteed that the string *s* is correct. | Print one string — the minimum correct string that you can obtain from the given one. | [
"4\n1001\n",
"1\n1\n"
] | [
"100\n",
"1\n"
] | In the first example you can obtain the answer by the following sequence of operations: "1001" <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/70a0795f45d32287dba0eb83fc4a3f470c6e5537.png" style="max-width: 100.0%;max-height: 100.0%;"/> "1010" <img align="middle" class="tex-formula" src="ht... | 0 | [
{
"input": "4\n1001",
"output": "100"
},
{
"input": "1\n1",
"output": "1"
},
{
"input": "100\n1110111100001111011111111010110011111111011110000111101101011100110110001011000000101010110101011100",
"output": "1000000000000000000000000000000000000000"
},
{
"input": "100\n100000... | 1,629,885,025 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 6 | 77 | 6,758,400 | print(int(0*input()+'1'+'0'*input().count('0'))) | Title: Minimum Binary Number
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
String can be called correct if it consists of characters "0" and "1" and there are no redundant leading zeroes. Here are some examples: "0", "10", "1001".
You are given a correct string *s*.
You can perform two... | ```python
print(int(0*input()+'1'+'0'*input().count('0')))
``` | 0 | |
831 | A | Unimodal Array | PROGRAMMING | 1,000 | [
"implementation"
] | null | null | Array of integers is unimodal, if:
- it is strictly increasing in the beginning; - after that it is constant; - after that it is strictly decreasing.
The first block (increasing) and the last block (decreasing) may be absent. It is allowed that both of this blocks are absent.
For example, the following three arra... | The first line contains integer *n* (1<=≤<=*n*<=≤<=100) — the number of elements in the array.
The second line contains *n* integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=1<=000) — the elements of the array. | Print "YES" if the given array is unimodal. Otherwise, print "NO".
You can output each letter in any case (upper or lower). | [
"6\n1 5 5 5 4 2\n",
"5\n10 20 30 20 10\n",
"4\n1 2 1 2\n",
"7\n3 3 3 3 3 3 3\n"
] | [
"YES\n",
"YES\n",
"NO\n",
"YES\n"
] | In the first example the array is unimodal, because it is strictly increasing in the beginning (from position 1 to position 2, inclusively), that it is constant (from position 2 to position 4, inclusively) and then it is strictly decreasing (from position 4 to position 6, inclusively). | 500 | [
{
"input": "6\n1 5 5 5 4 2",
"output": "YES"
},
{
"input": "5\n10 20 30 20 10",
"output": "YES"
},
{
"input": "4\n1 2 1 2",
"output": "NO"
},
{
"input": "7\n3 3 3 3 3 3 3",
"output": "YES"
},
{
"input": "6\n5 7 11 11 2 1",
"output": "YES"
},
{
"input":... | 1,641,206,482 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 30 | 0 | inp, lst1 = int(input()), input().split()
lst1 = [int(ch) for ch in lst]
def f(m, n, flag):
if flag == 1:
return m < n
elif flag == 2:
return m == n
else:
return m > n
def is_modal(inp, lst1):
flag = 1
for i in range(1, a):
if f(lst1[i - 1], lst1[i... | Title: Unimodal Array
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Array of integers is unimodal, if:
- it is strictly increasing in the beginning; - after that it is constant; - after that it is strictly decreasing.
The first block (increasing) and the last block (decreasing) may ... | ```python
inp, lst1 = int(input()), input().split()
lst1 = [int(ch) for ch in lst]
def f(m, n, flag):
if flag == 1:
return m < n
elif flag == 2:
return m == n
else:
return m > n
def is_modal(inp, lst1):
flag = 1
for i in range(1, a):
if f(lst1[i - ... | -1 | |
34 | A | Reconnaissance 2 | PROGRAMMING | 800 | [
"implementation"
] | A. Reconnaissance 2 | 2 | 256 | *n* soldiers stand in a circle. For each soldier his height *a**i* is known. A reconnaissance unit can be made of such two neighbouring soldiers, whose heights difference is minimal, i.e. |*a**i*<=-<=*a**j*| is minimal. So each of them will be less noticeable with the other. Output any pair of soldiers that can form a ... | The first line contains integer *n* (2<=≤<=*n*<=≤<=100) — amount of soldiers. Then follow the heights of the soldiers in their order in the circle — *n* space-separated integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=1000). The soldier heights are given in clockwise or counterclockwise direction. | Output two integers — indexes of neighbouring soldiers, who should form a reconnaissance unit. If there are many optimum solutions, output any of them. Remember, that the soldiers stand in a circle. | [
"5\n10 12 13 15 10\n",
"4\n10 20 30 40\n"
] | [
"5 1\n",
"1 2\n"
] | none | 500 | [
{
"input": "5\n10 12 13 15 10",
"output": "5 1"
},
{
"input": "4\n10 20 30 40",
"output": "1 2"
},
{
"input": "6\n744 359 230 586 944 442",
"output": "2 3"
},
{
"input": "5\n826 747 849 687 437",
"output": "1 2"
},
{
"input": "5\n999 999 993 969 999",
"output"... | 1,656,613,977 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 2 | 186 | 512,000 | n=int(input())
a=[int(x)for x in input().split()]
mn=a[n-1]-a[0]
for i in range(n-1):
mn=min(mn,abs(a[i]-a[i+1]))
for i in range(n-1):
if mn==abs(a[i]-a[i+1]):
print(i+1,i+2);break
else:
print(1,n) | Title: Reconnaissance 2
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
*n* soldiers stand in a circle. For each soldier his height *a**i* is known. A reconnaissance unit can be made of such two neighbouring soldiers, whose heights difference is minimal, i.e. |*a**i*<=-<=*a**j*| is minimal. So... | ```python
n=int(input())
a=[int(x)for x in input().split()]
mn=a[n-1]-a[0]
for i in range(n-1):
mn=min(mn,abs(a[i]-a[i+1]))
for i in range(n-1):
if mn==abs(a[i]-a[i+1]):
print(i+1,i+2);break
else:
print(1,n)
``` | 0 |
358 | A | Dima and Continuous Line | PROGRAMMING | 1,400 | [
"brute force",
"implementation"
] | null | null | Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework.
The teacher gave Seryozha the coordinates of *n* distinct points on the abscissa axis and asked to consecutively connect th... | The first line contains a single integer *n* (1<=≤<=*n*<=≤<=103). The second line contains *n* distinct integers *x*1,<=*x*2,<=...,<=*x**n* (<=-<=106<=≤<=*x**i*<=≤<=106) — the *i*-th point has coordinates (*x**i*,<=0). The points are not necessarily sorted by their *x* coordinate. | In the single line print "yes" (without the quotes), if the line has self-intersections. Otherwise, print "no" (without the quotes). | [
"4\n0 10 5 15\n",
"4\n0 15 5 10\n"
] | [
"yes\n",
"no\n"
] | The first test from the statement is on the picture to the left, the second test is on the picture to the right. | 500 | [
{
"input": "4\n0 10 5 15",
"output": "yes"
},
{
"input": "4\n0 15 5 10",
"output": "no"
},
{
"input": "5\n0 1000 2000 3000 1500",
"output": "yes"
},
{
"input": "5\n-724093 710736 -383722 -359011 439613",
"output": "no"
},
{
"input": "50\n384672 661179 -775591 -989... | 1,470,816,519 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 14 | 46 | 4,608,000 | n = int(input())
c = list(map(int, input().split()))
intersection = False
for i in range(n - 1):
min1 = min(c[i], c[i + 1])
max1 = max(c[i], c[i + 1])
for j in range(i + 1, n - 1):
min2 = min(c[j], c[j + 1])
max2 = max(c[j], c[j + 1])
if (min2 > min1 and min2 < max1) and max... | Title: Dima and Continuous Line
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework.
The teacher g... | ```python
n = int(input())
c = list(map(int, input().split()))
intersection = False
for i in range(n - 1):
min1 = min(c[i], c[i + 1])
max1 = max(c[i], c[i + 1])
for j in range(i + 1, n - 1):
min2 = min(c[j], c[j + 1])
max2 = max(c[j], c[j + 1])
if (min2 > min1 and min2 < max... | 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,665,479,664 | 2,147,483,647 | Python 3 | OK | TESTS | 36 | 46 | 0 | def qu(x):
n = 0
while 1:
a = 0
while 1:
if 2**a > x:
a -= 1
break
a += 1
x -= 2**a
n += 1
if x == 0:
return n
print(qu(int(input()))) | 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
def qu(x):
n = 0
while 1:
a = 0
while 1:
if 2**a > x:
a -= 1
break
a += 1
x -= 2**a
n += 1
if x == 0:
return n
print(qu(int(input())))
``` | 3 | |
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,698,997,670 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 6 | 60 | 0 | y = int(input())
while y <= 9000:
y += 1
s_y = str(y)
n = len(s_y)
y_ = set(s_y)
n_ = len(y_)
if n == n_:
print(y)
break
| 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
y = int(input())
while y <= 9000:
y += 1
s_y = str(y)
n = len(s_y)
y_ = set(s_y)
n_ = len(y_)
if n == n_:
print(y)
break
``` | 0 | |
31 | A | Worms Evolution | PROGRAMMING | 1,200 | [
"implementation"
] | A. Worms Evolution | 2 | 256 | Professor Vasechkin is studying evolution of worms. Recently he put forward hypotheses that all worms evolve by division. There are *n* forms of worms. Worms of these forms have lengths *a*1, *a*2, ..., *a**n*. To prove his theory, professor needs to find 3 different forms that the length of the first form is equal to ... | The first line contains integer *n* (3<=≤<=*n*<=≤<=100) — amount of worm's forms. The second line contains *n* space-separated integers *a**i* (1<=≤<=*a**i*<=≤<=1000) — lengths of worms of each form. | Output 3 distinct integers *i* *j* *k* (1<=≤<=*i*,<=*j*,<=*k*<=≤<=*n*) — such indexes of worm's forms that *a**i*<==<=*a**j*<=+<=*a**k*. If there is no such triple, output -1. If there are several solutions, output any of them. It possible that *a**j*<==<=*a**k*. | [
"5\n1 2 3 5 7\n",
"5\n1 8 1 5 1\n"
] | [
"3 2 1\n",
"-1\n"
] | none | 500 | [
{
"input": "5\n1 2 3 5 7",
"output": "3 2 1"
},
{
"input": "5\n1 8 1 5 1",
"output": "-1"
},
{
"input": "4\n303 872 764 401",
"output": "-1"
},
{
"input": "6\n86 402 133 524 405 610",
"output": "6 4 1"
},
{
"input": "8\n217 779 418 895 996 473 3 22",
"output":... | 1,568,140,163 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 154 | 0 | n=int(input(""))
r=input((""))
i=0
while i<(2*n):
k=r[i]
a=int(k)
j=0
while j<len(r):
b=int(r[j])
l=0
while l <len(r):
c=int(r[l])
if a==b+c and j!=l and b>c:
print(a,b,c)
i=(2*n)+1
break
... | Title: Worms Evolution
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Professor Vasechkin is studying evolution of worms. Recently he put forward hypotheses that all worms evolve by division. There are *n* forms of worms. Worms of these forms have lengths *a*1, *a*2, ..., *a**n*. To prove his... | ```python
n=int(input(""))
r=input((""))
i=0
while i<(2*n):
k=r[i]
a=int(k)
j=0
while j<len(r):
b=int(r[j])
l=0
while l <len(r):
c=int(r[l])
if a==b+c and j!=l and b>c:
print(a,b,c)
i=(2*n)+1
... | 0 |
835 | A | Key races | PROGRAMMING | 800 | [
"math"
] | null | null | Two boys decided to compete in text typing on the site "Key races". During the competition, they have to type a text consisting of *s* characters. The first participant types one character in *v*1 milliseconds and has ping *t*1 milliseconds. The second participant types one character in *v*2 milliseconds and has ping *... | The first line contains five integers *s*, *v*1, *v*2, *t*1, *t*2 (1<=≤<=*s*,<=*v*1,<=*v*2,<=*t*1,<=*t*2<=≤<=1000) — the number of characters in the text, the time of typing one character for the first participant, the time of typing one character for the the second participant, the ping of the first participant and th... | If the first participant wins, print "First". If the second participant wins, print "Second". In case of a draw print "Friendship". | [
"5 1 2 1 2\n",
"3 3 1 1 1\n",
"4 5 3 1 5\n"
] | [
"First\n",
"Second\n",
"Friendship\n"
] | In the first example, information on the success of the first participant comes in 7 milliseconds, of the second participant — in 14 milliseconds. So, the first wins.
In the second example, information on the success of the first participant comes in 11 milliseconds, of the second participant — in 5 milliseconds. So, ... | 500 | [
{
"input": "5 1 2 1 2",
"output": "First"
},
{
"input": "3 3 1 1 1",
"output": "Second"
},
{
"input": "4 5 3 1 5",
"output": "Friendship"
},
{
"input": "1000 1000 1000 1000 1000",
"output": "Friendship"
},
{
"input": "1 1 1 1 1",
"output": "Friendship"
},
... | 1,593,677,476 | 2,147,483,647 | Python 3 | OK | TESTS | 32 | 124 | 0 | a,b,c,d,e = map(int, input().split())
k=a*(c-b)+2*(e -d)
print('First' if k > 0 else 'Second' if k < 0 else 'Friendship')
| Title: Key races
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Two boys decided to compete in text typing on the site "Key races". During the competition, they have to type a text consisting of *s* characters. The first participant types one character in *v*1 milliseconds and has ping *t... | ```python
a,b,c,d,e = map(int, input().split())
k=a*(c-b)+2*(e -d)
print('First' if k > 0 else 'Second' if k < 0 else 'Friendship')
``` | 3 | |
71 | C | Round Table Knights | PROGRAMMING | 1,600 | [
"dp",
"math",
"number theory"
] | C. Round Table Knights | 0 | 256 | There are *n* knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knight... | The first line contains number *n*, which is the number of knights at the round table (3<=≤<=*n*<=≤<=105). The second line contains space-separated moods of all the *n* knights in the order of passing them around the table. "1" means that the knight is in a good mood an "0" means that he is in a bad mood. | Print "YES" without the quotes if the following month will turn out to be lucky. Otherwise, print "NO". | [
"3\n1 1 1\n",
"6\n1 0 1 1 1 0\n",
"6\n1 0 0 1 0 1\n"
] | [
"YES",
"YES",
"NO"
] | none | 1,500 | [
{
"input": "3\n1 1 1",
"output": "YES"
},
{
"input": "6\n1 0 1 1 1 0",
"output": "YES"
},
{
"input": "6\n1 0 0 1 0 1",
"output": "NO"
},
{
"input": "10\n1 0 1 1 1 0 1 0 1 0",
"output": "YES"
},
{
"input": "15\n0 0 0 1 0 1 1 0 1 0 0 1 0 1 0",
"output": "YES"
... | 1,678,734,266 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 5 | 62 | 0 | def sol(c, m) :
for i in range(2, m+1) :
for j in range(c, n, i) :
if arr[i] != 1 : break
else : return 1
return 0
n = int(input())
arr = list(map(int, input().split()))
if 1 not in arr :
print('NO')
elif arr.count(1) == n :
print('YES')
else :
c =... | Title: Round Table Knights
Time Limit: 0 seconds
Memory Limit: 256 megabytes
Problem Description:
There are *n* knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to... | ```python
def sol(c, m) :
for i in range(2, m+1) :
for j in range(c, n, i) :
if arr[i] != 1 : break
else : return 1
return 0
n = int(input())
arr = list(map(int, input().split()))
if 1 not in arr :
print('NO')
elif arr.count(1) == n :
print('YES')
else :... | 0 |
935 | A | Fafa and his Company | PROGRAMMING | 800 | [
"brute force",
"implementation"
] | null | null | Fafa owns a company that works on huge projects. There are *n* employees in Fafa's company. Whenever the company has a new project to start working on, Fafa has to divide the tasks of this project among all the employees.
Fafa finds doing this every time is very tiring for him. So, he decided to choose the best *l* em... | The input consists of a single line containing a positive integer *n* (2<=≤<=*n*<=≤<=105) — the number of employees in Fafa's company. | Print a single integer representing the answer to the problem. | [
"2\n",
"10\n"
] | [
"1\n",
"3\n"
] | In the second sample Fafa has 3 ways:
- choose only 1 employee as a team leader with 9 employees under his responsibility. - choose 2 employees as team leaders with 4 employees under the responsibility of each of them. - choose 5 employees as team leaders with 1 employee under the responsibility of each of them. | 500 | [
{
"input": "2",
"output": "1"
},
{
"input": "10",
"output": "3"
},
{
"input": "3",
"output": "1"
},
{
"input": "4",
"output": "2"
},
{
"input": "6",
"output": "3"
},
{
"input": "13",
"output": "1"
},
{
"input": "100000",
"output": "35"
... | 1,685,212,246 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 33 | 62 | 1,331,200 | n = int(input())
sum = 0
for i in range(1,n):
if (n-i)%i==0:
sum = sum + 1
print(sum) | Title: Fafa and his Company
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Fafa owns a company that works on huge projects. There are *n* employees in Fafa's company. Whenever the company has a new project to start working on, Fafa has to divide the tasks of this project among all the emp... | ```python
n = int(input())
sum = 0
for i in range(1,n):
if (n-i)%i==0:
sum = sum + 1
print(sum)
``` | 3 | |
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,696,655,907 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 62 | 0 | username=input()
distinct=0
for i in username:
if username.count(i)==1:
distinct+=1
if distinct//2==0:
print("CHAT WITH HER!")
else:
print("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()
distinct=0
for i in username:
if username.count(i)==1:
distinct+=1
if distinct//2==0:
print("CHAT WITH HER!")
else:
print("IGNORE HIM!")
``` | 0 | |
869 | B | The Eternal Immortality | PROGRAMMING | 1,100 | [
"math"
] | null | null | Even if the world is full of counterfeits, I still regard it as wonderful.
Pile up herbs and incense, and arise again from the flames and ashes of its predecessor — as is known to many, the phoenix does it like this.
The phoenix has a rather long lifespan, and reincarnates itself once every *a*! years. Here *a*! deno... | The first and only line of input contains two space-separated integers *a* and *b* (0<=≤<=*a*<=≤<=*b*<=≤<=1018). | Output one line containing a single decimal digit — the last digit of the value that interests Koyomi. | [
"2 4\n",
"0 10\n",
"107 109\n"
] | [
"2\n",
"0\n",
"2\n"
] | In the first example, the last digit of <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/99c47ca8b182f097e38094d12f0c06ce0b081b76.png" style="max-width: 100.0%;max-height: 100.0%;"/> is 2;
In the second example, the last digit of <img align="middle" class="tex-formula" src="https://espresso... | 1,000 | [
{
"input": "2 4",
"output": "2"
},
{
"input": "0 10",
"output": "0"
},
{
"input": "107 109",
"output": "2"
},
{
"input": "10 13",
"output": "6"
},
{
"input": "998244355 998244359",
"output": "4"
},
{
"input": "999999999000000000 1000000000000000000",
... | 1,597,359,332 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 4 | 1,000 | 1,536,000 | import math
a, b = map(int, input().split())
first_number = math.factorial(b)
second_number = math.factorial(a)
result = (first_number / second_number) % 10
print(int(result)) | Title: The Eternal Immortality
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Even if the world is full of counterfeits, I still regard it as wonderful.
Pile up herbs and incense, and arise again from the flames and ashes of its predecessor — as is known to many, the phoenix does it like... | ```python
import math
a, b = map(int, input().split())
first_number = math.factorial(b)
second_number = math.factorial(a)
result = (first_number / second_number) % 10
print(int(result))
``` | 0 | |
670 | D1 | Magic Powder - 1 | PROGRAMMING | 1,400 | [
"binary search",
"brute force",
"implementation"
] | null | null | This problem is given in two versions that differ only by constraints. If you can solve this problem in large constraints, then you can just write a single solution to the both versions. If you find the problem too difficult in large constraints, you can write solution to the simplified version only.
Waking up in the ... | The first line of the input contains two positive integers *n* and *k* (1<=≤<=*n*,<=*k*<=≤<=1000) — the number of ingredients and the number of grams of the magic powder.
The second line contains the sequence *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=1000), where the *i*-th number is equal to the number of grams of... | Print the maximum number of cookies, which Apollinaria will be able to bake using the ingredients that she has and the magic powder. | [
"3 1\n2 1 4\n11 3 16\n",
"4 3\n4 3 5 6\n11 12 14 20\n"
] | [
"4\n",
"3\n"
] | In the first sample it is profitably for Apollinaria to make the existing 1 gram of her magic powder to ingredient with the index 2, then Apollinaria will be able to bake 4 cookies.
In the second sample Apollinaria should turn 1 gram of magic powder to ingredient with the index 1 and 1 gram of magic powder to ingredie... | 1,000 | [
{
"input": "3 1\n2 1 4\n11 3 16",
"output": "4"
},
{
"input": "4 3\n4 3 5 6\n11 12 14 20",
"output": "3"
},
{
"input": "10 926\n5 6 8 1 2 5 1 8 4 4\n351 739 998 725 953 970 906 691 707 1000",
"output": "137"
},
{
"input": "20 925\n7 3 1 2 1 3 1 3 1 2 3 1 5 8 1 3 7 3 4 2\n837 ... | 1,685,194,972 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 119 | 77 | 3,276,800 | n, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
l = 0
h = 1000 + k
flagged = True
while l <= h:
m = (l + h) // 2
need = 0
for ind in range(n):
need += max(a[ind] * m - b[ind], 0)
if need == k:
print(m)
flagged ... | Title: Magic Powder - 1
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
This problem is given in two versions that differ only by constraints. If you can solve this problem in large constraints, then you can just write a single solution to the both versions. If you find the problem too dif... | ```python
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
l = 0
h = 1000 + k
flagged = True
while l <= h:
m = (l + h) // 2
need = 0
for ind in range(n):
need += max(a[ind] * m - b[ind], 0)
if need == k:
print(m)
... | 3 | |
580 | A | Kefa and First Steps | PROGRAMMING | 900 | [
"brute force",
"dp",
"implementation"
] | null | null | Kefa decided to make some money doing business on the Internet for exactly *n* days. He knows that on the *i*-th day (1<=≤<=*i*<=≤<=*n*) he makes *a**i* money. Kefa loves progress, that's why he wants to know the length of the maximum non-decreasing subsegment in sequence *a**i*. Let us remind you that the subsegment o... | The first line contains integer *n* (1<=≤<=*n*<=≤<=105).
The second line contains *n* integers *a*1,<=<=*a*2,<=<=...,<=<=*a**n* (1<=≤<=*a**i*<=≤<=109). | Print a single integer — the length of the maximum non-decreasing subsegment of sequence *a*. | [
"6\n2 2 1 3 4 1\n",
"3\n2 2 9\n"
] | [
"3",
"3"
] | In the first test the maximum non-decreasing subsegment is the numbers from the third to the fifth one.
In the second test the maximum non-decreasing subsegment is the numbers from the first to the third one. | 750 | [
{
"input": "6\n2 2 1 3 4 1",
"output": "3"
},
{
"input": "3\n2 2 9",
"output": "3"
},
{
"input": "5\n10 100 111 1 2",
"output": "3"
},
{
"input": "10\n1 2 3 4 1 2 3 4 5 6",
"output": "6"
},
{
"input": "50\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... | 1,699,224,104 | 2,147,483,647 | Python 3 | OK | TESTS | 28 | 93 | 13,926,400 | n=int(input(''))
x=list(map(int,input().split()))
c=1
m=1
for i in range(n):
if i == n-1:
break
if x[i]<=x[i+1]:
c+=1
else:
if m<=c :
m=c
c=1
if m > c :
print(m)
else:
print(c) | Title: Kefa and First Steps
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Kefa decided to make some money doing business on the Internet for exactly *n* days. He knows that on the *i*-th day (1<=≤<=*i*<=≤<=*n*) he makes *a**i* money. Kefa loves progress, that's why he wants to know the l... | ```python
n=int(input(''))
x=list(map(int,input().split()))
c=1
m=1
for i in range(n):
if i == n-1:
break
if x[i]<=x[i+1]:
c+=1
else:
if m<=c :
m=c
c=1
if m > c :
print(m)
else:
print(c)
``` | 3 | |
264 | A | Escape from Stones | PROGRAMMING | 1,200 | [
"constructive algorithms",
"data structures",
"implementation",
"two pointers"
] | null | null | Squirrel Liss lived in a forest peacefully, but unexpected trouble happens. Stones fall from a mountain. Initially Squirrel Liss occupies an interval [0,<=1]. Next, *n* stones will fall and Liss will escape from the stones. The stones are numbered from 1 to *n* in order.
The stones always fall to the center of Liss's ... | The input consists of only one line. The only line contains the string *s* (1<=≤<=|*s*|<=≤<=106). Each character in *s* will be either "l" or "r". | Output *n* lines — on the *i*-th line you should print the *i*-th stone's number from the left. | [
"llrlr\n",
"rrlll\n",
"lrlrr\n"
] | [
"3\n5\n4\n2\n1\n",
"1\n2\n5\n4\n3\n",
"2\n4\n5\n3\n1\n"
] | In the first example, the positions of stones 1, 2, 3, 4, 5 will be <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/58fdb5684df807bfcb705a9da9ce175613362b7d.png" style="max-width: 100.0%;max-height: 100.0%;"/>, respectively. So you should print the sequence: 3, 5, 4, 2, 1. | 500 | [
{
"input": "llrlr",
"output": "3\n5\n4\n2\n1"
},
{
"input": "rrlll",
"output": "1\n2\n5\n4\n3"
},
{
"input": "lrlrr",
"output": "2\n4\n5\n3\n1"
},
{
"input": "lllrlrllrl",
"output": "4\n6\n9\n10\n8\n7\n5\n3\n2\n1"
},
{
"input": "llrlrrrlrr",
"output": "3\n5\n6... | 1,669,698,979 | 2,147,483,647 | Python 3 | OK | TESTS | 57 | 1,980 | 38,502,400 | s=str(input())
l=list(s)
b=len(l)
r=[]
l1=[]
for i in range(b):
if l[i]=="r":
r.append(i+1)
for i in range(b):
if l[i]=="l":
l1.append(i+1)
l1=l1[::-1]
for i in r:
print(i)
for i in l1:
print(i)
| Title: Escape from Stones
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Squirrel Liss lived in a forest peacefully, but unexpected trouble happens. Stones fall from a mountain. Initially Squirrel Liss occupies an interval [0,<=1]. Next, *n* stones will fall and Liss will escape from the ... | ```python
s=str(input())
l=list(s)
b=len(l)
r=[]
l1=[]
for i in range(b):
if l[i]=="r":
r.append(i+1)
for i in range(b):
if l[i]=="l":
l1.append(i+1)
l1=l1[::-1]
for i in r:
print(i)
for i in l1:
print(i)
``` | 3 | |
12 | D | Ball | PROGRAMMING | 2,400 | [
"data structures",
"sortings"
] | D. Ball | 2 | 256 | *N* ladies attend the ball in the King's palace. Every lady can be described with three values: beauty, intellect and richness. King's Master of Ceremonies knows that ladies are very special creatures. If some lady understands that there is other lady at the ball which is more beautiful, smarter and more rich, she can ... | The first line contains one integer *N* (1<=≤<=*N*<=≤<=500000). The second line contains *N* integer numbers *B**i*, separated by single spaces. The third and the fourth lines contain sequences *I**i* and *R**i* in the same format. It is guaranteed that 0<=≤<=*B**i*,<=*I**i*,<=*R**i*<=≤<=109. | Output the answer to the problem. | [
"3\n1 4 2\n4 3 2\n2 5 3\n"
] | [
"1\n"
] | none | 0 | [
{
"input": "3\n1 4 2\n4 3 2\n2 5 3",
"output": "1"
},
{
"input": "5\n2 8 10 0 7\n7 7 3 0 10\n2 8 3 2 2",
"output": "1"
},
{
"input": "5\n3 0 0 2 0\n7 10 7 4 0\n9 1 6 1 9",
"output": "1"
},
{
"input": "5\n5 4 0 2 5\n8 3 1 0 10\n4 5 0 0 5",
"output": "2"
},
{
"input... | 1,644,318,380 | 2,147,483,647 | PyPy 3-64 | COMPILATION_ERROR | TESTS | 0 | 0 | 0 | #-------------------------------------------------------------------------------
# Name: module1
# Purpose:
#
# Author: Alam
#
# Created: 08.02.2022
# Copyright: (c) Alam 2022
# Licence: <your licence>
#-------------------------------------------------------------------------------
n=int... | Title: Ball
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
*N* ladies attend the ball in the King's palace. Every lady can be described with three values: beauty, intellect and richness. King's Master of Ceremonies knows that ladies are very special creatures. If some lady understands that th... | ```python
#-------------------------------------------------------------------------------
# Name: module1
# Purpose:
#
# Author: Alam
#
# Created: 08.02.2022
# Copyright: (c) Alam 2022
# Licence: <your licence>
#----------------------------------------------------------------------------... | -1 |
513 | A | Game | PROGRAMMING | 800 | [
"constructive algorithms",
"math"
] | null | null | Two players play a simple game. Each player is provided with a box with balls. First player's box contains exactly *n*1 balls and second player's box contains exactly *n*2 balls. In one move first player can take from 1 to *k*1 balls from his box and throw them away. Similarly, the second player can take from 1 to *k*2... | The first line contains four integers *n*1,<=*n*2,<=*k*1,<=*k*2. All numbers in the input are from 1 to 50.
This problem doesn't have subproblems. You will get 3 points for the correct submission. | Output "First" if the first player wins and "Second" otherwise. | [
"2 2 1 2\n",
"2 1 1 1\n"
] | [
"Second\n",
"First\n"
] | Consider the first sample test. Each player has a box with 2 balls. The first player draws a single ball from his box in one move and the second player can either take 1 or 2 balls from his box in one move. No matter how the first player acts, the second player can always win if he plays wisely. | 3 | [
{
"input": "2 2 1 2",
"output": "Second"
},
{
"input": "2 1 1 1",
"output": "First"
},
{
"input": "5 7 4 1",
"output": "Second"
},
{
"input": "5 7 1 4",
"output": "Second"
},
{
"input": "5 7 10 10",
"output": "Second"
},
{
"input": "5 7 1 10",
"out... | 1,592,587,811 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 93 | 0 | n1,n2,k1,k2=map(int,input().split())
print(['FIRST','SECOND'][n1<=n2]) | Title: Game
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Two players play a simple game. Each player is provided with a box with balls. First player's box contains exactly *n*1 balls and second player's box contains exactly *n*2 balls. In one move first player can take from 1 to *k*1 ba... | ```python
n1,n2,k1,k2=map(int,input().split())
print(['FIRST','SECOND'][n1<=n2])
``` | 0 | |
978 | B | File Name | PROGRAMMING | 800 | [
"greedy",
"strings"
] | null | null | You can not just take the file and send it. When Polycarp trying to send a file in the social network "Codehorses", he encountered an unexpected problem. If the name of the file contains three or more "x" (lowercase Latin letters "x") in a row, the system considers that the file content does not correspond to the socia... | The first line contains integer $n$ $(3 \le n \le 100)$ — the length of the file name.
The second line contains a string of length $n$ consisting of lowercase Latin letters only — the file name. | Print the minimum number of characters to remove from the file name so after that the name does not contain "xxx" as a substring. If initially the file name dost not contain a forbidden substring "xxx", print 0. | [
"6\nxxxiii\n",
"5\nxxoxx\n",
"10\nxxxxxxxxxx\n"
] | [
"1\n",
"0\n",
"8\n"
] | In the first example Polycarp tried to send a file with name contains number $33$, written in Roman numerals. But he can not just send the file, because it name contains three letters "x" in a row. To send the file he needs to remove any one of this letters. | 0 | [
{
"input": "6\nxxxiii",
"output": "1"
},
{
"input": "5\nxxoxx",
"output": "0"
},
{
"input": "10\nxxxxxxxxxx",
"output": "8"
},
{
"input": "100\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"output": "98"
},
{
... | 1,658,357,192 | 2,147,483,647 | Python 3 | OK | TESTS | 13 | 46 | 0 | def f():
_ = input()
s = input()
res = 0
cnt = 0
for i in range(len(s)):
c = s[i]
if c == 'x':
cnt += 1
if cnt >= 3:
res += 1
else:
cnt = 0
print(res)
f()
| Title: File Name
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You can not just take the file and send it. When Polycarp trying to send a file in the social network "Codehorses", he encountered an unexpected problem. If the name of the file contains three or more "x" (lowercase Latin let... | ```python
def f():
_ = input()
s = input()
res = 0
cnt = 0
for i in range(len(s)):
c = s[i]
if c == 'x':
cnt += 1
if cnt >= 3:
res += 1
else:
cnt = 0
print(res)
f()
``` | 3 | |
151 | A | Soft Drinking | PROGRAMMING | 800 | [
"implementation",
"math"
] | null | null | This winter is so cold in Nvodsk! A group of *n* friends decided to buy *k* bottles of a soft drink called "Take-It-Light" to warm up a bit. Each bottle has *l* milliliters of the drink. Also they bought *c* limes and cut each of them into *d* slices. After that they found *p* grams of salt.
To make a toast, each frie... | The first and only line contains positive integers *n*, *k*, *l*, *c*, *d*, *p*, *nl*, *np*, not exceeding 1000 and no less than 1. The numbers are separated by exactly one space. | Print a single integer — the number of toasts each friend can make. | [
"3 4 5 10 8 100 3 1\n",
"5 100 10 1 19 90 4 3\n",
"10 1000 1000 25 23 1 50 1\n"
] | [
"2\n",
"3\n",
"0\n"
] | A comment to the first sample:
Overall the friends have 4 * 5 = 20 milliliters of the drink, it is enough to make 20 / 3 = 6 toasts. The limes are enough for 10 * 8 = 80 toasts and the salt is enough for 100 / 1 = 100 toasts. However, there are 3 friends in the group, so the answer is *min*(6, 80, 100) / 3 = 2. | 500 | [
{
"input": "3 4 5 10 8 100 3 1",
"output": "2"
},
{
"input": "5 100 10 1 19 90 4 3",
"output": "3"
},
{
"input": "10 1000 1000 25 23 1 50 1",
"output": "0"
},
{
"input": "1 7 4 5 5 8 3 2",
"output": "4"
},
{
"input": "2 3 3 5 5 10 1 3",
"output": "1"
},
{
... | 1,679,520,444 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 9 | 62 | 0 | # A. Soft Drinking
lista = [int(x) for x in input().split(' ')]
n = lista[0]
k = lista[1]
l = lista[2]
c = lista[3]
d = lista[4]
p = lista[5]
nl = lista[6]
np = lista[7]
lista_resposta = []
lista_resposta.append((k*l)/n)
lista_resposta.append(c*d)
lista_resposta.append(p/np)
resposta = int(min(lista... | Title: Soft Drinking
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
This winter is so cold in Nvodsk! A group of *n* friends decided to buy *k* bottles of a soft drink called "Take-It-Light" to warm up a bit. Each bottle has *l* milliliters of the drink. Also they bought *c* limes and cut... | ```python
# A. Soft Drinking
lista = [int(x) for x in input().split(' ')]
n = lista[0]
k = lista[1]
l = lista[2]
c = lista[3]
d = lista[4]
p = lista[5]
nl = lista[6]
np = lista[7]
lista_resposta = []
lista_resposta.append((k*l)/n)
lista_resposta.append(c*d)
lista_resposta.append(p/np)
resposta = int... | 0 | |
762 | B | USB vs. PS/2 | PROGRAMMING | 1,400 | [
"greedy",
"implementation",
"sortings",
"two pointers"
] | null | null | Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis!
The computers bought for the room were different. Some of them had only USB ... | The first line contains three integers *a*, *b* and *c* (0<=≤<=*a*,<=*b*,<=*c*<=≤<=105) — the number of computers that only have USB ports, the number of computers, that only have PS/2 ports, and the number of computers, that have both options, respectively.
The next line contains one integer *m* (0<=≤<=*m*<=≤<=3·105... | Output two integers separated by space — the number of equipped computers and the total cost of the mouses you will buy. | [
"2 1 1\n4\n5 USB\n6 PS/2\n3 PS/2\n7 PS/2\n"
] | [
"3 14\n"
] | In the first example you can buy the first three mouses. This way you will equip one of the computers that has only a USB port with a USB mouse, and the two PS/2 mouses you will plug into the computer with PS/2 port and the computer with both ports. | 0 | [
{
"input": "2 1 1\n4\n5 USB\n6 PS/2\n3 PS/2\n7 PS/2",
"output": "3 14"
},
{
"input": "1 4 4\n12\n36949214 USB\n683538043 USB\n595594834 PS/2\n24951774 PS/2\n131512123 USB\n327575645 USB\n30947411 USB\n916758386 PS/2\n474310330 USB\n350512489 USB\n281054887 USB\n875326145 USB",
"output": "8 23453... | 1,645,369,063 | 2,147,483,647 | Python 3 | OK | TESTS | 48 | 795 | 9,728,000 | s = input()
s = s.split()
n = int(s[0])
m = int(s[1])
k = int(s[2])
num = int(input())
a = []
b = []
for i in range(num):
s = input()
s = s.split()
if s[1]=="USB":
a.append(int(s[0]))
else:
b.append(int(s[0]))
a.sort()
b.sort()
x = 0
y = 0
ans = 0
for i in range(n):
... | Title: USB vs. PS/2
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the c... | ```python
s = input()
s = s.split()
n = int(s[0])
m = int(s[1])
k = int(s[2])
num = int(input())
a = []
b = []
for i in range(num):
s = input()
s = s.split()
if s[1]=="USB":
a.append(int(s[0]))
else:
b.append(int(s[0]))
a.sort()
b.sort()
x = 0
y = 0
ans = 0
for i in r... | 3 | |
912 | A | Tricky Alchemy | PROGRAMMING | 800 | [
"implementation"
] | null | null | During the winter holidays, the demand for Christmas balls is exceptionally high. Since it's already 2018, the advances in alchemy allow easy and efficient ball creation by utilizing magic crystals.
Grisha needs to obtain some yellow, green and blue balls. It's known that to produce a yellow ball one needs two yellow ... | The first line features two integers *A* and *B* (0<=≤<=*A*,<=*B*<=≤<=109), denoting the number of yellow and blue crystals respectively at Grisha's disposal.
The next line contains three integers *x*, *y* and *z* (0<=≤<=*x*,<=*y*,<=*z*<=≤<=109) — the respective amounts of yellow, green and blue balls to be obtained. | Print a single integer — the minimum number of crystals that Grisha should acquire in addition. | [
"4 3\n2 1 1\n",
"3 9\n1 1 3\n",
"12345678 87654321\n43043751 1000000000 53798715\n"
] | [
"2\n",
"1\n",
"2147483648\n"
] | In the first sample case, Grisha needs five yellow and four blue crystals to create two yellow balls, one green ball, and one blue ball. To do that, Grisha needs to obtain two additional crystals: one yellow and one blue. | 500 | [
{
"input": "4 3\n2 1 1",
"output": "2"
},
{
"input": "3 9\n1 1 3",
"output": "1"
},
{
"input": "12345678 87654321\n43043751 1000000000 53798715",
"output": "2147483648"
},
{
"input": "12 12\n3 5 2",
"output": "0"
},
{
"input": "770 1390\n170 442 311",
"output"... | 1,626,042,632 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 3 | 46 | 6,758,400 | A,B = [int(i) for i in input().split(' ')]
x,y,z = [int(j) for j in input().split(' ')]
print((x*2 + y - A) + (z*3 + y - B)) | Title: Tricky Alchemy
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
During the winter holidays, the demand for Christmas balls is exceptionally high. Since it's already 2018, the advances in alchemy allow easy and efficient ball creation by utilizing magic crystals.
Grisha needs to obta... | ```python
A,B = [int(i) for i in input().split(' ')]
x,y,z = [int(j) for j in input().split(' ')]
print((x*2 + y - A) + (z*3 + y - B))
``` | 0 | |
124 | A | The number of positions | PROGRAMMING | 1,000 | [
"math"
] | null | null | Petr stands in line of *n* people, but he doesn't know exactly which position he occupies. He can say that there are no less than *a* people standing in front of him and no more than *b* people standing behind him. Find the number of different positions Petr can occupy. | The only line contains three integers *n*, *a* and *b* (0<=≤<=*a*,<=*b*<=<<=*n*<=≤<=100). | Print the single number — the number of the sought positions. | [
"3 1 1\n",
"5 2 3\n"
] | [
"2\n",
"3\n"
] | The possible positions in the first sample are: 2 and 3 (if we number the positions starting with 1).
In the second sample they are 3, 4 and 5. | 500 | [
{
"input": "3 1 1",
"output": "2"
},
{
"input": "5 2 3",
"output": "3"
},
{
"input": "5 4 0",
"output": "1"
},
{
"input": "6 5 5",
"output": "1"
},
{
"input": "9 4 3",
"output": "4"
},
{
"input": "11 4 6",
"output": "7"
},
{
"input": "13 8 ... | 1,643,256,870 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 4 | 60 | 0 | x=list(map(int,input().split()))
print(x[0]-x[1]) | Title: The number of positions
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Petr stands in line of *n* people, but he doesn't know exactly which position he occupies. He can say that there are no less than *a* people standing in front of him and no more than *b* people standing behind h... | ```python
x=list(map(int,input().split()))
print(x[0]-x[1])
``` | 0 | |
868 | B | Race Against Time | PROGRAMMING | 1,400 | [
"implementation"
] | null | null | Have you ever tried to explain to the coordinator, why it is eight hours to the contest and not a single problem has been prepared yet? Misha had. And this time he has a really strong excuse: he faced a space-time paradox! Space and time replaced each other.
The entire universe turned into an enormous clock face with ... | Five integers *h*, *m*, *s*, *t*1, *t*2 (1<=≤<=*h*<=≤<=12, 0<=≤<=*m*,<=*s*<=≤<=59, 1<=≤<=*t*1,<=*t*2<=≤<=12, *t*1<=≠<=*t*2).
Misha's position and the target time do not coincide with the position of any hand. | Print "YES" (quotes for clarity), if Misha can prepare the contest on time, and "NO" otherwise.
You can print each character either upper- or lowercase ("YeS" and "yes" are valid when the answer is "YES"). | [
"12 30 45 3 11\n",
"12 0 1 12 1\n",
"3 47 0 4 9\n"
] | [
"NO\n",
"YES\n",
"YES\n"
] | The three examples are shown on the pictures below from left to right. The starting position of Misha is shown with green, the ending position is shown with pink. Note that the positions of the hands on the pictures are not exact, but are close to the exact and the answer is the same. | 500 | [
{
"input": "12 30 45 3 11",
"output": "NO"
},
{
"input": "12 0 1 12 1",
"output": "YES"
},
{
"input": "3 47 0 4 9",
"output": "YES"
},
{
"input": "10 22 59 6 10",
"output": "YES"
},
{
"input": "3 1 13 12 3",
"output": "NO"
},
{
"input": "11 19 28 9 10"... | 1,574,280,651 | 2,147,483,647 | PyPy 3 | OK | TESTS | 133 | 155 | 1,638,400 | h, m, s, t1, t2 = map(int, input().split())
a = [0] * 43200
a[(h * 3600 + 60 * m + s) % 43200] = 1
a[(m * 720 + 12 * s) % 43200] = 1
a[(s * 720) % 43200] = 1
a[(t2 * 3600) % 43200] = 2
possible = False
for i in range(t1 * 3600, t1 * 3600 + 43200):
if a[i % 43200] == 1:
break
elif a[i % 43200] ... | Title: Race Against Time
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Have you ever tried to explain to the coordinator, why it is eight hours to the contest and not a single problem has been prepared yet? Misha had. And this time he has a really strong excuse: he faced a space-time par... | ```python
h, m, s, t1, t2 = map(int, input().split())
a = [0] * 43200
a[(h * 3600 + 60 * m + s) % 43200] = 1
a[(m * 720 + 12 * s) % 43200] = 1
a[(s * 720) % 43200] = 1
a[(t2 * 3600) % 43200] = 2
possible = False
for i in range(t1 * 3600, t1 * 3600 + 43200):
if a[i % 43200] == 1:
break
elif a[i... | 3 | |
940 | C | Phone Numbers | PROGRAMMING | 1,500 | [
"constructive algorithms",
"implementation",
"strings"
] | null | null | And where the are the phone numbers?
You are given a string *s* consisting of lowercase English letters and an integer *k*. Find the lexicographically smallest string *t* of length *k*, such that its set of letters is a subset of the set of letters of *s* and *s* is lexicographically smaller than *t*.
It's guaranteed... | The first line of input contains two space separated integers *n* and *k* (1<=≤<=*n*,<=*k*<=≤<=100<=000) — the length of *s* and the required length of *t*.
The second line of input contains the string *s* consisting of *n* lowercase English letters. | Output the string *t* conforming to the requirements above.
It's guaranteed that the answer exists. | [
"3 3\nabc\n",
"3 2\nabc\n",
"3 3\nayy\n",
"2 3\nba\n"
] | [
"aca\n",
"ac\n",
"yaa\n",
"baa\n"
] | In the first example the list of strings *t* of length 3, such that the set of letters of *t* is a subset of letters of *s* is as follows: aaa, aab, aac, aba, abb, abc, aca, acb, .... Among them, those are lexicographically greater than abc: aca, acb, .... Out of those the lexicographically smallest is aca. | 1,250 | [
{
"input": "3 3\nabc",
"output": "aca"
},
{
"input": "3 2\nabc",
"output": "ac"
},
{
"input": "3 3\nayy",
"output": "yaa"
},
{
"input": "2 3\nba",
"output": "baa"
},
{
"input": "1 3\nf",
"output": "fff"
},
{
"input": "3 1\nazz",
"output": "z"
},
... | 1,621,634,114 | 2,147,483,647 | PyPy 3 | OK | TESTS | 54 | 187 | 4,608,000 | n, k = map(int, input().split())
s = input()
S = set(s)
if k <= n:
for i in reversed(range(k)):
l = filter(lambda x: s[i] < x, S)
l = list(l)
if len(l):
print(s[:i] + min(l) + min(S) * (k - i - 1))
break
else:
print(s + min(S)*(k-n))
| Title: Phone Numbers
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
And where the are the phone numbers?
You are given a string *s* consisting of lowercase English letters and an integer *k*. Find the lexicographically smallest string *t* of length *k*, such that its set of letters is a ... | ```python
n, k = map(int, input().split())
s = input()
S = set(s)
if k <= n:
for i in reversed(range(k)):
l = filter(lambda x: s[i] < x, S)
l = list(l)
if len(l):
print(s[:i] + min(l) + min(S) * (k - i - 1))
break
else:
print(s + min(S)*(k-n))
... | 3 | |
0 | none | none | none | 0 | [
"none"
] | null | null | You are an experienced Codeforces user. Today you found out that during your activity on Codeforces you have made *y* submissions, out of which *x* have been successful. Thus, your current success rate on Codeforces is equal to *x*<=/<=*y*.
Your favorite rational number in the [0;1] range is *p*<=/<=*q*. Now you wonde... | The first line contains a single integer *t* (1<=≤<=*t*<=≤<=1000) — the number of test cases.
Each of the next *t* lines contains four integers *x*, *y*, *p* and *q* (0<=≤<=*x*<=≤<=*y*<=≤<=109; 0<=≤<=*p*<=≤<=*q*<=≤<=109; *y*<=><=0; *q*<=><=0).
It is guaranteed that *p*<=/<=*q* is an irreducible fraction.
Hacks... | For each test case, output a single integer equal to the smallest number of submissions you have to make if you want your success rate to be equal to your favorite rational number, or -1 if this is impossible to achieve. | [
"4\n3 10 1 2\n7 14 3 8\n20 70 2 7\n5 6 1 1\n"
] | [
"4\n10\n0\n-1\n"
] | In the first example, you have to make 4 successful submissions. Your success rate will be equal to 7 / 14, or 1 / 2.
In the second example, you have to make 2 successful and 8 unsuccessful submissions. Your success rate will be equal to 9 / 24, or 3 / 8.
In the third example, there is no need to make any new submiss... | 0 | [
{
"input": "4\n3 10 1 2\n7 14 3 8\n20 70 2 7\n5 6 1 1",
"output": "4\n10\n0\n-1"
},
{
"input": "8\n0 1 0 1\n0 2 1 2\n0 3 1 1\n1 2 0 1\n1 2 1 1\n2 2 0 1\n3 3 1 2\n4 4 1 1",
"output": "0\n2\n-1\n-1\n-1\n-1\n3\n0"
},
{
"input": "5\n1 1000000000 1 2\n1 1000000000 1 2\n1 1000000000 1 2\n1 100... | 1,494,419,179 | 2,147,483,647 | Python 3 | OK | TESTS | 56 | 93 | 0 | def gcd(a, b):
if b==0:
return a, 1, 0
g, y, x=gcd(b, a%b)
y-=x*(a//b)
return g, x, y
for _ in range(int(input())):
x, y, p, q=map(int, input().split())
if p==0:
print(0 if x==0 else -1)
continue
if q==1:
print(0 if x==y else -1)
continue
a, b=gcd(q, p)[1:]
a*=p*y-q*x
b*=q*x-p*y
if a<0:
t=(-a+p... | Title: none
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are an experienced Codeforces user. Today you found out that during your activity on Codeforces you have made *y* submissions, out of which *x* have been successful. Thus, your current success rate on Codeforces is equal to *x... | ```python
def gcd(a, b):
if b==0:
return a, 1, 0
g, y, x=gcd(b, a%b)
y-=x*(a//b)
return g, x, y
for _ in range(int(input())):
x, y, p, q=map(int, input().split())
if p==0:
print(0 if x==0 else -1)
continue
if q==1:
print(0 if x==y else -1)
continue
a, b=gcd(q, p)[1:]
a*=p*y-q*x
b*=q*x-p*y
if a<0:... | 3 | |
96 | A | Football | PROGRAMMING | 900 | [
"implementation",
"strings"
] | A. Football | 2 | 256 | Petya loves football very much. One day, as he was watching a football match, he was writing the players' current positions on a piece of paper. To simplify the situation he depicted it as a string consisting of zeroes and ones. A zero corresponds to players of one team; a one corresponds to players of another team. If... | The first input line contains a non-empty string consisting of characters "0" and "1", which represents players. The length of the string does not exceed 100 characters. There's at least one player from each team present on the field. | Print "YES" if the situation is dangerous. Otherwise, print "NO". | [
"001001\n",
"1000000001\n"
] | [
"NO\n",
"YES\n"
] | none | 500 | [
{
"input": "001001",
"output": "NO"
},
{
"input": "1000000001",
"output": "YES"
},
{
"input": "00100110111111101",
"output": "YES"
},
{
"input": "11110111111111111",
"output": "YES"
},
{
"input": "01",
"output": "NO"
},
{
"input": "10100101",
"outp... | 1,686,324,925 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 62 | 0 | import sys
input = sys.stdin.readline
############ ---- Input Functions ---- ############
def inp():
return(int(input()))
def inlt():
return(list(map(int,input().split())))
def insr():
s = input()
return(list(s[:len(s) - 1]))
def invr():
return(map(int,input().split()))
############ --... | 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
import sys
input = sys.stdin.readline
############ ---- Input Functions ---- ############
def inp():
return(int(input()))
def inlt():
return(list(map(int,input().split())))
def insr():
s = input()
return(list(s[:len(s) - 1]))
def invr():
return(map(int,input().split()))
#####... | 0 |
71 | A | Way Too Long Words | PROGRAMMING | 800 | [
"strings"
] | A. Way Too Long Words | 1 | 256 | Sometimes some words like "localization" or "internationalization" are so long that writing them many times in one text is quite tiresome.
Let's consider a word too long, if its length is strictly more than 10 characters. All too long words should be replaced with a special abbreviation.
This abbreviation is made lik... | The first line contains an integer *n* (1<=≤<=*n*<=≤<=100). Each of the following *n* lines contains one word. All the words consist of lowercase Latin letters and possess the lengths of from 1 to 100 characters. | Print *n* lines. The *i*-th line should contain the result of replacing of the *i*-th word from the input data. | [
"4\nword\nlocalization\ninternationalization\npneumonoultramicroscopicsilicovolcanoconiosis\n"
] | [
"word\nl10n\ni18n\np43s\n"
] | none | 500 | [
{
"input": "4\nword\nlocalization\ninternationalization\npneumonoultramicroscopicsilicovolcanoconiosis",
"output": "word\nl10n\ni18n\np43s"
},
{
"input": "5\nabcdefgh\nabcdefghi\nabcdefghij\nabcdefghijk\nabcdefghijklm",
"output": "abcdefgh\nabcdefghi\nabcdefghij\na9k\na11m"
},
{
"input":... | 1,669,029,439 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 30 | 0 | a = int(input())
for i in range(a):
s = input()
if len(s) > 10:
d = s[1] + str(len(s[1:-1])) + s[-1]
else:
d = s
print(d) | 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
a = int(input())
for i in range(a):
s = input()
if len(s) > 10:
d = s[1] + str(len(s[1:-1])) + s[-1]
else:
d = s
print(d)
``` | 0 |
284 | B | Cows and Poker Game | PROGRAMMING | 1,000 | [
"brute force",
"implementation"
] | null | null | There are *n* cows playing poker at a table. For the current betting phase, each player's status is either "ALLIN", "IN", or "FOLDED", and does not change throughout the phase. To increase the suspense, a player whose current status is not "FOLDED" may show his/her hand to the table. However, so as not to affect any be... | The first line contains a single integer, *n* (2<=≤<=*n*<=≤<=2·105). The second line contains *n* characters, each either "A", "I", or "F". The *i*-th character is "A" if the *i*-th player's status is "ALLIN", "I" if the *i*-th player's status is "IN", or "F" if the *i*-th player's status is "FOLDED". | The first line should contain a single integer denoting the number of players that can currently show their hands. | [
"6\nAFFAAA\n",
"3\nAFI\n"
] | [
"4\n",
"1\n"
] | In the first sample, cows 1, 4, 5, and 6 can show their hands. In the second sample, only cow 3 can show her hand. | 1,000 | [
{
"input": "6\nAFFAAA",
"output": "4"
},
{
"input": "3\nAFI",
"output": "1"
},
{
"input": "3\nFFF",
"output": "0"
},
{
"input": "3\nFIF",
"output": "1"
},
{
"input": "3\nAAA",
"output": "3"
},
{
"input": "3\nIII",
"output": "0"
},
{
"input"... | 1,448,902,476 | 2,147,483,647 | Python 3 | OK | TESTS | 66 | 154 | 1,331,200 | n = int(input())
status = list(input())
allin = status.count("A")
folded = status.count("F")
In = status.count("I")
if In > 1:
print(0)
if In == 1:
print(1)
if In == 0:
print(allin) | Title: Cows and Poker Game
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
There are *n* cows playing poker at a table. For the current betting phase, each player's status is either "ALLIN", "IN", or "FOLDED", and does not change throughout the phase. To increase the suspense, a player who... | ```python
n = int(input())
status = list(input())
allin = status.count("A")
folded = status.count("F")
In = status.count("I")
if In > 1:
print(0)
if In == 1:
print(1)
if In == 0:
print(allin)
``` | 3 | |
439 | B | Devu, the Dumb Guy | PROGRAMMING | 1,200 | [
"implementation",
"sortings"
] | null | null | Devu is a dumb guy, his learning curve is very slow. You are supposed to teach him *n* subjects, the *i**th* subject has *c**i* chapters. When you teach him, you are supposed to teach all the chapters of a subject continuously.
Let us say that his initial per chapter learning power of a subject is *x* hours. In other ... | The first line will contain two space separated integers *n*, *x* (1<=≤<=*n*,<=*x*<=≤<=105). The next line will contain *n* space separated integers: *c*1,<=*c*2,<=...,<=*c**n* (1<=≤<=*c**i*<=≤<=105). | Output a single integer representing the answer to the problem. | [
"2 3\n4 1\n",
"4 2\n5 1 2 1\n",
"3 3\n1 1 1\n"
] | [
"11\n",
"10\n",
"6\n"
] | Look at the first example. Consider the order of subjects: 1, 2. When you teach Devu the first subject, it will take him 3 hours per chapter, so it will take 12 hours to teach first subject. After teaching first subject, his per chapter learning time will be 2 hours. Now teaching him second subject will take 2 × 1 = 2 ... | 1,000 | [
{
"input": "2 3\n4 1",
"output": "11"
},
{
"input": "4 2\n5 1 2 1",
"output": "10"
},
{
"input": "3 3\n1 1 1",
"output": "6"
},
{
"input": "20 4\n1 1 3 5 5 1 3 4 2 5 2 4 3 1 3 3 3 3 4 3",
"output": "65"
},
{
"input": "20 10\n6 6 1 2 6 4 5 3 6 5 4 5 6 5 4 6 6 2 3 3... | 1,593,781,379 | 2,147,483,647 | Python 3 | OK | TESTS | 31 | 202 | 7,782,400 | n, x = map(int, input().split())
l = sorted(list(map(int, input().split())))
ans = 0
for i in l:
ans += i*x
if x > 1 :
x-=1
print(ans) | Title: Devu, the Dumb Guy
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Devu is a dumb guy, his learning curve is very slow. You are supposed to teach him *n* subjects, the *i**th* subject has *c**i* chapters. When you teach him, you are supposed to teach all the chapters of a subject co... | ```python
n, x = map(int, input().split())
l = sorted(list(map(int, input().split())))
ans = 0
for i in l:
ans += i*x
if x > 1 :
x-=1
print(ans)
``` | 3 | |
472 | A | Design Tutorial: Learn from Math | PROGRAMMING | 800 | [
"math",
"number theory"
] | null | null | One way to create a task is to learn from math. You can generate some random math statement or modify some theorems to get something new and build a new task from that.
For example, there is a statement called the "Goldbach's conjecture". It says: "each even number no less than four can be expressed as the sum of two ... | The only line contains an integer *n* (12<=≤<=*n*<=≤<=106). | Output two composite integers *x* and *y* (1<=<<=*x*,<=*y*<=<<=*n*) such that *x*<=+<=*y*<==<=*n*. If there are multiple solutions, you can output any of them. | [
"12\n",
"15\n",
"23\n",
"1000000\n"
] | [
"4 8\n",
"6 9\n",
"8 15\n",
"500000 500000\n"
] | In the first example, 12 = 4 + 8 and both 4, 8 are composite numbers. You can output "6 6" or "8 4" as well.
In the second example, 15 = 6 + 9. Note that you can't output "1 14" because 1 is not a composite number. | 500 | [
{
"input": "12",
"output": "4 8"
},
{
"input": "15",
"output": "6 9"
},
{
"input": "23",
"output": "8 15"
},
{
"input": "1000000",
"output": "500000 500000"
},
{
"input": "63874",
"output": "4 63870"
},
{
"input": "14568",
"output": "4 14564"
},
... | 1,681,318,129 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 0 | 30 | 0 | a=int(input())
if a%2==0:
print(2,a-2)
else:
print(9,a-9) | Title: Design Tutorial: Learn from Math
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
One way to create a task is to learn from math. You can generate some random math statement or modify some theorems to get something new and build a new task from that.
For example, there is a statemen... | ```python
a=int(input())
if a%2==0:
print(2,a-2)
else:
print(9,a-9)
``` | 0 | |
152 | C | Pocket Book | PROGRAMMING | 1,400 | [
"combinatorics"
] | null | null | One day little Vasya found mom's pocket book. The book had *n* names of her friends and unusually enough, each name was exactly *m* letters long. Let's number the names from 1 to *n* in the order in which they are written.
As mom wasn't home, Vasya decided to play with names: he chose three integers *i*, *j*, *k* (1<=... | The first input line contains two integers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=100) — the number of names and the length of each name, correspondingly. Then *n* lines contain names, each name consists of exactly *m* uppercase Latin letters. | Print the single number — the number of different names that could end up in position number 1 in the pocket book after the applying the procedures described above. Print the number modulo 1000000007 (109<=+<=7). | [
"2 3\nAAB\nBAA\n",
"4 5\nABABA\nBCGDG\nAAAAA\nYABSA\n"
] | [
"4\n",
"216\n"
] | In the first sample Vasya can get the following names in the position number 1: "AAB", "AAA", "BAA" and "BAB". | 1,500 | [
{
"input": "2 3\nAAB\nBAA",
"output": "4"
},
{
"input": "4 5\nABABA\nBCGDG\nAAAAA\nYABSA",
"output": "216"
},
{
"input": "1 1\nE",
"output": "1"
},
{
"input": "2 2\nNS\nPD",
"output": "4"
},
{
"input": "3 4\nPJKD\nNFJX\nFGFK",
"output": "81"
},
{
"inpu... | 1,694,478,358 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 60 | 154 | 1,536,000 | mod = 10**9 + 7
n, m = map(int, input().split())
v = []
for _ in range(n):
S = input()
v.append(S)
ans = 1
for i in range(m):
s = set()
for j in range(n):
p = v[j]
s.add(p[i])
cnt = len(s)
ans = (ans * cnt) % mod
s.clear()
print(ans)
| Title: Pocket Book
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
One day little Vasya found mom's pocket book. The book had *n* names of her friends and unusually enough, each name was exactly *m* letters long. Let's number the names from 1 to *n* in the order in which they are written.
... | ```python
mod = 10**9 + 7
n, m = map(int, input().split())
v = []
for _ in range(n):
S = input()
v.append(S)
ans = 1
for i in range(m):
s = set()
for j in range(n):
p = v[j]
s.add(p[i])
cnt = len(s)
ans = (ans * cnt) % mod
s.clear()
print(ans)
... | 3 | |
6 | D | Lizards and Basements 2 | PROGRAMMING | 2,600 | [
"brute force",
"dp"
] | D. Lizards and Basements 2 | 2 | 64 | This is simplified version of the problem used on the original contest. The original problem seems to have too difiicult solution. The constraints for input data have been reduced.
Polycarp likes to play computer role-playing game «Lizards and Basements». At the moment he is playing it as a magician. At one of the las... | The first line of the input contains three integers *n*,<=*a*,<=*b* (3<=≤<=*n*<=≤<=10; 1<=≤<=*b*<=<<=*a*<=≤<=10). The second line contains a sequence of *n* integers — *h*1,<=*h*2,<=...,<=*h**n* (1<=≤<=*h**i*<=≤<=15), where *h**i* is the amount of health points the *i*-th archer has. | In the first line print *t* — the required minimum amount of fire balls.
In the second line print *t* numbers — indexes of the archers that Polycarp should hit to kill all the archers in *t* shots. All these numbers should be between 2 and *n*<=-<=1. Separate numbers with spaces. If there are several solutions, output... | [
"3 2 1\n2 2 2\n",
"4 3 1\n1 4 1 1\n"
] | [
"3\n2 2 2 ",
"4\n2 2 3 3 "
] | none | 0 | [
{
"input": "3 2 1\n2 2 2",
"output": "3\n2 2 2 "
},
{
"input": "4 3 1\n1 4 1 1",
"output": "4\n2 2 3 3 "
},
{
"input": "3 5 3\n1 2 1",
"output": "1\n2 "
},
{
"input": "3 5 3\n3 2 2",
"output": "2\n2 2 "
},
{
"input": "3 5 3\n3 2 2",
"output": "2\n2 2 "
},
... | 1,598,747,813 | 6,113 | Python 3 | WRONG_ANSWER | TESTS | 18 | 342 | 2,764,800 | import sys
from typing import List, Union
def rl(int_: bool = True, is_split: bool = True) -> Union[List[str], List[int]]:
if int_:
return [int(w) for w in sys.stdin.readline().split()]
if is_split:
return [w for w in sys.stdin.readline().split()]
return sys.stdin.readline().strip()
n, a... | Title: Lizards and Basements 2
Time Limit: 2 seconds
Memory Limit: 64 megabytes
Problem Description:
This is simplified version of the problem used on the original contest. The original problem seems to have too difiicult solution. The constraints for input data have been reduced.
Polycarp likes to play computer ro... | ```python
import sys
from typing import List, Union
def rl(int_: bool = True, is_split: bool = True) -> Union[List[str], List[int]]:
if int_:
return [int(w) for w in sys.stdin.readline().split()]
if is_split:
return [w for w in sys.stdin.readline().split()]
return sys.stdin.readline().stri... | 0 |
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,609,850,386 | 2,147,483,647 | PyPy 3 | OK | TESTS | 37 | 498 | 1,024,000 | s = input()
ind = s.find('0')
if ind ==-1:
ans = s[:-1]
else:
ans = s[:ind]+s[ind+1:]
print(ans) | 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
s = input()
ind = s.find('0')
if ind ==-1:
ans = s[:-1]
else:
ans = s[:ind]+s[ind+1:]
print(ans)
``` | 3 | |
120 | E | Put Knight! | PROGRAMMING | 1,400 | [
"games",
"math"
] | null | null | Petya and Gena play a very interesting game "Put a Knight!" on a chessboard *n*<=×<=*n* in size. In this game they take turns to put chess pieces called "knights" on the board so that no two knights could threat each other. A knight located in square (*r*,<=*c*) can threat squares (*r*<=-<=1,<=*c*<=+<=2), (*r*<=-<=1,<=... | The first line contains integer *T* (1<=≤<=*T*<=≤<=100) — the number of boards, for which you should determine the winning player. Next *T* lines contain *T* integers *n**i* (1<=≤<=*n**i*<=≤<=10000) — the sizes of the chessboards. | For each *n**i*<=×<=*n**i* board print on a single line "0" if Petya wins considering both players play optimally well. Otherwise, print "1". | [
"2\n2\n1\n"
] | [
"1\n0\n"
] | none | 0 | [
{
"input": "2\n2\n1",
"output": "1\n0"
},
{
"input": "10\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10",
"output": "0\n1\n0\n1\n0\n1\n0\n1\n0\n1"
},
{
"input": "15\n10\n4\n7\n8\n9\n6\n2\n1\n3\n1\n5\n2\n3\n4\n5",
"output": "1\n1\n0\n1\n0\n1\n1\n0\n0\n0\n0\n1\n0\n1\n0"
},
{
"input": "6\n10\n7... | 1,385,732,932 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 92 | 0 | r = file('input.txt','r')
w = file('output.txt','w')
n = int(r.readline())
t = ['21'[int(r.readline()) % 2] for i in range(n)]
w.write('\n'.join(t)) | Title: Put Knight!
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Petya and Gena play a very interesting game "Put a Knight!" on a chessboard *n*<=×<=*n* in size. In this game they take turns to put chess pieces called "knights" on the board so that no two knights could threat each other.... | ```python
r = file('input.txt','r')
w = file('output.txt','w')
n = int(r.readline())
t = ['21'[int(r.readline()) % 2] for i in range(n)]
w.write('\n'.join(t))
``` | -1 | |
748 | E | Santa Claus and Tangerines | PROGRAMMING | 2,100 | [
"binary search",
"data structures",
"greedy",
"two pointers"
] | null | null | Santa Claus has *n* tangerines, and the *i*-th of them consists of exactly *a**i* slices. Santa Claus came to a school which has *k* pupils. Santa decided to treat them with tangerines.
However, there can be too few tangerines to present at least one tangerine to each pupil. So Santa decided to divide tangerines into ... | The first line contains two positive integers *n* and *k* (1<=≤<=*n*<=≤<=106, 1<=≤<=*k*<=≤<=2·109) denoting the number of tangerines and the number of pupils, respectively.
The second line consists of *n* positive integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=107), where *a**i* stands for the number of slices ... | If there's no way to present a tangerine or a part of tangerine to everyone, print -1. Otherwise, print the maximum possible joy that Santa can have. | [
"3 2\n5 9 3\n",
"2 4\n12 14\n",
"2 3\n1 1\n"
] | [
"5\n",
"6\n",
"-1\n"
] | In the first example Santa should divide the second tangerine into two parts with 5 and 4 slices. After that he can present the part with 5 slices to the first pupil and the whole first tangerine (with 5 slices, too) to the second pupil.
In the second example Santa should divide both tangerines, so that he'll be able ... | 2,500 | [] | 1,482,786,530 | 2,147,483,647 | PyPy 3 | MEMORY_LIMIT_EXCEEDED | TESTS | 10 | 826 | 268,390,400 | from collections import defaultdict
from itertools import accumulate
import bisect
def solve():
n, k = map(int, input().split())
A = [int(x) for x in input().split()]
D = [0]*(10**7)
for a in A:
D[a] += 1
for i in range(1, a.bit_length()):
D[a>>i] += 1<<i-1
T = list(ac... | Title: Santa Claus and Tangerines
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Santa Claus has *n* tangerines, and the *i*-th of them consists of exactly *a**i* slices. Santa Claus came to a school which has *k* pupils. Santa decided to treat them with tangerines.
However, there can be... | ```python
from collections import defaultdict
from itertools import accumulate
import bisect
def solve():
n, k = map(int, input().split())
A = [int(x) for x in input().split()]
D = [0]*(10**7)
for a in A:
D[a] += 1
for i in range(1, a.bit_length()):
D[a>>i] += 1<<i-1
T... | 0 | |
141 | A | Amusing Joke | PROGRAMMING | 800 | [
"implementation",
"sortings",
"strings"
] | null | null | So, the New Year holidays are over. Santa Claus and his colleagues can take a rest and have guests at last. When two "New Year and Christmas Men" meet, thear assistants cut out of cardboard the letters from the guest's name and the host's name in honor of this event. Then the hung the letters above the main entrance. O... | The input file consists of three lines: the first line contains the guest's name, the second line contains the name of the residence host and the third line contains letters in a pile that were found at the door in the morning. All lines are not empty and contain only uppercase Latin letters. The length of each line do... | Print "YES" without the quotes, if the letters in the pile could be permuted to make the names of the "New Year and Christmas Men". Otherwise, print "NO" without the quotes. | [
"SANTACLAUS\nDEDMOROZ\nSANTAMOROZDEDCLAUS\n",
"PAPAINOEL\nJOULUPUKKI\nJOULNAPAOILELUPUKKI\n",
"BABBONATALE\nFATHERCHRISTMAS\nBABCHRISTMASBONATALLEFATHER\n"
] | [
"YES\n",
"NO\n",
"NO\n"
] | In the first sample the letters written in the last line can be used to write the names and there won't be any extra letters left.
In the second sample letter "P" is missing from the pile and there's an extra letter "L".
In the third sample there's an extra letter "L". | 500 | [
{
"input": "SANTACLAUS\nDEDMOROZ\nSANTAMOROZDEDCLAUS",
"output": "YES"
},
{
"input": "PAPAINOEL\nJOULUPUKKI\nJOULNAPAOILELUPUKKI",
"output": "NO"
},
{
"input": "BABBONATALE\nFATHERCHRISTMAS\nBABCHRISTMASBONATALLEFATHER",
"output": "NO"
},
{
"input": "B\nA\nAB",
"output": ... | 1,697,884,917 | 2,147,483,647 | Python 3 | OK | TESTS | 54 | 92 | 0 | n1=input()
n2=input()
n3=input()
freq1={}
freq2={}
for i in n1 :
if i in freq1:
freq1[i]+=1
else:
freq1[i]=1
for i in n2 :
if i in freq1:
freq1[i]+=1
else:
freq1[i]=1
for i in n3:
if i in freq2:
freq2[i]+=1
else:
fr... | Title: Amusing Joke
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
So, the New Year holidays are over. Santa Claus and his colleagues can take a rest and have guests at last. When two "New Year and Christmas Men" meet, thear assistants cut out of cardboard the letters from the guest's nam... | ```python
n1=input()
n2=input()
n3=input()
freq1={}
freq2={}
for i in n1 :
if i in freq1:
freq1[i]+=1
else:
freq1[i]=1
for i in n2 :
if i in freq1:
freq1[i]+=1
else:
freq1[i]=1
for i in n3:
if i in freq2:
freq2[i]+=1
else:
... | 3 | |
0 | none | none | none | 0 | [
"none"
] | null | null | On vacations *n* pupils decided to go on excursion and gather all together. They need to overcome the path with the length *l* meters. Each of the pupils will go with the speed equal to *v*1. To get to the excursion quickly, it was decided to rent a bus, which has seats for *k* people (it means that it can't fit more t... | The first line of the input contains five positive integers *n*, *l*, *v*1, *v*2 and *k* (1<=≤<=*n*<=≤<=10<=000, 1<=≤<=*l*<=≤<=109, 1<=≤<=*v*1<=<<=*v*2<=≤<=109, 1<=≤<=*k*<=≤<=*n*) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of ... | Print the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10<=-<=6. | [
"5 10 1 2 5\n",
"3 6 1 2 1\n"
] | [
"5.0000000000\n",
"4.7142857143\n"
] | In the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5. | 0 | [
{
"input": "5 10 1 2 5",
"output": "5.0000000000"
},
{
"input": "3 6 1 2 1",
"output": "4.7142857143"
},
{
"input": "39 252 51 98 26",
"output": "3.5344336938"
},
{
"input": "59 96 75 98 9",
"output": "1.2315651330"
},
{
"input": "87 237 3 21 40",
"output": "3... | 1,607,498,110 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 0 | 108 | 0 | n, l, v1, v2, k = list(map(int, input().split()))
p = [0]*(l+1)
p[1] = n
i = l
t = (n+k-1)/k
low = 0.0
hi = 1e9+10
for i in range(100):
t1 = (hi+low)*0.5
len = t1 * t * v2 - (t-1) * v2 * t1 * (v2 - v1) / (v1 + v2)
if len>l:
hi = t1
else:
low = t1
print(t1+(l-t1*v2)/v1) | Title: none
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
On vacations *n* pupils decided to go on excursion and gather all together. They need to overcome the path with the length *l* meters. Each of the pupils will go with the speed equal to *v*1. To get to the excursion quickly, it wa... | ```python
n, l, v1, v2, k = list(map(int, input().split()))
p = [0]*(l+1)
p[1] = n
i = l
t = (n+k-1)/k
low = 0.0
hi = 1e9+10
for i in range(100):
t1 = (hi+low)*0.5
len = t1 * t * v2 - (t-1) * v2 * t1 * (v2 - v1) / (v1 + v2)
if len>l:
hi = t1
else:
low = t1
print(t1+(l-t1*v2)/v1)
``` | 0 | |
682 | A | Alyona and Numbers | PROGRAMMING | 1,100 | [
"constructive algorithms",
"math",
"number theory"
] | null | null | After finishing eating her bun, Alyona came up with two integers *n* and *m*. She decided to write down two columns of integers — the first column containing integers from 1 to *n* and the second containing integers from 1 to *m*. Now the girl wants to count how many pairs of integers she can choose, one from the first... | The only line of the input contains two integers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=1<=000<=000). | Print the only integer — the number of pairs of integers (*x*,<=*y*) such that 1<=≤<=*x*<=≤<=*n*, 1<=≤<=*y*<=≤<=*m* and (*x*<=+<=*y*) is divisible by 5. | [
"6 12\n",
"11 14\n",
"1 5\n",
"3 8\n",
"5 7\n",
"21 21\n"
] | [
"14\n",
"31\n",
"1\n",
"5\n",
"7\n",
"88\n"
] | Following pairs are suitable in the first sample case:
- for *x* = 1 fits *y* equal to 4 or 9; - for *x* = 2 fits *y* equal to 3 or 8; - for *x* = 3 fits *y* equal to 2, 7 or 12; - for *x* = 4 fits *y* equal to 1, 6 or 11; - for *x* = 5 fits *y* equal to 5 or 10; - for *x* = 6 fits *y* equal to 4 or 9.
Only th... | 500 | [
{
"input": "6 12",
"output": "14"
},
{
"input": "11 14",
"output": "31"
},
{
"input": "1 5",
"output": "1"
},
{
"input": "3 8",
"output": "5"
},
{
"input": "5 7",
"output": "7"
},
{
"input": "21 21",
"output": "88"
},
{
"input": "10 15",
... | 1,627,743,484 | 2,147,483,647 | Python 3 | OK | TESTS | 128 | 77 | 6,963,200 | n,k=map(int,input().split())
counter=0
if n>k:
h1=k
h2=n
else:
h1=n
h2=k
d=h2//5
mod=h2%5
r=h1//5
mod2=h1%5
counter=d*r*5+mod*r+mod2*d
for i in range(mod):
for j in range (mod2):
if ((i+1)+(j+1))%5==0:
counter+=1
print(int(counter)) | Title: Alyona and Numbers
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
After finishing eating her bun, Alyona came up with two integers *n* and *m*. She decided to write down two columns of integers — the first column containing integers from 1 to *n* and the second containing integers ... | ```python
n,k=map(int,input().split())
counter=0
if n>k:
h1=k
h2=n
else:
h1=n
h2=k
d=h2//5
mod=h2%5
r=h1//5
mod2=h1%5
counter=d*r*5+mod*r+mod2*d
for i in range(mod):
for j in range (mod2):
if ((i+1)+(j+1))%5==0:
counter+=1
print(int(counter))
``` | 3 | |
382 | C | Arithmetic Progression | PROGRAMMING | 1,700 | [
"implementation",
"sortings"
] | null | null | Everybody knows what an arithmetic progression is. Let us remind you just in case that an arithmetic progression is such sequence of numbers *a*1,<=*a*2,<=...,<=*a**n* of length *n*, that the following condition fulfills:
For example, sequences [1, 5], [10], [5, 4, 3] are arithmetic progressions and sequences [1, 3, ... | The first line contains integer *n* (1<=≤<=*n*<=≤<=105) — the number of cards. The next line contains the sequence of integers — the numbers on Alexander's cards. The numbers are positive integers, each of them doesn't exceed 108. | If Arthur can write infinitely many distinct integers on the card, print on a single line -1.
Otherwise, print on the first line the number of integers that suit you. In the second line, print the numbers in the increasing order. Note that the numbers in the answer can exceed 108 or even be negative (see test samples)... | [
"3\n4 1 7\n",
"1\n10\n",
"4\n1 3 5 9\n",
"4\n4 3 4 5\n",
"2\n2 4\n"
] | [
"2\n-2 10\n",
"-1\n",
"1\n7\n",
"0\n",
"3\n0 3 6\n"
] | none | 1,500 | [
{
"input": "3\n4 1 7",
"output": "2\n-2 10"
},
{
"input": "1\n10",
"output": "-1"
},
{
"input": "4\n1 3 5 9",
"output": "1\n7"
},
{
"input": "4\n4 3 4 5",
"output": "0"
},
{
"input": "2\n2 4",
"output": "3\n0 3 6"
},
{
"input": "4\n1 3 4 5",
"outpu... | 1,626,874,135 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 5 | 109 | 20,172,800 | n = int(input())
cards = list(map(int, input().split()))
if n == 1:
print(-1)
exit()
if n == 2:
middle = (cards[1] - cards[0]) // 2
if (cards[1] -cards[0]) % 2:
pass
else:
print(3)
print(cards[0] -middle-1, cards[0] + middle, cards[1] + middle+1)
exit()
cards.sor... | Title: Arithmetic Progression
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Everybody knows what an arithmetic progression is. Let us remind you just in case that an arithmetic progression is such sequence of numbers *a*1,<=*a*2,<=...,<=*a**n* of length *n*, that the following condition ... | ```python
n = int(input())
cards = list(map(int, input().split()))
if n == 1:
print(-1)
exit()
if n == 2:
middle = (cards[1] - cards[0]) // 2
if (cards[1] -cards[0]) % 2:
pass
else:
print(3)
print(cards[0] -middle-1, cards[0] + middle, cards[1] + middle+1)
exit()
... | 0 | |
459 | B | Pashmak and Flowers | PROGRAMMING | 1,300 | [
"combinatorics",
"implementation",
"sortings"
] | null | null | Pashmak decided to give Parmida a pair of flowers from the garden. There are *n* flowers in the garden and the *i*-th of them has a beauty number *b**i*. Parmida is a very strange girl so she doesn't want to have the two most beautiful flowers necessarily. She wants to have those pairs of flowers that their beauty diff... | The first line of the input contains *n* (2<=≤<=*n*<=≤<=2·105). In the next line there are *n* space-separated integers *b*1, *b*2, ..., *b**n* (1<=≤<=*b**i*<=≤<=109). | The only line of output should contain two integers. The maximum beauty difference and the number of ways this may happen, respectively. | [
"2\n1 2\n",
"3\n1 4 5\n",
"5\n3 1 2 3 1\n"
] | [
"1 1",
"4 1",
"2 4"
] | In the third sample the maximum beauty difference is 2 and there are 4 ways to do this:
1. choosing the first and the second flowers; 1. choosing the first and the fifth flowers; 1. choosing the fourth and the second flowers; 1. choosing the fourth and the fifth flowers. | 500 | [
{
"input": "2\n1 2",
"output": "1 1"
},
{
"input": "3\n1 4 5",
"output": "4 1"
},
{
"input": "5\n3 1 2 3 1",
"output": "2 4"
},
{
"input": "2\n1 1",
"output": "0 1"
},
{
"input": "3\n1 1 1",
"output": "0 3"
},
{
"input": "4\n1 1 1 1",
"output": "0 ... | 1,692,588,038 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 5 | 139 | 26,931,200 | n=int(input())
b=list(map(int,input().split()))
f=max(b)-min(b)
if(len(b)==2 and f==0):
print(f,1)
elif(b.count(max(b))>1 or b.count(min(b))):
print(f,(b.count(max(b))*b.count(min(b)))) | Title: Pashmak and Flowers
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Pashmak decided to give Parmida a pair of flowers from the garden. There are *n* flowers in the garden and the *i*-th of them has a beauty number *b**i*. Parmida is a very strange girl so she doesn't want to have th... | ```python
n=int(input())
b=list(map(int,input().split()))
f=max(b)-min(b)
if(len(b)==2 and f==0):
print(f,1)
elif(b.count(max(b))>1 or b.count(min(b))):
print(f,(b.count(max(b))*b.count(min(b))))
``` | 0 | |
482 | A | Diverse Permutation | PROGRAMMING | 1,200 | [
"constructive algorithms",
"greedy"
] | null | null | Permutation *p* is an ordered set of integers *p*1,<=<=<=*p*2,<=<=<=...,<=<=<=*p**n*, consisting of *n* distinct positive integers not larger than *n*. We'll denote as *n* the length of permutation *p*1,<=<=<=*p*2,<=<=<=...,<=<=<=*p**n*.
Your task is to find such permutation *p* of length *n*, that the group of number... | The single line of the input contains two space-separated positive integers *n*, *k* (1<=≤<=*k*<=<<=*n*<=≤<=105). | Print *n* integers forming the permutation. If there are multiple answers, print any of them. | [
"3 2\n",
"3 1\n",
"5 2\n"
] | [
"1 3 2\n",
"1 2 3\n",
"1 3 2 4 5\n"
] | By |*x*| we denote the absolute value of number *x*. | 500 | [
{
"input": "3 2",
"output": "1 3 2"
},
{
"input": "3 1",
"output": "1 2 3"
},
{
"input": "5 2",
"output": "1 3 2 4 5"
},
{
"input": "5 4",
"output": "1 5 2 4 3"
},
{
"input": "10 4",
"output": "1 10 2 9 8 7 6 5 4 3"
},
{
"input": "10 3",
"output": ... | 1,535,048,220 | 2,147,483,647 | Python 3 | OK | TESTS | 37 | 202 | 8,396,800 | n,k = map(int,input().split())
a = list(range(1,n+1))
for i in range(1,k+1): a[i] = a[i-1] + (k-i+1 if i&1 else i-k-1)
print(" ".join(repr(x) for x in a))
# Made By Mostafa_Khaled | Title: Diverse Permutation
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Permutation *p* is an ordered set of integers *p*1,<=<=<=*p*2,<=<=<=...,<=<=<=*p**n*, consisting of *n* distinct positive integers not larger than *n*. We'll denote as *n* the length of permutation *p*1,<=<=<=*p*2,<... | ```python
n,k = map(int,input().split())
a = list(range(1,n+1))
for i in range(1,k+1): a[i] = a[i-1] + (k-i+1 if i&1 else i-k-1)
print(" ".join(repr(x) for x in a))
# Made By Mostafa_Khaled
``` | 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.