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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
381 | A | Sereja and Dima | PROGRAMMING | 800 | [
"greedy",
"implementation",
"two pointers"
] | null | null | Sereja and Dima play a game. The rules of the game are very simple. The players have *n* cards in a row. Each card contains a number, all numbers on the cards are distinct. The players take turns, Sereja moves first. During his turn a player can take one card: either the leftmost card in a row, or the rightmost one. Th... | The first line contains integer *n* (1<=≤<=*n*<=≤<=1000) — the number of cards on the table. The second line contains space-separated numbers on the cards from left to right. The numbers on the cards are distinct integers from 1 to 1000. | On a single line, print two integers. The first number is the number of Sereja's points at the end of the game, the second number is the number of Dima's points at the end of the game. | [
"4\n4 1 2 10\n",
"7\n1 2 3 4 5 6 7\n"
] | [
"12 5\n",
"16 12\n"
] | In the first sample Sereja will take cards with numbers 10 and 2, so Sereja's sum is 12. Dima will take cards with numbers 4 and 1, so Dima's sum is 5. | 500 | [
{
"input": "4\n4 1 2 10",
"output": "12 5"
},
{
"input": "7\n1 2 3 4 5 6 7",
"output": "16 12"
},
{
"input": "42\n15 29 37 22 16 5 26 31 6 32 19 3 45 36 33 14 25 20 48 7 42 11 24 28 9 18 8 21 47 17 38 40 44 4 35 1 43 39 41 27 12 13",
"output": "613 418"
},
{
"input": "43\n32 ... | 1,689,764,071 | 2,147,483,647 | Python 3 | OK | TESTS | 34 | 46 | 0 | n=int(input())
l=[int(x) for x in input().split()]
s=d=0
count=0
for i in range(len(l)):
count+=1
if(count%2==1):
s+=max(l[0],l[-1])
else:
d+=max(l[0],l[-1])
l.remove(max(l[0],l[-1]))
print(s,d) | Title: Sereja and Dima
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Sereja and Dima play a game. The rules of the game are very simple. The players have *n* cards in a row. Each card contains a number, all numbers on the cards are distinct. The players take turns, Sereja moves first. Du... | ```python
n=int(input())
l=[int(x) for x in input().split()]
s=d=0
count=0
for i in range(len(l)):
count+=1
if(count%2==1):
s+=max(l[0],l[-1])
else:
d+=max(l[0],l[-1])
l.remove(max(l[0],l[-1]))
print(s,d)
``` | 3 | |
766 | A | Mahmoud and Longest Uncommon Subsequence | PROGRAMMING | 1,000 | [
"constructive algorithms",
"strings"
] | null | null | While Mahmoud and Ehab were practicing for IOI, they found a problem which name was Longest common subsequence. They solved it, and then Ehab challenged Mahmoud with another problem.
Given two strings *a* and *b*, find the length of their longest uncommon subsequence, which is the longest string that is a subsequence ... | The first line contains string *a*, and the second line — string *b*. Both of these strings are non-empty and consist of lowercase letters of English alphabet. The length of each string is not bigger than 105 characters. | If there's no uncommon subsequence, print "-1". Otherwise print the length of the longest uncommon subsequence of *a* and *b*. | [
"abcd\ndefgh\n",
"a\na\n"
] | [
"5\n",
"-1\n"
] | In the first example: you can choose "defgh" from string *b* as it is the longest subsequence of string *b* that doesn't appear as a subsequence of string *a*. | 500 | [
{
"input": "abcd\ndefgh",
"output": "5"
},
{
"input": "a\na",
"output": "-1"
},
{
"input": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaacccccccccccccccccccccccccccccccccccccccccccccccccc\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaadddddddddddddddddddddddddddddddddddddddddddd... | 1,674,040,839 | 2,147,483,647 | Python 3 | OK | TESTS | 73 | 46 | 204,800 | a = input()
b = input()
lena = len(a)
lenb = len(b)
if(lena != lenb):
print(max(lena,lenb))
exit()
if a.find(b) < 0:
print(lena)
exit()
print(-1)
| Title: Mahmoud and Longest Uncommon Subsequence
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
While Mahmoud and Ehab were practicing for IOI, they found a problem which name was Longest common subsequence. They solved it, and then Ehab challenged Mahmoud with another problem.
Given two ... | ```python
a = input()
b = input()
lena = len(a)
lenb = len(b)
if(lena != lenb):
print(max(lena,lenb))
exit()
if a.find(b) < 0:
print(lena)
exit()
print(-1)
``` | 3 | |
359 | B | Permutation | PROGRAMMING | 1,400 | [
"constructive algorithms",
"dp",
"math"
] | null | null | A permutation *p* is an ordered group of numbers *p*1,<=<=<=*p*2,<=<=<=...,<=<=<=*p**n*, consisting of *n* distinct positive integers, each is no more than *n*. We'll define number *n* as the length of permutation *p*1,<=<=<=*p*2,<=<=<=...,<=<=<=*p**n*.
Simon has a positive integer *n* and a non-negative integer *k*, ... | The first line contains two integers *n* and *k* (1<=≤<=*n*<=≤<=50000, 0<=≤<=2*k*<=≤<=*n*). | Print 2*n* integers *a*1,<=*a*2,<=...,<=*a*2*n* — the required permutation *a*. It is guaranteed that the solution exists. If there are multiple solutions, you can print any of them. | [
"1 0\n",
"2 1\n",
"4 0\n"
] | [
"1 2",
"3 2 1 4\n",
"2 7 4 6 1 3 5 8\n"
] | Record |*x*| represents the absolute value of number *x*.
In the first sample |1 - 2| - |1 - 2| = 0.
In the second sample |3 - 2| + |1 - 4| - |3 - 2 + 1 - 4| = 1 + 3 - 2 = 2.
In the third sample |2 - 7| + |4 - 6| + |1 - 3| + |5 - 8| - |2 - 7 + 4 - 6 + 1 - 3 + 5 - 8| = 12 - 12 = 0. | 1,000 | [
{
"input": "1 0",
"output": "1 2"
},
{
"input": "2 1",
"output": "3 2 1 4"
},
{
"input": "4 0",
"output": "2 7 4 6 1 3 5 8"
},
{
"input": "50000 0",
"output": "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 4... | 1,560,799,229 | 2,147,483,647 | Python 3 | OK | TESTS | 30 | 155 | 7,168,000 | import math
import sys
#imgur.com/Pkt7iIf.png
#n, m = map(int, input().split())
#n = int(input())
#d = list(map(int, input().split()))
n, k = map(int, input().split())
s = list(range(1, 2*n+1))
j = 0
for i in range(k):
s[j], s[j+1] = s[j+1], s[j]
j += 2
print(' '.join(str(x) for x in s)) | Title: Permutation
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
A permutation *p* is an ordered group of numbers *p*1,<=<=<=*p*2,<=<=<=...,<=<=<=*p**n*, consisting of *n* distinct positive integers, each is no more than *n*. We'll define number *n* as the length of permutation *p*1,<=<=... | ```python
import math
import sys
#imgur.com/Pkt7iIf.png
#n, m = map(int, input().split())
#n = int(input())
#d = list(map(int, input().split()))
n, k = map(int, input().split())
s = list(range(1, 2*n+1))
j = 0
for i in range(k):
s[j], s[j+1] = s[j+1], s[j]
j += 2
print(' '.join(str(x) for ... | 3 | |
808 | G | Anthem of Berland | PROGRAMMING | 2,300 | [
"dp",
"strings"
] | null | null | Berland has a long and glorious history. To increase awareness about it among younger citizens, King of Berland decided to compose an anthem.
Though there are lots and lots of victories in history of Berland, there is the one that stand out the most. King wants to mention it in the anthem as many times as possible.
H... | The first line contains string of small Latin letters and question marks *s* (1<=≤<=|*s*|<=≤<=105).
The second line contains string of small Latin letters *t* (1<=≤<=|*t*|<=≤<=105).
Product of lengths of strings |*s*|·|*t*| won't exceed 107. | Output the maximum number of occurrences of string *t* you can achieve by replacing all the question marks in string *s* with small Latin letters. | [
"winlose???winl???w??\nwin\n",
"glo?yto?e??an?\nor\n",
"??c?????\nabcab\n"
] | [
"5\n",
"3\n",
"2\n"
] | In the first example the resulting string *s* is "winlosewinwinlwinwin"
In the second example the resulting string *s* is "glorytoreorand". The last letter of the string can be arbitrary.
In the third example occurrences of string *t* are overlapping. String *s* with maximal number of occurrences of *t* is "abcabcab"... | 0 | [
{
"input": "winlose???winl???w??\nwin",
"output": "5"
},
{
"input": "glo?yto?e??an?\nor",
"output": "3"
},
{
"input": "??c?????\nabcab",
"output": "2"
},
{
"input": "ddddd\nd",
"output": "5"
},
{
"input": "ww?ww\nw",
"output": "5"
},
{
"input": "?????\... | 1,692,286,690 | 2,147,483,647 | Python 3 | COMPILATION_ERROR | TESTS | 0 | 0 | 0 | def maximize_occurences(s,t):
n=len(s)
m=len(t)
max_occurence=0
for i in range(m):
occurences=0
for j in range(m):
if s[i+1]!='?' and s[i+j]!=t[i]:
break
else:
for i in range(m):
if s[i+j]=='?':
... | Title: Anthem of Berland
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Berland has a long and glorious history. To increase awareness about it among younger citizens, King of Berland decided to compose an anthem.
Though there are lots and lots of victories in history of Berland, there i... | ```python
def maximize_occurences(s,t):
n=len(s)
m=len(t)
max_occurence=0
for i in range(m):
occurences=0
for j in range(m):
if s[i+1]!='?' and s[i+j]!=t[i]:
break
else:
for i in range(m):
if s[i+j]=='... | -1 | |
6 | B | President's Office | PROGRAMMING | 1,100 | [
"implementation"
] | B. President's Office | 2 | 64 | President of Berland has a very vast office-room, where, apart from him, work his subordinates. Each subordinate, as well as President himself, has his own desk of a unique colour. Each desk is rectangular, and its sides are parallel to the office walls. One day President decided to establish an assembly, of which all ... | The first line contains two separated by a space integer numbers *n*, *m* (1<=≤<=*n*,<=*m*<=≤<=100) — the length and the width of the office-room, and *c* character — the President's desk colour. The following *n* lines contain *m* characters each — the office-room description. It is guaranteed that the colour of each ... | Print the only number — the amount of President's deputies. | [
"3 4 R\nG.B.\n.RR.\nTTT.\n",
"3 3 Z\n...\n.H.\n..Z\n"
] | [
"2\n",
"0\n"
] | none | 0 | [
{
"input": "3 4 R\nG.B.\n.RR.\nTTT.",
"output": "2"
},
{
"input": "3 3 Z\n...\n.H.\n..Z",
"output": "0"
},
{
"input": "1 1 C\nC",
"output": "0"
},
{
"input": "2 2 W\nKW\nKW",
"output": "1"
},
{
"input": "1 10 H\n....DDHHHH",
"output": "1"
},
{
"input":... | 1,675,189,768 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 3 | 46 | 0 | n = input().split()
k =int(n[0])
h =int(n[1])
l=(n[2])
s=0
c=[]
for i in range (k-1):
a=[]
m = input()
for j in m:
a.append(j)
c.append(a)
for p in range(h-1):
if a[p] == l:
if (a[p+1] =='.'or a[p+1]==l) and (a[p-1]=='.' or a[p-1]==l) :
s+=1
if k >=2:
for i in range (len(c)-1):
if c[i] == c[i+1]:
... | Title: President's Office
Time Limit: 2 seconds
Memory Limit: 64 megabytes
Problem Description:
President of Berland has a very vast office-room, where, apart from him, work his subordinates. Each subordinate, as well as President himself, has his own desk of a unique colour. Each desk is rectangular, and its sides ... | ```python
n = input().split()
k =int(n[0])
h =int(n[1])
l=(n[2])
s=0
c=[]
for i in range (k-1):
a=[]
m = input()
for j in m:
a.append(j)
c.append(a)
for p in range(h-1):
if a[p] == l:
if (a[p+1] =='.'or a[p+1]==l) and (a[p-1]=='.' or a[p-1]==l) :
s+=1
if k >=2:
for i in range (len(c)-1):
if c[i] == c... | 0 |
7 | A | Kalevitch and Chess | PROGRAMMING | 1,100 | [
"brute force",
"constructive algorithms"
] | A. Kalevitch and Chess | 2 | 64 | A famous Berland's painter Kalevitch likes to shock the public. One of his last obsessions is chess. For more than a thousand years people have been playing this old game on uninteresting, monotonous boards. Kalevitch decided to put an end to this tradition and to introduce a new attitude to chessboards.
As before, th... | The input file contains 8 lines, each of the lines contains 8 characters. The given matrix describes the client's requirements, W character stands for a white square, and B character — for a square painted black.
It is guaranteed that client's requirments can be fulfilled with a sequence of allowed strokes (vertical/c... | Output the only number — the minimum amount of rows and columns that Kalevitch has to paint on the white chessboard to meet the client's requirements. | [
"WWWBWWBW\nBBBBBBBB\nWWWBWWBW\nWWWBWWBW\nWWWBWWBW\nWWWBWWBW\nWWWBWWBW\nWWWBWWBW\n",
"WWWWWWWW\nBBBBBBBB\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW\n"
] | [
"3\n",
"1\n"
] | none | 0 | [
{
"input": "WWWBWWBW\nBBBBBBBB\nWWWBWWBW\nWWWBWWBW\nWWWBWWBW\nWWWBWWBW\nWWWBWWBW\nWWWBWWBW",
"output": "3"
},
{
"input": "WWWWWWWW\nBBBBBBBB\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW",
"output": "1"
},
{
"input": "WWWWWWWW\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW\nWWWWWW... | 1,669,755,511 | 2,147,483,647 | Python 3 | OK | TESTS | 30 | 92 | 0 | board = [input().split() for i in range(8)]
numberOfLines = 0
for y in range(8):
if board[y] == ['BBBBBBBB']:
numberOfLines += 1
for x in range(8):
verticalCount = 0
for y in range(8):
# [down from top][0][across from left]
if board[y][0][x] == 'B':
verti... | Title: Kalevitch and Chess
Time Limit: 2 seconds
Memory Limit: 64 megabytes
Problem Description:
A famous Berland's painter Kalevitch likes to shock the public. One of his last obsessions is chess. For more than a thousand years people have been playing this old game on uninteresting, monotonous boards. Kalevitch de... | ```python
board = [input().split() for i in range(8)]
numberOfLines = 0
for y in range(8):
if board[y] == ['BBBBBBBB']:
numberOfLines += 1
for x in range(8):
verticalCount = 0
for y in range(8):
# [down from top][0][across from left]
if board[y][0][x] == 'B':
... | 3.977 |
0 | none | none | none | 0 | [
"none"
] | null | null | Once upon a time in the Kingdom of Far Far Away lived Sam the Farmer. Sam had a cow named Dawn and he was deeply attached to her. Sam would spend the whole summer stocking hay to feed Dawn in winter. Sam scythed hay and put it into haystack. As Sam was a bright farmer, he tried to make the process of storing hay simple... | The only line contains integer *n* from the problem's statement (1<=≤<=*n*<=≤<=109). | Print space-separated minimum and maximum number of hay blocks that could have been stolen by the thieves.
Note that the answer to the problem can be large enough, so you must use the 64-bit integer type for calculations. Please, do not use the %lld specificator to read or write 64-bit integers in С++. It is preferred... | [
"4\n",
"7\n",
"12\n"
] | [
"28 41\n",
"47 65\n",
"48 105\n"
] | Let's consider the first sample test. If initially Sam has a parallelepiped consisting of 32 = 2 × 4 × 4 hay blocks in his barn, then after the theft the barn has 4 = (2 - 1) × (4 - 2) × (4 - 2) hay blocks left. Thus, the thieves could have stolen 32 - 4 = 28 hay blocks. If Sam initially had a parallelepiped consisting... | 0 | [
{
"input": "4",
"output": "28 41"
},
{
"input": "7",
"output": "47 65"
},
{
"input": "12",
"output": "48 105"
},
{
"input": "1",
"output": "17 17"
},
{
"input": "6",
"output": "34 57"
},
{
"input": "8",
"output": "40 73"
},
{
"input": "9",
... | 1,689,437,113 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 0 | 15 | 0 | print("_RANDOM_GUESS_1689437113.2760484")# 1689437113.2760677 | Title: none
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Once upon a time in the Kingdom of Far Far Away lived Sam the Farmer. Sam had a cow named Dawn and he was deeply attached to her. Sam would spend the whole summer stocking hay to feed Dawn in winter. Sam scythed hay and put it int... | ```python
print("_RANDOM_GUESS_1689437113.2760484")# 1689437113.2760677
``` | 0 | |
302 | B | Eugeny and Play List | PROGRAMMING | 1,200 | [
"binary search",
"implementation",
"two pointers"
] | null | null | Eugeny loves listening to music. He has *n* songs in his play list. We know that song number *i* has the duration of *t**i* minutes. Eugeny listens to each song, perhaps more than once. He listens to song number *i* *c**i* times. Eugeny's play list is organized as follows: first song number 1 plays *c*1 times, then son... | The first line contains two integers *n*, *m* (1<=≤<=*n*,<=*m*<=≤<=105). The next *n* lines contain pairs of integers. The *i*-th line contains integers *c**i*,<=*t**i* (1<=≤<=*c**i*,<=*t**i*<=≤<=109) — the description of the play list. It is guaranteed that the play list's total duration doesn't exceed 109 .
The next... | Print *m* integers — the *i*-th number must equal the number of the song that was playing during the *v**i*-th minute after Eugeny started listening to the play list. | [
"1 2\n2 8\n1 16\n",
"4 9\n1 2\n2 1\n1 1\n2 2\n1 2 3 4 5 6 7 8 9\n"
] | [
"1\n1\n",
"1\n1\n2\n2\n3\n4\n4\n4\n4\n"
] | none | 1,000 | [
{
"input": "1 2\n2 8\n1 16",
"output": "1\n1"
},
{
"input": "4 9\n1 2\n2 1\n1 1\n2 2\n1 2 3 4 5 6 7 8 9",
"output": "1\n1\n2\n2\n3\n4\n4\n4\n4"
},
{
"input": "3 3\n2 8\n5 1\n10 5\n13 16 62",
"output": "1\n1\n3"
},
{
"input": "4 4\n2 8\n2 2\n6 3\n8 7\n13 23 29 85",
"output... | 1,517,788,603 | 2,147,483,647 | Python 3 | OK | TESTS | 54 | 1,526 | 20,582,400 | import sys
def dist(x1, y1, x2, y2):
return abs(x2 - x1) + abs(y2 - y1)
n, m = [int(x) for x in sys.stdin.readline().strip().split(" ")]
songs = []
for i in range(n):
cur = [int(x) for x in sys.stdin.readline().strip().split(" ")]
songs.append(cur)
queries = [int(x) for x in sys.stdin.readline().strip().spli... | Title: Eugeny and Play List
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Eugeny loves listening to music. He has *n* songs in his play list. We know that song number *i* has the duration of *t**i* minutes. Eugeny listens to each song, perhaps more than once. He listens to song number *i... | ```python
import sys
def dist(x1, y1, x2, y2):
return abs(x2 - x1) + abs(y2 - y1)
n, m = [int(x) for x in sys.stdin.readline().strip().split(" ")]
songs = []
for i in range(n):
cur = [int(x) for x in sys.stdin.readline().strip().split(" ")]
songs.append(cur)
queries = [int(x) for x in sys.stdin.readline().st... | 3 | |
228 | A | Is your horseshoe on the other hoof? | PROGRAMMING | 800 | [
"implementation"
] | null | null | Valera the Horse is going to the party with friends. He has been following the fashion trends for a while, and he knows that it is very popular to wear all horseshoes of different color. Valera has got four horseshoes left from the last year, but maybe some of them have the same color. In this case he needs to go to th... | The first line contains four space-separated integers *s*1,<=*s*2,<=*s*3,<=*s*4 (1<=≤<=*s*1,<=*s*2,<=*s*3,<=*s*4<=≤<=109) — the colors of horseshoes Valera has.
Consider all possible colors indexed with integers. | Print a single integer — the minimum number of horseshoes Valera needs to buy. | [
"1 7 3 3\n",
"7 7 7 7\n"
] | [
"1\n",
"3\n"
] | none | 500 | [
{
"input": "1 7 3 3",
"output": "1"
},
{
"input": "7 7 7 7",
"output": "3"
},
{
"input": "81170865 673572653 756938629 995577259",
"output": "0"
},
{
"input": "3491663 217797045 522540872 715355328",
"output": "0"
},
{
"input": "251590420 586975278 916631563 58697... | 1,686,122,780 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 34 | 122 | 0 | '''
1
'''
# n = int(input().strip())
# ans = 0
# for i in range(n):
# a = map(int, input().split(' '))
# if sum(a) > 1:
# ans+=1
# print(ans)
'''
2
'''
print(4-len(set(input().strip().split(' ')))) | Title: Is your horseshoe on the other hoof?
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Valera the Horse is going to the party with friends. He has been following the fashion trends for a while, and he knows that it is very popular to wear all horseshoes of different color. Valera has ... | ```python
'''
1
'''
# n = int(input().strip())
# ans = 0
# for i in range(n):
# a = map(int, input().split(' '))
# if sum(a) > 1:
# ans+=1
# print(ans)
'''
2
'''
print(4-len(set(input().strip().split(' '))))
``` | 3 | |
965 | A | Paper Airplanes | PROGRAMMING | 800 | [
"math"
] | null | null | To make a paper airplane, one has to use a rectangular piece of paper. From a sheet of standard size you can make $s$ airplanes.
A group of $k$ people decided to make $n$ airplanes each. They are going to buy several packs of paper, each of them containing $p$ sheets, and then distribute the sheets between the people.... | The only line contains four integers $k$, $n$, $s$, $p$ ($1 \le k, n, s, p \le 10^4$) — the number of people, the number of airplanes each should make, the number of airplanes that can be made using one sheet and the number of sheets in one pack, respectively. | Print a single integer — the minimum number of packs they should buy. | [
"5 3 2 3\n",
"5 3 100 1\n"
] | [
"4\n",
"5\n"
] | In the first sample they have to buy $4$ packs of paper: there will be $12$ sheets in total, and giving $2$ sheets to each person is enough to suit everyone's needs.
In the second sample they have to buy a pack for each person as they can't share sheets. | 500 | [
{
"input": "5 3 2 3",
"output": "4"
},
{
"input": "5 3 100 1",
"output": "5"
},
{
"input": "10000 10000 1 1",
"output": "100000000"
},
{
"input": "1 1 10000 10000",
"output": "1"
},
{
"input": "300 300 21 23",
"output": "196"
},
{
"input": "300 2 37 51... | 1,524,680,468 | 2,768 | Python 3 | RUNTIME_ERROR | PRETESTS | 0 | 62 | 7,065,600 | {
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"l=input().split()\n",
"\n",
"k=int(l[0])\n",
"n=int(l[1])\n",
"s=int(l[2])\n",
"p=int(l[3])\n",
"\n",
"print((((n-1)//s+1)*k-1)//p+1)"
]
}
],
"metadata": {
... | Title: Paper Airplanes
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
To make a paper airplane, one has to use a rectangular piece of paper. From a sheet of standard size you can make $s$ airplanes.
A group of $k$ people decided to make $n$ airplanes each. They are going to buy several p... | ```python
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"l=input().split()\n",
"\n",
"k=int(l[0])\n",
"n=int(l[1])\n",
"s=int(l[2])\n",
"p=int(l[3])\n",
"\n",
"print((((n-1)//s+1)*k-1)//p+1)"
]
}
],
"metad... | -1 | |
276 | C | Little Girl and Maximum Sum | PROGRAMMING | 1,500 | [
"data structures",
"greedy",
"implementation",
"sortings"
] | null | null | The little girl loves the problems on array queries very much.
One day she came across a rather well-known problem: you've got an array of $n$ elements (the elements of the array are indexed starting from 1); also, there are $q$ queries, each one is defined by a pair of integers $l_i$, $r_i$ $(1 \le l_i \le r_i \le n)... | The first line contains two space-separated integers $n$ ($1 \le n \le 2\cdot10^5$) and $q$ ($1 \le q \le 2\cdot10^5$) — the number of elements in the array and the number of queries, correspondingly.
The next line contains $n$ space-separated integers $a_i$ ($1 \le a_i \le 2\cdot10^5$) — the array elements.
Each of ... | In a single line print, a single integer — the maximum sum of query replies after the array elements are reordered.
Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier. | [
"3 3\n5 3 2\n1 2\n2 3\n1 3\n",
"5 3\n5 2 4 1 3\n1 5\n2 3\n2 3\n"
] | [
"25\n",
"33\n"
] | none | 1,500 | [
{
"input": "3 3\n5 3 2\n1 2\n2 3\n1 3",
"output": "25"
},
{
"input": "5 3\n5 2 4 1 3\n1 5\n2 3\n2 3",
"output": "33"
},
{
"input": "34 21\n23 38 16 49 44 50 48 34 33 19 18 31 11 15 20 47 44 30 39 33 45 46 1 13 27 16 31 36 17 23 38 5 30 16\n8 16\n14 27\n8 26\n1 8\n5 6\n23 28\n4 33\n13 30\... | 1,635,818,335 | 2,147,483,647 | Python 3 | MEMORY_LIMIT_EXCEEDED | TESTS | 6 | 764 | 268,390,400 | import collections
n,q = [int(x) for x in input().split(" ")]
lis = sorted([int(x) for x in input().split(" ")],reverse=True)
count = []
for i in range(q):
l,r = [int(x) for x in input().split(" ")]
count += list(range(l,r+1))
count = sorted(collections.Counter(count).values(),reverse=True)
ll... | Title: Little Girl and Maximum Sum
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The little girl loves the problems on array queries very much.
One day she came across a rather well-known problem: you've got an array of $n$ elements (the elements of the array are indexed starting from 1... | ```python
import collections
n,q = [int(x) for x in input().split(" ")]
lis = sorted([int(x) for x in input().split(" ")],reverse=True)
count = []
for i in range(q):
l,r = [int(x) for x in input().split(" ")]
count += list(range(l,r+1))
count = sorted(collections.Counter(count).values(),reverse=T... | 0 | |
59 | A | Word | PROGRAMMING | 800 | [
"implementation",
"strings"
] | A. Word | 2 | 256 | Vasya is very upset that many people on the Net mix uppercase and lowercase letters in one word. That's why he decided to invent an extension for his favorite browser that would change the letters' register in every word so that it either only consisted of lowercase letters or, vice versa, only of uppercase ones. At th... | The first line contains a word *s* — it consists of uppercase and lowercase Latin letters and possesses the length from 1 to 100. | Print the corrected word *s*. If the given word *s* has strictly more uppercase letters, make the word written in the uppercase register, otherwise - in the lowercase one. | [
"HoUse\n",
"ViP\n",
"maTRIx\n"
] | [
"house\n",
"VIP\n",
"matrix\n"
] | none | 500 | [
{
"input": "HoUse",
"output": "house"
},
{
"input": "ViP",
"output": "VIP"
},
{
"input": "maTRIx",
"output": "matrix"
},
{
"input": "BNHWpnpawg",
"output": "bnhwpnpawg"
},
{
"input": "VTYGP",
"output": "VTYGP"
},
{
"input": "CHNenu",
"output": "chn... | 1,661,106,993 | 2,147,483,647 | Python 3 | OK | TESTS | 30 | 92 | 0 | word = [x for x in input()]
upper = 0
for i in word:
if i.isupper():
upper += 1
if upper > len(word)-upper:
for x in word:
print(x.upper(), end="")
else:
for x in word:
print(x.lower(), end="")
| Title: Word
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Vasya is very upset that many people on the Net mix uppercase and lowercase letters in one word. That's why he decided to invent an extension for his favorite browser that would change the letters' register in every word so that it ei... | ```python
word = [x for x in input()]
upper = 0
for i in word:
if i.isupper():
upper += 1
if upper > len(word)-upper:
for x in word:
print(x.upper(), end="")
else:
for x in word:
print(x.lower(), end="")
``` | 3.977 |
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,432,117,048 | 2,147,483,647 | Python 3 | OK | TESTS | 37 | 92 | 409,600 | b = input().strip()
p = b.find('0')
os = ''
if p != -1:
os = b[:p] + b[p+1:]
else:
os = b[1:]
print(os) | 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
b = input().strip()
p = b.find('0')
os = ''
if p != -1:
os = b[:p] + b[p+1:]
else:
os = b[1:]
print(os)
``` | 3 | |
899 | A | Splitting in Teams | PROGRAMMING | 800 | [
"constructive algorithms",
"greedy",
"math"
] | null | null | There were *n* groups of students which came to write a training contest. A group is either one person who can write the contest with anyone else, or two people who want to write the contest in the same team.
The coach decided to form teams of exactly three people for this training. Determine the maximum number of tea... | The first line contains single integer *n* (2<=≤<=*n*<=≤<=2·105) — the number of groups.
The second line contains a sequence of integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=2), where *a**i* is the number of people in group *i*. | Print the maximum number of teams of three people the coach can form. | [
"4\n1 1 2 1\n",
"2\n2 2\n",
"7\n2 2 2 1 1 1 1\n",
"3\n1 1 1\n"
] | [
"1\n",
"0\n",
"3\n",
"1\n"
] | In the first example the coach can form one team. For example, he can take students from the first, second and fourth groups.
In the second example he can't make a single team.
In the third example the coach can form three teams. For example, he can do this in the following way:
- The first group (of two people) an... | 500 | [
{
"input": "4\n1 1 2 1",
"output": "1"
},
{
"input": "2\n2 2",
"output": "0"
},
{
"input": "7\n2 2 2 1 1 1 1",
"output": "3"
},
{
"input": "3\n1 1 1",
"output": "1"
},
{
"input": "3\n2 2 2",
"output": "0"
},
{
"input": "3\n1 2 1",
"output": "1"
}... | 1,674,923,657 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 6 | 108 | 3,891,200 | n = int(input())
lis = list(map(int,input().split()))
c_1 = 0
c_2 = 0
t = 0
for i in lis:
if i == 1:
c_1 += 1
else:
c_2 += 1
if c_1 == c_2:
t = c_1
elif c_1 > c_2:
t = c_2
c1 = c_1 - c_2
t += c1 // 3
elif c_1 != 0:
t = c_2
print(t) | Title: Splitting in Teams
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
There were *n* groups of students which came to write a training contest. A group is either one person who can write the contest with anyone else, or two people who want to write the contest in the same team.
The co... | ```python
n = int(input())
lis = list(map(int,input().split()))
c_1 = 0
c_2 = 0
t = 0
for i in lis:
if i == 1:
c_1 += 1
else:
c_2 += 1
if c_1 == c_2:
t = c_1
elif c_1 > c_2:
t = c_2
c1 = c_1 - c_2
t += c1 // 3
elif c_1 != 0:
t = c_2
print(t)
``` | 0 | |
883 | M | Quadcopter Competition | PROGRAMMING | 1,100 | [
"greedy",
"math"
] | null | null | Polycarp takes part in a quadcopter competition. According to the rules a flying robot should:
- start the race from some point of a field, - go around the flag, - close cycle returning back to the starting point.
Polycarp knows the coordinates of the starting point (*x*1,<=*y*1) and the coordinates of the point w... | The first line contains two integer numbers *x*1 and *y*1 (<=-<=100<=≤<=*x*1,<=*y*1<=≤<=100) — coordinates of the quadcopter starting (and finishing) point.
The second line contains two integer numbers *x*2 and *y*2 (<=-<=100<=≤<=*x*2,<=*y*2<=≤<=100) — coordinates of the flag.
It is guaranteed that the quadcopter sta... | Print the length of minimal path of the quadcopter to surround the flag and return back. | [
"1 5\n5 2\n",
"0 1\n0 0\n"
] | [
"18\n",
"8\n"
] | none | 0 | [
{
"input": "1 5\n5 2",
"output": "18"
},
{
"input": "0 1\n0 0",
"output": "8"
},
{
"input": "-100 -100\n100 100",
"output": "804"
},
{
"input": "-100 -100\n-100 100",
"output": "406"
},
{
"input": "-100 -100\n100 -100",
"output": "406"
},
{
"input": "1... | 1,508,802,046 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 30 | 5,529,600 | z=lambda:map(int,input().split())
d=lambda:max(abs(a-b)+1,2)
q,w=z()
e,r=z()
print((d(q,e)+d(w,r))*2) | Title: Quadcopter Competition
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Polycarp takes part in a quadcopter competition. According to the rules a flying robot should:
- start the race from some point of a field, - go around the flag, - close cycle returning back to the starting p... | ```python
z=lambda:map(int,input().split())
d=lambda:max(abs(a-b)+1,2)
q,w=z()
e,r=z()
print((d(q,e)+d(w,r))*2)
``` | -1 | |
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,680,972,882 | 2,147,483,647 | PyPy 3-64 | COMPILATION_ERROR | TESTS | 0 | 0 | 0 | n, f = map(int, input().split())
products = []
clients = []
total_sold = 0
for i in range(n):
k, l = map(int, input().split())
products.append(k)
clients.append(l)
total_sold += min(k, l)
diff = [products[i] - clients[i] for i in range(n)]
for i in sorted(range(n), key=lambda i: diff[i], reverse=True)[:... | 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())
products = []
clients = []
total_sold = 0
for i in range(n):
k, l = map(int, input().split())
products.append(k)
clients.append(l)
total_sold += min(k, l)
diff = [products[i] - clients[i] for i in range(n)]
for i in sorted(range(n), key=lambda i: diff[i], rever... | -1 | |
938 | D | Buy a Ticket | PROGRAMMING | 2,000 | [
"data structures",
"graphs",
"shortest paths"
] | null | null | Musicians of a popular band "Flayer" have announced that they are going to "make their exit" with a world tour. Of course, they will visit Berland as well.
There are *n* cities in Berland. People can travel between cities using two-directional train routes; there are exactly *m* routes, *i*-th route can be used to go ... | The first line contains two integers *n* and *m* (2<=≤<=*n*<=≤<=2·105, 1<=≤<=*m*<=≤<=2·105).
Then *m* lines follow, *i*-th contains three integers *v**i*, *u**i* and *w**i* (1<=≤<=*v**i*,<=*u**i*<=≤<=*n*,<=*v**i*<=≠<=*u**i*, 1<=≤<=*w**i*<=≤<=1012) denoting *i*-th train route. There are no multiple train routes connect... | Print *n* integers. *i*-th of them must be equal to the minimum number of coins a person from city *i* has to spend to travel to some city *j* (or possibly stay in city *i*), attend a concert there, and return to city *i* (if *j*<=≠<=*i*). | [
"4 2\n1 2 4\n2 3 7\n6 20 1 25\n",
"3 3\n1 2 1\n2 3 1\n1 3 1\n30 10 20\n"
] | [
"6 14 1 25 \n",
"12 10 12 \n"
] | none | 0 | [
{
"input": "4 2\n1 2 4\n2 3 7\n6 20 1 25",
"output": "6 14 1 25 "
},
{
"input": "3 3\n1 2 1\n2 3 1\n1 3 1\n30 10 20",
"output": "12 10 12 "
},
{
"input": "7 7\n1 6 745325\n2 3 3581176\n2 4 19\n3 6 71263060078\n5 4 141198\n7 4 163953\n5 6 15994\n1 297404206755 82096176217 14663411 1873897... | 1,537,041,325 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 2 | 2,000 | 61,337,600 | import heapq
n, m = input().split(' ')
n, m = int(n), int(m)
# Add in a source at index 0
adj_list = [[] for _ in range(n + 1)]
for i in range(m):
v, u, w = input().split(' ')
v, u, w = int(v), int(u), int(w)
adj_list[v].append((u, 2 * w))
adj_list[u].append((v, 2 * w))
costs = [int(x) for x in in... | Title: Buy a Ticket
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Musicians of a popular band "Flayer" have announced that they are going to "make their exit" with a world tour. Of course, they will visit Berland as well.
There are *n* cities in Berland. People can travel between cities... | ```python
import heapq
n, m = input().split(' ')
n, m = int(n), int(m)
# Add in a source at index 0
adj_list = [[] for _ in range(n + 1)]
for i in range(m):
v, u, w = input().split(' ')
v, u, w = int(v), int(u), int(w)
adj_list[v].append((u, 2 * w))
adj_list[u].append((v, 2 * w))
costs = [int(x) f... | 0 | |
59 | A | Word | PROGRAMMING | 800 | [
"implementation",
"strings"
] | A. Word | 2 | 256 | Vasya is very upset that many people on the Net mix uppercase and lowercase letters in one word. That's why he decided to invent an extension for his favorite browser that would change the letters' register in every word so that it either only consisted of lowercase letters or, vice versa, only of uppercase ones. At th... | The first line contains a word *s* — it consists of uppercase and lowercase Latin letters and possesses the length from 1 to 100. | Print the corrected word *s*. If the given word *s* has strictly more uppercase letters, make the word written in the uppercase register, otherwise - in the lowercase one. | [
"HoUse\n",
"ViP\n",
"maTRIx\n"
] | [
"house\n",
"VIP\n",
"matrix\n"
] | none | 500 | [
{
"input": "HoUse",
"output": "house"
},
{
"input": "ViP",
"output": "VIP"
},
{
"input": "maTRIx",
"output": "matrix"
},
{
"input": "BNHWpnpawg",
"output": "bnhwpnpawg"
},
{
"input": "VTYGP",
"output": "VTYGP"
},
{
"input": "CHNenu",
"output": "chn... | 1,671,558,571 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 30 | 122 | 0 | a = input()
b,c = 0,0
for i in a:
if i.isupper():
b+=1
else:
c+=1
if b > c:
print(a.upper())
else:
print(a.lower()) | Title: Word
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Vasya is very upset that many people on the Net mix uppercase and lowercase letters in one word. That's why he decided to invent an extension for his favorite browser that would change the letters' register in every word so that it ei... | ```python
a = input()
b,c = 0,0
for i in a:
if i.isupper():
b+=1
else:
c+=1
if b > c:
print(a.upper())
else:
print(a.lower())
``` | 3.9695 |
16 | A | Flag | PROGRAMMING | 800 | [
"implementation"
] | A. Flag | 2 | 64 | According to a new ISO standard, a flag of every country should have a chequered field *n*<=×<=*m*, each square should be of one of 10 colours, and the flag should be «striped»: each horizontal row of the flag should contain squares of the same colour, and the colours of adjacent horizontal rows should be different. Be... | The first line of the input contains numbers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=100), *n* — the amount of rows, *m* — the amount of columns on the flag of Berland. Then there follows the description of the flag: each of the following *n* lines contain *m* characters. Each character is a digit between 0 and 9, and stands ... | Output YES, if the flag meets the new ISO standard, and NO otherwise. | [
"3 3\n000\n111\n222\n",
"3 3\n000\n000\n111\n",
"3 3\n000\n111\n002\n"
] | [
"YES\n",
"NO\n",
"NO\n"
] | none | 0 | [
{
"input": "3 3\n000\n111\n222",
"output": "YES"
},
{
"input": "3 3\n000\n000\n111",
"output": "NO"
},
{
"input": "3 3\n000\n111\n002",
"output": "NO"
},
{
"input": "10 10\n2222222222\n5555555555\n0000000000\n4444444444\n1111111111\n3333333393\n3333333333\n5555555555\n0000000... | 1,631,480,161 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 92 | 6,963,200 | n, m = map(int, input().split())
list1 = [ []*m for _ in range(n) ]
for a in range(n):
str1 = input()
for b in range(m):
list1[a][b] = str1[b]
yes = True
for x in range(n-1):
for y in range(m-1):
if not(list1[x][y] != list1[x+1][y] and list1[x][y] == list1[x][y... | Title: Flag
Time Limit: 2 seconds
Memory Limit: 64 megabytes
Problem Description:
According to a new ISO standard, a flag of every country should have a chequered field *n*<=×<=*m*, each square should be of one of 10 colours, and the flag should be «striped»: each horizontal row of the flag should contain squares of... | ```python
n, m = map(int, input().split())
list1 = [ []*m for _ in range(n) ]
for a in range(n):
str1 = input()
for b in range(m):
list1[a][b] = str1[b]
yes = True
for x in range(n-1):
for y in range(m-1):
if not(list1[x][y] != list1[x+1][y] and list1[x][y] == ... | -1 |
749 | A | Bachgold Problem | PROGRAMMING | 800 | [
"greedy",
"implementation",
"math",
"number theory"
] | null | null | Bachgold problem is very easy to formulate. Given a positive integer *n* represent it as a sum of maximum possible number of prime numbers. One can prove that such representation exists for any integer greater than 1.
Recall that integer *k* is called prime if it is greater than 1 and has exactly two positive integer ... | The only line of the input contains a single integer *n* (2<=≤<=*n*<=≤<=100<=000). | The first line of the output contains a single integer *k* — maximum possible number of primes in representation.
The second line should contain *k* primes with their sum equal to *n*. You can print them in any order. If there are several optimal solution, print any of them. | [
"5\n",
"6\n"
] | [
"2\n2 3\n",
"3\n2 2 2\n"
] | none | 500 | [
{
"input": "5",
"output": "2\n2 3"
},
{
"input": "6",
"output": "3\n2 2 2"
},
{
"input": "2",
"output": "1\n2"
},
{
"input": "3",
"output": "1\n3"
},
{
"input": "99999",
"output": "49999\n2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ... | 1,683,706,440 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 31 | 0 | #여기서 prime 넘버는 소수(옛날 솟수)를 의미하는것이다.
#그런데 최대 개수의 솟수로 채우라고 했으니 최대한 2를 많이 넣고 나머지는 3으로 채우는것이 방법이다.
x=int(input())
print(x//2)
print('2 '*((n//2)-1),2+n%2) #최대한 2로 꽉 채우고 숫자가 홀수냐 짝수냐에 따라서 마지막에 2가될지 3이될지 결정한다. | Title: Bachgold Problem
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Bachgold problem is very easy to formulate. Given a positive integer *n* represent it as a sum of maximum possible number of prime numbers. One can prove that such representation exists for any integer greater than 1.
... | ```python
#여기서 prime 넘버는 소수(옛날 솟수)를 의미하는것이다.
#그런데 최대 개수의 솟수로 채우라고 했으니 최대한 2를 많이 넣고 나머지는 3으로 채우는것이 방법이다.
x=int(input())
print(x//2)
print('2 '*((n//2)-1),2+n%2) #최대한 2로 꽉 채우고 숫자가 홀수냐 짝수냐에 따라서 마지막에 2가될지 3이될지 결정한다.
``` | -1 | |
939 | A | Love Triangle | PROGRAMMING | 800 | [
"graphs"
] | null | null | As you could know there are no male planes nor female planes. However, each plane on Earth likes some other plane. There are *n* planes on Earth, numbered from 1 to *n*, and the plane with number *i* likes the plane with number *f**i*, where 1<=≤<=*f**i*<=≤<=*n* and *f**i*<=≠<=*i*.
We call a love triangle a situation ... | The first line contains a single integer *n* (2<=≤<=*n*<=≤<=5000) — the number of planes.
The second line contains *n* integers *f*1,<=*f*2,<=...,<=*f**n* (1<=≤<=*f**i*<=≤<=*n*, *f**i*<=≠<=*i*), meaning that the *i*-th plane likes the *f**i*-th. | Output «YES» if there is a love triangle consisting of planes on Earth. Otherwise, output «NO».
You can output any letter in lower case or in upper case. | [
"5\n2 4 5 1 3\n",
"5\n5 5 5 5 1\n"
] | [
"YES\n",
"NO\n"
] | In first example plane 2 likes plane 4, plane 4 likes plane 1, plane 1 likes plane 2 and that is a love triangle.
In second example there are no love triangles. | 500 | [
{
"input": "5\n2 4 5 1 3",
"output": "YES"
},
{
"input": "5\n5 5 5 5 1",
"output": "NO"
},
{
"input": "3\n3 1 2",
"output": "YES"
},
{
"input": "10\n4 10 9 5 3 1 5 10 6 4",
"output": "NO"
},
{
"input": "10\n5 5 4 9 10 9 9 5 3 1",
"output": "YES"
},
{
"... | 1,616,288,939 | 2,147,483,647 | PyPy 3 | RUNTIME_ERROR | TESTS | 0 | 124 | 2,150,400 | n, k = map(int, input().split())
boxes = [int(box) for box in input().split() if int(box) <=n]
if len(boxes) == 0:
print("NO")
exit()
for x in boxes:
x = n%x
print(boxes.index(min(boxes)) + 1, n//min(boxes))
| Title: Love Triangle
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
As you could know there are no male planes nor female planes. However, each plane on Earth likes some other plane. There are *n* planes on Earth, numbered from 1 to *n*, and the plane with number *i* likes the plane with ... | ```python
n, k = map(int, input().split())
boxes = [int(box) for box in input().split() if int(box) <=n]
if len(boxes) == 0:
print("NO")
exit()
for x in boxes:
x = n%x
print(boxes.index(min(boxes)) + 1, n//min(boxes))
``` | -1 | |
988 | E | Divisibility by 25 | PROGRAMMING | 2,100 | [
"brute force",
"greedy"
] | null | null | You are given an integer $n$ from $1$ to $10^{18}$ without leading zeroes.
In one move you can swap any two adjacent digits in the given number in such a way that the resulting number will not contain leading zeroes. In other words, after each move the number you have cannot contain any leading zeroes.
What is the mi... | The first line contains an integer $n$ ($1 \le n \le 10^{18}$). It is guaranteed that the first (left) digit of the number $n$ is not a zero. | If it is impossible to obtain a number that is divisible by $25$, print -1. Otherwise print the minimum number of moves required to obtain such number.
Note that you can swap only adjacent digits in the given number. | [
"5071\n",
"705\n",
"1241367\n"
] | [
"4\n",
"1\n",
"-1\n"
] | In the first example one of the possible sequences of moves is 5071 $\rightarrow$ 5701 $\rightarrow$ 7501 $\rightarrow$ 7510 $\rightarrow$ 7150. | 0 | [
{
"input": "5071",
"output": "4"
},
{
"input": "705",
"output": "1"
},
{
"input": "1241367",
"output": "-1"
},
{
"input": "7501",
"output": "2"
},
{
"input": "507",
"output": "2"
},
{
"input": "17010",
"output": "1"
},
{
"input": "52231",
... | 1,648,951,691 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 48 | 77 | 512,000 | s, pat, ans = list(input())[::-1], ['25', '50', '75'], float('inf')
ix0 = [i for i, j in enumerate(s) if j == '0']
for i in range(len(ix0)):
for j in range(i + 1, len(ix0)):
ans = min(ans, ix0[i] + ix0[j] - 1)
for p in pat:
ix1 = [i for i, j in enumerate(s) if j == p[0]]
ix0 = [i for i, j... | Title: Divisibility by 25
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given an integer $n$ from $1$ to $10^{18}$ without leading zeroes.
In one move you can swap any two adjacent digits in the given number in such a way that the resulting number will not contain leading zeroes... | ```python
s, pat, ans = list(input())[::-1], ['25', '50', '75'], float('inf')
ix0 = [i for i, j in enumerate(s) if j == '0']
for i in range(len(ix0)):
for j in range(i + 1, len(ix0)):
ans = min(ans, ix0[i] + ix0[j] - 1)
for p in pat:
ix1 = [i for i, j in enumerate(s) if j == p[0]]
ix0 = [... | 0 | |
25 | A | IQ test | PROGRAMMING | 1,300 | [
"brute force"
] | A. IQ test | 2 | 256 | Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given *n* numbers differs from the others. Bob observed that one number usually differs from the others in evenness. Help Bob — to check his answers, he needs a program that among the given *n* numbers finds one that i... | The first line contains integer *n* (3<=≤<=*n*<=≤<=100) — amount of numbers in the task. The second line contains *n* space-separated natural numbers, not exceeding 100. It is guaranteed, that exactly one of these numbers differs from the others in evenness. | Output index of number that differs from the others in evenness. Numbers are numbered from 1 in the input order. | [
"5\n2 4 7 8 10\n",
"4\n1 2 1 1\n"
] | [
"3\n",
"2\n"
] | none | 0 | [
{
"input": "5\n2 4 7 8 10",
"output": "3"
},
{
"input": "4\n1 2 1 1",
"output": "2"
},
{
"input": "3\n1 2 2",
"output": "1"
},
{
"input": "3\n100 99 100",
"output": "2"
},
{
"input": "3\n5 3 2",
"output": "3"
},
{
"input": "4\n43 28 1 91",
"output"... | 1,619,328,787 | 2,147,483,647 | Python 3 | OK | TESTS | 32 | 124 | 0 | n=input();
a=[x%2 for x in list(map(int,input().split()))];
print(a.index(sum(a)==1)+1); | Title: IQ test
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given *n* numbers differs from the others. Bob observed that one number usually differs from the others in evenness. Help Bob — t... | ```python
n=input();
a=[x%2 for x in list(map(int,input().split()))];
print(a.index(sum(a)==1)+1);
``` | 3.969 |
142 | A | Help Farmer | PROGRAMMING | 1,600 | [
"brute force",
"math"
] | null | null | Once upon a time in the Kingdom of Far Far Away lived Sam the Farmer. Sam had a cow named Dawn and he was deeply attached to her. Sam would spend the whole summer stocking hay to feed Dawn in winter. Sam scythed hay and put it into haystack. As Sam was a bright farmer, he tried to make the process of storing hay simple... | The only line contains integer *n* from the problem's statement (1<=≤<=*n*<=≤<=109). | Print space-separated minimum and maximum number of hay blocks that could have been stolen by the thieves.
Note that the answer to the problem can be large enough, so you must use the 64-bit integer type for calculations. Please, do not use the %lld specificator to read or write 64-bit integers in С++. It is preferred... | [
"4\n",
"7\n",
"12\n"
] | [
"28 41\n",
"47 65\n",
"48 105\n"
] | Let's consider the first sample test. If initially Sam has a parallelepiped consisting of 32 = 2 × 4 × 4 hay blocks in his barn, then after the theft the barn has 4 = (2 - 1) × (4 - 2) × (4 - 2) hay blocks left. Thus, the thieves could have stolen 32 - 4 = 28 hay blocks. If Sam initially had a parallelepiped consisting... | 500 | [
{
"input": "4",
"output": "28 41"
},
{
"input": "7",
"output": "47 65"
},
{
"input": "12",
"output": "48 105"
},
{
"input": "1",
"output": "17 17"
},
{
"input": "6",
"output": "34 57"
},
{
"input": "8",
"output": "40 73"
},
{
"input": "9",
... | 1,686,475,012 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 100 | 109 | 12,083,200 |
n=int(input())
i=1
l=[]
#prime-factoraiztion
while(i*i<=n):
if(n%i==0):
l.append(i)
i+=1
lmax=[]
lmin=[]
for i in range(len(l)):
for j in range(i,len(l)):
if(l[i]*l[j]<=n):
t=l[i]*l[j]
if(n%t==0):
k=n//t
lmax.append((l... | Title: Help Farmer
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Once upon a time in the Kingdom of Far Far Away lived Sam the Farmer. Sam had a cow named Dawn and he was deeply attached to her. Sam would spend the whole summer stocking hay to feed Dawn in winter. Sam scythed hay and put... | ```python
n=int(input())
i=1
l=[]
#prime-factoraiztion
while(i*i<=n):
if(n%i==0):
l.append(i)
i+=1
lmax=[]
lmin=[]
for i in range(len(l)):
for j in range(i,len(l)):
if(l[i]*l[j]<=n):
t=l[i]*l[j]
if(n%t==0):
k=n//t
lmax... | 3 | |
420 | A | Start Up | PROGRAMMING | 1,000 | [
"implementation"
] | null | null | Recently, a start up by two students of a state university of city F gained incredible popularity. Now it's time to start a new company. But what do we call it?
The market analysts came up with a very smart plan: the name of the company should be identical to its reflection in a mirror! In other words, if we write out... | The first line contains a non-empty name that needs to be checked. The name contains at most 105 large English letters. The name will be written with the next sans serif font: | Print 'YES' (without the quotes), if the given name matches its mirror reflection. Otherwise, print 'NO' (without the quotes). | [
"AHA\n",
"Z\n",
"XO\n"
] | [
"YES\n",
"NO\n",
"NO\n"
] | none | 500 | [
{
"input": "AHA",
"output": "YES"
},
{
"input": "Z",
"output": "NO"
},
{
"input": "XO",
"output": "NO"
},
{
"input": "AAA",
"output": "YES"
},
{
"input": "AHHA",
"output": "YES"
},
{
"input": "BAB",
"output": "NO"
},
{
"input": "OMMMAAMMMO"... | 1,687,059,919 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 80 | 77 | 1,638,400 | charset = "BCDEFGJKLNPQRSZ"
flag = False
e = input()
for i in e:
if i in charset:
flag = True
break
if flag:
print("NO")
else:
if e == e[::-1]:
print("YES")
else:
print("NO")
| Title: Start Up
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Recently, a start up by two students of a state university of city F gained incredible popularity. Now it's time to start a new company. But what do we call it?
The market analysts came up with a very smart plan: the name of ... | ```python
charset = "BCDEFGJKLNPQRSZ"
flag = False
e = input()
for i in e:
if i in charset:
flag = True
break
if flag:
print("NO")
else:
if e == e[::-1]:
print("YES")
else:
print("NO")
``` | 3 | |
937 | A | Olympiad | PROGRAMMING | 800 | [
"implementation",
"sortings"
] | null | null | The recent All-Berland Olympiad in Informatics featured *n* participants with each scoring a certain amount of points.
As the head of the programming committee, you are to determine the set of participants to be awarded with diplomas with respect to the following criteria:
- At least one participant should get a di... | The first line contains a single integer *n* (1<=≤<=*n*<=≤<=100) — the number of participants.
The next line contains a sequence of *n* integers *a*1,<=*a*2,<=...,<=*a**n* (0<=≤<=*a**i*<=≤<=600) — participants' scores.
It's guaranteed that at least one participant has non-zero score. | Print a single integer — the desired number of ways. | [
"4\n1 3 3 2\n",
"3\n1 1 1\n",
"4\n42 0 0 42\n"
] | [
"3\n",
"1\n",
"1\n"
] | There are three ways to choose a subset in sample case one.
1. Only participants with 3 points will get diplomas. 1. Participants with 2 or 3 points will get diplomas. 1. Everyone will get a diploma!
The only option in sample case two is to award everyone.
Note that in sample case three participants with zero sco... | 500 | [
{
"input": "4\n1 3 3 2",
"output": "3"
},
{
"input": "3\n1 1 1",
"output": "1"
},
{
"input": "4\n42 0 0 42",
"output": "1"
},
{
"input": "10\n1 0 1 0 1 0 0 0 0 1",
"output": "1"
},
{
"input": "10\n572 471 540 163 50 30 561 510 43 200",
"output": "10"
},
{
... | 1,587,099,156 | 2,147,483,647 | Python 3 | OK | TESTS | 21 | 108 | 0 | n=int(input())
print(len(set((input().split()))-{'0'})) | Title: Olympiad
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The recent All-Berland Olympiad in Informatics featured *n* participants with each scoring a certain amount of points.
As the head of the programming committee, you are to determine the set of participants to be awarded with ... | ```python
n=int(input())
print(len(set((input().split()))-{'0'}))
``` | 3 | |
177 | B2 | Rectangular Game | PROGRAMMING | 1,200 | [
"number theory"
] | null | null | The Smart Beaver from ABBYY decided to have a day off. But doing nothing the whole day turned out to be too boring, and he decided to play a game with pebbles. Initially, the Beaver has *n* pebbles. He arranges them in *a* equal rows, each row has *b* pebbles (*a*<=><=1). Note that the Beaver must use all the pebble... | The single line of the input contains a single integer *n* — the initial number of pebbles the Smart Beaver has.
The input limitations for getting 30 points are:
- 2<=≤<=*n*<=≤<=50
The input limitations for getting 100 points are:
- 2<=≤<=*n*<=≤<=109 | Print a single number — the maximum possible result of the game. | [
"10\n",
"8\n"
] | [
"16\n",
"15\n"
] | Consider the first example (*c*<sub class="lower-index">1</sub> = 10). The possible options for the game development are:
- Arrange the pebbles in 10 rows, one pebble per row. Then *c*<sub class="lower-index">2</sub> = 1, and the game ends after the first move with the result of 11. - Arrange the pebbles in 5 rows, ... | 70 | [
{
"input": "10",
"output": "16"
},
{
"input": "8",
"output": "15"
},
{
"input": "4",
"output": "7"
},
{
"input": "36",
"output": "67"
},
{
"input": "32",
"output": "63"
},
{
"input": "46",
"output": "70"
},
{
"input": "6",
"output": "10... | 1,556,985,871 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS2 | 0 | 186 | 0 | n = int(input())
i = 2
s = n
m = int(n ** 0.5)
while n > 1 and i <= m:
if n % i:
i += 1
else:
print(i, n)
n //= i
s += n
print(s + (n > 1))
| Title: Rectangular Game
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The Smart Beaver from ABBYY decided to have a day off. But doing nothing the whole day turned out to be too boring, and he decided to play a game with pebbles. Initially, the Beaver has *n* pebbles. He arranges them in... | ```python
n = int(input())
i = 2
s = n
m = int(n ** 0.5)
while n > 1 and i <= m:
if n % i:
i += 1
else:
print(i, n)
n //= i
s += n
print(s + (n > 1))
``` | 0 | |
789 | A | Anastasia and pebbles | PROGRAMMING | 1,100 | [
"implementation",
"math"
] | null | null | Anastasia loves going for a walk in Central Uzhlyandian Park. But she became uninterested in simple walking, so she began to collect Uzhlyandian pebbles. At first, she decided to collect all the pebbles she could find in the park.
She has only two pockets. She can put at most *k* pebbles in each pocket at the same tim... | The first line contains two integers *n* and *k* (1<=≤<=*n*<=≤<=105, 1<=≤<=*k*<=≤<=109) — the number of different pebble types and number of pebbles Anastasia can place in one pocket.
The second line contains *n* integers *w*1,<=*w*2,<=...,<=*w**n* (1<=≤<=*w**i*<=≤<=104) — number of pebbles of each type. | The only line of output contains one integer — the minimum number of days Anastasia needs to collect all the pebbles. | [
"3 2\n2 3 4\n",
"5 4\n3 1 8 9 7\n"
] | [
"3\n",
"5\n"
] | In the first sample case, Anastasia can collect all pebbles of the first type on the first day, of second type — on the second day, and of third type — on the third day.
Optimal sequence of actions in the second sample case:
- In the first day Anastasia collects 8 pebbles of the third type. - In the second day she... | 500 | [
{
"input": "3 2\n2 3 4",
"output": "3"
},
{
"input": "5 4\n3 1 8 9 7",
"output": "5"
},
{
"input": "1 22\n1",
"output": "1"
},
{
"input": "3 57\n78 165 54",
"output": "3"
},
{
"input": "5 72\n74 10 146 189 184",
"output": "6"
},
{
"input": "9 13\n132 8... | 1,490,892,637 | 2,147,483,647 | Python 3 | OK | TESTS | 31 | 124 | 12,902,400 | n,k=input().split()
w=[((int(i)-1)//(int(k))+1) for i in (input().split())]
s=sum(w);m=max(w);
print(((s if(s>m) else m)+1)//2)
| Title: Anastasia and pebbles
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Anastasia loves going for a walk in Central Uzhlyandian Park. But she became uninterested in simple walking, so she began to collect Uzhlyandian pebbles. At first, she decided to collect all the pebbles she could ... | ```python
n,k=input().split()
w=[((int(i)-1)//(int(k))+1) for i in (input().split())]
s=sum(w);m=max(w);
print(((s if(s>m) else m)+1)//2)
``` | 3 | |
867 | A | Between the Offices | PROGRAMMING | 800 | [
"implementation"
] | null | null | As you may know, MemSQL has American offices in both San Francisco and Seattle. Being a manager in the company, you travel a lot between the two cities, always by plane.
You prefer flying from Seattle to San Francisco than in the other direction, because it's warmer in San Francisco. You are so busy that you don't rem... | The first line of input contains single integer *n* (2<=≤<=*n*<=≤<=100) — the number of days.
The second line contains a string of length *n* consisting of only capital 'S' and 'F' letters. If the *i*-th letter is 'S', then you were in Seattle office on that day. Otherwise you were in San Francisco. The days are given... | Print "YES" if you flew more times from Seattle to San Francisco, and "NO" otherwise.
You can print each letter in any case (upper or lower). | [
"4\nFSSF\n",
"2\nSF\n",
"10\nFFFFFFFFFF\n",
"10\nSSFFSFFSFF\n"
] | [
"NO\n",
"YES\n",
"NO\n",
"YES\n"
] | In the first example you were initially at San Francisco, then flew to Seattle, were there for two days and returned to San Francisco. You made one flight in each direction, so the answer is "NO".
In the second example you just flew from Seattle to San Francisco, so the answer is "YES".
In the third example you staye... | 500 | [
{
"input": "4\nFSSF",
"output": "NO"
},
{
"input": "2\nSF",
"output": "YES"
},
{
"input": "10\nFFFFFFFFFF",
"output": "NO"
},
{
"input": "10\nSSFFSFFSFF",
"output": "YES"
},
{
"input": "20\nSFSFFFFSSFFFFSSSSFSS",
"output": "NO"
},
{
"input": "20\nSSFFF... | 1,573,112,723 | 2,147,483,647 | PyPy 3 | OK | TESTS | 34 | 140 | 0 | input()
s = ''
for c in input():
if not s or s[-1] != c:
s += c
s = s[1:]
print('YES' if s.count('F') > s.count('S') else 'NO') | Title: Between the Offices
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
As you may know, MemSQL has American offices in both San Francisco and Seattle. Being a manager in the company, you travel a lot between the two cities, always by plane.
You prefer flying from Seattle to San Franci... | ```python
input()
s = ''
for c in input():
if not s or s[-1] != c:
s += c
s = s[1:]
print('YES' if s.count('F') > s.count('S') else 'NO')
``` | 3 | |
129 | A | Cookies | PROGRAMMING | 900 | [
"implementation"
] | null | null | Olga came to visit the twins Anna and Maria and saw that they have many cookies. The cookies are distributed into bags. As there are many cookies, Olga decided that it's no big deal if she steals a bag. However, she doesn't want the sisters to quarrel because of nothing when they divide the cookies. That's why Olga wan... | The first line contains the only integer *n* (1<=≤<=*n*<=≤<=100) — the number of cookie bags Anna and Maria have. The second line contains *n* integers *a**i* (1<=≤<=*a**i*<=≤<=100) — the number of cookies in the *i*-th bag. | Print in the only line the only number — the sought number of ways. If there are no such ways print 0. | [
"1\n1\n",
"10\n1 2 2 3 4 4 4 2 2 2\n",
"11\n2 2 2 2 2 2 2 2 2 2 99\n"
] | [
"1\n",
"8\n",
"1\n"
] | In the first sample Olga should take the only bag so that the twins ended up with the even number of cookies.
In the second sample Olga can take any of five bags with two cookies or any of three bags with four cookies — 5 + 3 = 8 ways in total.
In the third sample, no matter which bag with two cookies Olga chooses, t... | 500 | [
{
"input": "1\n1",
"output": "1"
},
{
"input": "10\n1 2 2 3 4 4 4 2 2 2",
"output": "8"
},
{
"input": "11\n2 2 2 2 2 2 2 2 2 2 99",
"output": "1"
},
{
"input": "2\n1 1",
"output": "0"
},
{
"input": "2\n2 2",
"output": "2"
},
{
"input": "2\n1 2",
"o... | 1,632,561,067 | 2,147,483,647 | Python 3 | OK | TESTS | 52 | 154 | 6,758,400 | n = int(input())
s = [int(i) for i in input().split()]
k = 0
d = 0
for i in range(n):
k += s[i]
if s[i] % 2 == 0:
d += 1
if k % 2 == 0:
print(d)
else:
print(n - d)
# Sat Sep 25 2021 12:11:07 GMT+0300 (Москва, стандартное время)
| Title: Cookies
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Olga came to visit the twins Anna and Maria and saw that they have many cookies. The cookies are distributed into bags. As there are many cookies, Olga decided that it's no big deal if she steals a bag. However, she doesn't wan... | ```python
n = int(input())
s = [int(i) for i in input().split()]
k = 0
d = 0
for i in range(n):
k += s[i]
if s[i] % 2 == 0:
d += 1
if k % 2 == 0:
print(d)
else:
print(n - d)
# Sat Sep 25 2021 12:11:07 GMT+0300 (Москва, стандартное время)
``` | 3 | |
59 | A | Word | PROGRAMMING | 800 | [
"implementation",
"strings"
] | A. Word | 2 | 256 | Vasya is very upset that many people on the Net mix uppercase and lowercase letters in one word. That's why he decided to invent an extension for his favorite browser that would change the letters' register in every word so that it either only consisted of lowercase letters or, vice versa, only of uppercase ones. At th... | The first line contains a word *s* — it consists of uppercase and lowercase Latin letters and possesses the length from 1 to 100. | Print the corrected word *s*. If the given word *s* has strictly more uppercase letters, make the word written in the uppercase register, otherwise - in the lowercase one. | [
"HoUse\n",
"ViP\n",
"maTRIx\n"
] | [
"house\n",
"VIP\n",
"matrix\n"
] | none | 500 | [
{
"input": "HoUse",
"output": "house"
},
{
"input": "ViP",
"output": "VIP"
},
{
"input": "maTRIx",
"output": "matrix"
},
{
"input": "BNHWpnpawg",
"output": "bnhwpnpawg"
},
{
"input": "VTYGP",
"output": "VTYGP"
},
{
"input": "CHNenu",
"output": "chn... | 1,599,896,377 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 186 | 307,200 | s = input()
count_a=0
count_b=0
for x in s:
if (x>='a'):
count_a= count_a+1
else:
count_b= count_b+1
if (count_a>count_b):
for x in s:
if (x.islower()):
print(x,end='')
else:
x=chr(ord(x)+32)
print(x,end='')
if (count_b>count_a):
... | Title: Word
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Vasya is very upset that many people on the Net mix uppercase and lowercase letters in one word. That's why he decided to invent an extension for his favorite browser that would change the letters' register in every word so that it ei... | ```python
s = input()
count_a=0
count_b=0
for x in s:
if (x>='a'):
count_a= count_a+1
else:
count_b= count_b+1
if (count_a>count_b):
for x in s:
if (x.islower()):
print(x,end='')
else:
x=chr(ord(x)+32)
print(x,end='')
if (count_b>cou... | 0 |
748 | A | Santa Claus and a Place in a Class | PROGRAMMING | 800 | [
"implementation",
"math"
] | null | null | Santa Claus is the first who came to the Christmas Olympiad, and he is going to be the first to take his place at a desk! In the classroom there are *n* lanes of *m* desks each, and there are two working places at each of the desks. The lanes are numbered from 1 to *n* from the left to the right, the desks in a lane ar... | The only line contains three integers *n*, *m* and *k* (1<=≤<=*n*,<=*m*<=≤<=10<=000, 1<=≤<=*k*<=≤<=2*nm*) — the number of lanes, the number of desks in each lane and the number of Santa Claus' place. | Print two integers: the number of lane *r*, the number of desk *d*, and a character *s*, which stands for the side of the desk Santa Claus. The character *s* should be "L", if Santa Clause should sit on the left, and "R" if his place is on the right. | [
"4 3 9\n",
"4 3 24\n",
"2 4 4\n"
] | [
"2 2 L\n",
"4 3 R\n",
"1 2 R\n"
] | The first and the second samples are shown on the picture. The green place corresponds to Santa Claus' place in the first example, the blue place corresponds to Santa Claus' place in the second example.
In the third sample there are two lanes with four desks in each, and Santa Claus has the fourth place. Thus, his pla... | 500 | [
{
"input": "4 3 9",
"output": "2 2 L"
},
{
"input": "4 3 24",
"output": "4 3 R"
},
{
"input": "2 4 4",
"output": "1 2 R"
},
{
"input": "3 10 24",
"output": "2 2 R"
},
{
"input": "10 3 59",
"output": "10 3 L"
},
{
"input": "10000 10000 160845880",
"... | 1,482,660,955 | 4,255 | Python 3 | OK | TESTS | 46 | 93 | 4,608,000 | string = input()
string = string.split()
n = int(string[0])
m = int(string[1])
k = int(string[2])
if k % 2 != 0:
s ="L"
k +=1
else:
s = "R"
r = k//(m*2)
if k % (m*2) != 0:
r += 1
d = (k % (m*2)) //2
if d == 0:
d = m
print(r, d, s)
| Title: Santa Claus and a Place in a Class
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Santa Claus is the first who came to the Christmas Olympiad, and he is going to be the first to take his place at a desk! In the classroom there are *n* lanes of *m* desks each, and there are two work... | ```python
string = input()
string = string.split()
n = int(string[0])
m = int(string[1])
k = int(string[2])
if k % 2 != 0:
s ="L"
k +=1
else:
s = "R"
r = k//(m*2)
if k % (m*2) != 0:
r += 1
d = (k % (m*2)) //2
if d == 0:
d = m
print(r, d, s)
``` | 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,680,200,552 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 27 | 92 | 0 | # Whoever made this question was high on vibranium..............
# A group of 'n friends'
# Decided to buy 'k bottles'
# Each bottle has 'l milliliters'
# They bought 'c limes'
# Cut each of them into 'd slices'
# They found 'p grams of salt'
# To make a toast = Each friend needs nl milliliters of th... | 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
# Whoever made this question was high on vibranium..............
# A group of 'n friends'
# Decided to buy 'k bottles'
# Each bottle has 'l milliliters'
# They bought 'c limes'
# Cut each of them into 'd slices'
# They found 'p grams of salt'
# To make a toast = Each friend needs nl millili... | 3 | |
946 | B | Weird Subtraction Process | PROGRAMMING | 1,100 | [
"math",
"number theory"
] | null | null | You have two variables *a* and *b*. Consider the following sequence of actions performed with these variables:
1. If *a*<==<=0 or *b*<==<=0, end the process. Otherwise, go to step 2;1. If *a*<=≥<=2·*b*, then set the value of *a* to *a*<=-<=2·*b*, and repeat step 1. Otherwise, go to step 3;1. If *b*<=≥<=2·*a*, then s... | The only line of the input contains two integers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=1018). *n* is the initial value of variable *a*, and *m* is the initial value of variable *b*. | Print two integers — the values of *a* and *b* after the end of the process. | [
"12 5\n",
"31 12\n"
] | [
"0 1\n",
"7 12\n"
] | Explanations to the samples:
1. *a* = 12, *b* = 5 <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/70a0795f45d32287dba0eb83fc4a3f470c6e5537.png" style="max-width: 100.0%;max-height: 100.0%;"/> *a* = 2, *b* = 5 <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/70a0... | 0 | [
{
"input": "12 5",
"output": "0 1"
},
{
"input": "31 12",
"output": "7 12"
},
{
"input": "1000000000000000000 7",
"output": "8 7"
},
{
"input": "31960284556200 8515664064180",
"output": "14928956427840 8515664064180"
},
{
"input": "1000000000000000000 100000000000... | 1,692,805,461 | 2,147,483,647 | PyPy 3-64 | RUNTIME_ERROR | TESTS | 2 | 108 | 9,932,800 | a,b=map(int,input().split())
def step1():
global a,b
if a==0 or b==0:
print(a,b)
exit()
else:
step2()
def step2():
global a,b
if a>=2*b:
a=a-2*b
step1()
else:
step3()
def step3():
global a,b
if b>=2*a:
b=b-2*a
... | Title: Weird Subtraction Process
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You have two variables *a* and *b*. Consider the following sequence of actions performed with these variables:
1. If *a*<==<=0 or *b*<==<=0, end the process. Otherwise, go to step 2;1. If *a*<=≥<=2·*b*, then... | ```python
a,b=map(int,input().split())
def step1():
global a,b
if a==0 or b==0:
print(a,b)
exit()
else:
step2()
def step2():
global a,b
if a>=2*b:
a=a-2*b
step1()
else:
step3()
def step3():
global a,b
if b>=2*a:
b=... | -1 | |
59 | A | Word | PROGRAMMING | 800 | [
"implementation",
"strings"
] | A. Word | 2 | 256 | Vasya is very upset that many people on the Net mix uppercase and lowercase letters in one word. That's why he decided to invent an extension for his favorite browser that would change the letters' register in every word so that it either only consisted of lowercase letters or, vice versa, only of uppercase ones. At th... | The first line contains a word *s* — it consists of uppercase and lowercase Latin letters and possesses the length from 1 to 100. | Print the corrected word *s*. If the given word *s* has strictly more uppercase letters, make the word written in the uppercase register, otherwise - in the lowercase one. | [
"HoUse\n",
"ViP\n",
"maTRIx\n"
] | [
"house\n",
"VIP\n",
"matrix\n"
] | none | 500 | [
{
"input": "HoUse",
"output": "house"
},
{
"input": "ViP",
"output": "VIP"
},
{
"input": "maTRIx",
"output": "matrix"
},
{
"input": "BNHWpnpawg",
"output": "bnhwpnpawg"
},
{
"input": "VTYGP",
"output": "VTYGP"
},
{
"input": "CHNenu",
"output": "chn... | 1,645,217,336 | 2,147,483,647 | Python 3 | OK | TESTS | 30 | 92 | 0 | word = input()
count_upper = 0
count_lower = 0
for i in word:
if(i.isupper()):
count_upper += 1
else:
count_lower += 1
if(count_lower >= count_upper):
print(word.lower())
else:
print(word.upper()) | Title: Word
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Vasya is very upset that many people on the Net mix uppercase and lowercase letters in one word. That's why he decided to invent an extension for his favorite browser that would change the letters' register in every word so that it ei... | ```python
word = input()
count_upper = 0
count_lower = 0
for i in word:
if(i.isupper()):
count_upper += 1
else:
count_lower += 1
if(count_lower >= count_upper):
print(word.lower())
else:
print(word.upper())
``` | 3.977 |
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,539,003,809 | 2,147,483,647 | Python 3 | OK | TESTS | 42 | 124 | 0 | l,r = map(int,input().split())
def gcd(x,y):
while y!= 0:
(x,y) = (y,x%y)
return x
for a in range(l,r+1):
for b in range(a+1,r+1):
for c in range(b+1,r+1):
if (gcd(a,b) ==1 and gcd(b,c) ==1 and gcd(a,c) !=1 ):
print(a,b,c)
exit()
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
l,r = map(int,input().split())
def gcd(x,y):
while y!= 0:
(x,y) = (y,x%y)
return x
for a in range(l,r+1):
for b in range(a+1,r+1):
for c in range(b+1,r+1):
if (gcd(a,b) ==1 and gcd(b,c) ==1 and gcd(a,c) !=1 ):
print(a,b,c)
exit()
print(-1)
``` | 3 | |
888 | A | Local Extrema | PROGRAMMING | 800 | [
"brute force",
"implementation"
] | null | null | You are given an array *a*. Some element of this array *a**i* is a local minimum iff it is strictly less than both of its neighbours (that is, *a**i*<=<<=*a**i*<=-<=1 and *a**i*<=<<=*a**i*<=+<=1). Also the element can be called local maximum iff it is strictly greater than its neighbours (that is, *a**i*<=><=*... | The first line contains one integer *n* (1<=≤<=*n*<=≤<=1000) — the number of elements in array *a*.
The second line contains *n* integers *a*1, *a*2, ..., *a**n* (1<=≤<=*a**i*<=≤<=1000) — the elements of array *a*. | Print the number of local extrema in the given array. | [
"3\n1 2 3\n",
"4\n1 5 2 5\n"
] | [
"0\n",
"2\n"
] | none | 0 | [
{
"input": "3\n1 2 3",
"output": "0"
},
{
"input": "4\n1 5 2 5",
"output": "2"
},
{
"input": "1\n1",
"output": "0"
},
{
"input": "1\n548",
"output": "0"
},
{
"input": "2\n1 1",
"output": "0"
},
{
"input": "3\n3 2 3",
"output": "1"
},
{
"inp... | 1,653,933,839 | 2,147,483,647 | PyPy 3 | OK | TESTS | 14 | 78 | 0 | n = int(input(""))
L = list(map(int,input("").strip().split()))[:n]
ans=0;
for i in range(1 , n-1):
if((L[i-1] > L[i] and L[i+1] > L[i]) or (L[i-1] < L[i] and L[i+1] < L[i])):
ans+=1;
print(ans)
| Title: Local Extrema
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given an array *a*. Some element of this array *a**i* is a local minimum iff it is strictly less than both of its neighbours (that is, *a**i*<=<<=*a**i*<=-<=1 and *a**i*<=<<=*a**i*<=+<=1). Also the element c... | ```python
n = int(input(""))
L = list(map(int,input("").strip().split()))[:n]
ans=0;
for i in range(1 , n-1):
if((L[i-1] > L[i] and L[i+1] > L[i]) or (L[i-1] < L[i] and L[i+1] < L[i])):
ans+=1;
print(ans)
``` | 3 | |
894 | A | QAQ | PROGRAMMING | 800 | [
"brute force",
"dp"
] | null | null | "QAQ" is a word to denote an expression of crying. Imagine "Q" as eyes with tears and "A" as a mouth.
Now Diamond has given Bort a string consisting of only uppercase English letters of length *n*. There is a great number of "QAQ" in the string (Diamond is so cute!).
Bort wants to know how many subsequences "QAQ" are... | The only line contains a string of length *n* (1<=≤<=*n*<=≤<=100). It's guaranteed that the string only contains uppercase English letters. | Print a single integer — the number of subsequences "QAQ" in the string. | [
"QAQAQYSYIOIWIN\n",
"QAQQQZZYNOIWIN\n"
] | [
"4\n",
"3\n"
] | In the first example there are 4 subsequences "QAQ": "QAQAQYSYIOIWIN", "QAQAQYSYIOIWIN", "QAQAQYSYIOIWIN", "QAQAQYSYIOIWIN". | 500 | [
{
"input": "QAQAQYSYIOIWIN",
"output": "4"
},
{
"input": "QAQQQZZYNOIWIN",
"output": "3"
},
{
"input": "QA",
"output": "0"
},
{
"input": "IAQVAQZLQBQVQFTQQQADAQJA",
"output": "24"
},
{
"input": "QQAAQASGAYAAAAKAKAQIQEAQAIAAIAQQQQQ",
"output": "378"
},
{
... | 1,657,875,360 | 2,147,483,647 | Python 3 | OK | TESTS | 43 | 46 | 0 | s = input()
t = 0
q = [0]*len(s)
a = [0]*len(s)
ans = 0
for i in range(len(s)):
if s[i] == 'Q':
t += 1
q[i] = t
for i in range(len(s)):
if s[i] == 'A':
ans += q[i]*(t-q[i])
print(ans)
| Title: QAQ
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
"QAQ" is a word to denote an expression of crying. Imagine "Q" as eyes with tears and "A" as a mouth.
Now Diamond has given Bort a string consisting of only uppercase English letters of length *n*. There is a great number of "QAQ"... | ```python
s = input()
t = 0
q = [0]*len(s)
a = [0]*len(s)
ans = 0
for i in range(len(s)):
if s[i] == 'Q':
t += 1
q[i] = t
for i in range(len(s)):
if s[i] == 'A':
ans += q[i]*(t-q[i])
print(ans)
``` | 3 | |
9 | A | Die Roll | PROGRAMMING | 800 | [
"math",
"probabilities"
] | A. Die Roll | 1 | 64 | Yakko, Wakko and Dot, world-famous animaniacs, decided to rest from acting in cartoons, and take a leave to travel a bit. Yakko dreamt to go to Pennsylvania, his Motherland and the Motherland of his ancestors. Wakko thought about Tasmania, its beaches, sun and sea. Dot chose Transylvania as the most mysterious and unpr... | The only line of the input file contains two natural numbers Y and W — the results of Yakko's and Wakko's die rolls. | Output the required probability in the form of irreducible fraction in format «A/B», where A — the numerator, and B — the denominator. If the required probability equals to zero, output «0/1». If the required probability equals to 1, output «1/1». | [
"4 2\n"
] | [
"1/2\n"
] | Dot will go to Transylvania, if she is lucky to roll 4, 5 or 6 points. | 0 | [
{
"input": "4 2",
"output": "1/2"
},
{
"input": "1 1",
"output": "1/1"
},
{
"input": "1 2",
"output": "5/6"
},
{
"input": "1 3",
"output": "2/3"
},
{
"input": "1 4",
"output": "1/2"
},
{
"input": "1 5",
"output": "1/3"
},
{
"input": "1 6",
... | 1,583,939,310 | 2,147,483,647 | Python 3 | OK | TESTS | 36 | 218 | 307,200 | y, w = map(int, input().split())
number = max(y, w)
need = 6 - number + 1
if need == 6:
print('1/1')
elif need % 3 == 0:
print('1/2')
elif need % 2 == 0:
print(str(need // 2) + '/' + '3')
else:
print(str(need) + '/' + '6')
| Title: Die Roll
Time Limit: 1 seconds
Memory Limit: 64 megabytes
Problem Description:
Yakko, Wakko and Dot, world-famous animaniacs, decided to rest from acting in cartoons, and take a leave to travel a bit. Yakko dreamt to go to Pennsylvania, his Motherland and the Motherland of his ancestors. Wakko thought about T... | ```python
y, w = map(int, input().split())
number = max(y, w)
need = 6 - number + 1
if need == 6:
print('1/1')
elif need % 3 == 0:
print('1/2')
elif need % 2 == 0:
print(str(need // 2) + '/' + '3')
else:
print(str(need) + '/' + '6')
``` | 3.888711 |
69 | A | Young Physicist | PROGRAMMING | 1,000 | [
"implementation",
"math"
] | A. Young Physicist | 2 | 256 | A guy named Vasya attends the final grade of a high school. One day Vasya decided to watch a match of his favorite hockey team. And, as the boy loves hockey very much, even more than physics, he forgot to do the homework. Specifically, he forgot to complete his physics tasks. Next day the teacher got very angry at Vasy... | The first line contains a positive integer *n* (1<=≤<=*n*<=≤<=100), then follow *n* lines containing three integers each: the *x**i* coordinate, the *y**i* coordinate and the *z**i* coordinate of the force vector, applied to the body (<=-<=100<=≤<=*x**i*,<=*y**i*,<=*z**i*<=≤<=100). | Print the word "YES" if the body is in equilibrium, or the word "NO" if it is not. | [
"3\n4 1 7\n-2 4 -1\n1 -5 -3\n",
"3\n3 -1 7\n-5 2 -4\n2 -1 -3\n"
] | [
"NO",
"YES"
] | none | 500 | [
{
"input": "3\n4 1 7\n-2 4 -1\n1 -5 -3",
"output": "NO"
},
{
"input": "3\n3 -1 7\n-5 2 -4\n2 -1 -3",
"output": "YES"
},
{
"input": "10\n21 32 -46\n43 -35 21\n42 2 -50\n22 40 20\n-27 -9 38\n-4 1 1\n-40 6 -31\n-13 -2 34\n-21 34 -12\n-32 -29 41",
"output": "NO"
},
{
"input": "10... | 1,573,670,708 | 2,147,483,647 | Python 3 | OK | TESTS | 81 | 218 | 0 | n= int(input(""))
all_cordinate= []
for a in range(n):
cordinate= map(int,input().split(" "))
cordinate=list(cordinate)
all_cordinate.append(cordinate)
# for cordinate in all_cordinate:
# print(cordinate[0])
sum_x = sum_y = sum_z=0
for cordinate in all_cordinate:
sum_x=sum_x+cordinat... | Title: Young Physicist
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
A guy named Vasya attends the final grade of a high school. One day Vasya decided to watch a match of his favorite hockey team. And, as the boy loves hockey very much, even more than physics, he forgot to do the homework. S... | ```python
n= int(input(""))
all_cordinate= []
for a in range(n):
cordinate= map(int,input().split(" "))
cordinate=list(cordinate)
all_cordinate.append(cordinate)
# for cordinate in all_cordinate:
# print(cordinate[0])
sum_x = sum_y = sum_z=0
for cordinate in all_cordinate:
sum_x=sum_... | 3.9455 |
591 | A | Wizards' Duel | PROGRAMMING | 900 | [
"implementation",
"math"
] | null | null | Harry Potter and He-Who-Must-Not-Be-Named engaged in a fight to the death once again. This time they are located at opposite ends of the corridor of length *l*. Two opponents simultaneously charge a deadly spell in the enemy. We know that the impulse of Harry's magic spell flies at a speed of *p* meters per second, and... | The first line of the input contains a single integer *l* (1<=≤<=*l*<=≤<=1<=000) — the length of the corridor where the fight takes place.
The second line contains integer *p*, the third line contains integer *q* (1<=≤<=*p*,<=*q*<=≤<=500) — the speeds of magical impulses for Harry Potter and He-Who-Must-Not-Be-Named, ... | Print a single real number — the distance from the end of the corridor, where Harry is located, to the place of the second meeting of the spell impulses. Your answer will be considered correct if its absolute or relative error will not exceed 10<=-<=4.
Namely: let's assume that your answer equals *a*, and the answer ... | [
"100\n50\n50\n",
"199\n60\n40\n"
] | [
"50\n",
"119.4\n"
] | In the first sample the speeds of the impulses are equal, so both of their meetings occur exactly in the middle of the corridor. | 500 | [
{
"input": "100\n50\n50",
"output": "50"
},
{
"input": "199\n60\n40",
"output": "119.4"
},
{
"input": "1\n1\n1",
"output": "0.5"
},
{
"input": "1\n1\n500",
"output": "0.001996007984"
},
{
"input": "1\n500\n1",
"output": "0.998003992"
},
{
"input": "1\n... | 1,445,822,471 | 2,147,483,647 | Python 3 | OK | TESTS | 45 | 62 | 0 | l = float(input())
a = float(input())
b = float(input())
print(l * a / (a + b)) | Title: Wizards' Duel
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Harry Potter and He-Who-Must-Not-Be-Named engaged in a fight to the death once again. This time they are located at opposite ends of the corridor of length *l*. Two opponents simultaneously charge a deadly spell in the en... | ```python
l = float(input())
a = float(input())
b = float(input())
print(l * a / (a + b))
``` | 3 | |
717 | C | Potions Homework | PROGRAMMING | 1,200 | [
"implementation",
"sortings"
] | null | null | Harry Water, Ronaldo, Her-my-oh-knee and their friends have started a new school year at their MDCS School of Speechcraft and Misery. At the time, they are very happy to have seen each other after a long time. The sun is shining, birds are singing, flowers are blooming, and their Potions class teacher, professor Snipe ... | The first line of input contains integer *n* (1<=≤<=*n*<=≤<=100<=000) — the number of tasks. The next *n* lines contain exactly one integer number *a**i* (1<=≤<=*a**i*<=≤<=100<=000) — both the difficulty of the initial task and the laziness of the *i*-th students. | Print the minimum total time to finish all tasks modulo 10<=007. | [
"2\n1\n3\n"
] | [
"6\n"
] | In the first sample, if the students switch their tasks, they will be able to finish them in 3 + 3 = 6 time units. | 0 | [
{
"input": "2\n1\n3",
"output": "6"
}
] | 1,624,658,375 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 124 | 1,331,200 | import math
from collections import *
from heapq import *
def intlist():
return list(map(int, input().split()))
class Solution:
def solve(self):
n = int(input())
nums = [0] * n
for i in range(n):
nums[i] = int(input())
ans = 0
x = sorted(nums... | Title: Potions Homework
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Harry Water, Ronaldo, Her-my-oh-knee and their friends have started a new school year at their MDCS School of Speechcraft and Misery. At the time, they are very happy to have seen each other after a long time. The sun ... | ```python
import math
from collections import *
from heapq import *
def intlist():
return list(map(int, input().split()))
class Solution:
def solve(self):
n = int(input())
nums = [0] * n
for i in range(n):
nums[i] = int(input())
ans = 0
x = s... | 0 | |
604 | A | Uncowed Forces | PROGRAMMING | 1,000 | [
"implementation"
] | null | null | Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging tasks, Kevin was uncowed and bulldozed through all of them, distinguishing himself from the herd a... | The first line of the input contains five space-separated integers *m*1, *m*2, *m*3, *m*4, *m*5, where *m**i* (0<=≤<=*m**i*<=≤<=119) is the time of Kevin's last submission for problem *i*. His last submission is always correct and gets accepted.
The second line contains five space-separated integers *w*1, *w*2, *w*3, ... | Print a single integer, the value of Kevin's final score. | [
"20 40 60 80 100\n0 1 2 3 4\n1 0\n",
"119 119 119 119 119\n0 0 0 0 0\n10 0\n"
] | [
"4900\n",
"4930\n"
] | In the second sample, Kevin takes 119 minutes on all of the problems. Therefore, he gets <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/42158dc2bc78cd21fa679530ae9ef8b9ea298d15.png" style="max-width: 100.0%;max-height: 100.0%;"/> of the points on each problem. So his score from solving pro... | 500 | [
{
"input": "20 40 60 80 100\n0 1 2 3 4\n1 0",
"output": "4900"
},
{
"input": "119 119 119 119 119\n0 0 0 0 0\n10 0",
"output": "4930"
},
{
"input": "3 6 13 38 60\n6 10 10 3 8\n9 9",
"output": "5088"
},
{
"input": "21 44 11 68 75\n6 2 4 8 4\n2 8",
"output": "4522"
},
{... | 1,552,810,266 | 2,147,483,647 | Python 3 | OK | TESTS | 57 | 109 | 0 | Scores = [500, 1000, 1500, 2000, 2500]
Time = list(map(int, input().split()))
Wrong = list(map(int, input().split()))
SUM = 0
for i in range(5):
SUM += max(0.3 * Scores[i], (1 - (Time[i] / 250)) * Scores[i] - (50 * Wrong[i]))
Hack = list(map(int, input().split()))
print(int(SUM + (Hack[0] * 100) - (Hack[1] *... | Title: Uncowed Forces
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challengin... | ```python
Scores = [500, 1000, 1500, 2000, 2500]
Time = list(map(int, input().split()))
Wrong = list(map(int, input().split()))
SUM = 0
for i in range(5):
SUM += max(0.3 * Scores[i], (1 - (Time[i] / 250)) * Scores[i] - (50 * Wrong[i]))
Hack = list(map(int, input().split()))
print(int(SUM + (Hack[0] * 100) - ... | 3 | |
1 | A | Theatre Square | PROGRAMMING | 1,000 | [
"math"
] | A. Theatre Square | 1 | 256 | Theatre Square in the capital city of Berland has a rectangular shape with the size *n*<=×<=*m* meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the size *a*<=×<=*a*.
What is the least number of flagstones needed to pave the... | The input contains three positive integer numbers in the first line: *n*,<=<=*m* and *a* (1<=≤<=<=*n*,<=*m*,<=*a*<=≤<=109). | Write the needed number of flagstones. | [
"6 6 4\n"
] | [
"4\n"
] | none | 0 | [
{
"input": "6 6 4",
"output": "4"
},
{
"input": "1 1 1",
"output": "1"
},
{
"input": "2 1 1",
"output": "2"
},
{
"input": "1 2 1",
"output": "2"
},
{
"input": "2 2 1",
"output": "4"
},
{
"input": "2 1 2",
"output": "1"
},
{
"input": "1 1 3"... | 1,663,382,752 | 2,147,483,647 | Python 3 | OK | TESTS | 20 | 46 | 0 | n,m,a=[int(x) for x in input().split()]
q=(n-1)//a+1
z=(m-1)//a+1
print(q*z) | Title: Theatre Square
Time Limit: 1 seconds
Memory Limit: 256 megabytes
Problem Description:
Theatre Square in the capital city of Berland has a rectangular shape with the size *n*<=×<=*m* meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each ... | ```python
n,m,a=[int(x) for x in input().split()]
q=(n-1)//a+1
z=(m-1)//a+1
print(q*z)
``` | 3.977 |
908 | A | New Year and Counting Cards | PROGRAMMING | 800 | [
"brute force",
"implementation"
] | null | null | Your friend has *n* cards.
You know that each card has a lowercase English letter on one side and a digit on the other.
Currently, your friend has laid out the cards on a table so only one side of each card is visible.
You would like to know if the following statement is true for cards that your friend owns: "If a c... | The first and only line of input will contain a string *s* (1<=≤<=|*s*|<=≤<=50), denoting the sides of the cards that you can see on the table currently. Each character of *s* is either a lowercase English letter or a digit. | Print a single integer, the minimum number of cards you must turn over to verify your claim. | [
"ee\n",
"z\n",
"0ay1\n"
] | [
"2\n",
"0\n",
"2\n"
] | In the first sample, we must turn over both cards. Note that even though both cards have the same letter, they could possibly have different numbers on the other side.
In the second sample, we don't need to turn over any cards. The statement is vacuously true, since you know your friend has no cards with a vowel on th... | 500 | [
{
"input": "ee",
"output": "2"
},
{
"input": "z",
"output": "0"
},
{
"input": "0ay1",
"output": "2"
},
{
"input": "0abcdefghijklmnopqrstuvwxyz1234567896",
"output": "10"
},
{
"input": "0a0a9e9e2i2i9o9o6u6u9z9z4x4x9b9b",
"output": "18"
},
{
"input": "01... | 1,521,282,306 | 2,147,483,647 | Python 3 | OK | TESTS | 38 | 93 | 7,372,800 | s=input()
count=0
for i in s:
if i in 'aeiou13579':
count+=1
print(count)
| Title: New Year and Counting Cards
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Your friend has *n* cards.
You know that each card has a lowercase English letter on one side and a digit on the other.
Currently, your friend has laid out the cards on a table so only one side of each car... | ```python
s=input()
count=0
for i in s:
if i in 'aeiou13579':
count+=1
print(count)
``` | 3 | |
0 | none | none | none | 0 | [
"none"
] | null | null | You've got a string $a_1, a_2, \dots, a_n$, consisting of zeros and ones.
Let's call a sequence of consecutive elements $a_i, a_{i<=+<=1}, \ldots,<=a_j$ ($1\leq<=i\leq<=j\leq<=n$) a substring of string $a$.
You can apply the following operations any number of times:
- Choose some substring of string $a$ (for examp... | The first line of input contains integers $n$, $x$ and $y$ ($1<=\leq<=n<=\leq<=300\,000, 0 \leq x, y \leq 10^9$) — length of the string, cost of the first operation (substring reverse) and cost of the second operation (inverting all elements of substring).
The second line contains the string $a$ of length $n$, consist... | Print a single integer — the minimum total cost of operations you need to spend to get a string consisting only of ones. Print $0$, if you do not need to perform any operations. | [
"5 1 10\n01000\n",
"5 10 1\n01000\n",
"7 2 3\n1111111\n"
] | [
"11\n",
"2\n",
"0\n"
] | In the first sample, at first you need to reverse substring $[1 \dots 2]$, and then you need to invert substring $[2 \dots 5]$.
Then the string was changed as follows:
«01000» $\to$ «10000» $\to$ «11111».
The total cost of operations is $1 + 10 = 11$.
In the second sample, at first you need to invert substring $[1... | 0 | [
{
"input": "5 1 10\n01000",
"output": "11"
},
{
"input": "5 10 1\n01000",
"output": "2"
},
{
"input": "7 2 3\n1111111",
"output": "0"
},
{
"input": "1 60754033 959739508\n0",
"output": "959739508"
},
{
"input": "1 431963980 493041212\n1",
"output": "0"
},
... | 1,550,844,728 | 4,928 | Python 3 | WRONG_ANSWER | TESTS | 6 | 233 | 2,457,600 | n,x,y=map(int,input().split())
a=list(input())
sa=set(a)
if len(sa)==1:
if a[0]=='1':print(0)
else:print(y)
else:
ans=0
i=0;su=0
chx=0;chy=0
while i<n:
if a[i]=='0':
#print('Start',i,a[i])
i+=1;ch=0
while i<n and ch<=1:
i... | Title: none
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You've got a string $a_1, a_2, \dots, a_n$, consisting of zeros and ones.
Let's call a sequence of consecutive elements $a_i, a_{i<=+<=1}, \ldots,<=a_j$ ($1\leq<=i\leq<=j\leq<=n$) a substring of string $a$.
You can apply the fo... | ```python
n,x,y=map(int,input().split())
a=list(input())
sa=set(a)
if len(sa)==1:
if a[0]=='1':print(0)
else:print(y)
else:
ans=0
i=0;su=0
chx=0;chy=0
while i<n:
if a[i]=='0':
#print('Start',i,a[i])
i+=1;ch=0
while i<n and ch<=1:
... | 0 | |
547 | B | Mike and Feet | PROGRAMMING | 1,900 | [
"binary search",
"data structures",
"dp",
"dsu"
] | null | null | Mike is the president of country What-The-Fatherland. There are *n* bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to *n* from left to right. *i*-th bear is exactly *a**i* feet high.
A group of bears is a non-empty contiguous segment of the line. The size of... | The first line of input contains integer *n* (1<=≤<=*n*<=≤<=2<=×<=105), the number of bears.
The second line contains *n* integers separated by space, *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=109), heights of bears. | Print *n* integers in one line. For each *x* from 1 to *n*, print the maximum strength among all groups of size *x*. | [
"10\n1 2 3 4 5 4 3 2 1 6\n"
] | [
"6 4 4 3 3 2 2 1 1 1 \n"
] | none | 1,000 | [
{
"input": "10\n1 2 3 4 5 4 3 2 1 6",
"output": "6 4 4 3 3 2 2 1 1 1 "
},
{
"input": "3\n524125987 923264237 374288891",
"output": "923264237 524125987 374288891 "
},
{
"input": "5\n585325539 365329221 412106895 291882089 564718673",
"output": "585325539 365329221 365329221 291882089... | 1,642,751,653 | 2,147,483,647 | PyPy 3-64 | TIME_LIMIT_EXCEEDED | TESTS | 44 | 1,000 | 43,724,800 | import sys
ip=sys.stdin.readline
n = int(ip())
arr = list(map(int, ip().split()))
seq = [0 for _ in range(n)]
stack = [n - 1]
p1 = n - 2
while p1 >= 0:
while stack and arr[p1] < arr[stack[len(stack)-1]]:
seq[stack[len(stack)-1]] = stack[len(stack)-1] - p1
stack.pop(len(stack)-1)
stack... | Title: Mike and Feet
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Mike is the president of country What-The-Fatherland. There are *n* bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to *n* from left to right. *i*-th bear is exac... | ```python
import sys
ip=sys.stdin.readline
n = int(ip())
arr = list(map(int, ip().split()))
seq = [0 for _ in range(n)]
stack = [n - 1]
p1 = n - 2
while p1 >= 0:
while stack and arr[p1] < arr[stack[len(stack)-1]]:
seq[stack[len(stack)-1]] = stack[len(stack)-1] - p1
stack.pop(len(stack)-1)
... | 0 | |
161 | A | Dress'em in Vests! | PROGRAMMING | 1,300 | [
"binary search",
"brute force",
"greedy",
"two pointers"
] | null | null | The Two-dimensional kingdom is going through hard times... This morning the Three-Dimensional kingdom declared war on the Two-dimensional one. This (possibly armed) conflict will determine the ultimate owner of the straight line.
The Two-dimensional kingdom has a regular army of *n* people. Each soldier registered him... | The first input line contains four integers *n*, *m*, *x* and *y* (1<=≤<=*n*,<=*m*<=≤<=105, 0<=≤<=*x*,<=*y*<=≤<=109) — the number of soldiers, the number of vests and two numbers that specify the soldiers' unpretentiousness, correspondingly.
The second line contains *n* integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i... | In the first line print a single integer *k* — the maximum number of soldiers equipped with bulletproof vests.
In the next *k* lines print *k* pairs, one pair per line, as "*u**i* *v**i*" (without the quotes). Pair (*u**i*, *v**i*) means that soldier number *u**i* must wear vest number *v**i*. Soldiers and vests are ... | [
"5 3 0 0\n1 2 3 3 4\n1 3 5\n",
"3 3 2 2\n1 5 9\n3 5 7\n"
] | [
"2\n1 1\n3 2\n",
"3\n1 1\n2 2\n3 3\n"
] | In the first sample you need the vests' sizes to match perfectly: the first soldier gets the first vest (size 1), the third soldier gets the second vest (size 3). This sample allows another answer, which gives the second vest to the fourth soldier instead of the third one.
In the second sample the vest size can differ... | 1,000 | [
{
"input": "5 3 0 0\n1 2 3 3 4\n1 3 5",
"output": "2\n1 1\n3 2"
},
{
"input": "3 3 2 2\n1 5 9\n3 5 7",
"output": "3\n1 1\n2 2\n3 3"
},
{
"input": "1 1 0 0\n1\n1",
"output": "1\n1 1"
},
{
"input": "1 1 0 0\n1\n2",
"output": "0"
},
{
"input": "2 3 1 4\n1 5\n1 2 2",
... | 1,697,442,846 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 84 | 902 | 20,172,800 | soldiers, bpVests, x, y = map(int, input().split())
sizes = list(map(int, input().split()))
availableVests = list(map(int, input().split()))
ans, i, j = [], 0, 0
while i < soldiers:
if j >= bpVests:
break
if sizes[i] - x > availableVests[j]:
j = j + 1
continue
elif size... | Title: Dress'em in Vests!
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The Two-dimensional kingdom is going through hard times... This morning the Three-Dimensional kingdom declared war on the Two-dimensional one. This (possibly armed) conflict will determine the ultimate owner of the s... | ```python
soldiers, bpVests, x, y = map(int, input().split())
sizes = list(map(int, input().split()))
availableVests = list(map(int, input().split()))
ans, i, j = [], 0, 0
while i < soldiers:
if j >= bpVests:
break
if sizes[i] - x > availableVests[j]:
j = j + 1
continue
... | 3 | |
914 | B | Conan and Agasa play a Card Game | PROGRAMMING | 1,200 | [
"games",
"greedy",
"implementation"
] | null | null | Edogawa Conan got tired of solving cases, and invited his friend, Professor Agasa, over. They decided to play a game of cards. Conan has *n* cards, and the *i*-th card has a number *a**i* written on it.
They take turns playing, starting with Conan. In each turn, the player chooses a card and removes it. Also, he remov... | The first line contains an integer *n* (1<=≤<=*n*<=≤<=105) — the number of cards Conan has.
The next line contains *n* integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=105), where *a**i* is the number on the *i*-th card. | If Conan wins, print "Conan" (without quotes), otherwise print "Agasa" (without quotes). | [
"3\n4 5 7\n",
"2\n1 1\n"
] | [
"Conan\n",
"Agasa\n"
] | In the first example, Conan can just choose the card having number 7 on it and hence remove all the cards. After that, there are no cards left on Agasa's turn.
In the second example, no matter which card Conan chooses, there will be one one card left, which Agasa can choose. After that, there are no cards left when it... | 1,000 | [
{
"input": "3\n4 5 7",
"output": "Conan"
},
{
"input": "2\n1 1",
"output": "Agasa"
},
{
"input": "10\n38282 53699 38282 38282 38282 38282 38282 38282 38282 38282",
"output": "Conan"
},
{
"input": "10\n50165 50165 50165 50165 50165 50165 50165 50165 50165 50165",
"output":... | 1,542,607,958 | 2,147,483,647 | Python 3 | OK | TESTS | 91 | 171 | 8,396,800 | import collections
n = int(input())
temp = [int(x) for x in input().split()]
d = collections.Counter(temp)
switch = True
for i in d.keys():
if d[i] % 2 == 1:
print('Conan')
switch = False
break
if switch:
print('Agasa')
| Title: Conan and Agasa play a Card Game
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Edogawa Conan got tired of solving cases, and invited his friend, Professor Agasa, over. They decided to play a game of cards. Conan has *n* cards, and the *i*-th card has a number *a**i* written on it.... | ```python
import collections
n = int(input())
temp = [int(x) for x in input().split()]
d = collections.Counter(temp)
switch = True
for i in d.keys():
if d[i] % 2 == 1:
print('Conan')
switch = False
break
if switch:
print('Agasa')
``` | 3 | |
222 | B | Cosmic Tables | PROGRAMMING | 1,300 | [
"data structures",
"implementation"
] | null | null | The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement.
UCDHP stores some secret information about meteors as an *n*<=×<=*m* table with integers in its cells. The order of mete... | The first line contains three space-separated integers *n*, *m* and *k* (1<=≤<=*n*,<=*m*<=≤<=1000, 1<=≤<=*k*<=≤<=500000) — the number of table columns and rows and the number of queries, correspondingly.
Next *n* lines contain *m* space-separated numbers each — the initial state of the table. Each number *p* in the ta... | For each query to obtain a number (*s**i* = "g") print the required number. Print the answers to the queries in the order of the queries in the input. | [
"3 3 5\n1 2 3\n4 5 6\n7 8 9\ng 3 2\nr 3 2\nc 2 3\ng 2 2\ng 3 2\n",
"2 3 3\n1 2 4\n3 1 5\nc 2 1\nr 1 2\ng 1 3\n"
] | [
"8\n9\n6\n",
"5\n"
] | Let's see how the table changes in the second test case.
After the first operation is fulfilled, the table looks like that:
2 1 4
1 3 5
After the second operation is fulfilled, the table looks like that:
1 3 5
2 1 4
So the answer to the third query (the number located in the first row and in the third column) wi... | 1,000 | [
{
"input": "3 3 5\n1 2 3\n4 5 6\n7 8 9\ng 3 2\nr 3 2\nc 2 3\ng 2 2\ng 3 2",
"output": "8\n9\n6"
},
{
"input": "2 3 3\n1 2 4\n3 1 5\nc 2 1\nr 1 2\ng 1 3",
"output": "5"
},
{
"input": "1 1 15\n1\ng 1 1\ng 1 1\ng 1 1\ng 1 1\ng 1 1\ng 1 1\ng 1 1\ng 1 1\ng 1 1\ng 1 1\ng 1 1\ng 1 1\ng 1 1\ng 1... | 1,600,503,524 | 2,147,483,647 | PyPy 3 | RUNTIME_ERROR | TESTS | 7 | 404 | 2,150,400 | n,m,k=map(int, input().split())
l1=[]
for i in range(0,n):
l2=list(set(map(int, input().split())))
l1.append(l2)
for i in range(0,k):
temp=list(input().split())
q=temp[0]
row=int(temp[1])-1
col=int(temp[2])-1
if temp[0]=='g':
print (l1[row][col])
elif temp[0... | Title: Cosmic Tables
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement.
UCDHP stores some sec... | ```python
n,m,k=map(int, input().split())
l1=[]
for i in range(0,n):
l2=list(set(map(int, input().split())))
l1.append(l2)
for i in range(0,k):
temp=list(input().split())
q=temp[0]
row=int(temp[1])-1
col=int(temp[2])-1
if temp[0]=='g':
print (l1[row][col])
e... | -1 | |
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,545,271,664 | 2,147,483,647 | Python 3 | OK | TESTS | 14 | 124 | 0 | n = int(input())
string = input()
if string == '0':
print('0')
else:
string = list(string)
print('1' + string.count('0')*'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
n = int(input())
string = input()
if string == '0':
print('0')
else:
string = list(string)
print('1' + string.count('0')*'0')
``` | 3 | |
165 | B | Burning Midnight Oil | PROGRAMMING | 1,500 | [
"binary search",
"implementation"
] | null | null | One day a highly important task was commissioned to Vasya — writing a program in a night. The program consists of *n* lines of code. Vasya is already exhausted, so he works like that: first he writes *v* lines of code, drinks a cup of tea, then he writes as much as lines, drinks another cup of tea, then he writes lin... | The input consists of two integers *n* and *k*, separated by spaces — the size of the program in lines and the productivity reduction coefficient, 1<=≤<=*n*<=≤<=109, 2<=≤<=*k*<=≤<=10. | Print the only integer — the minimum value of *v* that lets Vasya write the program in one night. | [
"7 2\n",
"59 9\n"
] | [
"4\n",
"54\n"
] | In the first sample the answer is *v* = 4. Vasya writes the code in the following portions: first 4 lines, then 2, then 1, and then Vasya falls asleep. Thus, he manages to write 4 + 2 + 1 = 7 lines in a night and complete the task.
In the second sample the answer is *v* = 54. Vasya writes the code in the following por... | 1,000 | [
{
"input": "7 2",
"output": "4"
},
{
"input": "59 9",
"output": "54"
},
{
"input": "1 9",
"output": "1"
},
{
"input": "11 2",
"output": "7"
},
{
"input": "747 2",
"output": "376"
},
{
"input": "6578 2",
"output": "3293"
},
{
"input": "37212... | 1,601,229,360 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 186 | 0 | import math
n,k = map(int,input().split())
l=1
r=n
while l!= r:
middle= math.floor(l+(r-l)/2)
tempAdder = middle
sum = 0
while tempAdder!= 0:
sum+=tempAdder
tempAdder=math.floor(tempAdder/k)
if sum>n:
r=middle
elif sum==n:
break
else:
l... | Title: Burning Midnight Oil
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
One day a highly important task was commissioned to Vasya — writing a program in a night. The program consists of *n* lines of code. Vasya is already exhausted, so he works like that: first he writes *v* lines of c... | ```python
import math
n,k = map(int,input().split())
l=1
r=n
while l!= r:
middle= math.floor(l+(r-l)/2)
tempAdder = middle
sum = 0
while tempAdder!= 0:
sum+=tempAdder
tempAdder=math.floor(tempAdder/k)
if sum>n:
r=middle
elif sum==n:
break
else:
... | 0 | |
633 | C | Spy Syndrome 2 | PROGRAMMING | 1,900 | [
"data structures",
"dp",
"hashing",
"implementation",
"sortings",
"string suffix structures",
"strings"
] | null | null | After observing the results of Spy Syndrome, Yash realised the errors of his ways. He now believes that a super spy such as Siddhant can't use a cipher as basic and ancient as Caesar cipher. After many weeks of observation of Siddhant’s sentences, Yash determined a new cipher technique.
For a given sentence, the ciphe... | The first line of the input contains a single integer *n* (1<=≤<=*n*<=≤<=10<=000) — the length of the ciphered text. The second line consists of *n* lowercase English letters — the ciphered text *t*.
The third line contains a single integer *m* (1<=≤<=*m*<=≤<=100<=000) — the number of words which will be considered wh... | Print one line — the original sentence. It is guaranteed that at least one solution exists. If there are multiple solutions, you may output any of those. | [
"30\nariksihsidlihcdnaehsetahgnisol\n10\nKira\nhates\nis\nhe\nlosing\ndeath\nchildish\nL\nand\nNote\n",
"12\niherehtolleh\n5\nHI\nHo\nthere\nHeLLo\nhello\n"
] | [
"Kira is childish and he hates losing \n",
"HI there HeLLo \n"
] | In sample case 2 there may be multiple accepted outputs, "HI there HeLLo" and "HI there hello" you may output any of them. | 1,500 | [
{
"input": "30\nariksihsidlihcdnaehsetahgnisol\n10\nKira\nhates\nis\nhe\nlosing\ndeath\nchildish\nL\nand\nNote",
"output": "Kira is childish and he hates losing "
},
{
"input": "12\niherehtolleh\n5\nHI\nHo\nthere\nHeLLo\nhello",
"output": "HI there HeLLo "
},
{
"input": "71\nbaaaaaaaaaaa... | 1,689,651,021 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 0 | 46 | 0 | print("_RANDOM_GUESS_1689651020.9320993")# 1689651020.932119 | Title: Spy Syndrome 2
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
After observing the results of Spy Syndrome, Yash realised the errors of his ways. He now believes that a super spy such as Siddhant can't use a cipher as basic and ancient as Caesar cipher. After many weeks of observati... | ```python
print("_RANDOM_GUESS_1689651020.9320993")# 1689651020.932119
``` | 0 | |
107 | B | Basketball Team | PROGRAMMING | 1,600 | [
"combinatorics",
"dp",
"math",
"probabilities"
] | B. Basketball Team | 1 | 256 | As a German University in Cairo (GUC) student and a basketball player, Herr Wafa was delighted once he heard the news. GUC is finally participating in the Annual Basketball Competition (ABC).
A team is to be formed of *n* players, all of which are GUC students. However, the team might have players belonging to differ... | The first line contains three integers *n*, *m* and *h* (1<=≤<=*n*<=≤<=100,<=1<=≤<=*m*<=≤<=1000,<=1<=≤<=*h*<=≤<=*m*) — the number of players on the team, the number of departments in GUC and Herr Wafa's department, correspondingly.
The second line contains a single-space-separated list of *m* integers *s**i* (1<=≤<=*... | Print the probability that Herr Wafa will have at least one teammate from his department. If there is not enough basketball players in GUC to participate in ABC, print -1. The answer will be accepted if it has absolute or relative error not exceeding 10<=-<=6. | [
"3 2 1\n2 1\n",
"3 2 1\n1 1\n",
"3 2 1\n2 2\n"
] | [
"1\n",
"-1\n",
"0.666667\n"
] | In the first example all 3 players (2 from department 1 and 1 from department 2) must be chosen for the team. Both players from Wafa's departments will be chosen, so he's guaranteed to have a teammate from his department.
In the second example, there are not enough players.
In the third example, there are three possi... | 1,000 | [
{
"input": "3 2 1\n2 1",
"output": "1"
},
{
"input": "3 2 1\n1 1",
"output": "-1"
},
{
"input": "3 2 1\n2 2",
"output": "0.666667"
},
{
"input": "3 2 1\n1 2",
"output": "0.000000"
},
{
"input": "6 5 3\n5 2 3 10 5",
"output": "0.380435"
},
{
"input": "7... | 1,597,830,769 | 2,147,483,647 | PyPy 3 | MEMORY_LIMIT_EXCEEDED | TESTS | 31 | 545 | 268,390,400 | def comb(n,m):
return cb[n]//cb[n-m]//cb[m]
n,m,h = map(int,input().split())
a = list(map(int,input().split()))
n-=1
a[h-1]-=1;
s =0
for i in a:
s+=i
cb = [1]*(s+1);
j = 1
for i in range(2,s+1):
j*=i;
cb[i]=j;
if(s<n):
print(-1)
else:
e = comb(s,n)
print((e-comb(s-a[h-1],n)... | Title: Basketball Team
Time Limit: 1 seconds
Memory Limit: 256 megabytes
Problem Description:
As a German University in Cairo (GUC) student and a basketball player, Herr Wafa was delighted once he heard the news. GUC is finally participating in the Annual Basketball Competition (ABC).
A team is to be formed of *n*... | ```python
def comb(n,m):
return cb[n]//cb[n-m]//cb[m]
n,m,h = map(int,input().split())
a = list(map(int,input().split()))
n-=1
a[h-1]-=1;
s =0
for i in a:
s+=i
cb = [1]*(s+1);
j = 1
for i in range(2,s+1):
j*=i;
cb[i]=j;
if(s<n):
print(-1)
else:
e = comb(s,n)
print((e-comb(s... | 0 |
711 | E | ZS and The Birthday Paradox | PROGRAMMING | 2,300 | [
"math",
"number theory",
"probabilities"
] | null | null | ZS the Coder has recently found an interesting concept called the Birthday Paradox. It states that given a random set of 23 people, there is around 50% chance that some two of them share the same birthday. ZS the Coder finds this very interesting, and decides to test this with the inhabitants of Udayland.
In Udayland,... | The first and only line of the input contains two integers *n* and *k* (1<=≤<=*n*<=≤<=1018,<=2<=≤<=*k*<=≤<=1018), meaning that there are 2*n* days in a year and that ZS the Coder wants to interview exactly *k* people. | If the probability of at least two *k* people having the same birthday in 2*n* days long year equals (*A*<=≥<=0, *B*<=≥<=1, ), print the *A* and *B* in a single line.
Since these numbers may be too large, print them modulo 106<=+<=3. Note that *A* and *B* must be coprime before their remainders modulo 106<=+<=3 are t... | [
"3 2\n",
"1 3\n",
"4 3\n"
] | [
"1 8",
"1 1",
"23 128"
] | In the first sample case, there are 2<sup class="upper-index">3</sup> = 8 days in Udayland. The probability that 2 people have the same birthday among 2 people is clearly <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/5947a169159fe867f85f3fd8b9690019b48152f5.png" style="max-width: 100.0%;m... | 2,500 | [
{
"input": "3 2",
"output": "1 8"
},
{
"input": "1 3",
"output": "1 1"
},
{
"input": "4 3",
"output": "23 128"
},
{
"input": "1000000000000000000 1000000000000000000",
"output": "906300 906300"
},
{
"input": "59 576460752303423489",
"output": "1 1"
},
{
... | 1,689,603,378 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 0 | 31 | 0 | print("_RANDOM_GUESS_1689603378.844023")# 1689603378.8440428 | Title: ZS and The Birthday Paradox
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
ZS the Coder has recently found an interesting concept called the Birthday Paradox. It states that given a random set of 23 people, there is around 50% chance that some two of them share the same birthday. Z... | ```python
print("_RANDOM_GUESS_1689603378.844023")# 1689603378.8440428
``` | 0 | |
26 | A | Almost Prime | PROGRAMMING | 900 | [
"number theory"
] | A. Almost Prime | 2 | 256 | A number is called almost prime if it has exactly two distinct prime divisors. For example, numbers 6, 18, 24 are almost prime, while 4, 8, 9, 42 are not. Find the amount of almost prime numbers which are between 1 and *n*, inclusive. | Input contains one integer number *n* (1<=≤<=*n*<=≤<=3000). | Output the amount of almost prime numbers between 1 and *n*, inclusive. | [
"10\n",
"21\n"
] | [
"2\n",
"8\n"
] | none | 500 | [
{
"input": "10",
"output": "2"
},
{
"input": "21",
"output": "8"
},
{
"input": "1",
"output": "0"
},
{
"input": "2",
"output": "0"
},
{
"input": "4",
"output": "0"
},
{
"input": "3",
"output": "0"
},
{
"input": "8",
"output": "1"
},
... | 1,578,848,338 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 13 | 2,000 | 307,200 | # prime fn.
def prime(num):
flag=1
if num >2:
if num%2==0:
flag=0
else:
for i in range(2,num//2):
if num%i==0:
flag=0
break
return flag
# fn to find no. of prime divisors
def num_prime_divisors(num):
prime_list=[]
for i in range(2,num//... | Title: Almost Prime
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
A number is called almost prime if it has exactly two distinct prime divisors. For example, numbers 6, 18, 24 are almost prime, while 4, 8, 9, 42 are not. Find the amount of almost prime numbers which are between 1 and *n*, in... | ```python
# prime fn.
def prime(num):
flag=1
if num >2:
if num%2==0:
flag=0
else:
for i in range(2,num//2):
if num%i==0:
flag=0
break
return flag
# fn to find no. of prime divisors
def num_prime_divisors(num):
prime_list=[]
for i in ran... | 0 |
803 | B | Distances to Zero | PROGRAMMING | 1,200 | [
"constructive algorithms"
] | null | null | You are given the array of integer numbers *a*0,<=*a*1,<=...,<=*a**n*<=-<=1. For each element find the distance to the nearest zero (to the element which equals to zero). There is at least one zero element in the given array. | The first line contains integer *n* (1<=≤<=*n*<=≤<=2·105) — length of the array *a*. The second line contains integer elements of the array separated by single spaces (<=-<=109<=≤<=*a**i*<=≤<=109). | Print the sequence *d*0,<=*d*1,<=...,<=*d**n*<=-<=1, where *d**i* is the difference of indices between *i* and nearest *j* such that *a**j*<==<=0. It is possible that *i*<==<=*j*. | [
"9\n2 1 0 3 0 0 3 2 4\n",
"5\n0 1 2 3 4\n",
"7\n5 6 0 1 -2 3 4\n"
] | [
"2 1 0 1 0 0 1 2 3 ",
"0 1 2 3 4 ",
"2 1 0 1 2 3 4 "
] | none | 0 | [
{
"input": "9\n2 1 0 3 0 0 3 2 4",
"output": "2 1 0 1 0 0 1 2 3 "
},
{
"input": "5\n0 1 2 3 4",
"output": "0 1 2 3 4 "
},
{
"input": "7\n5 6 0 1 -2 3 4",
"output": "2 1 0 1 2 3 4 "
},
{
"input": "1\n0",
"output": "0 "
},
{
"input": "2\n0 0",
"output": "0 0 "
... | 1,612,326,593 | 2,147,483,647 | Python 3 | OK | TESTS | 164 | 686 | 20,172,800 | from array import *
n = int(input())
ar = list(map(int, input().split()))
dist1 = []
dist2 = []
for i in range(n):
dist1.append(0)
dist2.append(0)
st = n
for i in range(n):
if ar[i] != 0:
dist1[i] = st
else:
st = 0
st += 1
st = n
ar.reverse()
for i in range(n):
... | Title: Distances to Zero
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given the array of integer numbers *a*0,<=*a*1,<=...,<=*a**n*<=-<=1. For each element find the distance to the nearest zero (to the element which equals to zero). There is at least one zero element in the give... | ```python
from array import *
n = int(input())
ar = list(map(int, input().split()))
dist1 = []
dist2 = []
for i in range(n):
dist1.append(0)
dist2.append(0)
st = n
for i in range(n):
if ar[i] != 0:
dist1[i] = st
else:
st = 0
st += 1
st = n
ar.reverse()
for i in ran... | 3 | |
934 | A | A Compatible Pair | PROGRAMMING | 1,400 | [
"brute force",
"games"
] | null | null | Nian is a monster which lives deep in the oceans. Once a year, it shows up on the land, devouring livestock and even people. In order to keep the monster away, people fill their villages with red colour, light, and cracking noise, all of which frighten the monster out of coming.
Little Tommy has *n* lanterns and Big B... | The first line contains two space-separated integers *n* and *m* (2<=≤<=*n*,<=*m*<=≤<=50).
The second line contains *n* space-separated integers *a*1,<=*a*2,<=...,<=*a**n*.
The third line contains *m* space-separated integers *b*1,<=*b*2,<=...,<=*b**m*.
All the integers range from <=-<=109 to 109. | Print a single integer — the brightness of the chosen pair. | [
"2 2\n20 18\n2 14\n",
"5 3\n-1 0 1 2 3\n-1 0 1\n"
] | [
"252\n",
"2\n"
] | In the first example, Tommy will hide 20 and Banban will choose 18 from Tommy and 14 from himself.
In the second example, Tommy will hide 3 and Banban will choose 2 from Tommy and 1 from himself. | 500 | [
{
"input": "2 2\n20 18\n2 14",
"output": "252"
},
{
"input": "5 3\n-1 0 1 2 3\n-1 0 1",
"output": "2"
},
{
"input": "10 2\n1 6 2 10 2 3 2 10 6 4\n5 7",
"output": "70"
},
{
"input": "50 50\n1 6 2 10 2 3 2 10 6 4 5 0 3 1 7 3 2 4 4 2 1 5 0 6 10 1 8 0 10 9 0 4 10 5 5 7 4 9 9 5 5 ... | 1,595,518,023 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 6 | 155 | 21,811,200 | n,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
l=[]
for i in a:
for j in b:
l.append(i*j)
l.sort()
print(l[-2]) | Title: A Compatible Pair
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Nian is a monster which lives deep in the oceans. Once a year, it shows up on the land, devouring livestock and even people. In order to keep the monster away, people fill their villages with red colour, light, and cr... | ```python
n,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
l=[]
for i in a:
for j in b:
l.append(i*j)
l.sort()
print(l[-2])
``` | 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,693,282,190 | 2,147,483,647 | Python 3 | OK | TESTS | 31 | 124 | 0 | n=m=-1
for s in open(0):m+=n!=s;n=s
print(m) | 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
n=m=-1
for s in open(0):m+=n!=s;n=s
print(m)
``` | 3 | |
415 | B | Mashmokh and Tokens | PROGRAMMING | 1,500 | [
"binary search",
"greedy",
"implementation",
"math"
] | null | null | Bimokh is Mashmokh's boss. For the following *n* days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest o... | The first line of input contains three space-separated integers *n*,<=*a*,<=*b* (1<=≤<=*n*<=≤<=105; 1<=≤<=*a*,<=*b*<=≤<=109). The second line of input contains *n* space-separated integers *x*1,<=*x*2,<=...,<=*x**n* (1<=≤<=*x**i*<=≤<=109). | Output *n* space-separated integers. The *i*-th of them is the number of tokens Mashmokh can save on the *i*-th day. | [
"5 1 4\n12 6 11 9 1\n",
"3 1 2\n1 2 3\n",
"1 1 1\n1\n"
] | [
"0 2 3 1 1 ",
"1 0 1 ",
"0 "
] | none | 1,000 | [
{
"input": "5 1 4\n12 6 11 9 1",
"output": "0 2 3 1 1 "
},
{
"input": "3 1 2\n1 2 3",
"output": "1 0 1 "
},
{
"input": "1 1 1\n1",
"output": "0 "
},
{
"input": "1 1 1000000000\n1000000000",
"output": "0 "
},
{
"input": "1 1 1000000000\n999999999",
"output": "9... | 1,486,125,807 | 2,147,483,647 | Python 3 | COMPILATION_ERROR | TESTS | 0 | 0 | 0 | #include <bits/stdc++.h>
using namespace std;
int n, a, b, x;
int main(){
scanf("%d %d %d", &n, &a, &b);
for(int it = 0; it < n; it++){
scanf("%d", &x);
printf( it != n - 1 ? "%I64d " : "%I64d\n", 1LL * x * a % b );
}
return(0);
}
| Title: Mashmokh and Tokens
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Bimokh is Mashmokh's boss. For the following *n* days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each... | ```python
#include <bits/stdc++.h>
using namespace std;
int n, a, b, x;
int main(){
scanf("%d %d %d", &n, &a, &b);
for(int it = 0; it < n; it++){
scanf("%d", &x);
printf( it != n - 1 ? "%I64d " : "%I64d\n", 1LL * x * a % b );
}
return(0);
}
``` | -1 | |
830 | A | Office Keys | PROGRAMMING | 1,800 | [
"binary search",
"brute force",
"dp",
"greedy",
"sortings"
] | null | null | There are *n* people and *k* keys on a straight line. Every person wants to get to the office which is located on the line as well. To do that, he needs to reach some point with a key, take the key and then go to the office. Once a key is taken by somebody, it couldn't be taken by anybody else.
You are to determine th... | The first line contains three integers *n*, *k* and *p* (1<=≤<=*n*<=≤<=1<=000, *n*<=≤<=*k*<=≤<=2<=000, 1<=≤<=*p*<=≤<=109) — the number of people, the number of keys and the office location.
The second line contains *n* distinct integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=109) — positions in which people are ... | Print the minimum time (in seconds) needed for all *n* to reach the office with keys. | [
"2 4 50\n20 100\n60 10 40 80\n",
"1 2 10\n11\n15 7\n"
] | [
"50\n",
"7\n"
] | In the first example the person located at point 20 should take the key located at point 40 and go with it to the office located at point 50. He spends 30 seconds. The person located at point 100 can take the key located at point 80 and go to the office with it. He spends 50 seconds. Thus, after 50 seconds everybody is... | 500 | [
{
"input": "2 4 50\n20 100\n60 10 40 80",
"output": "50"
},
{
"input": "1 2 10\n11\n15 7",
"output": "7"
},
{
"input": "2 5 15\n10 4\n29 23 21 22 26",
"output": "23"
},
{
"input": "3 10 1500\n106 160 129\n1333 1532 1181 1091 1656 1698 1291 1741 1242 1163",
"output": "1394... | 1,589,387,203 | 3,823 | PyPy 3 | WRONG_ANSWER | TESTS | 3 | 452 | 31,539,200 | import math as mt
import sys,string
input=sys.stdin.readline
#print=sys.stdout.write
import random
from collections import deque,defaultdict
L=lambda : list(map(int,input().split()))
Ls=lambda : list(input().split())
M=lambda : map(int,input().split())
I=lambda :int(input())
n,m,p=M()
l=L()
g=L()
leftl=[]
rightl=[]
le... | Title: Office Keys
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
There are *n* people and *k* keys on a straight line. Every person wants to get to the office which is located on the line as well. To do that, he needs to reach some point with a key, take the key and then go to the office... | ```python
import math as mt
import sys,string
input=sys.stdin.readline
#print=sys.stdout.write
import random
from collections import deque,defaultdict
L=lambda : list(map(int,input().split()))
Ls=lambda : list(input().split())
M=lambda : map(int,input().split())
I=lambda :int(input())
n,m,p=M()
l=L()
g=L()
leftl=[]
ri... | 0 | |
919 | B | Perfect Number | PROGRAMMING | 1,100 | [
"binary search",
"brute force",
"dp",
"implementation",
"number theory"
] | null | null | We consider a positive integer perfect, if and only if the sum of its digits is exactly $10$. Given a positive integer $k$, your task is to find the $k$-th smallest perfect positive integer. | A single line with a positive integer $k$ ($1 \leq k \leq 10\,000$). | A single number, denoting the $k$-th smallest perfect integer. | [
"1\n",
"2\n"
] | [
"19\n",
"28\n"
] | The first perfect integer is $19$ and the second one is $28$. | 750 | [
{
"input": "1",
"output": "19"
},
{
"input": "2",
"output": "28"
},
{
"input": "13",
"output": "136"
},
{
"input": "101",
"output": "1432"
},
{
"input": "1023",
"output": "100270"
},
{
"input": "9999",
"output": "10800010"
},
{
"input": "10... | 1,623,829,685 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 2 | 77 | 0 | k = int(input())
ans = 10
for i in range(k):
ans = ans+9
print(ans)
| Title: Perfect Number
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
We consider a positive integer perfect, if and only if the sum of its digits is exactly $10$. Given a positive integer $k$, your task is to find the $k$-th smallest perfect positive integer.
Input Specification:
A singl... | ```python
k = int(input())
ans = 10
for i in range(k):
ans = ans+9
print(ans)
``` | 0 | |
840 | A | Leha and Function | PROGRAMMING | 1,300 | [
"combinatorics",
"greedy",
"math",
"number theory",
"sortings"
] | null | null | Leha like all kinds of strange things. Recently he liked the function *F*(*n*,<=*k*). Consider all possible *k*-element subsets of the set [1,<=2,<=...,<=*n*]. For subset find minimal element in it. *F*(*n*,<=*k*) — mathematical expectation of the minimal element among all *k*-element subsets.
But only function does n... | First line of input data contains single integer *m* (1<=≤<=*m*<=≤<=2·105) — length of arrays *A* and *B*.
Next line contains *m* integers *a*1,<=*a*2,<=...,<=*a**m* (1<=≤<=*a**i*<=≤<=109) — array *A*.
Next line contains *m* integers *b*1,<=*b*2,<=...,<=*b**m* (1<=≤<=*b**i*<=≤<=109) — array *B*. | Output *m* integers *a*'1,<=*a*'2,<=...,<=*a*'*m* — array *A*' which is permutation of the array *A*. | [
"5\n7 3 5 3 4\n2 1 3 2 3\n",
"7\n4 6 5 8 8 2 6\n2 1 2 2 1 1 2\n"
] | [
"4 7 3 5 3\n",
"2 6 4 5 8 8 6\n"
] | none | 500 | [
{
"input": "5\n7 3 5 3 4\n2 1 3 2 3",
"output": "4 7 3 5 3"
},
{
"input": "7\n4 6 5 8 8 2 6\n2 1 2 2 1 1 2",
"output": "2 6 4 5 8 8 6"
}
] | 1,682,364,698 | 578 | PyPy 3 | OK | TESTS | 48 | 1,325 | 46,284,800 | import sys
input = sys.stdin.buffer.readline
def process(A, B):
n = len(A)
A.sort(reverse= True)
B2 = [[B[i], i] for i in range(n)]
B2.sort()
answer = [None for i in range(n)]
for i in range(n):
bi, I = B2[i]
ai = A[i]
answer[I] = ai
answer = ' '.join... | Title: Leha and Function
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Leha like all kinds of strange things. Recently he liked the function *F*(*n*,<=*k*). Consider all possible *k*-element subsets of the set [1,<=2,<=...,<=*n*]. For subset find minimal element in it. *F*(*n*,<=*k*) — m... | ```python
import sys
input = sys.stdin.buffer.readline
def process(A, B):
n = len(A)
A.sort(reverse= True)
B2 = [[B[i], i] for i in range(n)]
B2.sort()
answer = [None for i in range(n)]
for i in range(n):
bi, I = B2[i]
ai = A[i]
answer[I] = ai
answer ... | 3 | |
778 | B | Bitwise Formula | PROGRAMMING | 1,800 | [
"bitmasks",
"brute force",
"dfs and similar",
"expression parsing",
"implementation"
] | null | null | Bob recently read about bitwise operations used in computers: AND, OR and XOR. He have studied their properties and invented a new game.
Initially, Bob chooses integer *m*, bit depth of the game, which means that all numbers in the game will consist of *m* bits. Then he asks Peter to choose some *m*-bit number. After ... | The first line contains two integers *n* and *m*, the number of variables and bit depth, respectively (1<=≤<=*n*<=≤<=5000; 1<=≤<=*m*<=≤<=1000).
The following *n* lines contain descriptions of the variables. Each line describes exactly one variable. Description has the following format: name of a new variable, space, ... | In the first line output the minimum number that should be chosen by Peter, to make the sum of all variable values minimum possible, in the second line output the minimum number that should be chosen by Peter, to make the sum of all variable values maximum possible. Both numbers should be printed as *m*-bit binary numb... | [
"3 3\na := 101\nb := 011\nc := ? XOR b\n",
"5 1\na := 1\nbb := 0\ncx := ? OR a\nd := ? XOR ?\ne := d AND bb\n"
] | [
"011\n100\n",
"0\n0\n"
] | In the first sample if Peter chooses a number 011<sub class="lower-index">2</sub>, then *a* = 101<sub class="lower-index">2</sub>, *b* = 011<sub class="lower-index">2</sub>, *c* = 000<sub class="lower-index">2</sub>, the sum of their values is 8. If he chooses the number 100<sub class="lower-index">2</sub>, then *a* = ... | 1,000 | [
{
"input": "3 3\na := 101\nb := 011\nc := ? XOR b",
"output": "011\n100"
},
{
"input": "5 1\na := 1\nbb := 0\ncx := ? OR a\nd := ? XOR ?\ne := d AND bb",
"output": "0\n0"
},
{
"input": "2 10\nb := 0100101101\na := ? XOR b",
"output": "0100101101\n1011010010"
},
{
"input": "1 ... | 1,488,100,894 | 4,594 | Python 3 | TIME_LIMIT_EXCEEDED | PRETESTS | 11 | 3,000 | 7,782,400 | n, m = map(int, input().strip().split())
ar = []
for i in range(n):
ar.append(input().strip().split())
def calc_value(b_i, b_v):
ar_dict = {'?' : b_v}
for i in range(n):
# print(ar_dict)
name = ar[i][0]
if len(ar[i]) == 3:
value = int(ar[i][2][b_i])
else:
... | Title: Bitwise Formula
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Bob recently read about bitwise operations used in computers: AND, OR and XOR. He have studied their properties and invented a new game.
Initially, Bob chooses integer *m*, bit depth of the game, which means that all n... | ```python
n, m = map(int, input().strip().split())
ar = []
for i in range(n):
ar.append(input().strip().split())
def calc_value(b_i, b_v):
ar_dict = {'?' : b_v}
for i in range(n):
# print(ar_dict)
name = ar[i][0]
if len(ar[i]) == 3:
value = int(ar[i][2][b_i])
els... | 0 | |
922 | A | Cloning Toys | PROGRAMMING | 1,300 | [
"implementation"
] | null | null | Imp likes his plush toy a lot.
Recently, he found a machine that can clone plush toys. Imp knows that if he applies the machine to an original toy, he additionally gets one more original toy and one copy, and if he applies the machine to a copied toy, he gets two additional copies.
Initially, Imp has only one origina... | The only line contains two integers *x* and *y* (0<=≤<=*x*,<=*y*<=≤<=109) — the number of copies and the number of original toys Imp wants to get (including the initial one). | Print "Yes", if the desired configuration is possible, and "No" otherwise.
You can print each letter in arbitrary case (upper or lower). | [
"6 3\n",
"4 2\n",
"1000 1001\n"
] | [
"Yes\n",
"No\n",
"Yes\n"
] | In the first example, Imp has to apply the machine twice to original toys and then twice to copies. | 500 | [
{
"input": "6 3",
"output": "Yes"
},
{
"input": "4 2",
"output": "No"
},
{
"input": "1000 1001",
"output": "Yes"
},
{
"input": "1000000000 999999999",
"output": "Yes"
},
{
"input": "81452244 81452247",
"output": "No"
},
{
"input": "188032448 86524683",... | 1,571,815,141 | 2,147,483,647 | PyPy 3 | OK | TESTS | 52 | 140 | 0 | # t = int(input())
# for _ in range(t):
# n, k = map(int, input().split())
# s = list(map(int, input().split()))
# s.sort()
# res = s[0]
# for i in range(1, len(s)):
# res = max(res, (s[i] - s[i-1])//2 + 1)
# res = max(res, n - s[-1] + 1)
# print(res)
x, y = map(int, inpu... | Title: Cloning Toys
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Imp likes his plush toy a lot.
Recently, he found a machine that can clone plush toys. Imp knows that if he applies the machine to an original toy, he additionally gets one more original toy and one copy, and if he applie... | ```python
# t = int(input())
# for _ in range(t):
# n, k = map(int, input().split())
# s = list(map(int, input().split()))
# s.sort()
# res = s[0]
# for i in range(1, len(s)):
# res = max(res, (s[i] - s[i-1])//2 + 1)
# res = max(res, n - s[-1] + 1)
# print(res)
x, y = map... | 3 | |
78 | B | Easter Eggs | PROGRAMMING | 1,200 | [
"constructive algorithms",
"implementation"
] | B. Easter Eggs | 2 | 256 | The Easter Rabbit laid *n* eggs in a circle and is about to paint them.
Each egg should be painted one color out of 7: red, orange, yellow, green, blue, indigo or violet. Also, the following conditions should be satisfied:
- Each of the seven colors should be used to paint at least one egg. - Any four eggs lying s... | The only line contains an integer *n* — the amount of eggs (7<=≤<=*n*<=≤<=100). | Print one line consisting of *n* characters. The *i*-th character should describe the color of the *i*-th egg in the order they lie in the circle. The colors should be represented as follows: "R" stands for red, "O" stands for orange, "Y" stands for yellow, "G" stands for green, "B" stands for blue, "I" stands for indi... | [
"8\n",
"13\n"
] | [
"ROYGRBIV\n",
"ROYGBIVGBIVYG\n"
] | The way the eggs will be painted in the first sample is shown on the picture: | 1,000 | [
{
"input": "8",
"output": "ROYGBIVG"
},
{
"input": "13",
"output": "ROYGBIVOYGBIV"
},
{
"input": "7",
"output": "ROYGBIV"
},
{
"input": "10",
"output": "ROYGBIVYGB"
},
{
"input": "14",
"output": "ROYGBIVROYGBIV"
},
{
"input": "50",
"output": "ROYGB... | 1,678,893,826 | 2,147,483,647 | Python 3 | OK | TESTS | 34 | 92 | 0 | # LUOGU_RID: 104833040
print(('ROY' + 'GBIV' * 25)[:int(input())])
| Title: Easter Eggs
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
The Easter Rabbit laid *n* eggs in a circle and is about to paint them.
Each egg should be painted one color out of 7: red, orange, yellow, green, blue, indigo or violet. Also, the following conditions should be satisfied:
-... | ```python
# LUOGU_RID: 104833040
print(('ROY' + 'GBIV' * 25)[:int(input())])
``` | 3.977 |
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,526,379,142 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 3 | 2,000 | 10,035,200 | n,q=map(int,input().split())
a=[0 for x in range(n)]
last=0
i=0
for core in str(input()).split() :
a[i]=last+int(core)
last=a[i]
i+=1
last=0
#print(a)
for core in str(input()).split():
strela=last+int(core)
if strela>=a[-1]:
print(n)
last=0
else:
last=... | 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
n,q=map(int,input().split())
a=[0 for x in range(n)]
last=0
i=0
for core in str(input()).split() :
a[i]=last+int(core)
last=a[i]
i+=1
last=0
#print(a)
for core in str(input()).split():
strela=last+int(core)
if strela>=a[-1]:
print(n)
last=0
else:
... | 0 | |
754 | D | Fedor and coupons | PROGRAMMING | 2,100 | [
"binary search",
"data structures",
"greedy",
"sortings"
] | null | null | All our characters have hobbies. The same is true for Fedor. He enjoys shopping in the neighboring supermarket.
The goods in the supermarket have unique integer ids. Also, for every integer there is a product with id equal to this integer. Fedor has *n* discount coupons, the *i*-th of them can be used with products w... | The first line contains two integers *n* and *k* (1<=≤<=*k*<=≤<=*n*<=≤<=3·105) — the number of coupons Fedor has, and the number of coupons he wants to choose.
Each of the next *n* lines contains two integers *l**i* and *r**i* (<=-<=109<=≤<=*l**i*<=≤<=*r**i*<=≤<=109) — the description of the *i*-th coupon. The coupons... | In the first line print single integer — the maximum number of products with which all the chosen coupons can be used. The products with which at least one coupon cannot be used shouldn't be counted.
In the second line print *k* distinct integers *p*1,<=*p*2,<=...,<=*p**k* (1<=≤<=*p**i*<=≤<=*n*) — the ids of the coupo... | [
"4 2\n1 100\n40 70\n120 130\n125 180\n",
"3 2\n1 12\n15 20\n25 30\n",
"5 2\n1 10\n5 15\n14 50\n30 70\n99 100\n"
] | [
"31\n1 2 \n",
"0\n1 2 \n",
"21\n3 4 \n"
] | In the first example if we take the first two coupons then all the products with ids in range [40, 70] can be bought with both coupons. There are 31 products in total.
In the second example, no product can be bought with two coupons, that is why the answer is 0. Fedor can choose any two coupons in this example. | 2,000 | [
{
"input": "4 2\n1 100\n40 70\n120 130\n125 180",
"output": "31\n1 2 "
},
{
"input": "3 2\n1 12\n15 20\n25 30",
"output": "0\n1 2 "
},
{
"input": "5 2\n1 10\n5 15\n14 50\n30 70\n99 100",
"output": "21\n3 4 "
},
{
"input": "7 6\n-8 6\n7 9\n-10 -5\n-6 10\n-7 -3\n5 8\n4 10",
... | 1,665,052,818 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 77 | 1,122 | 74,240,000 | import sys
from heapq import *
input = sys.stdin.readline
n, k = map(int, input().split())
a = []
for i in range(n):
l, r = map(int, input().split())
a.append((l, r, i))
a.sort(key=lambda p: p[0])
ans = ll = 0
h = [p[1] for p in a[:k]]
heapify(h)
d = h[0] - a[k - 1][0] + 1
if d > ans:
ans ... | Title: Fedor and coupons
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
All our characters have hobbies. The same is true for Fedor. He enjoys shopping in the neighboring supermarket.
The goods in the supermarket have unique integer ids. Also, for every integer there is a product with i... | ```python
import sys
from heapq import *
input = sys.stdin.readline
n, k = map(int, input().split())
a = []
for i in range(n):
l, r = map(int, input().split())
a.append((l, r, i))
a.sort(key=lambda p: p[0])
ans = ll = 0
h = [p[1] for p in a[:k]]
heapify(h)
d = h[0] - a[k - 1][0] + 1
if d > ans:... | 3 | |
488 | B | Candy Boxes | PROGRAMMING | 1,900 | [
"brute force",
"constructive algorithms",
"math"
] | null | null | There is an old tradition of keeping 4 boxes of candies in the house in Cyberland. The numbers of candies are special if their arithmetic mean, their median and their range are all equal. By definition, for a set {*x*1,<=*x*2,<=*x*3,<=*x*4} (*x*1<=≤<=*x*2<=≤<=*x*3<=≤<=*x*4) arithmetic mean is , median is and range is ... | The first line of input contains an only integer *n* (0<=≤<=*n*<=≤<=4).
The next *n* lines contain integers *a**i*, denoting the number of candies in the *i*-th box (1<=≤<=*a**i*<=≤<=500). | In the first output line, print "YES" if a solution exists, or print "NO" if there is no solution.
If a solution exists, you should output 4<=-<=*n* more lines, each line containing an integer *b*, denoting the number of candies in a missing box.
All your numbers *b* must satisfy inequality 1<=≤<=*b*<=≤<=106. It is g... | [
"2\n1\n1\n",
"3\n1\n1\n1\n",
"4\n1\n2\n2\n3\n"
] | [
"YES\n3\n3\n",
"NO\n",
"YES\n"
] | For the first sample, the numbers of candies in 4 boxes can be 1, 1, 3, 3. The arithmetic mean, the median and the range of them are all 2.
For the second sample, it's impossible to find the missing number of candies.
In the third example no box has been lost and numbers satisfy the condition.
You may output *b* in ... | 1,500 | [
{
"input": "2\n1\n1",
"output": "YES\n3\n3"
},
{
"input": "3\n1\n1\n1",
"output": "NO"
},
{
"input": "4\n1\n2\n2\n3",
"output": "YES"
},
{
"input": "0",
"output": "YES\n1\n1\n3\n3"
},
{
"input": "1\n125",
"output": "YES\n125\n375\n375"
},
{
"input": "2... | 1,698,325,776 | 2,147,483,647 | Python 3 | COMPILATION_ERROR | TESTS | 0 | 0 | 0 | n = int(input())
candies = [int(input()) for _ in range(n)]
def find_missing_candies(n, candies):
if n == 4:
return ("YES", [])
if n == 3:
candies.sort()
a, b, c = candies
if 2 * b == a + c:
d = 2 * b - a
return ("YES", [d])
if n == 2:
... | Title: Candy Boxes
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
There is an old tradition of keeping 4 boxes of candies in the house in Cyberland. The numbers of candies are special if their arithmetic mean, their median and their range are all equal. By definition, for a set {*x*1,<=*x... | ```python
n = int(input())
candies = [int(input()) for _ in range(n)]
def find_missing_candies(n, candies):
if n == 4:
return ("YES", [])
if n == 3:
candies.sort()
a, b, c = candies
if 2 * b == a + c:
d = 2 * b - a
return ("YES", [d])
if n... | -1 | |
556 | A | Case of the Zeros and Ones | PROGRAMMING | 900 | [
"greedy"
] | null | null | Andrewid the Android is a galaxy-famous detective. In his free time he likes to think about strings containing zeros and ones.
Once he thought about a string of length *n* consisting of zeroes and ones. Consider the following operation: we choose any two adjacent positions in the string, and if one them contains 0, an... | First line of the input contains a single integer *n* (1<=≤<=*n*<=≤<=2·105), the length of the string that Andreid has.
The second line contains the string of length *n* consisting only from zeros and ones. | Output the minimum length of the string that may remain after applying the described operations several times. | [
"4\n1100\n",
"5\n01010\n",
"8\n11101111\n"
] | [
"0\n",
"1\n",
"6\n"
] | In the first sample test it is possible to change the string like the following: <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/10df55364c21c6e8d5da31b6ab6f6294c4fc26b3.png" style="max-width: 100.0%;max-height: 100.0%;"/>.
In the second sample test it is possible to change the string like... | 250 | [
{
"input": "4\n1100",
"output": "0"
},
{
"input": "5\n01010",
"output": "1"
},
{
"input": "8\n11101111",
"output": "6"
},
{
"input": "1\n0",
"output": "1"
},
{
"input": "1\n1",
"output": "1"
},
{
"input": "2\n00",
"output": "2"
},
{
"input"... | 1,695,962,293 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 49 | 77 | 13,312,000 | count0 = count1 = 0
n = int(input())
l = list(input())
for i in l:
if i == '0':count0 += 1
else: count1 += 1
print(abs(count1-count0)) | Title: Case of the Zeros and Ones
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Andrewid the Android is a galaxy-famous detective. In his free time he likes to think about strings containing zeros and ones.
Once he thought about a string of length *n* consisting of zeroes and ones. Cons... | ```python
count0 = count1 = 0
n = int(input())
l = list(input())
for i in l:
if i == '0':count0 += 1
else: count1 += 1
print(abs(count1-count0))
``` | 3 | |
248 | A | Cupboards | PROGRAMMING | 800 | [
"implementation"
] | null | null | One foggy Stockholm morning, Karlsson decided to snack on some jam in his friend Lillebror Svantenson's house. Fortunately for Karlsson, there wasn't anybody in his friend's house. Karlsson was not going to be hungry any longer, so he decided to get some food in the house.
Karlsson's gaze immediately fell on *n* woode... | The first input line contains a single integer *n* — the number of cupboards in the kitchen (2<=≤<=*n*<=≤<=104). Then follow *n* lines, each containing two integers *l**i* and *r**i* (0<=≤<=*l**i*,<=*r**i*<=≤<=1). Number *l**i* equals one, if the left door of the *i*-th cupboard is opened, otherwise number *l**i* equal... | In the only output line print a single integer *t* — the minimum number of seconds Karlsson needs to change the doors of all cupboards to the position he needs. | [
"5\n0 1\n1 0\n0 1\n1 1\n0 1\n"
] | [
"3\n"
] | none | 500 | [
{
"input": "5\n0 1\n1 0\n0 1\n1 1\n0 1",
"output": "3"
},
{
"input": "2\n0 0\n0 0",
"output": "0"
},
{
"input": "3\n0 1\n1 1\n1 1",
"output": "1"
},
{
"input": "8\n0 1\n1 0\n0 1\n1 1\n0 1\n1 0\n0 1\n1 0",
"output": "7"
},
{
"input": "8\n1 0\n1 0\n1 0\n0 1\n0 1\n1 ... | 1,566,421,397 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 186 | 0 | n = int(input())
l = []
r = []
for i in range(n):
k,j = map(int, input().split())
l.append(k)
r.append(j)
a,b = l.count(1),r.count(1)
if a>=b:
print(n-a + b)
else:
print(n-b + a) | Title: Cupboards
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
One foggy Stockholm morning, Karlsson decided to snack on some jam in his friend Lillebror Svantenson's house. Fortunately for Karlsson, there wasn't anybody in his friend's house. Karlsson was not going to be hungry any long... | ```python
n = int(input())
l = []
r = []
for i in range(n):
k,j = map(int, input().split())
l.append(k)
r.append(j)
a,b = l.count(1),r.count(1)
if a>=b:
print(n-a + b)
else:
print(n-b + a)
``` | 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,691,868,428 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 1 | 92 | 0 | str1 = input("")
str2 = input("")
str3 = input("")
str1 = str1+str2
dict1 = {}
for i in str1:
dict1[i] = str1.count(i)
set1 = set(dict1)
sorted(set1)
dict2 = {}
for i in str3:
dict2[i] = str3.count(i)
set2 = set(dict2)
sorted(set2)
if (set1 == set2):
print("YES")
else:
print... | 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
str1 = input("")
str2 = input("")
str3 = input("")
str1 = str1+str2
dict1 = {}
for i in str1:
dict1[i] = str1.count(i)
set1 = set(dict1)
sorted(set1)
dict2 = {}
for i in str3:
dict2[i] = str3.count(i)
set2 = set(dict2)
sorted(set2)
if (set1 == set2):
print("YES")
else:
... | 0 | |
26 | A | Almost Prime | PROGRAMMING | 900 | [
"number theory"
] | A. Almost Prime | 2 | 256 | A number is called almost prime if it has exactly two distinct prime divisors. For example, numbers 6, 18, 24 are almost prime, while 4, 8, 9, 42 are not. Find the amount of almost prime numbers which are between 1 and *n*, inclusive. | Input contains one integer number *n* (1<=≤<=*n*<=≤<=3000). | Output the amount of almost prime numbers between 1 and *n*, inclusive. | [
"10\n",
"21\n"
] | [
"2\n",
"8\n"
] | none | 500 | [
{
"input": "10",
"output": "2"
},
{
"input": "21",
"output": "8"
},
{
"input": "1",
"output": "0"
},
{
"input": "2",
"output": "0"
},
{
"input": "4",
"output": "0"
},
{
"input": "3",
"output": "0"
},
{
"input": "8",
"output": "1"
},
... | 1,680,275,952 | 2,147,483,647 | Python 3 | OK | TESTS | 23 | 92 | 0 | number = int(input())
count = 0
for n in range(number + 1):
ans = []
d = 2
while d * d <= n:
while n % d == 0:
ans.append(d)
n = n // d
d += 1
if n > 1:
ans.append(n)
check = set(ans)
if len(check) == 2:
count += 1
print(... | Title: Almost Prime
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
A number is called almost prime if it has exactly two distinct prime divisors. For example, numbers 6, 18, 24 are almost prime, while 4, 8, 9, 42 are not. Find the amount of almost prime numbers which are between 1 and *n*, in... | ```python
number = int(input())
count = 0
for n in range(number + 1):
ans = []
d = 2
while d * d <= n:
while n % d == 0:
ans.append(d)
n = n // d
d += 1
if n > 1:
ans.append(n)
check = set(ans)
if len(check) == 2:
count +=... | 3.977 |
592 | C | The Big Race | PROGRAMMING | 1,800 | [
"math"
] | null | null | Vector Willman and Array Bolt are the two most famous athletes of Byteforces. They are going to compete in a race with a distance of *L* meters today.
Willman and Bolt have exactly the same speed, so when they compete the result is always a tie. That is a problem for the organizers because they want a winner.
While ... | The first line of the input contains three integers *t*, *w* and *b* (1<=≤<=*t*,<=*w*,<=*b*<=≤<=5·1018) — the maximum possible length of the racetrack, the length of Willman's steps and the length of Bolt's steps respectively. | Print the answer to the problem as an irreducible fraction . Follow the format of the samples output.
The fraction (*p* and *q* are integers, and both *p*<=≥<=0 and *q*<=><=0 holds) is called irreducible, if there is no such integer *d*<=><=1, that both *p* and *q* are divisible by *d*. | [
"10 3 2\n",
"7 1 2\n"
] | [
"3/10\n",
"3/7\n"
] | In the first sample Willman and Bolt will tie in case 1, 6 or 7 are chosen as the length of the racetrack. | 1,500 | [
{
"input": "10 3 2",
"output": "3/10"
},
{
"input": "7 1 2",
"output": "3/7"
},
{
"input": "1 1 1",
"output": "1/1"
},
{
"input": "5814 31 7",
"output": "94/2907"
},
{
"input": "94268 813 766",
"output": "765/94268"
},
{
"input": "262610 5583 4717",
... | 1,459,509,401 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 3 | 62 | 4,608,000 | t,w,b = map(int,input().split())
def foo(x,y, d):
return y/d-x/d + (x%d)
res1 = foo(1,t,w)
res2 = foo(1,t,b)
print(str(abs(int(min(res1,res2)-1)))+'/'+str(t)) | Title: The Big Race
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vector Willman and Array Bolt are the two most famous athletes of Byteforces. They are going to compete in a race with a distance of *L* meters today.
Willman and Bolt have exactly the same speed, so when they compete the... | ```python
t,w,b = map(int,input().split())
def foo(x,y, d):
return y/d-x/d + (x%d)
res1 = foo(1,t,w)
res2 = foo(1,t,b)
print(str(abs(int(min(res1,res2)-1)))+'/'+str(t))
``` | 0 | |
371 | B | Fox Dividing Cheese | PROGRAMMING | 1,300 | [
"math",
"number theory"
] | null | null | Two little greedy bears have found two pieces of cheese in the forest of weight *a* and *b* grams, correspondingly. The bears are so greedy that they are ready to fight for the larger piece. That's where the fox comes in and starts the dialog: "Little bears, wait a little, I want to make your pieces equal" "Come off it... | The first line contains two space-separated integers *a* and *b* (1<=≤<=*a*,<=*b*<=≤<=109). | If the fox is lying to the little bears and it is impossible to make the pieces equal, print -1. Otherwise, print the required minimum number of operations. If the pieces of the cheese are initially equal, the required number is 0. | [
"15 20\n",
"14 8\n",
"6 6\n"
] | [
"3\n",
"-1\n",
"0\n"
] | none | 1,000 | [
{
"input": "15 20",
"output": "3"
},
{
"input": "14 8",
"output": "-1"
},
{
"input": "6 6",
"output": "0"
},
{
"input": "1 1",
"output": "0"
},
{
"input": "1 1024",
"output": "10"
},
{
"input": "1024 729",
"output": "16"
},
{
"input": "1024... | 1,628,145,486 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 4 | 109 | 20,172,800 | # link: https://codeforces.com/contest/371/problem/B
import math
for _ in range(1):
a, b = map(int, input().split())
if a==b:
print(0)
else:
gcd_value = math.gcd(a,b)
if gcd_value <= 2:
print(-1)
else:
print(min(a//gcd_value, b//gcd_valu... | Title: Fox Dividing Cheese
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Two little greedy bears have found two pieces of cheese in the forest of weight *a* and *b* grams, correspondingly. The bears are so greedy that they are ready to fight for the larger piece. That's where the fox com... | ```python
# link: https://codeforces.com/contest/371/problem/B
import math
for _ in range(1):
a, b = map(int, input().split())
if a==b:
print(0)
else:
gcd_value = math.gcd(a,b)
if gcd_value <= 2:
print(-1)
else:
print(min(a//gcd_value, b... | 0 | |
417 | B | Crash | PROGRAMMING | 1,400 | [
"implementation"
] | null | null | During the "Russian Code Cup" programming competition, the testing system stores all sent solutions for each participant. We know that many participants use random numbers in their programs and are often sent several solutions with the same source code to check.
Each participant is identified by some unique positive i... | The first line of the input contains an integer *n* (1<=≤<=*n*<=≤<=105) — the number of solutions. Each of the following *n* lines contains two integers separated by space *x* and *k* (0<=≤<=*x*<=≤<=105; 1<=≤<=*k*<=≤<=105) — the number of previous unique solutions and the identifier of the participant. | A single line of the output should contain «YES» if the data is in chronological order, and «NO» otherwise. | [
"2\n0 1\n1 1\n",
"4\n0 1\n1 2\n1 1\n0 2\n",
"4\n0 1\n1 1\n0 1\n0 2\n"
] | [
"YES\n",
"NO\n",
"YES\n"
] | none | 1,000 | [
{
"input": "2\n0 1\n1 1",
"output": "YES"
},
{
"input": "4\n0 1\n1 2\n1 1\n0 2",
"output": "NO"
},
{
"input": "4\n0 1\n1 1\n0 1\n0 2",
"output": "YES"
},
{
"input": "4\n7 1\n4 2\n8 2\n1 8",
"output": "NO"
},
{
"input": "2\n0 8\n0 5",
"output": "YES"
},
{
... | 1,399,209,502 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 3 | 62 | 409,600 | n = int(input())
A = [''] * (10 ** 5)
test = 'YES'
for i in range(n):
x, t = map(int, input().split())
if len(A[t]) > 0:
if int(A[t][len(A[t]) - 1]) > x and A[t].find(str(x)) == -1:
test = 'NO'
break
elif int(A[t][len(A[t]) - 1]) <= x and A[t].find(str(x)) == -1... | Title: Crash
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
During the "Russian Code Cup" programming competition, the testing system stores all sent solutions for each participant. We know that many participants use random numbers in their programs and are often sent several solutions wi... | ```python
n = int(input())
A = [''] * (10 ** 5)
test = 'YES'
for i in range(n):
x, t = map(int, input().split())
if len(A[t]) > 0:
if int(A[t][len(A[t]) - 1]) > x and A[t].find(str(x)) == -1:
test = 'NO'
break
elif int(A[t][len(A[t]) - 1]) <= x and A[t].find(str... | 0 | |
558 | A | Lala Land and Apple Trees | PROGRAMMING | 1,100 | [
"brute force",
"implementation",
"sortings"
] | null | null | Amr lives in Lala Land. Lala Land is a very beautiful country that is located on a coordinate line. Lala Land is famous with its apple trees growing everywhere.
Lala Land has exactly *n* apple trees. Tree number *i* is located in a position *x**i* and has *a**i* apples growing on it. Amr wants to collect apples from t... | The first line contains one number *n* (1<=≤<=*n*<=≤<=100), the number of apple trees in Lala Land.
The following *n* lines contains two integers each *x**i*, *a**i* (<=-<=105<=≤<=*x**i*<=≤<=105, *x**i*<=≠<=0, 1<=≤<=*a**i*<=≤<=105), representing the position of the *i*-th tree and number of apples on it.
It's guarant... | Output the maximum number of apples Amr can collect. | [
"2\n-1 5\n1 5\n",
"3\n-2 2\n1 4\n-1 3\n",
"3\n1 9\n3 5\n7 10\n"
] | [
"10",
"9",
"9"
] | In the first sample test it doesn't matter if Amr chose at first to go left or right. In both cases he'll get all the apples.
In the second sample test the optimal solution is to go left to *x* = - 1, collect apples from there, then the direction will be reversed, Amr has to go to *x* = 1, collect apples from there, ... | 500 | [
{
"input": "2\n-1 5\n1 5",
"output": "10"
},
{
"input": "3\n-2 2\n1 4\n-1 3",
"output": "9"
},
{
"input": "3\n1 9\n3 5\n7 10",
"output": "9"
},
{
"input": "1\n1 1",
"output": "1"
},
{
"input": "4\n10000 100000\n-1000 100000\n-2 100000\n-1 100000",
"output": "3... | 1,680,689,365 | 2,147,483,647 | Python 3 | COMPILATION_ERROR | TESTS | 0 | 0 | 0 | #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <sstream>
#include <cmath>
#include <limits>
#include <utility>
#include <iomanip>
#include <set>
#include <numeri... | Title: Lala Land and Apple Trees
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Amr lives in Lala Land. Lala Land is a very beautiful country that is located on a coordinate line. Lala Land is famous with its apple trees growing everywhere.
Lala Land has exactly *n* apple trees. Tree num... | ```python
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <sstream>
#include <cmath>
#include <limits>
#include <utility>
#include <iomanip>
#include <set>
#inclu... | -1 | |
832 | A | Sasha and Sticks | PROGRAMMING | 800 | [
"games",
"math"
] | null | null | It's one more school day now. Sasha doesn't like classes and is always bored at them. So, each day he invents some game and plays in it alone or with friends.
Today he invented one simple game to play with Lena, with whom he shares a desk. The rules are simple. Sasha draws *n* sticks in a row. After that the players t... | The first line contains two integers *n* and *k* (1<=≤<=*n*,<=*k*<=≤<=1018, *k*<=≤<=*n*) — the number of sticks drawn by Sasha and the number *k* — the number of sticks to be crossed out on each turn. | If Sasha wins, print "YES" (without quotes), otherwise print "NO" (without quotes).
You can print each letter in arbitrary case (upper of lower). | [
"1 1\n",
"10 4\n"
] | [
"YES\n",
"NO\n"
] | In the first example Sasha crosses out 1 stick, and then there are no sticks. So Lena can't make a move, and Sasha wins.
In the second example Sasha crosses out 4 sticks, then Lena crosses out 4 sticks, and after that there are only 2 sticks left. Sasha can't make a move. The players make equal number of moves, so Sas... | 500 | [
{
"input": "1 1",
"output": "YES"
},
{
"input": "10 4",
"output": "NO"
},
{
"input": "251656215122324104 164397544865601257",
"output": "YES"
},
{
"input": "963577813436662285 206326039287271924",
"output": "NO"
},
{
"input": "1000000000000000000 1",
"output":... | 1,592,844,585 | 2,147,483,647 | PyPy 3 | OK | TESTS | 62 | 155 | 0 | n,k=[int(x) for x in input().split()]
print(['NO','YES'][n//k%2]) | Title: Sasha and Sticks
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
It's one more school day now. Sasha doesn't like classes and is always bored at them. So, each day he invents some game and plays in it alone or with friends.
Today he invented one simple game to play with Lena, with ... | ```python
n,k=[int(x) for x in input().split()]
print(['NO','YES'][n//k%2])
``` | 3 | |
165 | B | Burning Midnight Oil | PROGRAMMING | 1,500 | [
"binary search",
"implementation"
] | null | null | One day a highly important task was commissioned to Vasya — writing a program in a night. The program consists of *n* lines of code. Vasya is already exhausted, so he works like that: first he writes *v* lines of code, drinks a cup of tea, then he writes as much as lines, drinks another cup of tea, then he writes lin... | The input consists of two integers *n* and *k*, separated by spaces — the size of the program in lines and the productivity reduction coefficient, 1<=≤<=*n*<=≤<=109, 2<=≤<=*k*<=≤<=10. | Print the only integer — the minimum value of *v* that lets Vasya write the program in one night. | [
"7 2\n",
"59 9\n"
] | [
"4\n",
"54\n"
] | In the first sample the answer is *v* = 4. Vasya writes the code in the following portions: first 4 lines, then 2, then 1, and then Vasya falls asleep. Thus, he manages to write 4 + 2 + 1 = 7 lines in a night and complete the task.
In the second sample the answer is *v* = 54. Vasya writes the code in the following por... | 1,000 | [
{
"input": "7 2",
"output": "4"
},
{
"input": "59 9",
"output": "54"
},
{
"input": "1 9",
"output": "1"
},
{
"input": "11 2",
"output": "7"
},
{
"input": "747 2",
"output": "376"
},
{
"input": "6578 2",
"output": "3293"
},
{
"input": "37212... | 1,692,122,052 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 56 | 124 | 1,331,200 | def calc(m, k0):
res = 0
k = 1
while m // k > 0:
res += m // k
k *= k0
return res
n, k = map(int, input().split())
l = -1
r = 1_000_000_000_000
while r - l > 1:
m = (l + r) >> 1
if calc(m, k) >= n:
r = m
else:
l = m
# print(calc(r, k)... | Title: Burning Midnight Oil
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
One day a highly important task was commissioned to Vasya — writing a program in a night. The program consists of *n* lines of code. Vasya is already exhausted, so he works like that: first he writes *v* lines of c... | ```python
def calc(m, k0):
res = 0
k = 1
while m // k > 0:
res += m // k
k *= k0
return res
n, k = map(int, input().split())
l = -1
r = 1_000_000_000_000
while r - l > 1:
m = (l + r) >> 1
if calc(m, k) >= n:
r = m
else:
l = m
# print(... | 3 | |
688 | A | Opponents | PROGRAMMING | 800 | [
"implementation"
] | null | null | Arya has *n* opponents in the school. Each day he will fight with all opponents who are present this day. His opponents have some fighting plan that guarantees they will win, but implementing this plan requires presence of them all. That means if one day at least one of Arya's opponents is absent at the school, then Ar... | The first line of the input contains two integers *n* and *d* (1<=≤<=*n*,<=*d*<=≤<=100) — the number of opponents and the number of days, respectively.
The *i*-th of the following *d* lines contains a string of length *n* consisting of characters '0' and '1'. The *j*-th character of this string is '0' if the *j*-th op... | Print the only integer — the maximum number of consecutive days that Arya will beat all present opponents. | [
"2 2\n10\n00\n",
"4 1\n0100\n",
"4 5\n1101\n1111\n0110\n1011\n1111\n"
] | [
"2\n",
"1\n",
"2\n"
] | In the first and the second samples, Arya will beat all present opponents each of the *d* days.
In the third sample, Arya will beat his opponents on days 1, 3 and 4 and his opponents will beat him on days 2 and 5. Thus, the maximum number of consecutive winning days is 2, which happens on days 3 and 4. | 500 | [
{
"input": "2 2\n10\n00",
"output": "2"
},
{
"input": "4 1\n0100",
"output": "1"
},
{
"input": "4 5\n1101\n1111\n0110\n1011\n1111",
"output": "2"
},
{
"input": "3 2\n110\n110",
"output": "2"
},
{
"input": "10 6\n1111111111\n0100110101\n1111111111\n0000011010\n1111... | 1,613,811,248 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 30 | 0 | n,m = int(input())
ch = 0
for i in range(m):
if input() == n*'1':
ch += 1
print(ch) | Title: Opponents
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Arya has *n* opponents in the school. Each day he will fight with all opponents who are present this day. His opponents have some fighting plan that guarantees they will win, but implementing this plan requires presence of th... | ```python
n,m = int(input())
ch = 0
for i in range(m):
if input() == n*'1':
ch += 1
print(ch)
``` | -1 | |
268 | A | Games | PROGRAMMING | 800 | [
"brute force"
] | null | null | Manao works on a sports TV. He's spent much time watching the football games of some country. After a while he began to notice different patterns. For example, each team has two sets of uniforms: home uniform and guest uniform. When a team plays a game at home, the players put on the home uniform. When a team plays as ... | The first line contains an integer *n* (2<=≤<=*n*<=≤<=30). Each of the following *n* lines contains a pair of distinct space-separated integers *h**i*, *a**i* (1<=≤<=*h**i*,<=*a**i*<=≤<=100) — the colors of the *i*-th team's home and guest uniforms, respectively. | In a single line print the number of games where the host team is going to play in the guest uniform. | [
"3\n1 2\n2 4\n3 4\n",
"4\n100 42\n42 100\n5 42\n100 5\n",
"2\n1 2\n1 2\n"
] | [
"1\n",
"5\n",
"0\n"
] | In the first test case the championship consists of 6 games. The only game with the event in question is the game between teams 2 and 1 on the stadium of team 2.
In the second test sample the host team will have to wear guest uniform in the games between teams: 1 and 2, 2 and 1, 2 and 3, 3 and 4, 4 and 2 (the host tea... | 500 | [
{
"input": "3\n1 2\n2 4\n3 4",
"output": "1"
},
{
"input": "4\n100 42\n42 100\n5 42\n100 5",
"output": "5"
},
{
"input": "2\n1 2\n1 2",
"output": "0"
},
{
"input": "7\n4 7\n52 55\n16 4\n55 4\n20 99\n3 4\n7 52",
"output": "6"
},
{
"input": "10\n68 42\n1 35\n25 70\n... | 1,674,671,222 | 2,147,483,647 | Python 3 | OK | TESTS | 31 | 92 | 0 | A,B,C=[],int(input()),0
for i in range(B):
A.append([int(i) for i in input().split()])
for i in range(B):
for j in range(B):
if j!=i:
if A[i][1]==A[j][0]:
C=C+1
print(C) | Title: Games
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Manao works on a sports TV. He's spent much time watching the football games of some country. After a while he began to notice different patterns. For example, each team has two sets of uniforms: home uniform and guest uniform. W... | ```python
A,B,C=[],int(input()),0
for i in range(B):
A.append([int(i) for i in input().split()])
for i in range(B):
for j in range(B):
if j!=i:
if A[i][1]==A[j][0]:
C=C+1
print(C)
``` | 3 | |
812 | C | Sagheer and Nubian Market | PROGRAMMING | 1,500 | [
"binary search",
"sortings"
] | null | null | On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains *n* different items numbered from 1 to *n*. The *i*-th item has base cost *a**i* Egyptian pounds. If Sagheer buys *k* items with indices *x*1,<=*x*2,<=...,<... | The first line contains two integers *n* and *S* (1<=≤<=*n*<=≤<=105 and 1<=≤<=*S*<=≤<=109) — the number of souvenirs in the market and Sagheer's budget.
The second line contains *n* space-separated integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=105) — the base costs of the souvenirs. | On a single line, print two integers *k*, *T* — the maximum number of souvenirs Sagheer can buy and the minimum total cost to buy these *k* souvenirs. | [
"3 11\n2 3 5\n",
"4 100\n1 2 5 6\n",
"1 7\n7\n"
] | [
"2 11\n",
"4 54\n",
"0 0\n"
] | In the first example, he cannot take the three items because they will cost him [5, 9, 14] with total cost 28. If he decides to take only two items, then the costs will be [4, 7, 11]. So he can afford the first and second items.
In the second example, he can buy all items as they will cost him [5, 10, 17, 22].
In the... | 1,500 | [
{
"input": "3 11\n2 3 5",
"output": "2 11"
},
{
"input": "4 100\n1 2 5 6",
"output": "4 54"
},
{
"input": "1 7\n7",
"output": "0 0"
},
{
"input": "1 7\n5",
"output": "1 6"
},
{
"input": "1 1\n1",
"output": "0 0"
},
{
"input": "4 33\n4 3 2 1",
"outp... | 1,496,330,505 | 4,005 | Python 3 | WRONG_ANSWER | PRETESTS | 2 | 46 | 0 | def proverka(k, a, s):
b = []
for i in a:
b.append(i)
for i in range(len(b)):
b[i] = b[i] + k * (i + 1)
b.sort()
cnt = 0
index = 0
while(cnt < k and s - b[index] >= 0):
cnt += 1
s -= b[index]
index += 1
if(cnt < k):
return Fal... | Title: Sagheer and Nubian Market
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains *n* different items numbered from 1 to *n*. T... | ```python
def proverka(k, a, s):
b = []
for i in a:
b.append(i)
for i in range(len(b)):
b[i] = b[i] + k * (i + 1)
b.sort()
cnt = 0
index = 0
while(cnt < k and s - b[index] >= 0):
cnt += 1
s -= b[index]
index += 1
if(cnt < k):
... | 0 | |
154 | B | Colliders | PROGRAMMING | 1,600 | [
"math",
"number theory"
] | null | null | By 2312 there were *n* Large Hadron Colliders in the inhabited part of the universe. Each of them corresponded to a single natural number from 1 to *n*. However, scientists did not know what activating several colliders simultaneously could cause, so the colliders were deactivated.
In 2312 there was a startling discov... | The first line contains two space-separated integers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=105) — the number of colliders and the number of requests, correspondingly.
Next *m* lines contain numbers of requests, one per line, in the form of either "+ i" (without the quotes) — activate the *i*-th collider, or "- i" (without ... | Print *m* lines — the results of executing requests in the above given format. The requests should be processed in the order, in which they are given in the input. Don't forget that the responses to the requests should be printed without quotes. | [
"10 10\n+ 6\n+ 10\n+ 5\n- 10\n- 5\n- 6\n+ 10\n+ 3\n+ 6\n+ 3\n"
] | [
"Success\nConflict with 6\nSuccess\nAlready off\nSuccess\nSuccess\nSuccess\nSuccess\nConflict with 10\nAlready on\n"
] | Note that in the sample the colliders don't turn on after the second and ninth requests. The ninth request could also receive response "Conflict with 3". | 1,000 | [
{
"input": "10 10\n+ 6\n+ 10\n+ 5\n- 10\n- 5\n- 6\n+ 10\n+ 3\n+ 6\n+ 3",
"output": "Success\nConflict with 6\nSuccess\nAlready off\nSuccess\nSuccess\nSuccess\nSuccess\nConflict with 10\nAlready on"
},
{
"input": "7 5\n+ 7\n+ 6\n+ 4\n+ 3\n- 7",
"output": "Success\nSuccess\nConflict with 6\nConfli... | 1,605,798,148 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 18 | 374 | 716,800 | # cook your dish here
'''
Online Python Compiler.
Code, Compile, Run and Debug python program online.
Write your code in this editor and press "Run" button to execute it.
'''
def gcd(a,b):
if a==b:
return a
if a>b:
return gcd(a-b,b)
... | Title: Colliders
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
By 2312 there were *n* Large Hadron Colliders in the inhabited part of the universe. Each of them corresponded to a single natural number from 1 to *n*. However, scientists did not know what activating several colliders simul... | ```python
# cook your dish here
'''
Online Python Compiler.
Code, Compile, Run and Debug python program online.
Write your code in this editor and press "Run" button to execute it.
'''
def gcd(a,b):
if a==b:
return a
if a>b:
return gcd(a-... | -1 | |
22 | A | Second Order Statistics | PROGRAMMING | 800 | [
"brute force"
] | A. Second Order Statistics | 2 | 256 | Once Bob needed to find the second order statistics of a sequence of integer numbers. Lets choose each number from the sequence exactly once and sort them. The value on the second position is the second order statistics of the given sequence. In other words it is the smallest element strictly greater than the minimum. ... | The first input line contains integer *n* (1<=≤<=*n*<=≤<=100) — amount of numbers in the sequence. The second line contains *n* space-separated integer numbers — elements of the sequence. These numbers don't exceed 100 in absolute value. | If the given sequence has the second order statistics, output this order statistics, otherwise output NO. | [
"4\n1 2 2 -4\n",
"5\n1 2 3 1 1\n"
] | [
"1\n",
"2\n"
] | none | 0 | [
{
"input": "4\n1 2 2 -4",
"output": "1"
},
{
"input": "5\n1 2 3 1 1",
"output": "2"
},
{
"input": "1\n28",
"output": "NO"
},
{
"input": "2\n-28 12",
"output": "12"
},
{
"input": "3\n-83 40 -80",
"output": "-80"
},
{
"input": "8\n93 77 -92 26 21 -48 53 ... | 1,673,329,204 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 2 | 62 | 0 | n = int(input())
num = set(map(int,input().split()))
num = list(num)
num.sort()
print(num[1]) | Title: Second Order Statistics
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Once Bob needed to find the second order statistics of a sequence of integer numbers. Lets choose each number from the sequence exactly once and sort them. The value on the second position is the second order statis... | ```python
n = int(input())
num = set(map(int,input().split()))
num = list(num)
num.sort()
print(num[1])
``` | -1 |
263 | A | Beautiful Matrix | PROGRAMMING | 800 | [
"implementation"
] | null | null | You've got a 5<=×<=5 matrix, consisting of 24 zeroes and a single number one. Let's index the matrix rows by numbers from 1 to 5 from top to bottom, let's index the matrix columns by numbers from 1 to 5 from left to right. In one move, you are allowed to apply one of the two following transformations to the matrix:
1.... | The input consists of five lines, each line contains five integers: the *j*-th integer in the *i*-th line of the input represents the element of the matrix that is located on the intersection of the *i*-th row and the *j*-th column. It is guaranteed that the matrix consists of 24 zeroes and a single number one. | Print a single integer — the minimum number of moves needed to make the matrix beautiful. | [
"0 0 0 0 0\n0 0 0 0 1\n0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n",
"0 0 0 0 0\n0 0 0 0 0\n0 1 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n"
] | [
"3\n",
"1\n"
] | none | 500 | [
{
"input": "0 0 0 0 0\n0 0 0 0 1\n0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0",
"output": "3"
},
{
"input": "0 0 0 0 0\n0 0 0 0 0\n0 1 0 0 0\n0 0 0 0 0\n0 0 0 0 0",
"output": "1"
},
{
"input": "0 0 0 0 0\n0 0 0 0 0\n0 0 1 0 0\n0 0 0 0 0\n0 0 0 0 0",
"output": "0"
},
{
"input": "0 0 0 0 0... | 1,695,641,792 | 2,147,483,647 | Python 3 | OK | TESTS | 25 | 92 | 0 | one_row = one_col = 0
for i in range(5):
row = list(map(int, input().split()))
if 1 in row:
one_row = i
one_col = row.index(1)
moves = abs(one_row - 2) + abs(one_col - 2)
print(moves)
| Title: Beautiful Matrix
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You've got a 5<=×<=5 matrix, consisting of 24 zeroes and a single number one. Let's index the matrix rows by numbers from 1 to 5 from top to bottom, let's index the matrix columns by numbers from 1 to 5 from left to ri... | ```python
one_row = one_col = 0
for i in range(5):
row = list(map(int, input().split()))
if 1 in row:
one_row = i
one_col = row.index(1)
moves = abs(one_row - 2) + abs(one_col - 2)
print(moves)
``` | 3 | |
899 | A | Splitting in Teams | PROGRAMMING | 800 | [
"constructive algorithms",
"greedy",
"math"
] | null | null | There were *n* groups of students which came to write a training contest. A group is either one person who can write the contest with anyone else, or two people who want to write the contest in the same team.
The coach decided to form teams of exactly three people for this training. Determine the maximum number of tea... | The first line contains single integer *n* (2<=≤<=*n*<=≤<=2·105) — the number of groups.
The second line contains a sequence of integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=2), where *a**i* is the number of people in group *i*. | Print the maximum number of teams of three people the coach can form. | [
"4\n1 1 2 1\n",
"2\n2 2\n",
"7\n2 2 2 1 1 1 1\n",
"3\n1 1 1\n"
] | [
"1\n",
"0\n",
"3\n",
"1\n"
] | In the first example the coach can form one team. For example, he can take students from the first, second and fourth groups.
In the second example he can't make a single team.
In the third example the coach can form three teams. For example, he can do this in the following way:
- The first group (of two people) an... | 500 | [
{
"input": "4\n1 1 2 1",
"output": "1"
},
{
"input": "2\n2 2",
"output": "0"
},
{
"input": "7\n2 2 2 1 1 1 1",
"output": "3"
},
{
"input": "3\n1 1 1",
"output": "1"
},
{
"input": "3\n2 2 2",
"output": "0"
},
{
"input": "3\n1 2 1",
"output": "1"
}... | 1,558,409,080 | 2,147,483,647 | Python 3 | OK | TESTS | 67 | 202 | 3,379,200 | #n, k = map(int, input().split(" "))
#L = [int(x) for x in input().split()]
n = int(input())
ct = [0,0]
for x in input().split() :
ct[int(x) - 1] += 1
ans = min(ct[:])
ct[0] -= ans
ct[1] -= ans
ans += ct[0] // 3
print(ans)
| Title: Splitting in Teams
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
There were *n* groups of students which came to write a training contest. A group is either one person who can write the contest with anyone else, or two people who want to write the contest in the same team.
The co... | ```python
#n, k = map(int, input().split(" "))
#L = [int(x) for x in input().split()]
n = int(input())
ct = [0,0]
for x in input().split() :
ct[int(x) - 1] += 1
ans = min(ct[:])
ct[0] -= ans
ct[1] -= ans
ans += ct[0] // 3
print(ans)
``` | 3 | |
884 | A | Book Reading | PROGRAMMING | 800 | [
"implementation"
] | null | null | Recently Luba bought a very interesting book. She knows that it will take *t* seconds to read the book. Luba wants to finish reading as fast as she can.
But she has some work to do in each of *n* next days. The number of seconds that Luba has to spend working during *i*-th day is *a**i*. If some free time remains, she... | The first line contains two integers *n* and *t* (1<=≤<=*n*<=≤<=100, 1<=≤<=*t*<=≤<=106) — the number of days and the time required to read the book.
The second line contains *n* integers *a**i* (0<=≤<=*a**i*<=≤<=86400) — the time Luba has to spend on her work during *i*-th day. | Print the minimum day Luba can finish reading the book.
It is guaranteed that answer doesn't exceed *n*. | [
"2 2\n86400 86398\n",
"2 86400\n0 86400\n"
] | [
"2\n",
"1\n"
] | none | 0 | [
{
"input": "2 2\n86400 86398",
"output": "2"
},
{
"input": "2 86400\n0 86400",
"output": "1"
},
{
"input": "2 86400\n1 86399",
"output": "2"
},
{
"input": "100 1000000\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0... | 1,597,922,604 | 2,147,483,647 | Python 3 | OK | TESTS | 16 | 109 | 0 | # Book Reading
def book(t, arr):
ans = 0
while t > 0:
t -= (86400 - arr.pop(0))
ans += 1
return ans
n, t = list(map(int, input().split()))
arr = list(map(int, input().split()))
print(book(t, arr)) | Title: Book Reading
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Recently Luba bought a very interesting book. She knows that it will take *t* seconds to read the book. Luba wants to finish reading as fast as she can.
But she has some work to do in each of *n* next days. The number of ... | ```python
# Book Reading
def book(t, arr):
ans = 0
while t > 0:
t -= (86400 - arr.pop(0))
ans += 1
return ans
n, t = list(map(int, input().split()))
arr = list(map(int, input().split()))
print(book(t, arr))
``` | 3 | |
380 | C | Sereja and Brackets | PROGRAMMING | 2,000 | [
"data structures",
"schedules"
] | null | null | Sereja has a bracket sequence *s*1,<=*s*2,<=...,<=*s**n*, or, in other words, a string *s* of length *n*, consisting of characters "(" and ")".
Sereja needs to answer *m* queries, each of them is described by two integers *l**i*,<=*r**i* (1<=≤<=*l**i*<=≤<=*r**i*<=≤<=*n*). The answer to the *i*-th query is the length o... | The first line contains a sequence of characters *s*1,<=*s*2,<=...,<=*s**n* (1<=≤<=*n*<=≤<=106) without any spaces. Each character is either a "(" or a ")". The second line contains integer *m* (1<=≤<=*m*<=≤<=105) — the number of queries. Each of the next *m* lines contains a pair of integers. The *i*-th line contains ... | Print the answer to each question on a single line. Print the answers in the order they go in the input. | [
"())(())(())(\n7\n1 1\n2 3\n1 2\n1 12\n8 12\n5 11\n2 10\n"
] | [
"0\n0\n2\n10\n4\n6\n6\n"
] | A subsequence of length |*x*| of string *s* = *s*<sub class="lower-index">1</sub>*s*<sub class="lower-index">2</sub>... *s*<sub class="lower-index">|*s*|</sub> (where |*s*| is the length of string *s*) is string *x* = *s*<sub class="lower-index">*k*<sub class="lower-index">1</sub></sub>*s*<sub class="lower-index">*k*<s... | 1,500 | [
{
"input": "())(())(())(\n7\n1 1\n2 3\n1 2\n1 12\n8 12\n5 11\n2 10",
"output": "0\n0\n2\n10\n4\n6\n6"
},
{
"input": "(((((()((((((((((()((()(((((\n1\n8 15",
"output": "0"
},
{
"input": "((()((())(((((((((()(()(()(((((((((((((((()(()((((((((((((((()(((((((((((((((((((()(((\n39\n28 56\n39 ... | 1,680,355,890 | 2,147,483,647 | PyPy 3-64 | MEMORY_LIMIT_EXCEEDED | TESTS | 12 | 982 | 268,390,400 | s=input()
n=len(s)
q=int(input())
class Pair():
def __init__(self,a=0,b=0,c=0):
self.a=a
self.b=b
self.c=c
tree=[Pair() for _ in range(4*n)]
def build(node,start,end):
if start==end:
tree[node].b=1 if s[start]=='(' else 0
tree[node].c=1 if s[s... | Title: Sereja and Brackets
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Sereja has a bracket sequence *s*1,<=*s*2,<=...,<=*s**n*, or, in other words, a string *s* of length *n*, consisting of characters "(" and ")".
Sereja needs to answer *m* queries, each of them is described by two i... | ```python
s=input()
n=len(s)
q=int(input())
class Pair():
def __init__(self,a=0,b=0,c=0):
self.a=a
self.b=b
self.c=c
tree=[Pair() for _ in range(4*n)]
def build(node,start,end):
if start==end:
tree[node].b=1 if s[start]=='(' else 0
tree[node].... | 0 | |
731 | A | Night at the Museum | PROGRAMMING | 800 | [
"implementation",
"strings"
] | null | null | Grigoriy, like the hero of one famous comedy film, found a job as a night security guard at the museum. At first night he received embosser and was to take stock of the whole exposition.
Embosser is a special devise that allows to "print" the text of a plastic tape. Text is printed sequentially, character by character... | The only line of input contains the name of some exhibit — the non-empty string consisting of no more than 100 characters. It's guaranteed that the string consists of only lowercase English letters. | Print one integer — the minimum number of rotations of the wheel, required to print the name given in the input. | [
"zeus\n",
"map\n",
"ares\n"
] | [
"18\n",
"35\n",
"34\n"
] | To print the string from the first sample it would be optimal to perform the following sequence of rotations:
1. from 'a' to 'z' (1 rotation counterclockwise), 1. from 'z' to 'e' (5 clockwise rotations), 1. from 'e' to 'u' (10 rotations counterclockwise), 1. from 'u' to 's' (2 counterclockwise rotations). | 500 | [
{
"input": "zeus",
"output": "18"
},
{
"input": "map",
"output": "35"
},
{
"input": "ares",
"output": "34"
},
{
"input": "l",
"output": "11"
},
{
"input": "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuv",
"... | 1,681,409,632 | 2,147,483,647 | Python 3 | OK | TESTS | 44 | 77 | 0 | list = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7, 'h': 8, 'i': 9,
'j': 10, 'k': 11, 'l': 12, 'm': 13, 'n': 14, 'o': 15, 'p': 16, 'q': 17,
'r': 18, 's': 19, 't': 20, 'u': 21, 'v': 22, 'w': 23, 'x': 24, 'y': 25, 'z': 26}
input = input()
sum = 0
temp = 0
if ((list[input[0]] - li... | 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
list = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7, 'h': 8, 'i': 9,
'j': 10, 'k': 11, 'l': 12, 'm': 13, 'n': 14, 'o': 15, 'p': 16, 'q': 17,
'r': 18, 's': 19, 't': 20, 'u': 21, 'v': 22, 'w': 23, 'x': 24, 'y': 25, 'z': 26}
input = input()
sum = 0
temp = 0
if ((list[inpu... | 3 | |
69 | B | Bets | PROGRAMMING | 1,200 | [
"greedy",
"implementation"
] | B. Bets | 2 | 256 | In Chelyabinsk lives a much respected businessman Nikita with a strange nickname "Boss". Once Nikita decided to go with his friend Alex to the Summer Biathlon World Cup. Nikita, as a very important person, received a token which allows to place bets on each section no more than on one competitor.
To begin with friends... | The first line contains two integers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=100). Then follow *m* lines, each containing 4 integers *l**i*, *r**i*, *t**i*, *c**i* (1<=≤<=*l**i*<=≤<=*r**i*<=≤<=*n*, 1<=≤<=*t**i*,<=*c**i*<=≤<=1000). | Print a single integer, the maximal profit in roubles that the friends can get. In each of *n* sections it is not allowed to place bets on more than one sportsman. | [
"4 4\n1 4 20 5\n1 3 21 10\n3 3 4 30\n3 4 4 20\n",
"8 4\n1 5 24 10\n2 4 6 15\n4 6 30 50\n6 7 4 20\n"
] | [
"60",
"105"
] | In the first test the optimal bet is: in the 1-2 sections on biathlete 1, in section 3 on biathlete 3, in section 4 on biathlete 4. Total: profit of 5 rubles for 1 section, the profit of 5 rubles for 2 section, profit of 30 rubles for a 3 section, profit of 20 rubles for 4 section. Total profit 60 rubles.
In the secon... | 1,000 | [
{
"input": "4 4\n1 4 20 5\n1 3 21 10\n3 3 4 30\n3 4 4 20",
"output": "60"
},
{
"input": "8 4\n1 5 24 10\n2 4 6 15\n4 6 30 50\n6 7 4 20",
"output": "105"
},
{
"input": "2 2\n1 2 3 1\n2 2 3 10",
"output": "2"
},
{
"input": "20 30\n15 17 54 46\n4 18 26 18\n18 20 49 94\n12 12 83 ... | 1,549,050,045 | 2,147,483,647 | Python 3 | COMPILATION_ERROR | TESTS | 0 | 0 | 0 | #include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#define ll long long
using namespace std;
struct section
{
int time = 1001, price = 0;
};
int main()
{
int n, m;
int res = 0;
cin >> n >> m;
vector<section> arr(n+1);
for (int i = 0; i < m; i++... | Title: Bets
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
In Chelyabinsk lives a much respected businessman Nikita with a strange nickname "Boss". Once Nikita decided to go with his friend Alex to the Summer Biathlon World Cup. Nikita, as a very important person, received a token which allow... | ```python
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#define ll long long
using namespace std;
struct section
{
int time = 1001, price = 0;
};
int main()
{
int n, m;
int res = 0;
cin >> n >> m;
vector<section> arr(n+1);
for (int i = 0; ... | -1 |
132 | B | Piet | PROGRAMMING | 2,100 | [
"implementation"
] | null | null | Piet is one of the most known visual esoteric programming languages. The programs in Piet are constructed from colorful blocks of pixels and interpreted using pretty complicated rules. In this problem we will use a subset of Piet language with simplified rules.
The program will be a rectangular image consisting of col... | The first line of the input contains two integer numbers *m* (1<=≤<=*m*<=≤<=50) and *n* (1<=≤<=*n*<=≤<=5·107). Next *m* lines contain the rows of the program. All the lines have the same length between 1 and 50 pixels, and consist of characters 0-9. The first character of the first line will not be equal to 0. | Output the color of the block which will be current after *n* steps of program interpretation. | [
"2 10\n12\n43\n",
"3 12\n1423\n6624\n6625\n",
"5 9\n10345\n23456\n34567\n45678\n56789\n"
] | [
"1\n",
"6\n",
"5\n"
] | In the first example IP changes in the following way. After step 1 block 2 becomes current one and stays it after two more steps. After step 4 BP moves to block 3, after step 7 — to block 4, and finally after step 10 BP returns to block 1.
The sequence of states of IP is shown on the image: the arrows are traversed cl... | 1,500 | [] | 1,689,591,510 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 0 | 92 | 0 | print("_RANDOM_GUESS_1689591510.5677986")# 1689591510.5678208 | Title: Piet
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Piet is one of the most known visual esoteric programming languages. The programs in Piet are constructed from colorful blocks of pixels and interpreted using pretty complicated rules. In this problem we will use a subset of Piet ... | ```python
print("_RANDOM_GUESS_1689591510.5677986")# 1689591510.5678208
``` | 0 | |
501 | C | Misha and Forest | PROGRAMMING | 1,500 | [
"constructive algorithms",
"data structures",
"greedy",
"sortings",
"trees"
] | null | null | Let's define a forest as a non-directed acyclic graph (also without loops and parallel edges). One day Misha played with the forest consisting of *n* vertices. For each vertex *v* from 0 to *n*<=-<=1 he wrote down two integers, *degree**v* and *s**v*, were the first integer is the number of vertices adjacent to vertex ... | The first line contains integer *n* (1<=≤<=*n*<=≤<=216), the number of vertices in the graph.
The *i*-th of the next lines contains numbers *degree**i* and *s**i* (0<=≤<=*degree**i*<=≤<=*n*<=-<=1, 0<=≤<=*s**i*<=<<=216), separated by a space. | In the first line print number *m*, the number of edges of the graph.
Next print *m* lines, each containing two distinct numbers, *a* and *b* (0<=≤<=*a*<=≤<=*n*<=-<=1, 0<=≤<=*b*<=≤<=*n*<=-<=1), corresponding to edge (*a*,<=*b*).
Edges can be printed in any order; vertices of the edge can also be printed in any order. | [
"3\n2 3\n1 0\n1 0\n",
"2\n1 1\n1 0\n"
] | [
"2\n1 0\n2 0\n",
"1\n0 1\n"
] | The XOR sum of numbers is the result of bitwise adding numbers modulo 2. This operation exists in many modern programming languages. For example, in languages C++, Java and Python it is represented as "^", and in Pascal — as "xor". | 1,500 | [
{
"input": "3\n2 3\n1 0\n1 0",
"output": "2\n1 0\n2 0"
},
{
"input": "2\n1 1\n1 0",
"output": "1\n0 1"
},
{
"input": "10\n3 13\n2 6\n1 5\n3 5\n1 3\n2 2\n2 6\n1 6\n1 3\n2 3",
"output": "9\n2 5\n4 3\n7 6\n8 3\n5 0\n6 1\n3 9\n1 0\n9 0"
},
{
"input": "10\n1 2\n1 7\n1 0\n1 8\n0 0\... | 1,636,693,657 | 2,147,483,647 | PyPy 3-64 | RUNTIME_ERROR | TESTS | 2 | 62 | 31,846,400 | from collections import deque
n = int(input())
L = []
S = []
for i in range(n):
u,v = map(int,input().split())
L.append([u,v])
S.append([u,v,i])
d = dict()
for i in range(n):
d[i] = []
S.sort(key = lambda x: x[0])
q = deque()
for j in range(n):
if L[j][0] == 1:
ad = L[j][1]
q.appe... | Title: Misha and Forest
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Let's define a forest as a non-directed acyclic graph (also without loops and parallel edges). One day Misha played with the forest consisting of *n* vertices. For each vertex *v* from 0 to *n*<=-<=1 he wrote down two ... | ```python
from collections import deque
n = int(input())
L = []
S = []
for i in range(n):
u,v = map(int,input().split())
L.append([u,v])
S.append([u,v,i])
d = dict()
for i in range(n):
d[i] = []
S.sort(key = lambda x: x[0])
q = deque()
for j in range(n):
if L[j][0] == 1:
ad = L[j][1]
... | -1 | |
299 | B | Ksusha the Squirrel | PROGRAMMING | 900 | [
"brute force",
"implementation"
] | null | null | Ksusha the Squirrel is standing at the beginning of a straight road, divided into *n* sectors. The sectors are numbered 1 to *n*, from left to right. Initially, Ksusha stands in sector 1.
Ksusha wants to walk to the end of the road, that is, get to sector *n*. Unfortunately, there are some rocks on the road. We know ... | The first line contains two integers *n* and *k* (2<=≤<=*n*<=≤<=3·105,<=1<=≤<=*k*<=≤<=3·105). The next line contains *n* characters — the description of the road: the *i*-th character equals ".", if the *i*-th sector contains no rocks. Otherwise, it equals "#".
It is guaranteed that the first and the last characters e... | Print "YES" (without the quotes) if Ksusha can reach the end of the road, otherwise print "NO" (without the quotes). | [
"2 1\n..\n",
"5 2\n.#.#.\n",
"7 3\n.#.###.\n"
] | [
"YES\n",
"YES\n",
"NO\n"
] | none | 1,000 | [
{
"input": "2 1\n..",
"output": "YES"
},
{
"input": "5 2\n.#.#.",
"output": "YES"
},
{
"input": "7 3\n.#.###.",
"output": "NO"
},
{
"input": "2 200\n..",
"output": "YES"
},
{
"input": "2 1\n..",
"output": "YES"
},
{
"input": "2 2\n..",
"output": "Y... | 1,617,243,543 | 2,147,483,647 | PyPy 3 | OK | TESTS | 33 | 218 | 1,945,600 | a , b = map(int , input().split())
s = input()
obs = b*'#'
if obs in s: print("NO")
else: print("YES") | Title: Ksusha the Squirrel
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Ksusha the Squirrel is standing at the beginning of a straight road, divided into *n* sectors. The sectors are numbered 1 to *n*, from left to right. Initially, Ksusha stands in sector 1.
Ksusha wants to walk to t... | ```python
a , b = map(int , input().split())
s = input()
obs = b*'#'
if obs in s: print("NO")
else: print("YES")
``` | 3 | |
757 | A | Gotta Catch Em' All! | PROGRAMMING | 1,000 | [
"implementation"
] | null | null | Bash wants to become a Pokemon master one day. Although he liked a lot of Pokemon, he has always been fascinated by Bulbasaur the most. Soon, things started getting serious and his fascination turned into an obsession. Since he is too young to go out and catch Bulbasaur, he came up with his own way of catching a Bulbas... | Input contains a single line containing a string *s* (1<=<=≤<=<=|*s*|<=<=≤<=<=105) — the text on the front page of the newspaper without spaces and punctuation marks. |*s*| is the length of the string *s*.
The string *s* contains lowercase and uppercase English letters, i.e. . | Output a single integer, the answer to the problem. | [
"Bulbbasaur\n",
"F\n",
"aBddulbasaurrgndgbualdBdsagaurrgndbb\n"
] | [
"1\n",
"0\n",
"2\n"
] | In the first case, you could pick: Bulbbasaur.
In the second case, there is no way to pick even a single Bulbasaur.
In the third case, you can rearrange the string to BulbasaurBulbasauraddrgndgddgargndbb to get two words "Bulbasaur". | 500 | [
{
"input": "Bulbbasaur",
"output": "1"
},
{
"input": "F",
"output": "0"
},
{
"input": "aBddulbasaurrgndgbualdBdsagaurrgndbb",
"output": "2"
},
{
"input": "BBBBBBBBBBbbbbbbbbbbuuuuuuuuuullllllllllssssssssssaaaaaaaaaarrrrrrrrrr",
"output": "5"
},
{
"input": "BBBBBBB... | 1,484,910,276 | 2,147,483,647 | Python 3 | OK | TESTS | 107 | 108 | 5,427,200 | def main():
from collections import Counter
b, c = Counter("Bulbasaur"), Counter(input())
for k, v in b.items():
b[k] = c[k] // v
print(min(b.values()))
if __name__ == '__main__':
main()
| Title: Gotta Catch Em' All!
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Bash wants to become a Pokemon master one day. Although he liked a lot of Pokemon, he has always been fascinated by Bulbasaur the most. Soon, things started getting serious and his fascination turned into an obsess... | ```python
def main():
from collections import Counter
b, c = Counter("Bulbasaur"), Counter(input())
for k, v in b.items():
b[k] = c[k] // v
print(min(b.values()))
if __name__ == '__main__':
main()
``` | 3 | |
533 | C | Board Game | PROGRAMMING | 1,700 | [
"games",
"greedy",
"implementation",
"math"
] | null | null | Polycarp and Vasiliy love simple logical games. Today they play a game with infinite chessboard and one pawn for each player. Polycarp and Vasiliy move in turns, Polycarp starts. In each turn Polycarp can move his pawn from cell (*x*,<=*y*) to (*x*<=-<=1,<=*y*) or (*x*,<=*y*<=-<=1). Vasiliy can move his pawn from (*x*,... | The first line contains four integers: *x**p*,<=*y**p*,<=*x**v*,<=*y**v* (0<=≤<=*x**p*,<=*y**p*,<=*x**v*,<=*y**v*<=≤<=105) — Polycarp's and Vasiliy's starting coordinates.
It is guaranteed that in the beginning the pawns are in different cells and none of them is in the cell (0,<=0). | Output the name of the winner: "Polycarp" or "Vasiliy". | [
"2 1 2 2\n",
"4 7 7 4\n"
] | [
"Polycarp\n",
"Vasiliy\n"
] | In the first sample test Polycarp starts in (2, 1) and will move to (1, 1) in the first turn. No matter what his opponent is doing, in the second turn Polycarp can move to (1, 0) and finally to (0, 0) in the third turn. | 250 | [
{
"input": "2 1 2 2",
"output": "Polycarp"
},
{
"input": "4 7 7 4",
"output": "Vasiliy"
},
{
"input": "20 0 7 22",
"output": "Polycarp"
},
{
"input": "80 100 83 97",
"output": "Vasiliy"
},
{
"input": "80 100 77 103",
"output": "Vasiliy"
},
{
"input": "... | 1,692,008,799 | 3,999 | Python 3 | WRONG_ANSWER | TESTS | 2 | 31 | 0 | x, y, x1, y1 = map(int, input().split())
if abs(x - x1) > 2 and abs(y - y1) > 2:
print("Vasiliy")
elif x + y < x1 + y1:
print("Polycarp")
else:
print("Vasiliy")
| Title: Board Game
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Polycarp and Vasiliy love simple logical games. Today they play a game with infinite chessboard and one pawn for each player. Polycarp and Vasiliy move in turns, Polycarp starts. In each turn Polycarp can move his pawn from ... | ```python
x, y, x1, y1 = map(int, input().split())
if abs(x - x1) > 2 and abs(y - y1) > 2:
print("Vasiliy")
elif x + y < x1 + y1:
print("Polycarp")
else:
print("Vasiliy")
``` | 0 | |
227 | B | Effective Approach | PROGRAMMING | 1,100 | [
"implementation"
] | null | null | Once at a team training Vasya, Petya and Sasha got a problem on implementing linear search in an array.
According to the boys, linear search works as follows. The array elements in a pre-selected order are in turn compared with the number that you need to find. Once you find the array element that is equal to the requ... | The first line contains integer *n* (1<=≤<=*n*<=≤<=105) — the number of elements in the array. The second line contains *n* distinct space-separated integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=*n*) — the elements of array.
The third line contains integer *m* (1<=≤<=*m*<=≤<=105) — the number of queries. The ... | Print two integers, showing how many comparisons Vasya's approach needs and how many comparisons Petya's approach needs. Separate the numbers by spaces.
Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specifier. | [
"2\n1 2\n1\n1\n",
"2\n2 1\n1\n1\n",
"3\n3 1 2\n3\n1 2 3\n"
] | [
"1 2\n",
"2 1\n",
"6 6\n"
] | In the first sample Vasya's approach will make one comparison (it starts with the 1-st element and immediately finds the required number), and Petya's approach makes two comparisons (first he compares with the 2-nd array element, doesn't find the search item and compares with the 1-st element).
In the second sample, o... | 1,000 | [
{
"input": "2\n1 2\n1\n1",
"output": "1 2"
},
{
"input": "2\n2 1\n1\n1",
"output": "2 1"
},
{
"input": "3\n3 1 2\n3\n1 2 3",
"output": "6 6"
},
{
"input": "9\n2 9 3 1 6 4 7 8 5\n9\n5 1 5 2 8 4 4 4 5",
"output": "58 32"
},
{
"input": "10\n3 10 9 2 7 6 5 8 4 1\n1\n4... | 1,636,695,102 | 2,147,483,647 | PyPy 3 | OK | TESTS | 34 | 496 | 33,280,000 | n=int(input())
l=list('0'*n)
l2=list(map(int,input().split()))
for i in range(n):
l[l2[i]-1]=i
m=int(input())
l3=list(map(int,input().split()))
sv,sp=0,0
for i in range(m):
sv+=l[l3[i]-1]+1
sp+=n-l[l3[i]-1]
print(sv,sp)
| Title: Effective Approach
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Once at a team training Vasya, Petya and Sasha got a problem on implementing linear search in an array.
According to the boys, linear search works as follows. The array elements in a pre-selected order are in turn c... | ```python
n=int(input())
l=list('0'*n)
l2=list(map(int,input().split()))
for i in range(n):
l[l2[i]-1]=i
m=int(input())
l3=list(map(int,input().split()))
sv,sp=0,0
for i in range(m):
sv+=l[l3[i]-1]+1
sp+=n-l[l3[i]-1]
print(sv,sp)
``` | 3 | |
553 | A | Kyoya and Colored Balls | PROGRAMMING | 1,500 | [
"combinatorics",
"dp",
"math"
] | null | null | Kyoya Ootori has a bag with *n* colored balls that are colored with *k* different colors. The colors are labeled from 1 to *k*. Balls of the same color are indistinguishable. He draws balls from the bag one by one until the bag is empty. He noticed that he drew the last ball of color *i* before drawing the last ball of... | The first line of input will have one integer *k* (1<=≤<=*k*<=≤<=1000) the number of colors.
Then, *k* lines will follow. The *i*-th line will contain *c**i*, the number of balls of the *i*-th color (1<=≤<=*c**i*<=≤<=1000).
The total number of balls doesn't exceed 1000. | A single integer, the number of ways that Kyoya can draw the balls from the bag as described in the statement, modulo 1<=000<=000<=007. | [
"3\n2\n2\n1\n",
"4\n1\n2\n3\n4\n"
] | [
"3\n",
"1680\n"
] | In the first sample, we have 2 balls of color 1, 2 balls of color 2, and 1 ball of color 3. The three ways for Kyoya are: | 250 | [
{
"input": "3\n2\n2\n1",
"output": "3"
},
{
"input": "4\n1\n2\n3\n4",
"output": "1680"
},
{
"input": "10\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100",
"output": "12520708"
},
{
"input": "5\n10\n10\n10\n10\n10",
"output": "425711769"
},
{
"input": "11\n291\n3... | 1,537,931,926 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 2 | 109 | 0 | k, mod = int(input()), 1000000007
c = [ int(input()) for _ in range(k) ]
ncr = [ [0] * k * k for _ in range(k * k) ] # rotates pascal lol
ncr[0][0] = 1
for n in range(1, k * k):
ncr[n][0] = 1
for r in range(k * k):
ncr[n][r] = (ncr[n - 1][r] + ncr[n - 1][r - 1]) % mod
ways, colors = 1, 0
for i in ran... | Title: Kyoya and Colored Balls
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Kyoya Ootori has a bag with *n* colored balls that are colored with *k* different colors. The colors are labeled from 1 to *k*. Balls of the same color are indistinguishable. He draws balls from the bag one by o... | ```python
k, mod = int(input()), 1000000007
c = [ int(input()) for _ in range(k) ]
ncr = [ [0] * k * k for _ in range(k * k) ] # rotates pascal lol
ncr[0][0] = 1
for n in range(1, k * k):
ncr[n][0] = 1
for r in range(k * k):
ncr[n][r] = (ncr[n - 1][r] + ncr[n - 1][r - 1]) % mod
ways, colors = 1, 0
fo... | -1 | |
628 | C | Bear and String Distance | PROGRAMMING | 1,300 | [
"greedy",
"strings"
] | null | null | Limak is a little polar bear. He likes nice strings — strings of length *n*, consisting of lowercase English letters only.
The distance between two letters is defined as the difference between their positions in the alphabet. For example, , and .
Also, the distance between two nice strings is defined as the sum of di... | The first line contains two integers *n* and *k* (1<=≤<=*n*<=≤<=105, 0<=≤<=*k*<=≤<=106).
The second line contains a string *s* of length *n*, consisting of lowercase English letters. | If there is no string satisfying the given conditions then print "-1" (without the quotes).
Otherwise, print any nice string *s*' that . | [
"4 26\nbear\n",
"2 7\naf\n",
"3 1000\nhey\n"
] | [
"roar",
"db\n",
"-1\n"
] | none | 0 | [
{
"input": "4 26\nbear",
"output": "zcar"
},
{
"input": "2 7\naf",
"output": "hf"
},
{
"input": "3 1000\nhey",
"output": "-1"
},
{
"input": "5 50\nkzsij",
"output": "zaiij"
},
{
"input": "5 500\nvsdxg",
"output": "-1"
},
{
"input": "1 0\na",
"outpu... | 1,694,238,431 | 431 | Python 3 | OK | TESTS | 38 | 124 | 2,355,200 | # read input
n, k = map(int, input().split())
s = input()
result = []
for c in s:
# distance to 'a' and 'z'
dist_a = ord(c) - ord('a')
dist_z = ord('z') - ord(c)
# find max possible change
if dist_a > dist_z:
max_change = dist_a
change_char = 'a'
else:
... | Title: Bear and String Distance
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Limak is a little polar bear. He likes nice strings — strings of length *n*, consisting of lowercase English letters only.
The distance between two letters is defined as the difference between their positions ... | ```python
# read input
n, k = map(int, input().split())
s = input()
result = []
for c in s:
# distance to 'a' and 'z'
dist_a = ord(c) - ord('a')
dist_z = ord('z') - ord(c)
# find max possible change
if dist_a > dist_z:
max_change = dist_a
change_char = 'a'
e... | 3 | |
557 | B | Pasha and Tea | PROGRAMMING | 1,500 | [
"constructive algorithms",
"implementation",
"math",
"sortings"
] | null | null | Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of *w* milliliters and 2*n* tea cups, each cup is for one of Pasha's friends. The *i*-th cup can hold at most *a**i* milliliters of water.
It turned out that among Pasha's friends there are exactly *n* boys a... | The first line of the input contains two integers, *n* and *w* (1<=≤<=*n*<=≤<=105, 1<=≤<=*w*<=≤<=109) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters.
The second line of the input contains the sequence of integers *... | Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10<=-<=6. | [
"2 4\n1 1 1 1\n",
"3 18\n4 4 4 2 2 2\n",
"1 5\n2 3\n"
] | [
"3",
"18",
"4.5"
] | Pasha also has candies that he is going to give to girls but that is another task... | 1,000 | [
{
"input": "2 4\n1 1 1 1",
"output": "3.0000000000"
},
{
"input": "3 18\n4 4 4 2 2 2",
"output": "18.0000000000"
},
{
"input": "1 5\n2 3",
"output": "4.5000000000"
},
{
"input": "1 1\n1000000000 1000000000",
"output": "1.0000000000"
},
{
"input": "4 1000000000\n1 ... | 1,436,552,489 | 6,089 | Python 3 | OK | TESTS | 50 | 233 | 16,486,400 | n, w = [int(x) for x in input().split(" ")]
L = [int(x) for x in input().split(" ")]
L.sort()
x = L[0]
y = L[n]
if 2 * x > y :
t = y/2
else :
t = x
t = t * 3 * n
if t > w :
t = w
print(t)
| Title: Pasha and Tea
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of *w* milliliters and 2*n* tea cups, each cup is for one of Pasha's friends. The *i*-th cup can hold at most ... | ```python
n, w = [int(x) for x in input().split(" ")]
L = [int(x) for x in input().split(" ")]
L.sort()
x = L[0]
y = L[n]
if 2 * x > y :
t = y/2
else :
t = x
t = t * 3 * n
if t > w :
t = w
print(t)
``` | 3 | |
208 | B | Solitaire | PROGRAMMING | 1,900 | [
"dfs and similar",
"dp"
] | null | null | A boy named Vasya wants to play an old Russian solitaire called "Accordion". In this solitaire, the player must observe the following rules:
- A deck of *n* cards is carefully shuffled, then all *n* cards are put on the table in a line from left to right; - Before each move the table has several piles of cards lying... | The first input line contains a single integer *n* (1<=≤<=*n*<=≤<=52) — the number of cards in Vasya's deck. The next line contains *n* space-separated strings *c*1,<=*c*2,<=...,<=*c**n*, where string *c**i* describes the *i*-th card on the table. Each string *c**i* consists of exactly two characters, the first one rep... | On a single line print the answer to the problem: string "YES" (without the quotes) if completing the solitaire is possible, string "NO" (without the quotes) otherwise. | [
"4\n2S 2S 2C 2C\n",
"2\n3S 2C\n"
] | [
"YES\n",
"NO\n"
] | In the first sample you can act like that:
- put the 4-th pile on the 1-st one; - put the 3-rd pile on the 2-nd one; - put the 2-nd pile on the 1-st one.
In the second sample there is no way to complete the solitaire. | 2,000 | [
{
"input": "4\n2S 2S 2C 2C",
"output": "YES"
},
{
"input": "2\n3S 2C",
"output": "NO"
},
{
"input": "5\n2S 2S 4S 3S 2S",
"output": "YES"
},
{
"input": "5\n5S 5S 7S 4S 3H",
"output": "NO"
},
{
"input": "5\n7S 7S 4S 8H 4H",
"output": "NO"
},
{
"input": "... | 1,691,662,427 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 8 | 30 | 0 | n=int(input())
ls=list(map(str,input().split()))
flag="NO"
for i in range(0,len(ls)-1):
for j in range(i+2,len(ls)-1):
s=ls[i+1]
y=ls[j+1]
if ls[i]==s:
flag="YES"
break
if ls[j]==y:
flag="YES"
else:
flag=... | Title: Solitaire
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
A boy named Vasya wants to play an old Russian solitaire called "Accordion". In this solitaire, the player must observe the following rules:
- A deck of *n* cards is carefully shuffled, then all *n* cards are put on the tab... | ```python
n=int(input())
ls=list(map(str,input().split()))
flag="NO"
for i in range(0,len(ls)-1):
for j in range(i+2,len(ls)-1):
s=ls[i+1]
y=ls[j+1]
if ls[i]==s:
flag="YES"
break
if ls[j]==y:
flag="YES"
else:
... | 0 |
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.