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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
462 | B | Appleman and Card Game | PROGRAMMING | 1,300 | [
"greedy"
] | null | null | Appleman has *n* cards. Each card has an uppercase letter written on it. Toastman must choose *k* cards from Appleman's cards. Then Appleman should give Toastman some coins depending on the chosen cards. Formally, for each Toastman's card *i* you should calculate how much Toastman's cards have the letter equal to lette... | The first line contains two integers *n* and *k* (1<=≤<=*k*<=≤<=*n*<=≤<=105). The next line contains *n* uppercase letters without spaces — the *i*-th letter describes the *i*-th card of the Appleman. | Print a single integer – the answer to the problem. | [
"15 10\nDZFDFZDFDDDDDDF\n",
"6 4\nYJSNPI\n"
] | [
"82\n",
"4\n"
] | In the first test example Toastman can choose nine cards with letter D and one additional card with any letter. For each card with D he will get 9 coins and for the additional card he will get 1 coin. | 1,000 | [
{
"input": "15 10\nDZFDFZDFDDDDDDF",
"output": "82"
},
{
"input": "6 4\nYJSNPI",
"output": "4"
},
{
"input": "5 3\nAOWBY",
"output": "3"
},
{
"input": "1 1\nV",
"output": "1"
},
{
"input": "2 1\nWT",
"output": "1"
},
{
"input": "2 2\nBL",
"output":... | 1,647,755,895 | 2,147,483,647 | Python 3 | OK | TESTS | 41 | 61 | 512,000 | n, k = map(int, input().split())
s = list(str(input()))
dict = {}
for i in s:
if i in dict:
dict[i] += 1
else :
dict[i] = 1
p = list(dict.values())
p.sort(reverse = True)
ans = 0
for i in p:
if i <= k:
k -= i
ans += i*i
else :
ans += k*k
break
print(ans)
| Title: Appleman and Card Game
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Appleman has *n* cards. Each card has an uppercase letter written on it. Toastman must choose *k* cards from Appleman's cards. Then Appleman should give Toastman some coins depending on the chosen cards. Formally... | ```python
n, k = map(int, input().split())
s = list(str(input()))
dict = {}
for i in s:
if i in dict:
dict[i] += 1
else :
dict[i] = 1
p = list(dict.values())
p.sort(reverse = True)
ans = 0
for i in p:
if i <= k:
k -= i
ans += i*i
else :
ans += k*k
break
pr... | 3 | |
486 | A | Calculating Function | PROGRAMMING | 800 | [
"implementation",
"math"
] | null | null | For a positive integer *n* let's define a function *f*:
*f*(*n*)<==<=<=-<=1<=+<=2<=-<=3<=+<=..<=+<=(<=-<=1)*n**n*
Your task is to calculate *f*(*n*) for a given integer *n*. | The single line contains the positive integer *n* (1<=≤<=*n*<=≤<=1015). | Print *f*(*n*) in a single line. | [
"4\n",
"5\n"
] | [
"2\n",
"-3\n"
] | *f*(4) = - 1 + 2 - 3 + 4 = 2
*f*(5) = - 1 + 2 - 3 + 4 - 5 = - 3 | 500 | [
{
"input": "4",
"output": "2"
},
{
"input": "5",
"output": "-3"
},
{
"input": "1000000000",
"output": "500000000"
},
{
"input": "1000000001",
"output": "-500000001"
},
{
"input": "1000000000000000",
"output": "500000000000000"
},
{
"input": "100",
... | 1,695,374,083 | 2,147,483,647 | Python 3 | OK | TESTS | 39 | 46 | 0 | # -*- coding: utf-8 -*-
"""
Created on Fri Sep 22 16:46:00 2023
@author: 2300011413
"""
n=int(input())
if n%2==0:
print(n//2)
else:
print((n-1)//2-n) | Title: Calculating Function
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
For a positive integer *n* let's define a function *f*:
*f*(*n*)<==<=<=-<=1<=+<=2<=-<=3<=+<=..<=+<=(<=-<=1)*n**n*
Your task is to calculate *f*(*n*) for a given integer *n*.
Input Specification:
The single line... | ```python
# -*- coding: utf-8 -*-
"""
Created on Fri Sep 22 16:46:00 2023
@author: 2300011413
"""
n=int(input())
if n%2==0:
print(n//2)
else:
print((n-1)//2-n)
``` | 3 | |
455 | A | Boredom | PROGRAMMING | 1,500 | [
"dp"
] | null | null | Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.
Given a sequence *a* consisting of *n* integers. The player can make several steps. In a single step he can choose an element of the sequence (let's denote it *a*... | The first line contains integer *n* (1<=≤<=*n*<=≤<=105) that shows how many numbers are in Alex's sequence.
The second line contains *n* integers *a*1, *a*2, ..., *a**n* (1<=≤<=*a**i*<=≤<=105). | Print a single integer — the maximum number of points that Alex can earn. | [
"2\n1 2\n",
"3\n1 2 3\n",
"9\n1 2 1 3 2 2 2 2 3\n"
] | [
"2\n",
"4\n",
"10\n"
] | Consider the third test example. At first step we need to choose any element equal to 2. After that step our sequence looks like this [2, 2, 2, 2]. Then we do 4 steps, on each step we choose any element equals to 2. In total we earn 10 points. | 500 | [
{
"input": "2\n1 2",
"output": "2"
},
{
"input": "3\n1 2 3",
"output": "4"
},
{
"input": "9\n1 2 1 3 2 2 2 2 3",
"output": "10"
},
{
"input": "5\n3 3 4 5 4",
"output": "11"
},
{
"input": "5\n5 3 5 3 4",
"output": "16"
},
{
"input": "5\n4 2 3 2 5",
... | 1,700,050,090 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 10 | 108 | 12,800,000 | n = int(input())
array = sorted(list(map(int,input().split())))
lst = ['s']+list(set(array))
dic = {0:0}
for i in array:
if i in dic:
dic[i] += 1
else:
dic[i] = 1
m = len(dic)
dp = [0]*m
for i in range(1,m):
if lst[i-1] != lst[i] - 1:
dp[i] = dp[i-1] + lst[i]*dic[lst[i]]... | Title: Boredom
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.
Given a sequence *a* consisting of *n* integers. The player can make ... | ```python
n = int(input())
array = sorted(list(map(int,input().split())))
lst = ['s']+list(set(array))
dic = {0:0}
for i in array:
if i in dic:
dic[i] += 1
else:
dic[i] = 1
m = len(dic)
dp = [0]*m
for i in range(1,m):
if lst[i-1] != lst[i] - 1:
dp[i] = dp[i-1] + lst[i]*d... | 0 | |
56 | A | Bar | PROGRAMMING | 1,000 | [
"implementation"
] | A. Bar | 2 | 256 | According to Berland laws it is only allowed to sell alcohol to people not younger than 18 years. Vasya's job is to monitor the law's enforcement. Tonight he entered a bar and saw *n* people sitting there. For every one of them Vasya happened to determine either the age or the drink the person is having. Vasya can chec... | The first line contains an integer *n* (1<=≤<=*n*<=≤<=100) which is the number of the bar's clients. Then follow *n* lines, each describing one visitor. A line either contains his age (an integer from 0 to 1000) or his drink (a string of capital Latin letters from 1 to 100 in length). It is guaranteed that the input da... | Print a single number which is the number of people Vasya should check to guarantee the law enforcement. | [
"5\n18\nVODKA\nCOKE\n19\n17\n"
] | [
"2\n"
] | In the sample test the second and fifth clients should be checked. | 500 | [
{
"input": "5\n18\nVODKA\nCOKE\n19\n17",
"output": "2"
},
{
"input": "2\n2\nGIN",
"output": "2"
},
{
"input": "3\nWHISKEY\n3\nGIN",
"output": "3"
},
{
"input": "4\n813\nIORBQITQXMPTFAEMEQDQIKFGKGOTNKTOSZCBRPXJLUKVLVHJYNRUJXK\nRUM\nRHVRWGODYWWTYZFLFYKCVUFFRTQDINKNWPKFHZBFWBHWI... | 1,540,759,962 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 216 | 0 | n=int(input())
l=[]
p=['0','1','2','3','4','5','6','7','8','9']
s=0
for i in range (n):
x=input()
l.append(x)
if x[0] not in (p) :
s=s+1
print(s) | Title: Bar
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
According to Berland laws it is only allowed to sell alcohol to people not younger than 18 years. Vasya's job is to monitor the law's enforcement. Tonight he entered a bar and saw *n* people sitting there. For every one of them Vasya h... | ```python
n=int(input())
l=[]
p=['0','1','2','3','4','5','6','7','8','9']
s=0
for i in range (n):
x=input()
l.append(x)
if x[0] not in (p) :
s=s+1
print(s)
``` | 0 |
630 | K | Indivisibility | PROGRAMMING | 1,500 | [
"math",
"number theory"
] | null | null | IT City company developing computer games decided to upgrade its way to reward its employees. Now it looks the following way. After a new game release users start buying it actively, and the company tracks the number of sales with precision to each transaction. Every time when the next number of sales is not divisible ... | The only line of the input contains one integer *n* (1<=≤<=*n*<=≤<=1018) — the prediction on the number of people who will buy the game. | Output one integer showing how many numbers from 1 to *n* are not divisible by any number from 2 to 10. | [
"12\n"
] | [
"2"
] | none | 0 | [
{
"input": "12",
"output": "2"
},
{
"input": "2519",
"output": "576"
},
{
"input": "2521",
"output": "577"
},
{
"input": "1",
"output": "1"
},
{
"input": "314159265",
"output": "71807832"
},
{
"input": "718281828459045235",
"output": "1641787036477... | 1,690,717,444 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 10 | 46 | 0 | n = int(input())
print(n-n//2-n//3-n//5-n//7+n//6+n//10+n//14+n//15+n//21+n//35-n//30-n//42-n//70-n//105+n//210) | Title: Indivisibility
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
IT City company developing computer games decided to upgrade its way to reward its employees. Now it looks the following way. After a new game release users start buying it actively, and the company tracks the number of ... | ```python
n = int(input())
print(n-n//2-n//3-n//5-n//7+n//6+n//10+n//14+n//15+n//21+n//35-n//30-n//42-n//70-n//105+n//210)
``` | 3 | |
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,680,626,002 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 92 | 0 | x1=input()
x2=input()
x3=input()
c=0
guest=x1+x2
guest_d={}
letter={}
for i in guest:
guest_d[i]=guest.count(i)
for i in letter:
letter[i]=x3.count(i)
if guest_d==letter:
print("YES")
else:
print("NO") | 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
x1=input()
x2=input()
x3=input()
c=0
guest=x1+x2
guest_d={}
letter={}
for i in guest:
guest_d[i]=guest.count(i)
for i in letter:
letter[i]=x3.count(i)
if guest_d==letter:
print("YES")
else:
print("NO")
``` | 0 | |
868 | A | Bark to Unlock | PROGRAMMING | 900 | [
"brute force",
"implementation",
"strings"
] | null | null | As technologies develop, manufacturers are making the process of unlocking a phone as user-friendly as possible. To unlock its new phone, Arkady's pet dog Mu-mu has to bark the password once. The phone represents a password as a string of two lowercase English letters.
Mu-mu's enemy Kashtanka wants to unlock Mu-mu's p... | The first line contains two lowercase English letters — the password on the phone.
The second line contains single integer *n* (1<=≤<=*n*<=≤<=100) — the number of words Kashtanka knows.
The next *n* lines contain two lowercase English letters each, representing the words Kashtanka knows. The words are guaranteed to b... | Print "YES" if Kashtanka can bark several words in a line forming a string containing the password, and "NO" otherwise.
You can print each letter in arbitrary case (upper or lower). | [
"ya\n4\nah\noy\nto\nha\n",
"hp\n2\nht\ntp\n",
"ah\n1\nha\n"
] | [
"YES\n",
"NO\n",
"YES\n"
] | In the first example the password is "ya", and Kashtanka can bark "oy" and then "ah", and then "ha" to form the string "oyahha" which contains the password. So, the answer is "YES".
In the second example Kashtanka can't produce a string containing password as a substring. Note that it can bark "ht" and then "tp" produ... | 250 | [
{
"input": "ya\n4\nah\noy\nto\nha",
"output": "YES"
},
{
"input": "hp\n2\nht\ntp",
"output": "NO"
},
{
"input": "ah\n1\nha",
"output": "YES"
},
{
"input": "bb\n4\nba\nab\naa\nbb",
"output": "YES"
},
{
"input": "bc\n4\nca\nba\nbb\ncc",
"output": "YES"
},
{
... | 1,602,282,855 | 2,147,483,647 | PyPy 3 | OK | TESTS | 90 | 140 | 0 | pw = input()
n = int(input())
words = [input() for i in range(n)]
match1 = False
match2 = False
if pw in words:
print("YES")
else:
for word in words:
if pw[0] == word[1]:
match1 = True
if pw[1] == word[0]:
match2 = True
if match1 and match2:
print("YES")
else:
print("NO") | Title: Bark to Unlock
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
As technologies develop, manufacturers are making the process of unlocking a phone as user-friendly as possible. To unlock its new phone, Arkady's pet dog Mu-mu has to bark the password once. The phone represents a passw... | ```python
pw = input()
n = int(input())
words = [input() for i in range(n)]
match1 = False
match2 = False
if pw in words:
print("YES")
else:
for word in words:
if pw[0] == word[1]:
match1 = True
if pw[1] == word[0]:
match2 = True
if match1 and match2:
print("YES")
else:
print("NO")
`... | 3 | |
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,691,095,514 | 2,147,483,647 | Python 3 | OK | TESTS | 46 | 46 | 0 | n = int(input())
l = []
l2 = []
l3 = []
for i in range(0,n) :
l.append(list(map(int,input().split(" "))))
for k in l :
if k[0] > 0 :
l2.append(k)
else :
l3.append(k)
l2.sort()
s = 0
lcv = min(len(l2),len(l3))
l3.sort(reverse=True)
if len(l2) == len(l3) :
for ... | 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
n = int(input())
l = []
l2 = []
l3 = []
for i in range(0,n) :
l.append(list(map(int,input().split(" "))))
for k in l :
if k[0] > 0 :
l2.append(k)
else :
l3.append(k)
l2.sort()
s = 0
lcv = min(len(l2),len(l3))
l3.sort(reverse=True)
if len(l2) == len(l3) : ... | 3 | |
909 | B | Segments | PROGRAMMING | 1,300 | [
"constructive algorithms",
"math"
] | null | null | You are given an integer *N*. Consider all possible segments on the coordinate axis with endpoints at integer points with coordinates between 0 and *N*, inclusive; there will be of them.
You want to draw these segments in several layers so that in each layer the segments don't overlap (they might touch at the endpoin... | The only input line contains a single integer *N* (1<=≤<=*N*<=≤<=100). | Output a single integer - the minimal number of layers required to draw the segments for the given *N*. | [
"2\n",
"3\n",
"4\n"
] | [
"2\n",
"4\n",
"6\n"
] | As an example, here are the segments and their optimal arrangement into layers for *N* = 4. | 1,000 | [
{
"input": "2",
"output": "2"
},
{
"input": "3",
"output": "4"
},
{
"input": "4",
"output": "6"
},
{
"input": "21",
"output": "121"
},
{
"input": "100",
"output": "2550"
},
{
"input": "1",
"output": "1"
},
{
"input": "5",
"output": "9"
... | 1,515,680,938 | 1,738 | Python 3 | OK | TESTS | 102 | 62 | 5,632,000 | n = int(input())
n += 1
n = n*n
n = n//4
print(n) | Title: Segments
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given an integer *N*. Consider all possible segments on the coordinate axis with endpoints at integer points with coordinates between 0 and *N*, inclusive; there will be of them.
You want to draw these segments in se... | ```python
n = int(input())
n += 1
n = n*n
n = n//4
print(n)
``` | 3 | |
330 | A | Cakeminator | PROGRAMMING | 800 | [
"brute force",
"implementation"
] | null | null | You are given a rectangular cake, represented as an *r*<=×<=*c* grid. Each cell either has an evil strawberry, or is empty. For example, a 3<=×<=4 cake may look as follows:
The cakeminator is going to eat the cake! Each time he eats, he chooses a row or a column that does not contain any evil strawberries and contains... | The first line contains two integers *r* and *c* (2<=≤<=*r*,<=*c*<=≤<=10), denoting the number of rows and the number of columns of the cake. The next *r* lines each contains *c* characters — the *j*-th character of the *i*-th line denotes the content of the cell at row *i* and column *j*, and is either one of these:
... | Output the maximum number of cake cells that the cakeminator can eat. | [
"3 4\nS...\n....\n..S.\n"
] | [
"8\n"
] | For the first example, one possible way to eat the maximum number of cake cells is as follows (perform 3 eats). | 500 | [
{
"input": "3 4\nS...\n....\n..S.",
"output": "8"
},
{
"input": "2 2\n..\n..",
"output": "4"
},
{
"input": "2 2\nSS\nSS",
"output": "0"
},
{
"input": "7 3\nS..\nS..\nS..\nS..\nS..\nS..\nS..",
"output": "14"
},
{
"input": "3 5\n..S..\nSSSSS\n..S..",
"output": "... | 1,672,846,272 | 2,147,483,647 | PyPy 3 | OK | TESTS | 42 | 186 | 0 | a , b = [int(x) for x in input().split()]
ls =[]
for i in range(0,a):
ls.append(input())
lt = [""] * b
p = 0
for i in range(0,len(ls)):
if "S" not in ls[i]:
p+= len(ls[i])
ls [i] = b*"a"
for i in range(0,b):
for j in range(0,a):
lt[i] += str(ls[j])[i]
... | Title: Cakeminator
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given a rectangular cake, represented as an *r*<=×<=*c* grid. Each cell either has an evil strawberry, or is empty. For example, a 3<=×<=4 cake may look as follows:
The cakeminator is going to eat the cake! Each ti... | ```python
a , b = [int(x) for x in input().split()]
ls =[]
for i in range(0,a):
ls.append(input())
lt = [""] * b
p = 0
for i in range(0,len(ls)):
if "S" not in ls[i]:
p+= len(ls[i])
ls [i] = b*"a"
for i in range(0,b):
for j in range(0,a):
lt[i] += str(ls[... | 3 | |
0 | none | none | none | 0 | [
"none"
] | null | null | Bear Limak has *n* colored balls, arranged in one long row. Balls are numbered 1 through *n*, from left to right. There are *n* possible colors, also numbered 1 through *n*. The *i*-th ball has color *t**i*.
For a fixed interval (set of consecutive elements) of balls we can define a dominant color. It's a color occurr... | The first line of the input contains a single integer *n* (1<=≤<=*n*<=≤<=5000) — the number of balls.
The second line contains *n* integers *t*1,<=*t*2,<=...,<=*t**n* (1<=≤<=*t**i*<=≤<=*n*) where *t**i* is the color of the *i*-th ball. | Print *n* integers. The *i*-th of them should be equal to the number of intervals where *i* is a dominant color. | [
"4\n1 2 1 2\n",
"3\n1 1 1\n"
] | [
"7 3 0 0 \n",
"6 0 0 \n"
] | In the first sample, color 2 is dominant in three intervals:
- An interval [2, 2] contains one ball. This ball's color is 2 so it's clearly a dominant color. - An interval [4, 4] contains one ball, with color 2 again. - An interval [2, 4] contains two balls of color 2 and one ball of color 1.
There are 7 more inte... | 0 | [
{
"input": "4\n1 2 1 2",
"output": "7 3 0 0 "
},
{
"input": "3\n1 1 1",
"output": "6 0 0 "
},
{
"input": "10\n9 1 5 2 9 2 9 2 1 1",
"output": "18 30 0 0 1 0 0 0 6 0 "
},
{
"input": "50\n17 13 19 19 19 34 32 24 24 13 34 17 19 19 7 32 19 13 13 30 19 34 34 28 41 24 24 47 22 34 2... | 1,689,441,131 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 0 | 62 | 0 | print("_RANDOM_GUESS_1689441131.7455006")# 1689441131.7455204 | Title: none
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Bear Limak has *n* colored balls, arranged in one long row. Balls are numbered 1 through *n*, from left to right. There are *n* possible colors, also numbered 1 through *n*. The *i*-th ball has color *t**i*.
For a fixed interval ... | ```python
print("_RANDOM_GUESS_1689441131.7455006")# 1689441131.7455204
``` | 0 | |
373 | B | Making Sequences is Fun | PROGRAMMING | 1,600 | [
"binary search",
"implementation",
"math"
] | null | null | We'll define *S*(*n*) for positive integer *n* as follows: the number of the *n*'s digits in the decimal base. For example, *S*(893)<==<=3, *S*(114514)<==<=6.
You want to make a consecutive integer sequence starting from number *m* (*m*,<=*m*<=+<=1,<=...). But you need to pay *S*(*n*)·*k* to add the number *n* to the ... | The first line contains three integers *w* (1<=≤<=*w*<=≤<=1016), *m* (1<=≤<=*m*<=≤<=1016), *k* (1<=≤<=*k*<=≤<=109).
Please, do not write 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. | The first line should contain a single integer — the answer to the problem. | [
"9 1 1\n",
"77 7 7\n",
"114 5 14\n",
"1 1 2\n"
] | [
"9\n",
"7\n",
"6\n",
"0\n"
] | none | 1,000 | [
{
"input": "9 1 1",
"output": "9"
},
{
"input": "77 7 7",
"output": "7"
},
{
"input": "114 5 14",
"output": "6"
},
{
"input": "1 1 2",
"output": "0"
},
{
"input": "462 183 8",
"output": "19"
},
{
"input": "462 183 8",
"output": "19"
},
{
"i... | 1,609,256,093 | 2,147,483,647 | Python 3 | OK | TESTS | 35 | 108 | 307,200 | def cnt(x, y):
return y-x
w, m, k = map(int, input().split())
p, d, res = 1, 0, 0
while p <= m:
p *= 10
d += 1
while cnt(m, p)*d*k <= w:
w -= cnt(m, p)*d*k
res += cnt(m, p)
m = p
p *= 10
d += 1
lo, hi = m, p
while hi-lo > 1:
mid = (lo+hi)//2
if (cnt(m, mid)*d*k <= w): lo = mid
e... | Title: Making Sequences is Fun
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
We'll define *S*(*n*) for positive integer *n* as follows: the number of the *n*'s digits in the decimal base. For example, *S*(893)<==<=3, *S*(114514)<==<=6.
You want to make a consecutive integer sequence sta... | ```python
def cnt(x, y):
return y-x
w, m, k = map(int, input().split())
p, d, res = 1, 0, 0
while p <= m:
p *= 10
d += 1
while cnt(m, p)*d*k <= w:
w -= cnt(m, p)*d*k
res += cnt(m, p)
m = p
p *= 10
d += 1
lo, hi = m, p
while hi-lo > 1:
mid = (lo+hi)//2
if (cnt(m, mid)*d*k <= w): lo ... | 3 | |
112 | A | Petya and Strings | PROGRAMMING | 800 | [
"implementation",
"strings"
] | A. Petya and Strings | 2 | 256 | Little Petya loves presents. His mum bought him two strings of the same size for his birthday. The strings consist of uppercase and lowercase Latin letters. Now Petya wants to compare those two strings lexicographically. The letters' case does not matter, that is an uppercase letter is considered equivalent to the corr... | Each of the first two lines contains a bought string. The strings' lengths range from 1 to 100 inclusive. It is guaranteed that the strings are of the same length and also consist of uppercase and lowercase Latin letters. | If the first string is less than the second one, print "-1". If the second string is less than the first one, print "1". If the strings are equal, print "0". Note that the letters' case is not taken into consideration when the strings are compared. | [
"aaaa\naaaA\n",
"abs\nAbz\n",
"abcdefg\nAbCdEfF\n"
] | [
"0\n",
"-1\n",
"1\n"
] | If you want more formal information about the lexicographical order (also known as the "dictionary order" or "alphabetical order"), you can visit the following site:
- http://en.wikipedia.org/wiki/Lexicographical_order | 500 | [
{
"input": "aaaa\naaaA",
"output": "0"
},
{
"input": "abs\nAbz",
"output": "-1"
},
{
"input": "abcdefg\nAbCdEfF",
"output": "1"
},
{
"input": "asadasdasd\nasdwasdawd",
"output": "-1"
},
{
"input": "aslkjlkasdd\nasdlkjdajwi",
"output": "1"
},
{
"input":... | 1,699,384,280 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 60 | 0 | a=str(input())
b=str(input())
if len(a)==len(b) :
print(0)
else:
if len(a)>len(b) :
print(1)
else:
print(-1) | Title: Petya and Strings
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Little Petya loves presents. His mum bought him two strings of the same size for his birthday. The strings consist of uppercase and lowercase Latin letters. Now Petya wants to compare those two strings lexicographically. ... | ```python
a=str(input())
b=str(input())
if len(a)==len(b) :
print(0)
else:
if len(a)>len(b) :
print(1)
else:
print(-1)
``` | 0 |
689 | D | Friends and Subsequences | PROGRAMMING | 2,100 | [
"binary search",
"data structures"
] | null | null | Mike and !Mike are old childhood rivals, they are opposite in everything they do, except programming. Today they have a problem they cannot solve on their own, but together (with you) — who knows?
Every one of them has an integer sequences *a* and *b* of length *n*. Being given a query of the form of pair of integers... | The first line contains only integer *n* (1<=≤<=*n*<=≤<=200<=000).
The second line contains *n* integer numbers *a*1,<=*a*2,<=...,<=*a**n* (<=-<=109<=≤<=*a**i*<=≤<=109) — the sequence *a*.
The third line contains *n* integer numbers *b*1,<=*b*2,<=...,<=*b**n* (<=-<=109<=≤<=*b**i*<=≤<=109) — the sequence *b*. | Print the only integer number — the number of occasions the robot will count, thus for how many pairs is satisfied. | [
"6\n1 2 3 2 1 4\n6 7 1 2 3 2\n",
"3\n3 3 3\n1 1 1\n"
] | [
"2\n",
"0\n"
] | The occasions in the first sample case are:
1.*l* = 4,*r* = 4 since *max*{2} = *min*{2}.
2.*l* = 4,*r* = 5 since *max*{2, 1} = *min*{2, 3}.
There are no occasions in the second sample case since Mike will answer 3 to any query pair, but !Mike will always answer 1. | 2,000 | [
{
"input": "6\n1 2 3 2 1 4\n6 7 1 2 3 2",
"output": "2"
},
{
"input": "3\n3 3 3\n1 1 1",
"output": "0"
},
{
"input": "17\n714413739 -959271262 714413739 -745891378 926207665 -404845105 -404845105 -959271262 -189641729 -670860364 714413739 -189641729 192457837 -745891378 -670860364 536388... | 1,654,092,441 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 94 | 982 | 456,908,800 |
dx=[[0]*(1<<20) for _ in range(20)]
dy=[[0]*(1<<20) for _ in range(20)]
lg=[0]*(1<<20)
def mx(l,r):
p=lg[r-l+1]
return max(dx[p][l],dx[p][r-(1<<p)+1])
def mn(l,r):
p=lg[r-l+1]
return min(dy[p][l],dy[p][r-(1<<p)+1])
if __name__ == '__main__':
n=int(input())
dx[0][1:n]=[int(... | Title: Friends and Subsequences
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Mike and !Mike are old childhood rivals, they are opposite in everything they do, except programming. Today they have a problem they cannot solve on their own, but together (with you) — who knows?
Every one o... | ```python
dx=[[0]*(1<<20) for _ in range(20)]
dy=[[0]*(1<<20) for _ in range(20)]
lg=[0]*(1<<20)
def mx(l,r):
p=lg[r-l+1]
return max(dx[p][l],dx[p][r-(1<<p)+1])
def mn(l,r):
p=lg[r-l+1]
return min(dy[p][l],dy[p][r-(1<<p)+1])
if __name__ == '__main__':
n=int(input())
dx[0][... | 3 | |
938 | A | Word Correction | PROGRAMMING | 800 | [
"implementation"
] | null | null | Victor tries to write his own text editor, with word correction included. However, the rules of word correction are really strange.
Victor thinks that if a word contains two consecutive vowels, then it's kinda weird and it needs to be replaced. So the word corrector works in such a way: as long as there are two consec... | The first line contains one integer *n* (1<=≤<=*n*<=≤<=100) — the number of letters in word *s* before the correction.
The second line contains a string *s* consisting of exactly *n* lowercase Latin letters — the word before the correction. | Output the word *s* after the correction. | [
"5\nweird\n",
"4\nword\n",
"5\naaeaa\n"
] | [
"werd\n",
"word\n",
"a\n"
] | Explanations of the examples:
1. There is only one replace: weird <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/70a0795f45d32287dba0eb83fc4a3f470c6e5537.png" style="max-width: 100.0%;max-height: 100.0%;"/> werd;1. No replace needed since there are no two consecutive vowels;1. aaeaa <i... | 0 | [
{
"input": "5\nweird",
"output": "werd"
},
{
"input": "4\nword",
"output": "word"
},
{
"input": "5\naaeaa",
"output": "a"
},
{
"input": "100\naaaaabbbbboyoyoyoyoyacadabbbbbiuiufgiuiuaahjabbbklboyoyoyoyoyaaaaabbbbbiuiuiuiuiuaaaaabbbbbeyiyuyzyw",
"output": "abbbbbocadabbbbb... | 1,518,879,699 | 2,147,483,647 | Python 3 | OK | TESTS | 49 | 77 | 5,632,000 | vowel="aeiouy"
n=int(input().strip())
s=input().strip()
s="3"+s
count=0
out=""
turn=True
for c in s:
if c not in vowel:
out+=c
turn=True
else:
if turn:
out+=c
turn=False
print(out[1:])
| Title: Word Correction
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Victor tries to write his own text editor, with word correction included. However, the rules of word correction are really strange.
Victor thinks that if a word contains two consecutive vowels, then it's kinda weird an... | ```python
vowel="aeiouy"
n=int(input().strip())
s=input().strip()
s="3"+s
count=0
out=""
turn=True
for c in s:
if c not in vowel:
out+=c
turn=True
else:
if turn:
out+=c
turn=False
print(out[1:])
... | 3 | |
461 | A | Appleman and Toastman | PROGRAMMING | 1,200 | [
"greedy",
"sortings"
] | null | null | Appleman and Toastman play a game. Initially Appleman gives one group of *n* numbers to the Toastman, then they start to complete the following tasks:
- Each time Toastman gets a group of numbers, he sums up all the numbers and adds this sum to the score. Then he gives the group to the Appleman. - Each time Appleman... | The first line contains a single integer *n* (1<=≤<=*n*<=≤<=3·105). The second line contains *n* integers *a*1, *a*2, ..., *a**n* (1<=≤<=*a**i*<=≤<=106) — the initial group that is given to Toastman. | Print a single integer — the largest possible score. | [
"3\n3 1 5\n",
"1\n10\n"
] | [
"26\n",
"10\n"
] | Consider the following situation in the first example. Initially Toastman gets group [3, 1, 5] and adds 9 to the score, then he give the group to Appleman. Appleman splits group [3, 1, 5] into two groups: [3, 5] and [1]. Both of them should be given to Toastman. When Toastman receives group [1], he adds 1 to score and ... | 500 | [
{
"input": "3\n3 1 5",
"output": "26"
},
{
"input": "1\n10",
"output": "10"
},
{
"input": "10\n8 10 2 5 6 2 4 7 2 1",
"output": "376"
},
{
"input": "10\n171308 397870 724672 431255 228496 892002 542924 718337 888642 161821",
"output": "40204082"
},
{
"input": "10\... | 1,512,551,136 | 2,147,483,647 | Python 3 | OK | TESTS | 36 | 421 | 26,214,400 | n=int(input())
N=[int(i) for i in input().split()]
number=0
if n==1:
print(N[0])
elif n==2:
print(2*sum(N))
else:
N.sort(reverse=True)
for i in range(n):
number+=N[i]*(n-i+1)
print(number-N[0])
| Title: Appleman and Toastman
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Appleman and Toastman play a game. Initially Appleman gives one group of *n* numbers to the Toastman, then they start to complete the following tasks:
- Each time Toastman gets a group of numbers, he sums up all... | ```python
n=int(input())
N=[int(i) for i in input().split()]
number=0
if n==1:
print(N[0])
elif n==2:
print(2*sum(N))
else:
N.sort(reverse=True)
for i in range(n):
number+=N[i]*(n-i+1)
print(number-N[0])
``` | 3 | |
131 | A | cAPS lOCK | PROGRAMMING | 1,000 | [
"implementation",
"strings"
] | null | null | wHAT DO WE NEED cAPS LOCK FOR?
Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage.
Let's consider that a word has been typed with the Caps lock key accidentall... | The first line of the input data contains a word consisting of uppercase and lowercase Latin letters. The word's length is from 1 to 100 characters, inclusive. | Print the result of the given word's processing. | [
"cAPS\n",
"Lock\n"
] | [
"Caps",
"Lock\n"
] | none | 500 | [
{
"input": "cAPS",
"output": "Caps"
},
{
"input": "Lock",
"output": "Lock"
},
{
"input": "cAPSlOCK",
"output": "cAPSlOCK"
},
{
"input": "CAPs",
"output": "CAPs"
},
{
"input": "LoCK",
"output": "LoCK"
},
{
"input": "OOPS",
"output": "oops"
},
{
... | 1,693,164,909 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 56 | 62 | 0 | a = input()
def caps(a):
f = True
for i in range(1, len(a)):
if a[i].islower() == 1:
f = False
if f == 1:
a = a.swapcase()
return a
else:
return a
print(caps(a))
| Title: cAPS lOCK
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
wHAT DO WE NEED cAPS LOCK FOR?
Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in th... | ```python
a = input()
def caps(a):
f = True
for i in range(1, len(a)):
if a[i].islower() == 1:
f = False
if f == 1:
a = a.swapcase()
return a
else:
return a
print(caps(a))
``` | 3 | |
82 | A | Double Cola | PROGRAMMING | 1,100 | [
"implementation",
"math"
] | A. Double Cola | 1 | 256 | Sheldon, Leonard, Penny, Rajesh and Howard are in the queue for a "Double Cola" drink vending machine; there are no other people in the queue. The first one in the queue (Sheldon) buys a can, drinks it and doubles! The resulting two Sheldons go to the end of the queue. Then the next in the queue (Leonard) buys a can, d... | The input data consist of a single integer *n* (1<=≤<=*n*<=≤<=109).
It is guaranteed that the pretests check the spelling of all the five names, that is, that they contain all the five possible answers. | Print the single line — the name of the person who drinks the *n*-th can of cola. The cans are numbered starting from 1. Please note that you should spell the names like this: "Sheldon", "Leonard", "Penny", "Rajesh", "Howard" (without the quotes). In that order precisely the friends are in the queue initially. | [
"1\n",
"6\n",
"1802\n"
] | [
"Sheldon\n",
"Sheldon\n",
"Penny\n"
] | none | 500 | [
{
"input": "1",
"output": "Sheldon"
},
{
"input": "6",
"output": "Sheldon"
},
{
"input": "1802",
"output": "Penny"
},
{
"input": "1",
"output": "Sheldon"
},
{
"input": "2",
"output": "Leonard"
},
{
"input": "3",
"output": "Penny"
},
{
"inpu... | 1,608,708,040 | 2,147,483,647 | Python 3 | OK | TESTS | 41 | 109 | 307,200 | n = int(input())
a1 = 'Sheldon'
a2 = 'Leonard'
a3 = 'Penny'
a4 = 'Rajesh'
a5 = 'Howard'
t = 0
k = 0
p = 1
f = 0
while t - 4 <= n:
p = 5 * 2 ** k
k = k + 1
t = p
if t - 4 == n:
p = t - 4
break
elif t - 4 > n:
p = p / 2 - 4
k = k - 1
break
... | Title: Double Cola
Time Limit: 1 seconds
Memory Limit: 256 megabytes
Problem Description:
Sheldon, Leonard, Penny, Rajesh and Howard are in the queue for a "Double Cola" drink vending machine; there are no other people in the queue. The first one in the queue (Sheldon) buys a can, drinks it and doubles! The resultin... | ```python
n = int(input())
a1 = 'Sheldon'
a2 = 'Leonard'
a3 = 'Penny'
a4 = 'Rajesh'
a5 = 'Howard'
t = 0
k = 0
p = 1
f = 0
while t - 4 <= n:
p = 5 * 2 ** k
k = k + 1
t = p
if t - 4 == n:
p = t - 4
break
elif t - 4 > n:
p = p / 2 - 4
k = k - 1
... | 3.944928 |
41 | A | Translation | PROGRAMMING | 800 | [
"implementation",
"strings"
] | A. Translation | 2 | 256 | The translation from the Berland language into the Birland language is not an easy task. Those languages are very similar: a berlandish word differs from a birlandish word with the same meaning a little: it is spelled (and pronounced) reversely. For example, a Berlandish word code corresponds to a Birlandish word edoc.... | The first line contains word *s*, the second line contains word *t*. The words consist of lowercase Latin letters. The input data do not consist unnecessary spaces. The words are not empty and their lengths do not exceed 100 symbols. | If the word *t* is a word *s*, written reversely, print YES, otherwise print NO. | [
"code\nedoc\n",
"abb\naba\n",
"code\ncode\n"
] | [
"YES\n",
"NO\n",
"NO\n"
] | none | 500 | [
{
"input": "code\nedoc",
"output": "YES"
},
{
"input": "abb\naba",
"output": "NO"
},
{
"input": "code\ncode",
"output": "NO"
},
{
"input": "abacaba\nabacaba",
"output": "YES"
},
{
"input": "q\nq",
"output": "YES"
},
{
"input": "asrgdfngfnmfgnhweratgjkk... | 1,607,141,929 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 156 | 0 | s=input()
if reversed(s)==(input()):
print("YES")
else:
print("NO") | Title: Translation
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
The translation from the Berland language into the Birland language is not an easy task. Those languages are very similar: a berlandish word differs from a birlandish word with the same meaning a little: it is spelled (and pron... | ```python
s=input()
if reversed(s)==(input()):
print("YES")
else:
print("NO")
``` | 0 |
150 | A | Win or Freeze | PROGRAMMING | 1,400 | [
"games",
"math",
"number theory"
] | null | null | You can't possibly imagine how cold our friends are this winter in Nvodsk! Two of them play the following game to warm up: initially a piece of paper has an integer *q*. During a move a player should write any integer number that is a non-trivial divisor of the last written number. Then he should run this number of cir... | The first line contains the only integer *q* (1<=≤<=*q*<=≤<=1013).
Please do not use the %lld specificator to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specificator. | In the first line print the number of the winning player (1 or 2). If the first player wins then the second line should contain another integer — his first move (if the first player can't even make the first move, print 0). If there are multiple solutions, print any of them. | [
"6\n",
"30\n",
"1\n"
] | [
"2\n",
"1\n6\n",
"1\n0\n"
] | Number 6 has only two non-trivial divisors: 2 and 3. It is impossible to make a move after the numbers 2 and 3 are written, so both of them are winning, thus, number 6 is the losing number. A player can make a move and write number 6 after number 30; 6, as we know, is a losing number. Thus, this move will bring us the ... | 500 | [
{
"input": "6",
"output": "2"
},
{
"input": "30",
"output": "1\n6"
},
{
"input": "1",
"output": "1\n0"
},
{
"input": "2",
"output": "1\n0"
},
{
"input": "3",
"output": "1\n0"
},
{
"input": "5",
"output": "1\n0"
},
{
"input": "445538663413",... | 1,524,398,129 | 2,147,483,647 | Python 3 | OK | TESTS | 53 | 498 | 7,372,800 | import math
q = int(input())
c = 0
ans = 1
while q % 2 == 0:
q //= 2
if c == 2:
print("1\n"+str(ans), '')
exit()
c +=1
ans *= 2
for i in range(3, int(math.sqrt(q)+1), 2):
while q%i == 0:
q //= i
if c == 2:
print("1\n"+str(ans), '')
... | Title: Win or Freeze
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You can't possibly imagine how cold our friends are this winter in Nvodsk! Two of them play the following game to warm up: initially a piece of paper has an integer *q*. During a move a player should write any integer num... | ```python
import math
q = int(input())
c = 0
ans = 1
while q % 2 == 0:
q //= 2
if c == 2:
print("1\n"+str(ans), '')
exit()
c +=1
ans *= 2
for i in range(3, int(math.sqrt(q)+1), 2):
while q%i == 0:
q //= i
if c == 2:
print("1\n"+str(... | 3 | |
664 | A | Complicated GCD | PROGRAMMING | 800 | [
"math",
"number theory"
] | null | null | Greatest common divisor *GCD*(*a*,<=*b*) of two positive integers *a* and *b* is equal to the biggest integer *d* such that both integers *a* and *b* are divisible by *d*. There are many efficient algorithms to find greatest common divisor *GCD*(*a*,<=*b*), for example, Euclid algorithm.
Formally, find the biggest in... | The only line of the input contains two integers *a* and *b* (1<=≤<=*a*<=≤<=*b*<=≤<=10100). | Output one integer — greatest common divisor of all integers from *a* to *b* inclusive. | [
"1 2\n",
"61803398874989484820458683436563811772030917980576 61803398874989484820458683436563811772030917980576\n"
] | [
"1\n",
"61803398874989484820458683436563811772030917980576\n"
] | none | 500 | [
{
"input": "1 2",
"output": "1"
},
{
"input": "61803398874989484820458683436563811772030917980576 61803398874989484820458683436563811772030917980576",
"output": "61803398874989484820458683436563811772030917980576"
},
{
"input": "1 100",
"output": "1"
},
{
"input": "100 100000... | 1,631,521,017 | 2,147,483,647 | PyPy 3 | RUNTIME_ERROR | TESTS | 0 | 124 | 22,220,800 | # your code goes here
def hcfnaive(a,b):
if(b==0):
return a
else:
return hcfnaive(b,a%b)
a = input()
b= input()
# prints 12
print ("The gcd of 60 and 48 is : ",end="")
print (hcfnaive(a,b)) | Title: Complicated GCD
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Greatest common divisor *GCD*(*a*,<=*b*) of two positive integers *a* and *b* is equal to the biggest integer *d* such that both integers *a* and *b* are divisible by *d*. There are many efficient algorithms to find gre... | ```python
# your code goes here
def hcfnaive(a,b):
if(b==0):
return a
else:
return hcfnaive(b,a%b)
a = input()
b= input()
# prints 12
print ("The gcd of 60 and 48 is : ",end="")
print (hcfnaive(a,b))
``` | -1 | |
200 | B | Drinks | PROGRAMMING | 800 | [
"implementation",
"math"
] | null | null | Little Vasya loves orange juice very much. That's why any food and drink in his kitchen necessarily contains orange juice. There are *n* drinks in his fridge, the volume fraction of orange juice in the *i*-th drink equals *p**i* percent.
One day Vasya decided to make himself an orange cocktail. He took equal proportio... | The first input line contains a single integer *n* (1<=≤<=*n*<=≤<=100) — the number of orange-containing drinks in Vasya's fridge. The second line contains *n* integers *p**i* (0<=≤<=*p**i*<=≤<=100) — the volume fraction of orange juice in the *i*-th drink, in percent. The numbers are separated by a space. | Print the volume fraction in percent of orange juice in Vasya's cocktail. The answer will be considered correct if the absolute or relative error does not exceed 10<=<=-<=4. | [
"3\n50 50 100\n",
"4\n0 25 50 75\n"
] | [
"66.666666666667\n",
"37.500000000000\n"
] | Note to the first sample: let's assume that Vasya takes *x* milliliters of each drink from the fridge. Then the volume of pure juice in the cocktail will equal <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/c1fac6e64d3a8ee6a5ac138cbe51e60039b22473.png" style="max-width: 100.0%;max-height: ... | 500 | [
{
"input": "3\n50 50 100",
"output": "66.666666666667"
},
{
"input": "4\n0 25 50 75",
"output": "37.500000000000"
},
{
"input": "3\n0 1 8",
"output": "3.000000000000"
},
{
"input": "5\n96 89 93 95 70",
"output": "88.600000000000"
},
{
"input": "7\n62 41 78 4 38 39... | 1,696,485,954 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 60 | 0 | x = int(input())
for _ in range(x):
i = int(input())
z = i / x
print(z)
| Title: Drinks
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Little Vasya loves orange juice very much. That's why any food and drink in his kitchen necessarily contains orange juice. There are *n* drinks in his fridge, the volume fraction of orange juice in the *i*-th drink equals *p**i*... | ```python
x = int(input())
for _ in range(x):
i = int(input())
z = i / x
print(z)
``` | -1 | |
1,008 | A | Romaji | PROGRAMMING | 900 | [
"implementation",
"strings"
] | null | null | Vitya has just started learning Berlanese language. It is known that Berlanese uses the Latin alphabet. Vowel letters are "a", "o", "u", "i", and "e". Other letters are consonant.
In Berlanese, there has to be a vowel after every consonant, but there can be any letter after any vowel. The only exception is a consonant... | The first line of the input contains the string $s$ consisting of $|s|$ ($1\leq |s|\leq 100$) lowercase Latin letters. | Print "YES" (without quotes) if there is a vowel after every consonant except "n", otherwise print "NO".
You can print each letter in any case (upper or lower). | [
"sumimasen\n",
"ninja\n",
"codeforces\n"
] | [
"YES\n",
"YES\n",
"NO\n"
] | In the first and second samples, a vowel goes after each consonant except "n", so the word is Berlanese.
In the third sample, the consonant "c" goes after the consonant "r", and the consonant "s" stands on the end, so the word is not Berlanese. | 500 | [
{
"input": "sumimasen",
"output": "YES"
},
{
"input": "ninja",
"output": "YES"
},
{
"input": "codeforces",
"output": "NO"
},
{
"input": "auuaoonntanonnuewannnnpuuinniwoonennyolonnnvienonpoujinndinunnenannmuveoiuuhikucuziuhunnnmunzancenen",
"output": "YES"
},
{
"in... | 1,645,366,047 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 5 | 62 | 0 | s=input()+'*'
ans= 'YES'
for i in range (len(s)-1):
if s[i] not in 'aeioun' and s[i+1] not in 'aeioun':
ans= 'NO'
break
print (ans)
| Title: Romaji
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vitya has just started learning Berlanese language. It is known that Berlanese uses the Latin alphabet. Vowel letters are "a", "o", "u", "i", and "e". Other letters are consonant.
In Berlanese, there has to be a vowel after eve... | ```python
s=input()+'*'
ans= 'YES'
for i in range (len(s)-1):
if s[i] not in 'aeioun' and s[i+1] not in 'aeioun':
ans= 'NO'
break
print (ans)
``` | 0 | |
897 | A | Scarborough Fair | PROGRAMMING | 800 | [
"implementation"
] | null | null | Parsley, sage, rosemary and thyme.
Remember me to one who lives there.
He once was the true love of mine.
Willem is taking the girl to the highest building in island No.28, however, neither of them knows how to get there.
Willem asks his friend, Grick for directions, Grick helped them, and gave them a task.
Althou... | The first line contains two integers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=100).
The second line contains a string *s* of length *n*, consisting of lowercase English letters.
Each of the next *m* lines contains four parameters *l*,<=*r*,<=*c*1,<=*c*2 (1<=≤<=*l*<=≤<=*r*<=≤<=*n*, *c*1,<=*c*2 are lowercase English letters), ... | Output string *s* after performing *m* operations described above. | [
"3 1\nioi\n1 1 i n\n",
"5 3\nwxhak\n3 3 h x\n1 5 x a\n1 3 w g\n"
] | [
"noi",
"gaaak"
] | For the second example:
After the first operation, the string is wxxak.
After the second operation, the string is waaak.
After the third operation, the string is gaaak. | 500 | [
{
"input": "3 1\nioi\n1 1 i n",
"output": "noi"
},
{
"input": "5 3\nwxhak\n3 3 h x\n1 5 x a\n1 3 w g",
"output": "gaaak"
},
{
"input": "9 51\nbhfbdcgff\n2 3 b b\n2 8 e f\n3 8 g f\n5 7 d a\n1 5 e b\n3 4 g b\n6 7 c d\n3 6 e g\n3 6 e h\n5 6 a e\n7 9 a c\n4 9 a h\n3 7 c b\n6 9 b g\n1 7 h b\n... | 1,618,161,839 | 2,147,483,647 | PyPy 3 | OK | TESTS | 47 | 108 | 0 | n, m = list(map(int,input().split()))
a = input()
for i in range(m):
l,r,c1,c2 = input().split()
l = int(l)
r = int(r)
a = a[:l-1] + a[l-1:r].replace(c1,c2) + a[r:]
print(a) | Title: Scarborough Fair
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Parsley, sage, rosemary and thyme.
Remember me to one who lives there.
He once was the true love of mine.
Willem is taking the girl to the highest building in island No.28, however, neither of them knows how to get ... | ```python
n, m = list(map(int,input().split()))
a = input()
for i in range(m):
l,r,c1,c2 = input().split()
l = int(l)
r = int(r)
a = a[:l-1] + a[l-1:r].replace(c1,c2) + a[r:]
print(a)
``` | 3 | |
817 | C | Really Big Numbers | PROGRAMMING | 1,600 | [
"binary search",
"brute force",
"dp",
"math"
] | null | null | Ivan likes to learn different things about numbers, but he is especially interested in really big numbers. Ivan thinks that a positive integer number *x* is really big if the difference between *x* and the sum of its digits (in decimal representation) is not less than *s*. To prove that these numbers may have different... | The first (and the only) line contains two integers *n* and *s* (1<=≤<=*n*,<=*s*<=≤<=1018). | Print one integer — the quantity of really big numbers that are not greater than *n*. | [
"12 1\n",
"25 20\n",
"10 9\n"
] | [
"3\n",
"0\n",
"1\n"
] | In the first example numbers 10, 11 and 12 are really big.
In the second example there are no really big numbers that are not greater than 25 (in fact, the first really big number is 30: 30 - 3 ≥ 20).
In the third example 10 is the only really big number (10 - 1 ≥ 9). | 0 | [
{
"input": "12 1",
"output": "3"
},
{
"input": "25 20",
"output": "0"
},
{
"input": "10 9",
"output": "1"
},
{
"input": "300 1000",
"output": "0"
},
{
"input": "500 1000",
"output": "0"
},
{
"input": "1000 2000",
"output": "0"
},
{
"input":... | 1,694,528,809 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 6 | 30 | 0 | n, s = tuple(map(int,input().split()))
def get_first_after(n):
for i in range(1, 9):
if (n + i) % 9 == 0:
return n + i
if s % 9 == 0:
ans = n - (s / 9) * 10
print(max(0, int(ans + 1)))
else:
s = get_first_after(s)
ans = n - (s / 9) * 10
print(max(0, int(ans + 1)))
... | Title: Really Big Numbers
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Ivan likes to learn different things about numbers, but he is especially interested in really big numbers. Ivan thinks that a positive integer number *x* is really big if the difference between *x* and the sum of its... | ```python
n, s = tuple(map(int,input().split()))
def get_first_after(n):
for i in range(1, 9):
if (n + i) % 9 == 0:
return n + i
if s % 9 == 0:
ans = n - (s / 9) * 10
print(max(0, int(ans + 1)))
else:
s = get_first_after(s)
ans = n - (s / 9) * 10
print(max(0, int(ans + 1)))... | 0 | |
333 | B | Chips | PROGRAMMING | 1,800 | [
"greedy"
] | null | null | Gerald plays the following game. He has a checkered field of size *n*<=×<=*n* cells, where *m* various cells are banned. Before the game, he has to put a few chips on some border (but not corner) board cells. Then for *n*<=-<=1 minutes, Gerald every minute moves each chip into an adjacent cell. He moves each chip from ... | The first line contains two space-separated integers *n* and *m* (2<=≤<=*n*<=≤<=1000, 0<=≤<=*m*<=≤<=105) — the size of the field and the number of banned cells. Next *m* lines each contain two space-separated integers. Specifically, the *i*-th of these lines contains numbers *x**i* and *y**i* (1<=≤<=*x**i*,<=*y**i*<=≤<... | Print a single integer — the maximum points Gerald can earn in this game. | [
"3 1\n2 2\n",
"3 0\n",
"4 3\n3 1\n3 2\n3 3\n"
] | [
"0\n",
"1\n",
"1\n"
] | In the first test the answer equals zero as we can't put chips into the corner cells.
In the second sample we can place one chip into either cell (1, 2), or cell (3, 2), or cell (2, 1), or cell (2, 3). We cannot place two chips.
In the third sample we can only place one chip into either cell (2, 1), or cell (2, 4). | 1,000 | [
{
"input": "3 1\n2 2",
"output": "0"
},
{
"input": "3 0",
"output": "1"
},
{
"input": "4 3\n3 1\n3 2\n3 3",
"output": "1"
},
{
"input": "2 1\n1 1",
"output": "0"
},
{
"input": "2 3\n1 2\n2 1\n2 2",
"output": "0"
},
{
"input": "5 1\n3 2",
"output": ... | 1,488,614,318 | 2,147,483,647 | PyPy 3 | TIME_LIMIT_EXCEEDED | TESTS | 9 | 1,000 | 28,672,000 | n, m = map(int, input().split())
ans = 0
row = [1] * n * 2
for x in range(m):
a, b = [int(x) for x in input().split()]
row[a - 1] = 0
row[b - 1 + n] = 0
for i in range(1, (n + 1) // 2):
j = n - 1 - i
if i == j:
ans += min(1, row[i] + row[i + n])
else:
ans += row[i] + row[j] + row[i + n] + row[j ... | Title: Chips
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Gerald plays the following game. He has a checkered field of size *n*<=×<=*n* cells, where *m* various cells are banned. Before the game, he has to put a few chips on some border (but not corner) board cells. Then for *n*<=-<=1 m... | ```python
n, m = map(int, input().split())
ans = 0
row = [1] * n * 2
for x in range(m):
a, b = [int(x) for x in input().split()]
row[a - 1] = 0
row[b - 1 + n] = 0
for i in range(1, (n + 1) // 2):
j = n - 1 - i
if i == j:
ans += min(1, row[i] + row[i + n])
else:
ans += row[i] + row[j] + row[i + n... | 0 | |
152 | B | Steps | PROGRAMMING | 1,300 | [
"binary search",
"implementation"
] | null | null | One day Vasya went out for a walk in the yard but there weren't any of his friends outside and he had no one to play touch and run. But the boy didn't lose the high spirits and decided to play touch and run with himself. You may ask: "How did he do that?" The answer is simple.
Vasya noticed that the yard is a rectangu... | The first input line contains two integers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=109) — the yard's sizes. The second line contains integers *x**c* and *y**c* — the initial square's coordinates (1<=≤<=*x**c*<=≤<=*n*,<=1<=≤<=*y**c*<=≤<=*m*).
The third line contains an integer *k* (1<=≤<=*k*<=≤<=104) — the number of vectors. ... | Print the single number — the number of steps Vasya had made.
Please do not use the %lld specificator to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specificator. | [
"4 5\n1 1\n3\n1 1\n1 1\n0 -2\n",
"10 10\n1 2\n1\n-1 0\n"
] | [
"4\n",
"0\n"
] | In the first sample Vasya is initially positioned at square (1, 1) and makes 3 steps by the first vector (1, 1). So, he consecutively visits the squares (2, 2), (3, 3), (4, 4). Then he makes 0 steps by the second vector (1, 1). He makes 1 more step by the third vector (0, - 2) and he ends up in square (4, 2). Overall,... | 1,000 | [
{
"input": "4 5\n1 1\n3\n1 1\n1 1\n0 -2",
"output": "4"
},
{
"input": "10 10\n1 2\n1\n-1 0",
"output": "0"
},
{
"input": "10 20\n10 3\n10\n-2 -6\n-1 0\n-8 0\n0 5\n-1 3\n16 -16\n-1 9\n0 -18\n9 -1\n-9 5",
"output": "13"
},
{
"input": "20 10\n14 4\n10\n6 0\n-7 -7\n12 -2\n-4 9\n2... | 1,604,981,105 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 186 | 0 | n, m = map(int, input().split())
x, y = map(int, input().split())
length = int(input())
steps = 0
for i in range(length):
dx, dy = map(int, input().split())
while y + dy>=1 and y + dy<=n and dx + x>=1 and dx + x<=m:
x+= dx
y+= dy
steps+=1
print(steps)
| Title: Steps
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
One day Vasya went out for a walk in the yard but there weren't any of his friends outside and he had no one to play touch and run. But the boy didn't lose the high spirits and decided to play touch and run with himself. You may ... | ```python
n, m = map(int, input().split())
x, y = map(int, input().split())
length = int(input())
steps = 0
for i in range(length):
dx, dy = map(int, input().split())
while y + dy>=1 and y + dy<=n and dx + x>=1 and dx + x<=m:
x+= dx
y+= dy
steps+=1
print(steps)
``` | 0 | |
295 | A | Greg and Array | PROGRAMMING | 1,400 | [
"data structures",
"implementation"
] | null | null | Greg has an array *a*<==<=*a*1,<=*a*2,<=...,<=*a**n* and *m* operations. Each operation looks as: *l**i*, *r**i*, *d**i*, (1<=≤<=*l**i*<=≤<=*r**i*<=≤<=*n*). To apply operation *i* to the array means to increase all array elements with numbers *l**i*,<=*l**i*<=+<=1,<=...,<=*r**i* by value *d**i*.
Greg wrote down *k* qu... | The first line contains integers *n*, *m*, *k* (1<=≤<=*n*,<=*m*,<=*k*<=≤<=105). The second line contains *n* integers: *a*1,<=*a*2,<=...,<=*a**n* (0<=≤<=*a**i*<=≤<=105) — the initial array.
Next *m* lines contain operations, the operation number *i* is written as three integers: *l**i*, *r**i*, *d**i*, (1<=≤<=*l**i*<=... | On a single line print *n* integers *a*1,<=*a*2,<=...,<=*a**n* — the array after executing all the queries. Separate the printed numbers by spaces.
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 of the %I64d specifier. | [
"3 3 3\n1 2 3\n1 2 1\n1 3 2\n2 3 4\n1 2\n1 3\n2 3\n",
"1 1 1\n1\n1 1 1\n1 1\n",
"4 3 6\n1 2 3 4\n1 2 1\n2 3 2\n3 4 4\n1 2\n1 3\n2 3\n1 2\n1 3\n2 3\n"
] | [
"9 18 17\n",
"2\n",
"5 18 31 20\n"
] | none | 500 | [
{
"input": "3 3 3\n1 2 3\n1 2 1\n1 3 2\n2 3 4\n1 2\n1 3\n2 3",
"output": "9 18 17"
},
{
"input": "1 1 1\n1\n1 1 1\n1 1",
"output": "2"
},
{
"input": "4 3 6\n1 2 3 4\n1 2 1\n2 3 2\n3 4 4\n1 2\n1 3\n2 3\n1 2\n1 3\n2 3",
"output": "5 18 31 20"
},
{
"input": "1 1 1\n0\n1 1 0\n1 1... | 1,649,032,935 | 2,147,483,647 | Python 3 | COMPILATION_ERROR | TESTS | 0 | 0 | 0 | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int m = scan.nextInt();
int k = scan.nextInt();
long[] arr = new long[n + 1];
for (int i = 0; i < n; i++) {
... | Title: Greg and Array
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Greg has an array *a*<==<=*a*1,<=*a*2,<=...,<=*a**n* and *m* operations. Each operation looks as: *l**i*, *r**i*, *d**i*, (1<=≤<=*l**i*<=≤<=*r**i*<=≤<=*n*). To apply operation *i* to the array means to increase all array... | ```python
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int m = scan.nextInt();
int k = scan.nextInt();
long[] arr = new long[n + 1];
for (int i = 0; i < n; i++)... | -1 | |
320 | B | Ping-Pong (Easy Version) | PROGRAMMING | 1,500 | [
"dfs and similar",
"graphs"
] | null | null | In this problem at each moment you have a set of intervals. You can move from interval (*a*,<=*b*) from our set to interval (*c*,<=*d*) from our set if and only if *c*<=<<=*a*<=<<=*d* or *c*<=<<=*b*<=<<=*d*. Also there is a path from interval *I*1 from our set to interval *I*2 from our set if there is a seq... | The first line of the input contains integer *n* denoting the number of queries, (1<=≤<=*n*<=≤<=100). Each of the following lines contains a query as described above. All numbers in the input are integers and don't exceed 109 by their absolute value.
It's guaranteed that all queries are correct. | For each query of the second type print "YES" or "NO" on a separate line depending on the answer. | [
"5\n1 1 5\n1 5 11\n2 1 2\n1 2 9\n2 1 2\n"
] | [
"NO\nYES\n"
] | none | 1,000 | [
{
"input": "5\n1 1 5\n1 5 11\n2 1 2\n1 2 9\n2 1 2",
"output": "NO\nYES"
},
{
"input": "10\n1 -311 -186\n1 -1070 -341\n1 -1506 -634\n1 688 1698\n2 2 4\n1 70 1908\n2 1 2\n2 2 4\n1 -1053 1327\n2 5 4",
"output": "NO\nNO\nNO\nYES"
},
{
"input": "10\n1 -1365 -865\n1 1244 1834\n2 1 2\n1 -1508 -... | 1,621,488,090 | 2,147,483,647 | Python 3 | OK | TESTS | 24 | 154 | 0 |
n = 0;
def dfs(i):
vis[i] = 1;
for k in range(n+1):
if vis[k] == 1:
continue;
if (a[i] > a[k] and a[i] < b[k]):
dfs(k);
elif(b[i] > a[k] and b[i] < b[k]):
dfs(k);
k = int(input());
a = [0 for i in range(k+1)]
b =... | Title: Ping-Pong (Easy Version)
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
In this problem at each moment you have a set of intervals. You can move from interval (*a*,<=*b*) from our set to interval (*c*,<=*d*) from our set if and only if *c*<=<<=*a*<=<<=*d* or *c*<=<<=*b*<=&... | ```python
n = 0;
def dfs(i):
vis[i] = 1;
for k in range(n+1):
if vis[k] == 1:
continue;
if (a[i] > a[k] and a[i] < b[k]):
dfs(k);
elif(b[i] > a[k] and b[i] < b[k]):
dfs(k);
k = int(input());
a = [0 for i in range(... | 3 | |
25 | A | IQ test | PROGRAMMING | 1,300 | [
"brute force"
] | A. IQ test | 2 | 256 | Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given *n* numbers differs from the others. Bob observed that one number usually differs from the others in evenness. Help Bob — to check his answers, he needs a program that among the given *n* numbers finds one that i... | The first line contains integer *n* (3<=≤<=*n*<=≤<=100) — amount of numbers in the task. The second line contains *n* space-separated natural numbers, not exceeding 100. It is guaranteed, that exactly one of these numbers differs from the others in evenness. | Output index of number that differs from the others in evenness. Numbers are numbered from 1 in the input order. | [
"5\n2 4 7 8 10\n",
"4\n1 2 1 1\n"
] | [
"3\n",
"2\n"
] | none | 0 | [
{
"input": "5\n2 4 7 8 10",
"output": "3"
},
{
"input": "4\n1 2 1 1",
"output": "2"
},
{
"input": "3\n1 2 2",
"output": "1"
},
{
"input": "3\n100 99 100",
"output": "2"
},
{
"input": "3\n5 3 2",
"output": "3"
},
{
"input": "4\n43 28 1 91",
"output"... | 1,625,172,778 | 2,147,483,647 | Python 3 | OK | TESTS | 32 | 154 | 0 | n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n):
b.append(a[i] % 2)
for i in range(len(b)-1):
if b[i] != b[i+1] and b.count(b[i]) == 1:
print(i + 1)
exit()
print(len(b))
| Title: IQ test
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given *n* numbers differs from the others. Bob observed that one number usually differs from the others in evenness. Help Bob — t... | ```python
n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n):
b.append(a[i] % 2)
for i in range(len(b)-1):
if b[i] != b[i+1] and b.count(b[i]) == 1:
print(i + 1)
exit()
print(len(b))
``` | 3.9615 |
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,661,807,493 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 30 | 0 | import numpy as np
n = int(input())
l = [0]*3
x = [0]*3
for i in range(n):
l=list(map(lambda x,y:x+y,l,list(map(int,input().split()))))
if l==x:
print("YES")
else:
print("NO")
| 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
import numpy as np
n = int(input())
l = [0]*3
x = [0]*3
for i in range(n):
l=list(map(lambda x,y:x+y,l,list(map(int,input().split()))))
if l==x:
print("YES")
else:
print("NO")
``` | -1 |
350 | A | TL | PROGRAMMING | 1,200 | [
"brute force",
"greedy",
"implementation"
] | null | null | Valera wanted to prepare a Codesecrof round. He's already got one problem and he wants to set a time limit (TL) on it.
Valera has written *n* correct solutions. For each correct solution, he knows its running time (in seconds). Valera has also wrote *m* wrong solutions and for each wrong solution he knows its running ... | The first line contains two integers *n*, *m* (1<=≤<=*n*,<=*m*<=≤<=100). The second line contains *n* space-separated positive integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=100) — the running time of each of the *n* correct solutions in seconds. The third line contains *m* space-separated positive integers *b*1... | If there is a valid TL value, print it. Otherwise, print -1. | [
"3 6\n4 5 2\n8 9 6 10 7 11\n",
"3 1\n3 4 5\n6\n"
] | [
"5",
"-1\n"
] | none | 500 | [
{
"input": "3 6\n4 5 2\n8 9 6 10 7 11",
"output": "5"
},
{
"input": "3 1\n3 4 5\n6",
"output": "-1"
},
{
"input": "2 5\n45 99\n49 41 77 83 45",
"output": "-1"
},
{
"input": "50 50\n18 13 5 34 10 36 36 12 15 11 16 17 14 36 23 45 32 24 31 18 24 32 7 1 31 3 49 8 16 23 3 39 47 43... | 1,435,334,578 | 2,147,483,647 | Python 3 | OK | TESTS | 45 | 122 | 0 | input()
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
v, p, q = min(a), max(a), min(b)
ans = max(2 * v, p)
print(ans if q > ans else -1)
| Title: TL
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Valera wanted to prepare a Codesecrof round. He's already got one problem and he wants to set a time limit (TL) on it.
Valera has written *n* correct solutions. For each correct solution, he knows its running time (in seconds). Val... | ```python
input()
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
v, p, q = min(a), max(a), min(b)
ans = max(2 * v, p)
print(ans if q > ans else -1)
``` | 3 | |
52 | A | 123-sequence | PROGRAMMING | 900 | [
"implementation"
] | A. 123-sequence | 2 | 256 | There is a given sequence of integers *a*1,<=*a*2,<=...,<=*a**n*, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. | The first line contains an integer *n* (1<=≤<=*n*<=≤<=106). The second line contains a sequence of integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=3). | Print the minimum number of replacements needed to be performed to make all the numbers in the sequence equal. | [
"9\n1 3 2 2 2 1 1 2 3\n"
] | [
"5\n"
] | In the example all the numbers equal to 1 and 3 should be replaced by 2. | 500 | [
{
"input": "9\n1 3 2 2 2 1 1 2 3",
"output": "5"
},
{
"input": "6\n3 3 2 2 1 3",
"output": "3"
},
{
"input": "12\n3 1 3 1 2 1 3 2 2 1 2 1",
"output": "7"
},
{
"input": "15\n3 2 1 1 1 1 3 2 2 3 3 1 2 3 2",
"output": "10"
},
{
"input": "2\n2 1",
"output": "1"
... | 1,695,534,001 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 23 | 1,122 | 98,611,200 | n=int(input())
l=list(map(int,input().split()))
print(min((l.count(1)+l.count(3)),(l.count(1)+l.count(2)),(l.count(2)+l.count(3))))
| Title: 123-sequence
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
There is a given sequence of integers *a*1,<=*a*2,<=...,<=*a**n*, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each... | ```python
n=int(input())
l=list(map(int,input().split()))
print(min((l.count(1)+l.count(3)),(l.count(1)+l.count(2)),(l.count(2)+l.count(3))))
``` | 3.535822 |
0 | none | none | none | 0 | [
"none"
] | null | null | You are given an *n*<=×<=*m* rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the table
we obtain the table:
A table is called... | The first line contains two integers — *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=100).
Next *n* lines contain *m* small English letters each — the characters of the table. | Print a single number — the minimum number of columns that you need to remove in order to make the table good. | [
"1 10\ncodeforces\n",
"4 4\ncase\ncare\ntest\ncode\n",
"5 4\ncode\nforc\nesco\ndefo\nrces\n"
] | [
"0\n",
"2\n",
"4\n"
] | In the first sample the table is already good.
In the second sample you may remove the first and third column.
In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).
Let strings *s* and *t* have equal length. Then, *s* is lexicographica... | 0 | [
{
"input": "1 10\ncodeforces",
"output": "0"
},
{
"input": "4 4\ncase\ncare\ntest\ncode",
"output": "2"
},
{
"input": "5 4\ncode\nforc\nesco\ndefo\nrces",
"output": "4"
},
{
"input": "2 2\nfb\nye",
"output": "0"
},
{
"input": "5 5\nrzrzh\nrzrzh\nrzrzh\nrzrzh\nrzrz... | 1,689,336,186 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 0 | 31 | 0 | print("_RANDOM_GUESS_1689336185.798442")# 1689336185.798464 | Title: none
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given an *n*<=×<=*m* rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, afte... | ```python
print("_RANDOM_GUESS_1689336185.798442")# 1689336185.798464
``` | 0 | |
772 | A | Voltage Keepsake | PROGRAMMING | 1,800 | [
"binary search",
"math"
] | null | null | You have *n* devices that you want to use simultaneously.
The *i*-th device uses *a**i* units of power per second. This usage is continuous. That is, in λ seconds, the device will use λ·*a**i* units of power. The *i*-th device currently has *b**i* units of power stored. All devices can store an arbitrary amount of pow... | The first line contains two integers, *n* and *p* (1<=≤<=*n*<=≤<=100<=000, 1<=≤<=*p*<=≤<=109) — the number of devices and the power of the charger.
This is followed by *n* lines which contain two integers each. Line *i* contains the integers *a**i* and *b**i* (1<=≤<=*a**i*,<=*b**i*<=≤<=100<=000) — the power of the dev... | If you can use the devices indefinitely, print -1. Otherwise, print the maximum amount of time before any one device hits 0 power.
Your answer will be considered correct if its absolute or relative error does not exceed 10<=-<=4.
Namely, let's assume that your answer is *a* and the answer of the jury is *b*. The chec... | [
"2 1\n2 2\n2 1000\n",
"1 100\n1 1\n",
"3 5\n4 3\n5 2\n6 1\n"
] | [
"2.0000000000",
"-1\n",
"0.5000000000"
] | In sample test 1, you can charge the first device for the entire time until it hits zero power. The second device has enough power to last this time without being charged.
In sample test 2, you can use the device indefinitely.
In sample test 3, we can charge the third device for 2 / 5 of a second, then switch to char... | 500 | [
{
"input": "2 1\n2 2\n2 1000",
"output": "2.0000000000"
},
{
"input": "1 100\n1 1",
"output": "-1"
},
{
"input": "3 5\n4 3\n5 2\n6 1",
"output": "0.5000000000"
},
{
"input": "1 1\n1 87",
"output": "-1"
},
{
"input": "1 1\n100 77",
"output": "0.7777777778"
},... | 1,696,479,639 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 31 | 0 | n, x = map(int, input().split())
sas1 = -x
bob1 = 0
de1 = [list(map(int, input().split())) for _ in range(n)]
for i in de:
sas1 += i[0]
bob1 += i[1]
de.sort(key=lambda k: k[0] / k[1])
for d, e in de:
if bob1 * d < sas1 * e:
sas1 -= d
bob1 -= e
print(bob / sas if sas > 0 else -1)
... | Title: Voltage Keepsake
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You have *n* devices that you want to use simultaneously.
The *i*-th device uses *a**i* units of power per second. This usage is continuous. That is, in λ seconds, the device will use λ·*a**i* units of power. The *i*-... | ```python
n, x = map(int, input().split())
sas1 = -x
bob1 = 0
de1 = [list(map(int, input().split())) for _ in range(n)]
for i in de:
sas1 += i[0]
bob1 += i[1]
de.sort(key=lambda k: k[0] / k[1])
for d, e in de:
if bob1 * d < sas1 * e:
sas1 -= d
bob1 -= e
print(bob / sas if sas > 0 else -1... | -1 | |
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,654,442,356 | 2,147,483,647 | Python 3 | OK | TESTS | 52 | 92 | 0 | n = int(input())
values = input().split()
a = []
all_s = 0
for i in range(n):
s = int(values[i])
a.append(s)
all_s += s
c = 0
for i in range(n):
if (all_s - a[i])%2 == 0:
c += 1
print(c) | 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())
values = input().split()
a = []
all_s = 0
for i in range(n):
s = int(values[i])
a.append(s)
all_s += s
c = 0
for i in range(n):
if (all_s - a[i])%2 == 0:
c += 1
print(c)
``` | 3 | |
638 | A | Home Numbers | PROGRAMMING | 1,100 | [
"*special",
"constructive algorithms",
"math"
] | null | null | The main street of Berland is a straight line with *n* houses built along it (*n* is an even number). The houses are located at both sides of the street. The houses with odd numbers are at one side of the street and are numbered from 1 to *n*<=-<=1 in the order from the beginning of the street to the end (in the pictur... | The first line of the input contains two integers, *n* and *a* (1<=≤<=*a*<=≤<=*n*<=≤<=100<=000) — the number of houses on the street and the number of the house that Vasya needs to reach, correspondingly. It is guaranteed that number *n* is even. | Print a single integer — the minimum time Vasya needs to get from the beginning of the street to house *a*. | [
"4 2\n",
"8 5\n"
] | [
"2\n",
"3\n"
] | In the first sample there are only four houses on the street, two houses at each side. House 2 will be the last at Vasya's right.
The second sample corresponds to picture with *n* = 8. House 5 is the one before last at Vasya's left. | 500 | [
{
"input": "4 2",
"output": "2"
},
{
"input": "8 5",
"output": "3"
},
{
"input": "2 1",
"output": "1"
},
{
"input": "2 2",
"output": "1"
},
{
"input": "10 1",
"output": "1"
},
{
"input": "10 10",
"output": "1"
},
{
"input": "100000 100000",... | 1,696,142,973 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 2 | 77 | 0 | n,a=map(int,input().split())
if a%2==0:
print(1+int((n-a)/2))
else:
print(1+int((n-a+1)/2)) | Title: Home Numbers
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The main street of Berland is a straight line with *n* houses built along it (*n* is an even number). The houses are located at both sides of the street. The houses with odd numbers are at one side of the street and are nu... | ```python
n,a=map(int,input().split())
if a%2==0:
print(1+int((n-a)/2))
else:
print(1+int((n-a+1)/2))
``` | 0 | |
577 | A | Multiplication Table | PROGRAMMING | 1,000 | [
"implementation",
"number theory"
] | null | null | Let's consider a table consisting of *n* rows and *n* columns. The cell located at the intersection of *i*-th row and *j*-th column contains number *i*<=×<=*j*. The rows and columns are numbered starting from 1.
You are given a positive integer *x*. Your task is to count the number of cells in a table that contain num... | The single line contains numbers *n* and *x* (1<=≤<=*n*<=≤<=105, 1<=≤<=*x*<=≤<=109) — the size of the table and the number that we are looking for in the table. | Print a single number: the number of times *x* occurs in the table. | [
"10 5\n",
"6 12\n",
"5 13\n"
] | [
"2\n",
"4\n",
"0\n"
] | A table for the second sample test is given below. The occurrences of number 12 are marked bold. | 500 | [
{
"input": "10 5",
"output": "2"
},
{
"input": "6 12",
"output": "4"
},
{
"input": "5 13",
"output": "0"
},
{
"input": "1 1",
"output": "1"
},
{
"input": "2 1",
"output": "1"
},
{
"input": "100000 1",
"output": "1"
},
{
"input": "1 10000000... | 1,651,265,608 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 3 | 30 | 0 | line2=input()
line2=line2.split()
x=int(line2[0])
y=int(line2[1])
c=0
u=int(min(x,y))
for i in range(int(u/2)):
if(y%(i+1)==0):
t=y/(i+1)
if(t<=x and (i+1)<=x):
c=c+2
print(c) | Title: Multiplication Table
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Let's consider a table consisting of *n* rows and *n* columns. The cell located at the intersection of *i*-th row and *j*-th column contains number *i*<=×<=*j*. The rows and columns are numbered starting from 1.
Y... | ```python
line2=input()
line2=line2.split()
x=int(line2[0])
y=int(line2[1])
c=0
u=int(min(x,y))
for i in range(int(u/2)):
if(y%(i+1)==0):
t=y/(i+1)
if(t<=x and (i+1)<=x):
c=c+2
print(c)
``` | 0 | |
79 | B | Colorful Field | PROGRAMMING | 1,400 | [
"implementation",
"sortings"
] | B. Colorful Field | 2 | 256 | Fox Ciel saw a large field while she was on a bus. The field was a *n*<=×<=*m* rectangle divided into 1<=×<=1 cells. Some cells were wasteland, and other each cell contained crop plants: either carrots or kiwis or grapes.
After seeing the field carefully, Ciel found that the crop plants of each cell were planted in f... | In the first line there are four positive integers *n*,<=*m*,<=*k*,<=*t* (1<=≤<=*n*<=≤<=4·104,<=1<=≤<=*m*<=≤<=4·104,<=1<=≤<=*k*<=≤<=103,<=1<=≤<=*t*<=≤<=103), each of which represents the height of the field, the width of the field, the number of waste cells and the number of queries that ask the kind of crop plants in ... | For each query, if the cell is waste, print Waste. Otherwise, print the name of crop plants in the cell: either Carrots or Kiwis or Grapes. | [
"4 5 5 6\n4 3\n1 3\n3 3\n2 5\n3 2\n1 3\n1 4\n2 3\n2 4\n1 1\n1 1\n"
] | [
"Waste\nGrapes\nCarrots\nKiwis\nCarrots\nCarrots\n"
] | The sample corresponds to the figure in the statement. | 1,000 | [
{
"input": "4 5 5 6\n4 3\n1 3\n3 3\n2 5\n3 2\n1 3\n1 4\n2 3\n2 4\n1 1\n1 1",
"output": "Waste\nGrapes\nCarrots\nKiwis\nCarrots\nCarrots"
},
{
"input": "2 3 2 2\n1 1\n2 2\n2 1\n2 2",
"output": "Grapes\nWaste"
},
{
"input": "31 31 31 4\n4 9\n16 27\n11 29\n8 28\n11 2\n10 7\n22 6\n1 25\n14 8... | 1,630,332,405 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 1 | 186 | 20,172,800 | n,m,k,t = map(int, input().split())
waste, qry = [], []
a,b = 0,0
for _ in range(k):
a, b = map(int, input().split())
waste.append(m*(a-1)+b)
for i in range(t):
a, b = map(int, input().split())
qry.append([m*(a-1)+b, i])
ans = ['']*(t)
waste.sort()
qry.sort()
d = {0: "Carrots", 1: ... | Title: Colorful Field
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Fox Ciel saw a large field while she was on a bus. The field was a *n*<=×<=*m* rectangle divided into 1<=×<=1 cells. Some cells were wasteland, and other each cell contained crop plants: either carrots or kiwis or grapes.
... | ```python
n,m,k,t = map(int, input().split())
waste, qry = [], []
a,b = 0,0
for _ in range(k):
a, b = map(int, input().split())
waste.append(m*(a-1)+b)
for i in range(t):
a, b = map(int, input().split())
qry.append([m*(a-1)+b, i])
ans = ['']*(t)
waste.sort()
qry.sort()
d = {0: "Car... | 0 |
82 | A | Double Cola | PROGRAMMING | 1,100 | [
"implementation",
"math"
] | A. Double Cola | 1 | 256 | Sheldon, Leonard, Penny, Rajesh and Howard are in the queue for a "Double Cola" drink vending machine; there are no other people in the queue. The first one in the queue (Sheldon) buys a can, drinks it and doubles! The resulting two Sheldons go to the end of the queue. Then the next in the queue (Leonard) buys a can, d... | The input data consist of a single integer *n* (1<=≤<=*n*<=≤<=109).
It is guaranteed that the pretests check the spelling of all the five names, that is, that they contain all the five possible answers. | Print the single line — the name of the person who drinks the *n*-th can of cola. The cans are numbered starting from 1. Please note that you should spell the names like this: "Sheldon", "Leonard", "Penny", "Rajesh", "Howard" (without the quotes). In that order precisely the friends are in the queue initially. | [
"1\n",
"6\n",
"1802\n"
] | [
"Sheldon\n",
"Sheldon\n",
"Penny\n"
] | none | 500 | [
{
"input": "1",
"output": "Sheldon"
},
{
"input": "6",
"output": "Sheldon"
},
{
"input": "1802",
"output": "Penny"
},
{
"input": "1",
"output": "Sheldon"
},
{
"input": "2",
"output": "Leonard"
},
{
"input": "3",
"output": "Penny"
},
{
"inpu... | 1,460,545,976 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 61 | 0 | n = "Sheldon,Leonard,Penny,Rajesh,Howard".split(",")
print(n[ int(input())%6]) | Title: Double Cola
Time Limit: 1 seconds
Memory Limit: 256 megabytes
Problem Description:
Sheldon, Leonard, Penny, Rajesh and Howard are in the queue for a "Double Cola" drink vending machine; there are no other people in the queue. The first one in the queue (Sheldon) buys a can, drinks it and doubles! The resultin... | ```python
n = "Sheldon,Leonard,Penny,Rajesh,Howard".split(",")
print(n[ int(input())%6])
``` | 0 |
327 | A | Flipping Game | PROGRAMMING | 1,200 | [
"brute force",
"dp",
"implementation"
] | null | null | Iahub got bored, so he invented a game to be played on paper.
He writes *n* integers *a*1,<=*a*2,<=...,<=*a**n*. Each of those integers can be either 0 or 1. He's allowed to do exactly one move: he chooses two indices *i* and *j* (1<=≤<=*i*<=≤<=*j*<=≤<=*n*) and flips all values *a**k* for which their positions are in... | The first line of the input contains an integer *n* (1<=≤<=*n*<=≤<=100). In the second line of the input there are *n* integers: *a*1,<=*a*2,<=...,<=*a**n*. It is guaranteed that each of those *n* values is either 0 or 1. | Print an integer — the maximal number of 1s that can be obtained after exactly one move. | [
"5\n1 0 0 1 0\n",
"4\n1 0 0 1\n"
] | [
"4\n",
"4\n"
] | In the first case, flip the segment from 2 to 5 (*i* = 2, *j* = 5). That flip changes the sequence, it becomes: [1 1 1 0 1]. So, it contains four ones. There is no way to make the whole sequence equal to [1 1 1 1 1].
In the second case, flipping only the second and the third element (*i* = 2, *j* = 3) will turn all nu... | 500 | [
{
"input": "5\n1 0 0 1 0",
"output": "4"
},
{
"input": "4\n1 0 0 1",
"output": "4"
},
{
"input": "1\n1",
"output": "0"
},
{
"input": "1\n0",
"output": "1"
},
{
"input": "8\n1 0 0 0 1 0 0 0",
"output": "7"
},
{
"input": "18\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... | 1,674,617,031 | 2,147,483,647 | Python 3 | OK | TESTS | 21 | 154 | 0 | n=int(input())
a=list(map(int,input().split()))
summ=[]
summ.append(0)
maxsumm=0
count=1
window=1
b=a.copy()
for i in range(0,n,1):
for j in range(0,n-i,1):
b=a.copy()
for k in range(j,j+window,1):
if b[k]==1:
b[k]=0
else:
b[k]=1... | Title: Flipping Game
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Iahub got bored, so he invented a game to be played on paper.
He writes *n* integers *a*1,<=*a*2,<=...,<=*a**n*. Each of those integers can be either 0 or 1. He's allowed to do exactly one move: he chooses two indices *... | ```python
n=int(input())
a=list(map(int,input().split()))
summ=[]
summ.append(0)
maxsumm=0
count=1
window=1
b=a.copy()
for i in range(0,n,1):
for j in range(0,n-i,1):
b=a.copy()
for k in range(j,j+window,1):
if b[k]==1:
b[k]=0
else:
... | 3 | |
171 | F | ucyhf | PROGRAMMING | 1,600 | [
"*special",
"brute force",
"implementation",
"number theory"
] | null | null | qd ucyhf yi q fhycu dkcruh mxeiu huluhiu yi q tyvvuhudj fhycu dkcruh. oekh jqia yi je vydt jxu djx ucyhf. | jxu ydfkj sediyiji ev q iydwbu ydjuwuh *d* (1<=≤<=*d*<=≤<=11184) — jxu edu-rqiut ydtun ev jxu ucyhf je vydt. | ekjfkj q iydwbu dkcruh. | [
"1\n"
] | [
"13\n"
] | none | 0 | [
{
"input": "1",
"output": "13"
},
{
"input": "2",
"output": "17"
},
{
"input": "3",
"output": "31"
},
{
"input": "4",
"output": "37"
},
{
"input": "5",
"output": "71"
},
{
"input": "6",
"output": "73"
},
{
"input": "7",
"output": "79"
... | 1,621,654,894 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 10 | 746 | 1,228,800 | def process(n):
prime_set = set([])
primes = []
for p in range(2, 2*10**5):
prime = True
for p2 in primes:
if p2*p2 > p:
break
if p % p2==0:
prime = False
break
if prime:
prime_set.add(str... | Title: ucyhf
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
qd ucyhf yi q fhycu dkcruh mxeiu huluhiu yi q tyvvuhudj fhycu dkcruh. oekh jqia yi je vydt jxu djx ucyhf.
Input Specification:
jxu ydfkj sediyiji ev q iydwbu ydjuwuh *d* (1<=≤<=*d*<=≤<=11184) — jxu edu-rqiut ydtun ev jxu ucyhf j... | ```python
def process(n):
prime_set = set([])
primes = []
for p in range(2, 2*10**5):
prime = True
for p2 in primes:
if p2*p2 > p:
break
if p % p2==0:
prime = False
break
if prime:
prime_s... | -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,689,695,340 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 41 | 62 | 0 | n = int(input())
print(n//2)
if n%2:
print((n-2)//2*"2 ",end="")
print("3",end="")
else:
print((n-2)//2*"2 ",end="")
print("2",end="") | 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
n = int(input())
print(n//2)
if n%2:
print((n-2)//2*"2 ",end="")
print("3",end="")
else:
print((n-2)//2*"2 ",end="")
print("2",end="")
``` | 3 | |
32 | B | Borze | PROGRAMMING | 800 | [
"expression parsing",
"implementation"
] | B. Borze | 2 | 256 | Ternary numeric notation is quite popular in Berland. To telegraph the ternary number the Borze alphabet is used. Digit 0 is transmitted as «.», 1 as «-.» and 2 as «--». You are to decode the Borze code, i.e. to find out the ternary number given its representation in Borze alphabet. | The first line contains a number in Borze code. The length of the string is between 1 and 200 characters. It's guaranteed that the given string is a valid Borze code of some ternary number (this number can have leading zeroes). | Output the decoded ternary number. It can have leading zeroes. | [
".-.--\n",
"--.\n",
"-..-.--\n"
] | [
"012",
"20",
"1012"
] | none | 1,000 | [
{
"input": ".-.--",
"output": "012"
},
{
"input": "--.",
"output": "20"
},
{
"input": "-..-.--",
"output": "1012"
},
{
"input": "---..",
"output": "210"
},
{
"input": "..--.---..",
"output": "0020210"
},
{
"input": "-.....----.",
"output": "1000022... | 1,676,136,073 | 2,147,483,647 | Python 3 | OK | TESTS | 30 | 92 | 0 | code=list(input())
i=0
while i<len(code):
if code[i]=='-' and code[i+1]=='.':
print('1',end='')
i+=2
elif code[i]=='-' and code[i+1]=='-':
print('2',end='')
i+=2
else:
print('0',end='')
i+=1
print('\n') | Title: Borze
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Ternary numeric notation is quite popular in Berland. To telegraph the ternary number the Borze alphabet is used. Digit 0 is transmitted as «.», 1 as «-.» and 2 as «--». You are to decode the Borze code, i.e. to find out the ternary ... | ```python
code=list(input())
i=0
while i<len(code):
if code[i]=='-' and code[i+1]=='.':
print('1',end='')
i+=2
elif code[i]=='-' and code[i+1]=='-':
print('2',end='')
i+=2
else:
print('0',end='')
i+=1
print('\n')
``` | 3.977 |
294 | A | Shaass and Oskols | PROGRAMMING | 800 | [
"implementation",
"math"
] | null | null | Shaass has decided to hunt some birds. There are *n* horizontal electricity wires aligned parallel to each other. Wires are numbered 1 to *n* from top to bottom. On each wire there are some oskols sitting next to each other. Oskol is the name of a delicious kind of birds in Shaass's territory. Supposed there are *a**i*... | The first line of the input contains an integer *n*, (1<=≤<=*n*<=≤<=100). The next line contains a list of space-separated integers *a*1,<=*a*2,<=...,<=*a**n*, (0<=≤<=*a**i*<=≤<=100).
The third line contains an integer *m*, (0<=≤<=*m*<=≤<=100). Each of the next *m* lines contains two integers *x**i* and *y**i*. The i... | On the *i*-th line of the output print the number of birds on the *i*-th wire. | [
"5\n10 10 10 10 10\n5\n2 5\n3 13\n2 12\n1 13\n4 6\n",
"3\n2 4 1\n1\n2 2\n"
] | [
"0\n12\n5\n0\n16\n",
"3\n0\n3\n"
] | none | 500 | [
{
"input": "5\n10 10 10 10 10\n5\n2 5\n3 13\n2 12\n1 13\n4 6",
"output": "0\n12\n5\n0\n16"
},
{
"input": "3\n2 4 1\n1\n2 2",
"output": "3\n0\n3"
},
{
"input": "5\n58 51 45 27 48\n5\n4 9\n5 15\n4 5\n5 8\n1 43",
"output": "0\n66\n57\n7\n0"
},
{
"input": "10\n48 53 10 28 91 56 8... | 1,688,137,082 | 2,147,483,647 | Python 3 | OK | TESTS | 31 | 92 | 0 | n = int(input())
a = [int(i) for i in input().split()]
for _ in range(int(input())):
x, y = map(int, input().split())
if x != 1:
a[x - 2] += (y - 1)
if x != n:
a[x] += (a[x - 1] - y)
a[x - 1] = 0
for i in a:
print(i)
| Title: Shaass and Oskols
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Shaass has decided to hunt some birds. There are *n* horizontal electricity wires aligned parallel to each other. Wires are numbered 1 to *n* from top to bottom. On each wire there are some oskols sitting next to each... | ```python
n = int(input())
a = [int(i) for i in input().split()]
for _ in range(int(input())):
x, y = map(int, input().split())
if x != 1:
a[x - 2] += (y - 1)
if x != n:
a[x] += (a[x - 1] - y)
a[x - 1] = 0
for i in a:
print(i)
``` | 3 | |
71 | A | Way Too Long Words | PROGRAMMING | 800 | [
"strings"
] | A. Way Too Long Words | 1 | 256 | Sometimes some words like "localization" or "internationalization" are so long that writing them many times in one text is quite tiresome.
Let's consider a word too long, if its length is strictly more than 10 characters. All too long words should be replaced with a special abbreviation.
This abbreviation is made lik... | The first line contains an integer *n* (1<=≤<=*n*<=≤<=100). Each of the following *n* lines contains one word. All the words consist of lowercase Latin letters and possess the lengths of from 1 to 100 characters. | Print *n* lines. The *i*-th line should contain the result of replacing of the *i*-th word from the input data. | [
"4\nword\nlocalization\ninternationalization\npneumonoultramicroscopicsilicovolcanoconiosis\n"
] | [
"word\nl10n\ni18n\np43s\n"
] | none | 500 | [
{
"input": "4\nword\nlocalization\ninternationalization\npneumonoultramicroscopicsilicovolcanoconiosis",
"output": "word\nl10n\ni18n\np43s"
},
{
"input": "5\nabcdefgh\nabcdefghi\nabcdefghij\nabcdefghijk\nabcdefghijklm",
"output": "abcdefgh\nabcdefghi\nabcdefghij\na9k\na11m"
},
{
"input":... | 1,690,992,726 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 15 | 0 | a=int(input())
lst = []
for i in range(a):
m = input()
lst.append(m)
for i in lst:
if len(m)>10:
print(m[0]+str(len(m)-2)+m[len(m)-1])
else:
print(m)
| Title: Way Too Long Words
Time Limit: 1 seconds
Memory Limit: 256 megabytes
Problem Description:
Sometimes some words like "localization" or "internationalization" are so long that writing them many times in one text is quite tiresome.
Let's consider a word too long, if its length is strictly more than 10 character... | ```python
a=int(input())
lst = []
for i in range(a):
m = input()
lst.append(m)
for i in lst:
if len(m)>10:
print(m[0]+str(len(m)-2)+m[len(m)-1])
else:
print(m)
``` | 0 |
544 | A | Set of Strings | PROGRAMMING | 1,100 | [
"implementation",
"strings"
] | null | null | You are given a string *q*. A sequence of *k* strings *s*1,<=*s*2,<=...,<=*s**k* is called beautiful, if the concatenation of these strings is string *q* (formally, *s*1<=+<=*s*2<=+<=...<=+<=*s**k*<==<=*q*) and the first characters of these strings are distinct.
Find any beautiful sequence of strings or determine that... | The first line contains a positive integer *k* (1<=≤<=*k*<=≤<=26) — the number of strings that should be in a beautiful sequence.
The second line contains string *q*, consisting of lowercase Latin letters. The length of the string is within range from 1 to 100, inclusive. | If such sequence doesn't exist, then print in a single line "NO" (without the quotes). Otherwise, print in the first line "YES" (without the quotes) and in the next *k* lines print the beautiful sequence of strings *s*1,<=*s*2,<=...,<=*s**k*.
If there are multiple possible answers, print any of them. | [
"1\nabca\n",
"2\naaacas\n",
"4\nabc\n"
] | [
"YES\nabca\n",
"YES\naaa\ncas\n",
"NO\n"
] | In the second sample there are two possible answers: {"*aaaca*", "*s*"} and {"*aaa*", "*cas*"}. | 500 | [
{
"input": "1\nabca",
"output": "YES\nabca"
},
{
"input": "2\naaacas",
"output": "YES\naaa\ncas"
},
{
"input": "4\nabc",
"output": "NO"
},
{
"input": "3\nnddkhkhkdndknndkhrnhddkrdhrnrrnkkdnnndndrdhnknknhnrnnkrrdhrkhkrkhnkhkhhrhdnrndnknrrhdrdrkhdrkkhkrnkk",
"output": "YES\... | 1,604,431,075 | 2,147,483,647 | Python 3 | OK | TESTS | 33 | 109 | 307,200 | # The first line contains a positive integer k (1 ≤ k ≤ 26) — the number of strings that should be in a beautiful sequence.
# The second line contains string q, consisting of lowercase Latin letters. The length of the string is within range from 1 to 100, inclusive.
K = int(input())
Q = input()
chars = set... | Title: Set of Strings
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given a string *q*. A sequence of *k* strings *s*1,<=*s*2,<=...,<=*s**k* is called beautiful, if the concatenation of these strings is string *q* (formally, *s*1<=+<=*s*2<=+<=...<=+<=*s**k*<==<=*q*) and the first... | ```python
# The first line contains a positive integer k (1 ≤ k ≤ 26) — the number of strings that should be in a beautiful sequence.
# The second line contains string q, consisting of lowercase Latin letters. The length of the string is within range from 1 to 100, inclusive.
K = int(input())
Q = input()
c... | 3 | |
71 | A | Way Too Long Words | PROGRAMMING | 800 | [
"strings"
] | A. Way Too Long Words | 1 | 256 | Sometimes some words like "localization" or "internationalization" are so long that writing them many times in one text is quite tiresome.
Let's consider a word too long, if its length is strictly more than 10 characters. All too long words should be replaced with a special abbreviation.
This abbreviation is made lik... | The first line contains an integer *n* (1<=≤<=*n*<=≤<=100). Each of the following *n* lines contains one word. All the words consist of lowercase Latin letters and possess the lengths of from 1 to 100 characters. | Print *n* lines. The *i*-th line should contain the result of replacing of the *i*-th word from the input data. | [
"4\nword\nlocalization\ninternationalization\npneumonoultramicroscopicsilicovolcanoconiosis\n"
] | [
"word\nl10n\ni18n\np43s\n"
] | none | 500 | [
{
"input": "4\nword\nlocalization\ninternationalization\npneumonoultramicroscopicsilicovolcanoconiosis",
"output": "word\nl10n\ni18n\np43s"
},
{
"input": "5\nabcdefgh\nabcdefghi\nabcdefghij\nabcdefghijk\nabcdefghijklm",
"output": "abcdefgh\nabcdefghi\nabcdefghij\na9k\na11m"
},
{
"input":... | 1,691,179,956 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 15 | 0 | x = input()
while True:
if len(x) > 10:
y = (len(x)-2)
a,z = (x[0], x[-1])
print(f"{a}{y}{z}")
break
elif len(x) <= 10:
print(x)
break
pneumonoultramicroscopicsilicovolcanoconiosis
| Title: Way Too Long Words
Time Limit: 1 seconds
Memory Limit: 256 megabytes
Problem Description:
Sometimes some words like "localization" or "internationalization" are so long that writing them many times in one text is quite tiresome.
Let's consider a word too long, if its length is strictly more than 10 character... | ```python
x = input()
while True:
if len(x) > 10:
y = (len(x)-2)
a,z = (x[0], x[-1])
print(f"{a}{y}{z}")
break
elif len(x) <= 10:
print(x)
break
pneumonoultramicroscopicsilicovolcanoconiosis
``` | 0 |
357 | B | Flag Day | PROGRAMMING | 1,400 | [
"constructive algorithms",
"implementation"
] | null | null | In Berland, there is the national holiday coming — the Flag Day. In the honor of this event the president of the country decided to make a big dance party and asked your agency to organize it. He has several conditions:
- overall, there must be *m* dances;- exactly three people must take part in each dance;- each d... | The first line contains two space-separated integers *n* (3<=≤<=*n*<=≤<=105) and *m* (1<=≤<=*m*<=≤<=105) — the number of dancers and the number of dances, correspondingly. Then *m* lines follow, describing the dances in the order of dancing them. The *i*-th line contains three distinct integers — the numbers of the dan... | Print *n* space-separated integers: the *i*-th number must represent the color of the *i*-th dancer's clothes (1 for white, 2 for red, 3 for blue). If there are multiple valid solutions, print any of them. It is guaranteed that at least one solution exists. | [
"7 3\n1 2 3\n1 4 5\n4 6 7\n",
"9 3\n3 6 9\n2 5 8\n1 4 7\n",
"5 2\n4 1 5\n3 1 2\n"
] | [
"1 2 3 3 2 2 1 \n",
"1 1 1 2 2 2 3 3 3 \n",
"2 3 1 1 3 \n"
] | none | 1,000 | [
{
"input": "7 3\n1 2 3\n1 4 5\n4 6 7",
"output": "1 2 3 3 2 2 1 "
},
{
"input": "9 3\n3 6 9\n2 5 8\n1 4 7",
"output": "1 1 1 2 2 2 3 3 3 "
},
{
"input": "5 2\n4 1 5\n3 1 2",
"output": "2 3 1 1 3 "
},
{
"input": "14 5\n1 5 3\n13 10 11\n6 3 8\n14 9 2\n7 4 12",
"output": "1 ... | 1,591,080,645 | 2,147,483,647 | Python 3 | OK | TESTS | 63 | 514 | 10,035,200 | n,m=map(int,input().split())
li=[]
for i in range(m):
li.append([int(x) for x in input().split()])
d={}
for i in range(m):
x=li[i]
use=[True]*3
l=[]
for ele in x:
if d.get(ele,0)!=0:
use[d.get(ele)-1]=False
for i in range(3):
if use[i]==True:
... | Title: Flag Day
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
In Berland, there is the national holiday coming — the Flag Day. In the honor of this event the president of the country decided to make a big dance party and asked your agency to organize it. He has several conditions:
- ov... | ```python
n,m=map(int,input().split())
li=[]
for i in range(m):
li.append([int(x) for x in input().split()])
d={}
for i in range(m):
x=li[i]
use=[True]*3
l=[]
for ele in x:
if d.get(ele,0)!=0:
use[d.get(ele)-1]=False
for i in range(3):
if use[i]==True:
... | 3 | |
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,632,186,434 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 2 | 92 | 6,656,000 | n = int(input())
v = input().split(" ")
for i in range(0, n):
v[i] = int(v[i])
v = set(v)
v.discard(min(v))
print(min(v))
| 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())
v = input().split(" ")
for i in range(0, n):
v[i] = int(v[i])
v = set(v)
v.discard(min(v))
print(min(v))
``` | -1 |
1,005 | B | Delete from the Left | PROGRAMMING | 900 | [
"brute force",
"implementation",
"strings"
] | null | null | You are given two strings $s$ and $t$. In a single move, you can choose any of two strings and delete the first (that is, the leftmost) character. After a move, the length of the string decreases by $1$. You can't choose a string if it is empty.
For example:
- by applying a move to the string "where", the result is ... | The first line of the input contains $s$. In the second line of the input contains $t$. Both strings consist only of lowercase Latin letters. The number of letters in each string is between 1 and $2\cdot10^5$, inclusive. | Output the fewest number of moves required. It is possible that, in the end, both strings will be equal to the empty string, and so, are equal to each other. In this case, the answer is obviously the sum of the lengths of the given strings. | [
"test\nwest\n",
"codeforces\nyes\n",
"test\nyes\n",
"b\nab\n"
] | [
"2\n",
"9\n",
"7\n",
"1\n"
] | In the first example, you should apply the move once to the first string and apply the move once to the second string. As a result, both strings will be equal to "est".
In the second example, the move should be applied to the string "codeforces" $8$ times. As a result, the string becomes "codeforces" $\to$ "es". The m... | 0 | [
{
"input": "test\nwest",
"output": "2"
},
{
"input": "codeforces\nyes",
"output": "9"
},
{
"input": "test\nyes",
"output": "7"
},
{
"input": "b\nab",
"output": "1"
},
{
"input": "z\nz",
"output": "0"
},
{
"input": "abacabadabacaba\nabacabadacaba",
... | 1,689,355,257 | 2,147,483,647 | Python 3 | OK | TESTS | 28 | 93 | 819,200 | s1=input()
s2=input()
num=len(s1)+len(s2)
i=len(s1)-1
j=len(s2)-1
dl=0
while(s1[i]==s2[j]) and i>=0 and j>=0:
dl+=2
i-=1
j-=1
print(num-dl) | Title: Delete from the Left
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given two strings $s$ and $t$. In a single move, you can choose any of two strings and delete the first (that is, the leftmost) character. After a move, the length of the string decreases by $1$. You can't ... | ```python
s1=input()
s2=input()
num=len(s1)+len(s2)
i=len(s1)-1
j=len(s2)-1
dl=0
while(s1[i]==s2[j]) and i>=0 and j>=0:
dl+=2
i-=1
j-=1
print(num-dl)
``` | 3 | |
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,637,293,178 | 2,147,483,647 | Python 3 | OK | TESTS | 23 | 216 | 0 | n=int(input())
MM=n//2+1
prime=[True for i in range(MM)]
primes=[]
for i in range(2, MM):
if prime[i]:
for j in range(i+i, MM, i):
prime[j] = False
primes.append(i)
ans = 0
for i in range(6, n + 1):
cnt = 0
for p in primes:
if i % p == 0:
cnt += ... | 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
n=int(input())
MM=n//2+1
prime=[True for i in range(MM)]
primes=[]
for i in range(2, MM):
if prime[i]:
for j in range(i+i, MM, i):
prime[j] = False
primes.append(i)
ans = 0
for i in range(6, n + 1):
cnt = 0
for p in primes:
if i % p == 0:
... | 3.946 |
554 | A | Kyoya and Photobooks | PROGRAMMING | 900 | [
"brute force",
"math",
"strings"
] | null | null | Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He has 26 photos, labeled "a" to "z", and he has compiled them into a photo booklet with some photos in some order (possibly with some photos being duplicated). A photo booklet can be described as a string of lowercase letters, consisting of the pho... | The first line of input will be a single string *s* (1<=≤<=|*s*|<=≤<=20). String *s* consists only of lowercase English letters. | Output a single integer equal to the number of distinct photobooks Kyoya Ootori can make. | [
"a\n",
"hi\n"
] | [
"51\n",
"76\n"
] | In the first case, we can make 'ab','ac',...,'az','ba','ca',...,'za', and 'aa', producing a total of 51 distinct photo booklets. | 250 | [
{
"input": "a",
"output": "51"
},
{
"input": "hi",
"output": "76"
},
{
"input": "y",
"output": "51"
},
{
"input": "kgan",
"output": "126"
},
{
"input": "zoabkyuvus",
"output": "276"
},
{
"input": "spyemhyznjieyhhbk",
"output": "451"
},
{
"i... | 1,577,570,688 | 2,147,483,647 | Python 3 | OK | TESTS | 33 | 109 | 307,200 | x=input()
print((len(x)+1)*26-len(x)) | Title: Kyoya and Photobooks
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He has 26 photos, labeled "a" to "z", and he has compiled them into a photo booklet with some photos in some order (possibly with some photos b... | ```python
x=input()
print((len(x)+1)*26-len(x))
``` | 3 | |
50 | A | Domino piling | PROGRAMMING | 800 | [
"greedy",
"math"
] | A. Domino piling | 2 | 256 | You are given a rectangular board of *M*<=×<=*N* squares. Also you are given an unlimited number of standard domino pieces of 2<=×<=1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as possible on the board so as to meet the following conditions:
1. Each domino completely covers ... | In a single line you are given two integers *M* and *N* — board sizes in squares (1<=≤<=*M*<=≤<=*N*<=≤<=16). | Output one number — the maximal number of dominoes, which can be placed. | [
"2 4\n",
"3 3\n"
] | [
"4\n",
"4\n"
] | none | 500 | [
{
"input": "2 4",
"output": "4"
},
{
"input": "3 3",
"output": "4"
},
{
"input": "1 5",
"output": "2"
},
{
"input": "1 6",
"output": "3"
},
{
"input": "1 15",
"output": "7"
},
{
"input": "1 16",
"output": "8"
},
{
"input": "2 5",
"outpu... | 1,634,677,755 | 2,147,483,647 | Python 3 | OK | TESTS | 35 | 92 | 0 | m, n = tuple(map(int, input().split()))
area = m * n
if area % 2 == 0:
print(int(area/2))
else:
print(int((area-1)/2)) | Title: Domino piling
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
You are given a rectangular board of *M*<=×<=*N* squares. Also you are given an unlimited number of standard domino pieces of 2<=×<=1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as p... | ```python
m, n = tuple(map(int, input().split()))
area = m * n
if area % 2 == 0:
print(int(area/2))
else:
print(int((area-1)/2))
``` | 3.977 |
155 | A | I_love_\%username\% | PROGRAMMING | 800 | [
"brute force"
] | null | null | Vasya adores sport programming. He can't write programs but he loves to watch the contests' progress. Vasya even has a favorite coder and Vasya pays special attention to him.
One day Vasya decided to collect the results of all contests where his favorite coder participated and track the progress of his coolness. For e... | The first line contains the single integer *n* (1<=≤<=*n*<=≤<=1000) — the number of contests where the coder participated.
The next line contains *n* space-separated non-negative integer numbers — they are the points which the coder has earned. The points are given in the chronological order. All points do not exceed ... | Print the single number — the number of amazing performances the coder has had during his whole history of participating in the contests. | [
"5\n100 50 200 150 200\n",
"10\n4664 6496 5814 7010 5762 5736 6944 4850 3698 7242\n"
] | [
"2\n",
"4\n"
] | In the first sample the performances number 2 and 3 are amazing.
In the second sample the performances number 2, 4, 9 and 10 are amazing. | 500 | [
{
"input": "5\n100 50 200 150 200",
"output": "2"
},
{
"input": "10\n4664 6496 5814 7010 5762 5736 6944 4850 3698 7242",
"output": "4"
},
{
"input": "1\n6",
"output": "0"
},
{
"input": "2\n2 1",
"output": "1"
},
{
"input": "5\n100 36 53 7 81",
"output": "2"
... | 1,684,860,775 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 7 | 92 | 0 | t=int(input())
s=list(map(int,input().split()))
c=0
v=0
for i in range(len(s)-1):
if s[i+1]>s[i]:
c+=1
if c==0:
for i in range(len(s)-1):
if s[i+1]<s[i]:
v+=1
print(v)
else:
print(c) | Title: I_love_\%username\%
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vasya adores sport programming. He can't write programs but he loves to watch the contests' progress. Vasya even has a favorite coder and Vasya pays special attention to him.
One day Vasya decided to collect the re... | ```python
t=int(input())
s=list(map(int,input().split()))
c=0
v=0
for i in range(len(s)-1):
if s[i+1]>s[i]:
c+=1
if c==0:
for i in range(len(s)-1):
if s[i+1]<s[i]:
v+=1
print(v)
else:
print(c)
``` | 0 | |
549 | G | Happy Line | PROGRAMMING | 2,200 | [
"constructive algorithms",
"greedy",
"sortings"
] | null | null | Do you like summer? Residents of Berland do. They especially love eating ice cream in the hot summer. So this summer day a large queue of *n* Berland residents lined up in front of the ice cream stall. We know that each of them has a certain amount of berland dollars with them. The residents of Berland are nice people,... | The first line contains integer *n* (1<=≤<=*n*<=≤<=200<=000) — the number of residents who stand in the line.
The second line contains *n* space-separated integers *a**i* (0<=≤<=*a**i*<=≤<=109), where *a**i* is the number of Berland dollars of a man standing on the *i*-th position in the line. The positions are number... | If it is impossible to make all the residents happy, print ":(" without the quotes. Otherwise, print in the single line *n* space-separated integers, the *i*-th of them must be equal to the number of money of the person on position *i* in the new line. If there are multiple answers, print any of them. | [
"2\n11 8\n",
"5\n10 9 7 10 6\n",
"3\n12 3 3\n"
] | [
"9 10 ",
":(\n",
"4 4 10 "
] | In the first sample two residents should swap places, after that the first resident has 10 dollars and he is at the head of the line and the second resident will have 9 coins and he will be at the end of the line.
In the second sample it is impossible to achieve the desired result.
In the third sample the first pers... | 1,500 | [
{
"input": "2\n11 8",
"output": "9 10 "
},
{
"input": "5\n10 9 7 10 6",
"output": ":("
},
{
"input": "3\n12 3 3",
"output": "4 4 10 "
},
{
"input": "4\n7 3 9 10",
"output": "4 6 9 10 "
},
{
"input": "1\n1",
"output": "1 "
},
{
"input": "5\n15 5 8 6 3",... | 1,433,602,239 | 6,639 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 18 | 1,000 | 14,233,600 | n = int(input())
s = [int(i) for i in input().split()]
for i in range(n-1, 0, -1):
if s[i] < s[i-1]:
u = 0
for j in range(i-1, n-1):
if s[j]>s[j+1]:
s[j], s[j+1] = s[j+1]+1, s[j]-1
if s != sorted(s):
print(":(")
else:
print(*s)
| Title: Happy Line
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Do you like summer? Residents of Berland do. They especially love eating ice cream in the hot summer. So this summer day a large queue of *n* Berland residents lined up in front of the ice cream stall. We know that each of t... | ```python
n = int(input())
s = [int(i) for i in input().split()]
for i in range(n-1, 0, -1):
if s[i] < s[i-1]:
u = 0
for j in range(i-1, n-1):
if s[j]>s[j+1]:
s[j], s[j+1] = s[j+1]+1, s[j]-1
if s != sorted(s):
print(":(")
else:
print(*s)
``` | 0 | |
740 | A | Alyona and copybooks | PROGRAMMING | 1,300 | [
"brute force",
"implementation"
] | null | null | Little girl Alyona is in a shop to buy some copybooks for school. She study four subjects so she wants to have equal number of copybooks for each of the subjects. There are three types of copybook's packs in the shop: it is possible to buy one copybook for *a* rubles, a pack of two copybooks for *b* rubles, and a pack ... | The only line contains 4 integers *n*, *a*, *b*, *c* (1<=≤<=*n*,<=*a*,<=*b*,<=*c*<=≤<=109). | Print the minimum amount of rubles she should pay to buy such number of copybooks *k* that *n*<=+<=*k* is divisible by 4. | [
"1 1 3 4\n",
"6 2 1 1\n",
"4 4 4 4\n",
"999999999 1000000000 1000000000 1000000000\n"
] | [
"3\n",
"1\n",
"0\n",
"1000000000\n"
] | In the first example Alyona can buy 3 packs of 1 copybook for 3*a* = 3 rubles in total. After that she will have 4 copybooks which she can split between the subjects equally.
In the second example Alyuna can buy a pack of 2 copybooks for *b* = 1 ruble. She will have 8 copybooks in total.
In the third example Alyona ... | 500 | [
{
"input": "1 1 3 4",
"output": "3"
},
{
"input": "6 2 1 1",
"output": "1"
},
{
"input": "4 4 4 4",
"output": "0"
},
{
"input": "999999999 1000000000 1000000000 1000000000",
"output": "1000000000"
},
{
"input": "1016 3 2 1",
"output": "0"
},
{
"input":... | 1,479,919,171 | 271 | Python 3 | WRONG_ANSWER | PRETESTS | 6 | 61 | 0 | n, a, b, c = map(int,input().split())
ost = (-n) % 4
if ost == 0:
print(0)
elif ost == 1:
print(min(a, 3 * c))
elif ost == 2:
print(min(2 * a, b, 2 * c))
else:
print(min(3 * a, c)) | Title: Alyona and copybooks
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Little girl Alyona is in a shop to buy some copybooks for school. She study four subjects so she wants to have equal number of copybooks for each of the subjects. There are three types of copybook's packs in the sh... | ```python
n, a, b, c = map(int,input().split())
ost = (-n) % 4
if ost == 0:
print(0)
elif ost == 1:
print(min(a, 3 * c))
elif ost == 2:
print(min(2 * a, b, 2 * c))
else:
print(min(3 * a, c))
``` | 0 | |
931 | A | Friends Meeting | PROGRAMMING | 800 | [
"brute force",
"greedy",
"implementation",
"math"
] | null | null | Two friends are on the coordinate axis *Ox* in points with integer coordinates. One of them is in the point *x*1<==<=*a*, another one is in the point *x*2<==<=*b*.
Each of the friends can move by one along the line in any direction unlimited number of times. When a friend moves, the tiredness of a friend changes acco... | The first line contains a single integer *a* (1<=≤<=*a*<=≤<=1000) — the initial position of the first friend.
The second line contains a single integer *b* (1<=≤<=*b*<=≤<=1000) — the initial position of the second friend.
It is guaranteed that *a*<=≠<=*b*. | Print the minimum possible total tiredness if the friends meet in the same point. | [
"3\n4\n",
"101\n99\n",
"5\n10\n"
] | [
"1\n",
"2\n",
"9\n"
] | In the first example the first friend should move by one to the right (then the meeting happens at point 4), or the second friend should move by one to the left (then the meeting happens at point 3). In both cases, the total tiredness becomes 1.
In the second example the first friend should move by one to the left, an... | 500 | [
{
"input": "3\n4",
"output": "1"
},
{
"input": "101\n99",
"output": "2"
},
{
"input": "5\n10",
"output": "9"
},
{
"input": "1\n2",
"output": "1"
},
{
"input": "1\n1000",
"output": "250000"
},
{
"input": "999\n1000",
"output": "1"
},
{
"inpu... | 1,643,022,670 | 2,147,483,647 | PyPy 3 | OK | TESTS | 40 | 92 | 0 | a = int(input())
b = int(input())
diff = abs (a-b)
if diff % 2 == 0:
steps = int(diff / 2)
tiredness = 0
for i in range (1, steps+1):
tiredness +=i
print (tiredness*2)
else:
steps = int(diff // 2)
tiredness = 0
for i in range (1, steps+1):
tiredness +=i
... | Title: Friends Meeting
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Two friends are on the coordinate axis *Ox* in points with integer coordinates. One of them is in the point *x*1<==<=*a*, another one is in the point *x*2<==<=*b*.
Each of the friends can move by one along the line in... | ```python
a = int(input())
b = int(input())
diff = abs (a-b)
if diff % 2 == 0:
steps = int(diff / 2)
tiredness = 0
for i in range (1, steps+1):
tiredness +=i
print (tiredness*2)
else:
steps = int(diff // 2)
tiredness = 0
for i in range (1, steps+1):
tired... | 3 | |
0 | none | none | none | 0 | [
"none"
] | null | null | Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings *a* and *b* of equal length are called equivalent in one of the two cases:
1. They are equal. 1. If we split string *a* into two halves of the same size *a*1 and *a*2, and string *b* into two halves of the same size ... | The first two lines of the input contain two strings given by the teacher. Each of them has the length from 1 to 200<=000 and consists of lowercase English letters. The strings have the same length. | Print "YES" (without the quotes), if these two strings are equivalent, and "NO" (without the quotes) otherwise. | [
"aaba\nabaa\n",
"aabb\nabab\n"
] | [
"YES\n",
"NO\n"
] | In the first sample you should split the first string into strings "aa" and "ba", the second one — into strings "ab" and "aa". "aa" is equivalent to "aa"; "ab" is equivalent to "ba" as "ab" = "a" + "b", "ba" = "b" + "a".
In the second sample the first string can be splitted into strings "aa" and "bb", that are equival... | 0 | [
{
"input": "aaba\nabaa",
"output": "YES"
},
{
"input": "aabb\nabab",
"output": "NO"
},
{
"input": "a\na",
"output": "YES"
},
{
"input": "a\nb",
"output": "NO"
},
{
"input": "ab\nab",
"output": "YES"
},
{
"input": "ab\nba",
"output": "YES"
},
{
... | 1,650,575,530 | 2,147,483,647 | PyPy 3-64 | COMPILATION_ERROR | TESTS | 0 | 0 | 0 | #include <bits/stdc++.h>
#include <iostream>
using namespace std;
map<pair<size_t, size_t>, size_t> pair_to_id;
map<pair<size_t, size_t>, size_t> seg_id1, seg_id2;
size_t last_id;
vector<size_t> a1, a2;
void calc_ids1(size_t l, size_t r) {
if (l < r) {
size_t m = (l + r) / 2;
calc_... | Title: none
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings *a* and *b* of equal length are called equivalent in one of the two cases:
1. They are equal. 1. If we split string *a* into t... | ```python
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
map<pair<size_t, size_t>, size_t> pair_to_id;
map<pair<size_t, size_t>, size_t> seg_id1, seg_id2;
size_t last_id;
vector<size_t> a1, a2;
void calc_ids1(size_t l, size_t r) {
if (l < r) {
size_t m = (l + r) / 2;
... | -1 | |
0 | none | none | none | 0 | [
"none"
] | null | null | The last stage of Football World Cup is played using the play-off system.
There are *n* teams left in this stage, they are enumerated from 1 to *n*. Several rounds are held, in each round the remaining teams are sorted in the order of their ids, then the first in this order plays with the second, the third — with the ... | The only line contains three integers *n*, *a* and *b* (2<=≤<=*n*<=≤<=256, 1<=≤<=*a*,<=*b*<=≤<=*n*) — the total number of teams, and the ids of the teams that Arkady is interested in.
It is guaranteed that *n* is such that in each round an even number of team advance, and that *a* and *b* are not equal. | In the only line print "Final!" (without quotes), if teams *a* and *b* can meet in the Final.
Otherwise, print a single integer — the number of the round in which teams *a* and *b* can meet. The round are enumerated from 1. | [
"4 1 2\n",
"8 2 6\n",
"8 7 5\n"
] | [
"1\n",
"Final!\n",
"2\n"
] | In the first example teams 1 and 2 meet in the first round.
In the second example teams 2 and 6 can only meet in the third round, which is the Final, if they win all their opponents in earlier rounds.
In the third example the teams with ids 7 and 5 can meet in the second round, if they win their opponents in the firs... | 0 | [
{
"input": "4 1 2",
"output": "1"
},
{
"input": "8 2 6",
"output": "Final!"
},
{
"input": "8 7 5",
"output": "2"
},
{
"input": "128 30 98",
"output": "Final!"
},
{
"input": "256 128 256",
"output": "Final!"
},
{
"input": "256 2 127",
"output": "7"
... | 1,689,849,960 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 3 | 46 | 0 | from math import log
n, a, b = map(int, input().split())
rasn = abs(b - a)
if (log(rasn, 2) + 1 == log(n, 2)):
print("Final!")
else:
print(int(log(rasn, 2) + 1)) | Title: none
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The last stage of Football World Cup is played using the play-off system.
There are *n* teams left in this stage, they are enumerated from 1 to *n*. Several rounds are held, in each round the remaining teams are sorted in the ord... | ```python
from math import log
n, a, b = map(int, input().split())
rasn = abs(b - a)
if (log(rasn, 2) + 1 == log(n, 2)):
print("Final!")
else:
print(int(log(rasn, 2) + 1))
``` | 0 | |
99 | A | Help Far Away Kingdom | PROGRAMMING | 800 | [
"strings"
] | A. Help Far Away Kingdom | 2 | 256 | In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there.
Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Ki... | The first line contains a single number to round up — the integer part (a non-empty set of decimal digits that do not start with 0 — with the exception of a case when the set consists of a single digit — in this case 0 can go first), then follows character «.» (a dot), and then follows the fractional part (any non-empt... | If the last number of the integer part is not equal to 9, print the rounded-up number without leading zeroes. Otherwise, print the message "GOTO Vasilisa." (without the quotes). | [
"0.0\n",
"1.49\n",
"1.50\n",
"2.71828182845904523536\n",
"3.14159265358979323846\n",
"12345678901234567890.1\n",
"123456789123456789.999\n"
] | [
"0",
"1",
"2",
"3",
"3",
"12345678901234567890",
"GOTO Vasilisa."
] | none | 500 | [
{
"input": "0.0",
"output": "0"
},
{
"input": "1.49",
"output": "1"
},
{
"input": "1.50",
"output": "2"
},
{
"input": "2.71828182845904523536",
"output": "3"
},
{
"input": "3.14159265358979323846",
"output": "3"
},
{
"input": "12345678901234567890.1",
... | 1,636,318,566 | 2,147,483,647 | Python 3 | OK | TESTS | 150 | 124 | 4,505,600 | def rounder(s):
st = ""
tochkaindex1 = s.index(".")+2
for i in range(tochkaindex1):
st+=s[i]
return st
def integer(s):
sum = 0
st = ""
while s[sum]!=".":
st+=str(s[sum])
sum+=1
return st
a = str(input())
if str(integer(a))[-1] == "9":
print("GOT... | Title: Help Far Away Kingdom
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there.
Most damage those stran... | ```python
def rounder(s):
st = ""
tochkaindex1 = s.index(".")+2
for i in range(tochkaindex1):
st+=s[i]
return st
def integer(s):
sum = 0
st = ""
while s[sum]!=".":
st+=str(s[sum])
sum+=1
return st
a = str(input())
if str(integer(a))[-1] == "9":
... | 3.960608 |
0 | none | none | none | 0 | [
"none"
] | null | null | Поликарп мечтает стать программистом и фанатеет от степеней двойки. Среди двух чисел ему больше нравится то, которое делится на большую степень числа 2.
По заданной последовательности целых положительных чисел *a*1,<=*a*2,<=...,<=*a**n* требуется найти *r* — максимальную степень числа 2, на которую делится хотя бы од... | В первой строке записано целое число *n* (1<=≤<=*n*<=≤<=100) — длина последовательности *a*.
Во второй строке записана последовательность целых чисел *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=109). | Выведите два числа:
- *r* — максимальную степень двойки, на которую делится хотя бы одно из чисел заданной последовательности, - количество элементов последовательности, которые делятся на *r*. | [
"5\n80 7 16 4 48\n",
"4\n21 5 3 33\n"
] | [
"16 3\n",
"1 4\n"
] | В первом тестовом примере максимальная степень двойки, на которую делится хотя бы одно число, равна 16 = 2<sup class="upper-index">4</sup>, на неё делятся числа 80, 16 и 48.
Во втором тестовом примере все четыре числа нечётные, поэтому делятся только на 1 = 2<sup class="upper-index">0</sup>. Это и будет максимальной с... | 0 | [
{
"input": "5\n80 7 16 4 48",
"output": "16 3"
},
{
"input": "4\n21 5 3 33",
"output": "1 4"
},
{
"input": "10\n8 112 52 86 93 102 24 24 100 826791168",
"output": "256 1"
},
{
"input": "3\n458297759 18 104",
"output": "8 1"
},
{
"input": "7\n12 14 40 8 74 104 11",... | 1,458,976,228 | 628 | Python 3 | OK | TESTS | 172 | 77 | 4,608,000 | n = int(input())
a = list(map(int, input().split()))
ans = 1
ansc = 0
for x in a:
i = 0
while (x % (2 ** i) == 0):
i += 1
i -= 1
if (2 ** i == ans):
ansc += 1
if (2 ** i > ans):
ans = 2 ** i
ansc = 1
print(str(ans) + ' ' + str(ansc)) | Title: none
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Поликарп мечтает стать программистом и фанатеет от степеней двойки. Среди двух чисел ему больше нравится то, которое делится на большую степень числа 2.
По заданной последовательности целых положительных чисел *a*1,<=*a*2,<=...,... | ```python
n = int(input())
a = list(map(int, input().split()))
ans = 1
ansc = 0
for x in a:
i = 0
while (x % (2 ** i) == 0):
i += 1
i -= 1
if (2 ** i == ans):
ansc += 1
if (2 ** i > ans):
ans = 2 ** i
ansc = 1
print(str(ans) + ' ' + str(ansc))
``` | 3 | |
0 | none | none | none | 0 | [
"none"
] | null | null | Sereja has an *n*<=×<=*m* rectangular table *a*, each cell of the table contains a zero or a number one. Sereja wants his table to meet the following requirement: each connected component of the same values forms a rectangle with sides parallel to the sides of the table. Rectangles should be filled with cells, that is,... | The first line contains integers *n*, *m* and *k* (1<=≤<=*n*,<=*m*<=≤<=100; 1<=≤<=*k*<=≤<=10). Next *n* lines describe the table *a*: the *i*-th of them contains *m* integers *a**i*1,<=*a**i*2,<=...,<=*a**im* (0<=≤<=*a**i*,<=*j*<=≤<=1) — the values in the cells of the *i*-th row. | Print -1, if it is impossible to meet the requirement. Otherwise, print the minimum number of cells which should be changed. | [
"5 5 2\n1 1 1 1 1\n1 1 1 1 1\n1 1 0 1 1\n1 1 1 1 1\n1 1 1 1 1\n",
"3 4 1\n1 0 0 0\n0 1 1 1\n1 1 1 0\n",
"3 4 1\n1 0 0 1\n0 1 1 0\n1 0 0 1\n"
] | [
"1\n",
"-1\n",
"0\n"
] | none | 0 | [] | 1,691,657,769 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 0 | 46 | 0 | print("_RANDOM_GUESS_1691657769.6756732")# 1691657769.6756897 | Title: none
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Sereja has an *n*<=×<=*m* rectangular table *a*, each cell of the table contains a zero or a number one. Sereja wants his table to meet the following requirement: each connected component of the same values forms a rectangle with ... | ```python
print("_RANDOM_GUESS_1691657769.6756732")# 1691657769.6756897
``` | 0 | |
96 | A | Football | PROGRAMMING | 900 | [
"implementation",
"strings"
] | A. Football | 2 | 256 | Petya loves football very much. One day, as he was watching a football match, he was writing the players' current positions on a piece of paper. To simplify the situation he depicted it as a string consisting of zeroes and ones. A zero corresponds to players of one team; a one corresponds to players of another team. If... | The first input line contains a non-empty string consisting of characters "0" and "1", which represents players. The length of the string does not exceed 100 characters. There's at least one player from each team present on the field. | Print "YES" if the situation is dangerous. Otherwise, print "NO". | [
"001001\n",
"1000000001\n"
] | [
"NO\n",
"YES\n"
] | none | 500 | [
{
"input": "001001",
"output": "NO"
},
{
"input": "1000000001",
"output": "YES"
},
{
"input": "00100110111111101",
"output": "YES"
},
{
"input": "11110111111111111",
"output": "YES"
},
{
"input": "01",
"output": "NO"
},
{
"input": "10100101",
"outp... | 1,666,448,436 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 2 | 92 | 0 | string = input()
temp = None
counter = int()
for letter in string:
x = int()
if temp == None:
temp = letter
else:
if letter == temp:
counter += 1
else:
temp = letter
counter = 0
if counter == 7:
print('YES')
bre... | Title: Football
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Petya loves football very much. One day, as he was watching a football match, he was writing the players' current positions on a piece of paper. To simplify the situation he depicted it as a string consisting of zeroes and ones. A... | ```python
string = input()
temp = None
counter = int()
for letter in string:
x = int()
if temp == None:
temp = letter
else:
if letter == temp:
counter += 1
else:
temp = letter
counter = 0
if counter == 7:
print('YES')
... | 0 |
253 | A | Boys and Girls | PROGRAMMING | 1,100 | [
"greedy"
] | null | null | There are *n* boys and *m* girls studying in the class. They should stand in a line so that boys and girls alternated there as much as possible. Let's assume that positions in the line are indexed from left to right by numbers from 1 to *n*<=+<=*m*. Then the number of integers *i* (1<=≤<=*i*<=<<=*n*<=+<=*m*) such th... | The single line of the input contains two integers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=100), separated by a space. | Print a line of *n*<=+<=*m* characters. Print on the *i*-th position of the line character "B", if the *i*-th position of your arrangement should have a boy and "G", if it should have a girl.
Of course, the number of characters "B" should equal *n* and the number of characters "G" should equal *m*. If there are multi... | [
"3 3\n",
"4 2\n"
] | [
"GBGBGB\n",
"BGBGBB\n"
] | In the first sample another possible answer is BGBGBG.
In the second sample answer BBGBGB is also optimal. | 500 | [
{
"input": "3 3",
"output": "GBGBGB"
},
{
"input": "4 2",
"output": "BGBGBB"
},
{
"input": "5 5",
"output": "GBGBGBGBGB"
},
{
"input": "6 4",
"output": "BGBGBGBGBB"
},
{
"input": "100 1",
"output": "BGBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB... | 1,647,640,461 | 2,147,483,647 | Python 3 | OK | TESTS | 23 | 92 | 0 | INPUT = open('input.txt', 'r')
OUTPUT = open('output.txt', 'w')
n, m = map(int, INPUT.read().split())
if n>m:
OUTPUT.write(m*"BG"+(n-m)*"B")
else:
OUTPUT.write(n*"GB"+(m-n)*"G")
| Title: Boys and Girls
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
There are *n* boys and *m* girls studying in the class. They should stand in a line so that boys and girls alternated there as much as possible. Let's assume that positions in the line are indexed from left to right by n... | ```python
INPUT = open('input.txt', 'r')
OUTPUT = open('output.txt', 'w')
n, m = map(int, INPUT.read().split())
if n>m:
OUTPUT.write(m*"BG"+(n-m)*"B")
else:
OUTPUT.write(n*"GB"+(m-n)*"G")
``` | 3 | |
520 | A | Pangram | PROGRAMMING | 800 | [
"implementation",
"strings"
] | null | null | A word or a sentence in some language is called a pangram if all the characters of the alphabet of this language appear in it at least once. Pangrams are often used to demonstrate fonts in printing or test the output devices.
You are given a string consisting of lowercase and uppercase Latin letters. Check whether thi... | The first line contains a single integer *n* (1<=≤<=*n*<=≤<=100) — the number of characters in the string.
The second line contains the string. The string consists only of uppercase and lowercase Latin letters. | Output "YES", if the string is a pangram and "NO" otherwise. | [
"12\ntoosmallword\n",
"35\nTheQuickBrownFoxJumpsOverTheLazyDog\n"
] | [
"NO\n",
"YES\n"
] | none | 500 | [
{
"input": "12\ntoosmallword",
"output": "NO"
},
{
"input": "35\nTheQuickBrownFoxJumpsOverTheLazyDog",
"output": "YES"
},
{
"input": "1\na",
"output": "NO"
},
{
"input": "26\nqwertyuiopasdfghjklzxcvbnm",
"output": "YES"
},
{
"input": "26\nABCDEFGHIJKLMNOPQRSTUVWXY... | 1,694,187,266 | 2,147,483,647 | Python 3 | OK | TESTS | 59 | 46 | 0 | len_word=int(input())
word=input().lower()
count_simvols=set()
answer=[]
for i in word:
count_simvols.add(i)
for i in count_simvols:
answer.append(i)
if len(count_simvols)==26:
print('YES')
else:
print('NO') | Title: Pangram
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
A word or a sentence in some language is called a pangram if all the characters of the alphabet of this language appear in it at least once. Pangrams are often used to demonstrate fonts in printing or test the output devices.
... | ```python
len_word=int(input())
word=input().lower()
count_simvols=set()
answer=[]
for i in word:
count_simvols.add(i)
for i in count_simvols:
answer.append(i)
if len(count_simvols)==26:
print('YES')
else:
print('NO')
``` | 3 | |
219 | A | k-String | PROGRAMMING | 1,000 | [
"implementation",
"strings"
] | null | null | A string is called a *k*-string if it can be represented as *k* concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.
You are given a string... | The first input line contains integer *k* (1<=≤<=*k*<=≤<=1000). The second line contains *s*, all characters in *s* are lowercase English letters. The string length *s* satisfies the inequality 1<=≤<=|*s*|<=≤<=1000, where |*s*| is the length of string *s*. | Rearrange the letters in string *s* in such a way that the result is a *k*-string. Print the result on a single output line. If there are multiple solutions, print any of them.
If the solution doesn't exist, print "-1" (without quotes). | [
"2\naazz\n",
"3\nabcabcabz\n"
] | [
"azaz\n",
"-1\n"
] | none | 500 | [
{
"input": "2\naazz",
"output": "azaz"
},
{
"input": "3\nabcabcabz",
"output": "-1"
},
{
"input": "1\na",
"output": "a"
},
{
"input": "2\nabba",
"output": "abab"
},
{
"input": "2\naaab",
"output": "-1"
},
{
"input": "7\nabacaba",
"output": "-1"
}... | 1,649,352,818 | 2,147,483,647 | Python 3 | OK | TESTS | 42 | 92 | 0 | k = int(input())
s = input()
h = {}
for c in s:
if c in h:
h[c] += 1
else:
h[c] = 1
check = 0
for i in h.keys():
if h[i] % k == 0:
h[i] = h[i]//k
else:
check = -1
break
if check == -1:
print(-1)
else:
s = ""
for i in h.keys():
... | Title: k-String
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
A string is called a *k*-string if it can be represented as *k* concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a ... | ```python
k = int(input())
s = input()
h = {}
for c in s:
if c in h:
h[c] += 1
else:
h[c] = 1
check = 0
for i in h.keys():
if h[i] % k == 0:
h[i] = h[i]//k
else:
check = -1
break
if check == -1:
print(-1)
else:
s = ""
for i in h.keys... | 3 | |
1 | B | Spreadsheet | PROGRAMMING | 1,600 | [
"implementation",
"math"
] | B. Spreadsheets | 10 | 64 | In the popular spreadsheets systems (for example, in Excel) the following numeration of columns is used. The first column has number A, the second — number B, etc. till column 26 that is marked by Z. Then there are two-letter numbers: column 27 has number AA, 28 — AB, column 52 is marked by AZ. After ZZ there follow th... | The first line of the input contains integer number *n* (1<=≤<=*n*<=≤<=105), the number of coordinates in the test. Then there follow *n* lines, each of them contains coordinates. All the coordinates are correct, there are no cells with the column and/or the row numbers larger than 106 . | Write *n* lines, each line should contain a cell coordinates in the other numeration system. | [
"2\nR23C55\nBC23\n"
] | [
"BC23\nR23C55\n"
] | none | 0 | [
{
"input": "2\nR23C55\nBC23",
"output": "BC23\nR23C55"
},
{
"input": "1\nA1",
"output": "R1C1"
},
{
"input": "5\nR8C3\nD1\nR7C2\nR8C9\nR8C9",
"output": "C8\nR1C4\nB7\nI8\nI8"
},
{
"input": "4\nR4C25\nR90C35\nAP55\nX83",
"output": "Y4\nAI90\nR55C42\nR83C24"
},
{
"i... | 1,649,320,537 | 2,137 | Python 3 | WRONG_ANSWER | TESTS | 5 | 92 | 409,600 | import string
n = int(input())
for _ in range(n):
s = input()
last_isnumeric = False
arr = [[s[0]]]
for i in range(1, len(s)):
c = s[i]
isnumeric = c.isnumeric()
if isnumeric:
if last_isnumeric:
arr[-1].append(c)
else:
... | Title: Spreadsheet
Time Limit: 10 seconds
Memory Limit: 64 megabytes
Problem Description:
In the popular spreadsheets systems (for example, in Excel) the following numeration of columns is used. The first column has number A, the second — number B, etc. till column 26 that is marked by Z. Then there are two-letter n... | ```python
import string
n = int(input())
for _ in range(n):
s = input()
last_isnumeric = False
arr = [[s[0]]]
for i in range(1, len(s)):
c = s[i]
isnumeric = c.isnumeric()
if isnumeric:
if last_isnumeric:
arr[-1].append(c)
else:
... | 0 |
50 | A | Domino piling | PROGRAMMING | 800 | [
"greedy",
"math"
] | A. Domino piling | 2 | 256 | You are given a rectangular board of *M*<=×<=*N* squares. Also you are given an unlimited number of standard domino pieces of 2<=×<=1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as possible on the board so as to meet the following conditions:
1. Each domino completely covers ... | In a single line you are given two integers *M* and *N* — board sizes in squares (1<=≤<=*M*<=≤<=*N*<=≤<=16). | Output one number — the maximal number of dominoes, which can be placed. | [
"2 4\n",
"3 3\n"
] | [
"4\n",
"4\n"
] | none | 500 | [
{
"input": "2 4",
"output": "4"
},
{
"input": "3 3",
"output": "4"
},
{
"input": "1 5",
"output": "2"
},
{
"input": "1 6",
"output": "3"
},
{
"input": "1 15",
"output": "7"
},
{
"input": "1 16",
"output": "8"
},
{
"input": "2 5",
"outpu... | 1,633,544,102 | 2,147,483,647 | PyPy 3 | RUNTIME_ERROR | TESTS | 0 | 218 | 22,323,200 | m = int(input())
n = int(input())
board = (n*m)/2
print(int(board))
| Title: Domino piling
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
You are given a rectangular board of *M*<=×<=*N* squares. Also you are given an unlimited number of standard domino pieces of 2<=×<=1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as p... | ```python
m = int(input())
n = int(input())
board = (n*m)/2
print(int(board))
``` | -1 |
707 | A | Brain's Photos | PROGRAMMING | 800 | [
"implementation"
] | null | null | Small, but very brave, mouse Brain was not accepted to summer school of young villains. He was upset and decided to postpone his plans of taking over the world, but to become a photographer instead.
As you may know, the coolest photos are on the film (because you can specify the hashtag #film for such).
Brain took a ... | The first line of the input contains two integers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=100) — the number of photo pixel matrix rows and columns respectively.
Then *n* lines describing matrix rows follow. Each of them contains *m* space-separated characters describing colors of pixels in a row. Each character in the line i... | Print the "#Black&White" (without quotes), if the photo is black-and-white and "#Color" (without quotes), if it is colored, in the only line. | [
"2 2\nC M\nY Y\n",
"3 2\nW W\nW W\nB B\n",
"1 1\nW\n"
] | [
"#Color",
"#Black&White",
"#Black&White"
] | none | 500 | [
{
"input": "2 2\nC M\nY Y",
"output": "#Color"
},
{
"input": "3 2\nW W\nW W\nB B",
"output": "#Black&White"
},
{
"input": "1 1\nW",
"output": "#Black&White"
},
{
"input": "2 3\nW W W\nB G Y",
"output": "#Color"
},
{
"input": "1 1\nW",
"output": "#Black&White"
... | 1,687,864,763 | 2,147,483,647 | Python 3 | OK | TESTS | 50 | 46 | 0 | n, m = map(int, input().split())
for i in range(n):
a = list(input().split())
for j in range(m):
if a[j] == 'C' or a[j] == 'Y' or a[j] == 'M':
print('#Color')
quit()
print('#Black&White') | Title: Brain's Photos
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Small, but very brave, mouse Brain was not accepted to summer school of young villains. He was upset and decided to postpone his plans of taking over the world, but to become a photographer instead.
As you may know, the... | ```python
n, m = map(int, input().split())
for i in range(n):
a = list(input().split())
for j in range(m):
if a[j] == 'C' or a[j] == 'Y' or a[j] == 'M':
print('#Color')
quit()
print('#Black&White')
``` | 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,636,207,056 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 62 | 4,198,400 | s = input("")
count_upper = 0
count_lower = 0
for i in s:
if s.isupper():
count_upper += 1
elif s.islower():
count_lower += 1
if count_upper > count_lower:
print(s.upper())
elif count_lower >= count_upper:
print(s.lower())
| Title: Word
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Vasya is very upset that many people on the Net mix uppercase and lowercase letters in one word. That's why he decided to invent an extension for his favorite browser that would change the letters' register in every word so that it ei... | ```python
s = input("")
count_upper = 0
count_lower = 0
for i in s:
if s.isupper():
count_upper += 1
elif s.islower():
count_lower += 1
if count_upper > count_lower:
print(s.upper())
elif count_lower >= count_upper:
print(s.lower())
``` | 0 |
842 | C | Ilya And The Tree | PROGRAMMING | 2,000 | [
"dfs and similar",
"graphs",
"math",
"number theory",
"trees"
] | null | null | Ilya is very fond of graphs, especially trees. During his last trip to the forest Ilya found a very interesting tree rooted at vertex 1. There is an integer number written on each vertex of the tree; the number written on vertex *i* is equal to *a**i*.
Ilya believes that the beauty of the vertex *x* is the greatest co... | First line contains one integer number *n* — the number of vertices in tree (1<=≤<=*n*<=≤<=2·105).
Next line contains *n* integer numbers *a**i* (1<=≤<=*i*<=≤<=*n*, 1<=≤<=*a**i*<=≤<=2·105).
Each of next *n*<=-<=1 lines contains two integer numbers *x* and *y* (1<=≤<=*x*,<=*y*<=≤<=*n*, *x*<=≠<=*y*), which means that t... | Output *n* numbers separated by spaces, where *i*-th number equals to maximum possible beauty of vertex *i*. | [
"2\n6 2\n1 2\n",
"3\n6 2 3\n1 2\n1 3\n",
"1\n10\n"
] | [
"6 6 \n",
"6 6 6 \n",
"10 \n"
] | none | 1,500 | [
{
"input": "2\n6 2\n1 2",
"output": "6 6 "
},
{
"input": "3\n6 2 3\n1 2\n1 3",
"output": "6 6 6 "
},
{
"input": "1\n10",
"output": "10 "
},
{
"input": "10\n2 3 4 5 6 7 8 9 10 11\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n4 8\n8 9\n9 10",
"output": "2 3 2 1 1 1 1 1 1 1 "
},
{
... | 1,624,951,915 | 2,147,483,647 | PyPy 3 | TIME_LIMIT_EXCEEDED | TESTS | 14 | 2,000 | 53,145,600 | import os
import sys
from io import BytesIO, IOBase
from collections import deque
from math import gcd
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" ... | Title: Ilya And The Tree
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Ilya is very fond of graphs, especially trees. During his last trip to the forest Ilya found a very interesting tree rooted at vertex 1. There is an integer number written on each vertex of the tree; the number writte... | ```python
import os
import sys
from io import BytesIO, IOBase
from collections import deque
from math import gcd
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writa... | 0 | |
282 | A | Bit++ | PROGRAMMING | 800 | [
"implementation"
] | null | null | The classic programming language of Bitland is Bit++. This language is so peculiar and complicated.
The language is that peculiar as it has exactly one variable, called *x*. Also, there are two operations:
- Operation ++ increases the value of variable *x* by 1. - Operation -- decreases the value of variable *x* by... | The first line contains a single integer *n* (1<=≤<=*n*<=≤<=150) — the number of statements in the programme.
Next *n* lines contain a statement each. Each statement contains exactly one operation (++ or --) and exactly one variable *x* (denoted as letter «X»). Thus, there are no empty statements. The operation and th... | Print a single integer — the final value of *x*. | [
"1\n++X\n",
"2\nX++\n--X\n"
] | [
"1\n",
"0\n"
] | none | 500 | [
{
"input": "1\n++X",
"output": "1"
},
{
"input": "2\nX++\n--X",
"output": "0"
},
{
"input": "3\n++X\n++X\n++X",
"output": "3"
},
{
"input": "2\n--X\n--X",
"output": "-2"
},
{
"input": "5\n++X\n--X\n++X\n--X\n--X",
"output": "-1"
},
{
"input": "28\nX--\... | 1,699,550,707 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 36 | 62 | 0 | def execute_programme(n, l):
x = 0
for statement in l:
if "++" in statement:
x += 1
else:
x -= 1
return x
n = int(input())
l = [input() for _ in range(n)]
result = execute_programme(n, l)
print(result)
| Title: Bit++
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The classic programming language of Bitland is Bit++. This language is so peculiar and complicated.
The language is that peculiar as it has exactly one variable, called *x*. Also, there are two operations:
- Operation ++ incre... | ```python
def execute_programme(n, l):
x = 0
for statement in l:
if "++" in statement:
x += 1
else:
x -= 1
return x
n = int(input())
l = [input() for _ in range(n)]
result = execute_programme(n, l)
print(result)
``` | 3 | |
909 | A | Generate Login | PROGRAMMING | 1,000 | [
"brute force",
"greedy",
"sortings"
] | null | null | The preferred way to generate user login in Polygon is to concatenate a prefix of the user's first name and a prefix of their last name, in that order. Each prefix must be non-empty, and any of the prefixes can be the full name. Typically there are multiple possible logins for each person.
You are given the first and ... | The input consists of a single line containing two space-separated strings: the first and the last names. Each character of each string is a lowercase English letter. The length of each string is between 1 and 10, inclusive. | Output a single string — alphabetically earliest possible login formed from these names. The output should be given in lowercase as well. | [
"harry potter\n",
"tom riddle\n"
] | [
"hap\n",
"tomr\n"
] | none | 500 | [
{
"input": "harry potter",
"output": "hap"
},
{
"input": "tom riddle",
"output": "tomr"
},
{
"input": "a qdpinbmcrf",
"output": "aq"
},
{
"input": "wixjzniiub ssdfodfgap",
"output": "wis"
},
{
"input": "z z",
"output": "zz"
},
{
"input": "ertuyivhfg v"... | 1,514,393,459 | 959 | Python 3 | OK | TESTS | 64 | 62 | 5,632,000 | x=input().split()
a=x[0][0]
for i in range(1, len(x[0])):
if(x[0][i]<x[1][0]):
a+=x[0][i]
else:
break
a+=x[1][0]
print(a)
| Title: Generate Login
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The preferred way to generate user login in Polygon is to concatenate a prefix of the user's first name and a prefix of their last name, in that order. Each prefix must be non-empty, and any of the prefixes can be the fu... | ```python
x=input().split()
a=x[0][0]
for i in range(1, len(x[0])):
if(x[0][i]<x[1][0]):
a+=x[0][i]
else:
break
a+=x[1][0]
print(a)
``` | 3 | |
527 | A | Playing with Paper | PROGRAMMING | 1,100 | [
"implementation",
"math"
] | null | null | One day Vasya was sitting on a not so interesting Maths lesson and making an origami from a rectangular *a* mm <=×<= *b* mm sheet of paper (*a*<=><=*b*). Usually the first step in making an origami is making a square piece of paper from the rectangular sheet by folding the sheet along the bisector of the right angle... | The first line of the input contains two integers *a*, *b* (1<=≤<=*b*<=<<=*a*<=≤<=1012) — the sizes of the original sheet of paper. | Print a single integer — the number of ships that Vasya will make. | [
"2 1\n",
"10 7\n",
"1000000000000 1\n"
] | [
"2\n",
"6\n",
"1000000000000\n"
] | Pictures to the first and second sample test. | 500 | [
{
"input": "2 1",
"output": "2"
},
{
"input": "10 7",
"output": "6"
},
{
"input": "1000000000000 1",
"output": "1000000000000"
},
{
"input": "3 1",
"output": "3"
},
{
"input": "4 1",
"output": "4"
},
{
"input": "3 2",
"output": "3"
},
{
"in... | 1,467,631,611 | 2,147,483,647 | Python 3 | OK | TESTS | 46 | 92 | 0 | # Problem 527A
# Playing with Paper
dim = list(map(int, input().split(" ")))
length = dim[0]
breadth = dim[1]
no_of_ships = 0
while (length - breadth) > 0:
no_of_ships += length // breadth
length -= (breadth * (length // breadth))
if (length > 0) and (length < breadth):
temp = breadth
brea... | Title: Playing with Paper
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
One day Vasya was sitting on a not so interesting Maths lesson and making an origami from a rectangular *a* mm <=×<= *b* mm sheet of paper (*a*<=><=*b*). Usually the first step in making an origami is making a squ... | ```python
# Problem 527A
# Playing with Paper
dim = list(map(int, input().split(" ")))
length = dim[0]
breadth = dim[1]
no_of_ships = 0
while (length - breadth) > 0:
no_of_ships += length // breadth
length -= (breadth * (length // breadth))
if (length > 0) and (length < breadth):
temp = breadth
... | 3 | |
61 | B | Hard Work | PROGRAMMING | 1,300 | [
"strings"
] | B. Hard Work | 2 | 256 | After the contest in comparing numbers, Shapur's teacher found out that he is a real genius and that no one could possibly do the calculations faster than him even using a super computer!
Some days before the contest, the teacher took a very simple-looking exam and all his *n* students took part in the exam. The teach... | The first three lines contain a string each. These are the initial strings. They consists only of lowercase and uppercase Latin letters and signs ("-", ";" and "_"). All the initial strings have length from 1 to 100, inclusively.
In the fourth line there is a single integer *n* (0<=≤<=*n*<=≤<=1000), the number of stud... | For each student write in a different line. Print "WA" if his answer is wrong or "ACC" if his answer is OK. | [
"Iran_\nPersian;\nW_o;n;d;e;r;f;u;l;\n7\nWonderfulPersianIran\nwonderful_PersIAN_IRAN;;_\nWONDERFUL___IRAN__PERSIAN__;;\nIra__Persiann__Wonderful\nWonder;;fulPersian___;I;r;a;n;\n__________IranPersianWonderful__________\nPersianIran_is_Wonderful\n",
"Shapur;;\nis___\na_genius\n3\nShapur__a_is___geniUs\nis___shapu... | [
"ACC\nACC\nACC\nWA\nACC\nACC\nWA\n",
"WA\nACC\nACC\n"
] | none | 1,000 | [
{
"input": "Iran_\nPersian;\nW_o;n;d;e;r;f;u;l;\n7\nWonderfulPersianIran\nwonderful_PersIAN_IRAN;;_\nWONDERFUL___IRAN__PERSIAN__;;\nIra__Persiann__Wonderful\nWonder;;fulPersian___;I;r;a;n;\n__________IranPersianWonderful__________\nPersianIran_is_Wonderful",
"output": "ACC\nACC\nACC\nWA\nACC\nACC\nWA"
},
... | 1,567,981,338 | 1,038 | PyPy 3 | WRONG_ANSWER | TESTS | 32 | 187 | 3,276,800 | strings = [input().replace(';', '').replace('_', '').replace('-', '').lower() for _ in range(3)]
givens = list()
for _ in range(int(input())):
givens.append(input().replace(';', '').replace('_', '').replace('-', '').lower())
for given in givens:
if all([string in given for string in strings]) and len(''.jo... | Title: Hard Work
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
After the contest in comparing numbers, Shapur's teacher found out that he is a real genius and that no one could possibly do the calculations faster than him even using a super computer!
Some days before the contest, the teache... | ```python
strings = [input().replace(';', '').replace('_', '').replace('-', '').lower() for _ in range(3)]
givens = list()
for _ in range(int(input())):
givens.append(input().replace(';', '').replace('_', '').replace('-', '').lower())
for given in givens:
if all([string in given for string in strings]) and... | 0 |
522 | A | Reposts | PROGRAMMING | 1,200 | [
"*special",
"dfs and similar",
"dp",
"graphs",
"trees"
] | null | null | One day Polycarp published a funny picture in a social network making a poll about the color of his handle. Many of his friends started reposting Polycarp's joke to their news feed. Some of them reposted the reposts and so on.
These events are given as a sequence of strings "name1 reposted name2", where name1 is the n... | The first line of the input contains integer *n* (1<=≤<=*n*<=≤<=200) — the number of reposts. Next follow the reposts in the order they were made. Each of them is written on a single line and looks as "name1 reposted name2". All the names in the input consist of lowercase or uppercase English letters and/or digits and ... | Print a single integer — the maximum length of a repost chain. | [
"5\ntourist reposted Polycarp\nPetr reposted Tourist\nWJMZBMR reposted Petr\nsdya reposted wjmzbmr\nvepifanov reposted sdya\n",
"6\nMike reposted Polycarp\nMax reposted Polycarp\nEveryOne reposted Polycarp\n111 reposted Polycarp\nVkCup reposted Polycarp\nCodeforces reposted Polycarp\n",
"1\nSoMeStRaNgEgUe repos... | [
"6\n",
"2\n",
"2\n"
] | none | 500 | [
{
"input": "5\ntourist reposted Polycarp\nPetr reposted Tourist\nWJMZBMR reposted Petr\nsdya reposted wjmzbmr\nvepifanov reposted sdya",
"output": "6"
},
{
"input": "6\nMike reposted Polycarp\nMax reposted Polycarp\nEveryOne reposted Polycarp\n111 reposted Polycarp\nVkCup reposted Polycarp\nCodeforc... | 1,627,747,489 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 5 | 46 | 6,963,200 | n = int(input())
a = []
for j in range(0, n):
a.append(input())
if n != 1:
s = 1
pol = ''
q = 0
for i in range(0,n):
c, b, d = a[i].split()
if d == 'Polycarp' or pol.find(str(c)) != 0 or pol.find(capitalize(str(c))) != 0:
if d == 'Polycarp' and q < 1:
... | Title: Reposts
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
One day Polycarp published a funny picture in a social network making a poll about the color of his handle. Many of his friends started reposting Polycarp's joke to their news feed. Some of them reposted the reposts and so on.
... | ```python
n = int(input())
a = []
for j in range(0, n):
a.append(input())
if n != 1:
s = 1
pol = ''
q = 0
for i in range(0,n):
c, b, d = a[i].split()
if d == 'Polycarp' or pol.find(str(c)) != 0 or pol.find(capitalize(str(c))) != 0:
if d == 'Polycarp' and q < 1:... | 0 | |
49 | A | Sleuth | PROGRAMMING | 800 | [
"implementation"
] | A. Sleuth | 2 | 256 | Vasya plays the sleuth with his friends. The rules of the game are as follows: those who play for the first time, that is Vasya is the sleuth, he should investigate a "crime" and find out what is happening. He can ask any questions whatsoever that can be answered with "Yes" or "No". All the rest agree beforehand to ans... | The single line contains a question represented by a non-empty line consisting of large and small Latin letters, spaces and a question mark. The line length does not exceed 100. It is guaranteed that the question mark occurs exactly once in the line — as the last symbol and that the line contains at least one letter. | Print answer for the question in a single line: YES if the answer is "Yes", NO if the answer is "No".
Remember that in the reply to the question the last letter, not the last character counts. I. e. the spaces and the question mark do not count as letters. | [
"Is it a melon?\n",
"Is it an apple?\n",
"Is it a banana ?\n",
"Is it an apple and a banana simultaneouSLY?\n"
] | [
"NO\n",
"YES\n",
"YES\n",
"YES\n"
] | none | 500 | [
{
"input": "Is it a melon?",
"output": "NO"
},
{
"input": "Is it an apple?",
"output": "YES"
},
{
"input": " Is it a banana ?",
"output": "YES"
},
{
"input": "Is it an apple and a banana simultaneouSLY?",
"output": "YES"
},
{
"input": "oHtSbDwzHb?",
... | 1,544,094,669 | 2,147,483,647 | Python 3 | OK | TESTS | 35 | 248 | 0 | s = input().upper()
gl = 'AEIOUY'
sogl = 'BCDFGHJKLMNPQRSTVWXZ'
for i in s[::-1]:
if i in gl:
print('YES')
break
elif i in sogl:
print('NO')
break
| Title: Sleuth
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Vasya plays the sleuth with his friends. The rules of the game are as follows: those who play for the first time, that is Vasya is the sleuth, he should investigate a "crime" and find out what is happening. He can ask any questions ... | ```python
s = input().upper()
gl = 'AEIOUY'
sogl = 'BCDFGHJKLMNPQRSTVWXZ'
for i in s[::-1]:
if i in gl:
print('YES')
break
elif i in sogl:
print('NO')
break
``` | 3.938 |
832 | B | Petya and Exam | PROGRAMMING | 1,600 | [
"implementation",
"strings"
] | null | null | It's hard times now. Today Petya needs to score 100 points on Informatics exam. The tasks seem easy to Petya, but he thinks he lacks time to finish them all, so he asks you to help with one..
There is a glob pattern in the statements (a string consisting of lowercase English letters, characters "?" and "*"). It is kno... | The first line contains a string with length from 1 to 26 consisting of distinct lowercase English letters. These letters are good letters, all the others are bad.
The second line contains the pattern — a string *s* of lowercase English letters, characters "?" and "*" (1<=≤<=|*s*|<=≤<=105). It is guaranteed that chara... | Print *n* lines: in the *i*-th of them print "YES" if the pattern matches the *i*-th query string, and "NO" otherwise.
You can choose the case (lower or upper) for each letter arbitrary. | [
"ab\na?a\n2\naaa\naab\n",
"abc\na?a?a*\n4\nabacaba\nabaca\napapa\naaaaax\n"
] | [
"YES\nNO\n",
"NO\nYES\nNO\nYES\n"
] | In the first example we can replace "?" with good letters "a" and "b", so we can see that the answer for the first query is "YES", and the answer for the second query is "NO", because we can't match the third letter.
Explanation of the second example.
- The first query: "NO", because character "*" can be replaced w... | 1,000 | [
{
"input": "ab\na?a\n2\naaa\naab",
"output": "YES\nNO"
},
{
"input": "abc\na?a?a*\n4\nabacaba\nabaca\napapa\naaaaax",
"output": "NO\nYES\nNO\nYES"
},
{
"input": "s\nc*?cb\n26\nbbaa\nb\ncc\ncbaab\nacacc\nca\na\nc\ncb\nabb\nba\nb\nba\ncac\nccccb\nccb\nbbbc\nabbcb\na\nbc\nc\na\nabb\nca\ncac... | 1,633,625,929 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 11 | 358 | 26,112,000 | def coolf(b):
coolp = -1
for i in range(n):
coolp+=1
if(coolp >= len(b)):
if(a[i] == '*' and i + 1 >= n):
print("YES")
else:
print('NO')
return
if(a[i] == b[coolp]):
continue
elif(a[i] == ... | Title: Petya and Exam
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
It's hard times now. Today Petya needs to score 100 points on Informatics exam. The tasks seem easy to Petya, but he thinks he lacks time to finish them all, so he asks you to help with one..
There is a glob pattern in ... | ```python
def coolf(b):
coolp = -1
for i in range(n):
coolp+=1
if(coolp >= len(b)):
if(a[i] == '*' and i + 1 >= n):
print("YES")
else:
print('NO')
return
if(a[i] == b[coolp]):
continue
eli... | 0 | |
681 | C | Heap Operations | PROGRAMMING | 1,600 | [
"constructive algorithms",
"data structures",
"greedy"
] | null | null | Petya has recently learned data structure named "Binary heap".
The heap he is now operating with allows the following operations:
- put the given number into the heap; - get the value of the minimum element in the heap; - extract the minimum element from the heap;
Thus, at any moment of time the heap contains se... | The first line of the input contains the only integer *n* (1<=≤<=*n*<=≤<=100<=000) — the number of the records left in Petya's journal.
Each of the following *n* lines describe the records in the current log in the order they are applied. Format described in the statement is used. All numbers in the input are integers... | The first line of the output should contain a single integer *m* — the minimum possible number of records in the modified sequence of operations.
Next *m* lines should contain the corrected sequence of records following the format of the input (described in the statement), one per line and in the order they are applie... | [
"2\ninsert 3\ngetMin 4\n",
"4\ninsert 1\ninsert 1\nremoveMin\ngetMin 2\n"
] | [
"4\ninsert 3\nremoveMin\ninsert 4\ngetMin 4\n",
"6\ninsert 1\ninsert 1\nremoveMin\nremoveMin\ninsert 2\ngetMin 2\n"
] | In the first sample, after number 3 is inserted into the heap, the minimum number is 3. To make the result of the first getMin equal to 4 one should firstly remove number 3 from the heap and then add number 4 into the heap.
In the second sample case number 1 is inserted two times, so should be similarly removed twice. | 1,500 | [
{
"input": "2\ninsert 3\ngetMin 4",
"output": "4\ninsert 3\nremoveMin\ninsert 4\ngetMin 4"
},
{
"input": "4\ninsert 1\ninsert 1\nremoveMin\ngetMin 2",
"output": "6\ninsert 1\ninsert 1\nremoveMin\nremoveMin\ninsert 2\ngetMin 2"
},
{
"input": "1\ninsert 1",
"output": "1\ninsert 1"
},... | 1,683,345,623 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 9 | 326 | 11,468,800 | import heapq
lists= []
heapq.heapify(lists)
result = []
n = int(input())
for _ in range(n):
get = input()
if get[0] == "r":
if lists:
heapq.heappop(lists)
else:
result.append("insert 0")
elif get[0] == "i":
splitted = get.split()
... | Title: Heap Operations
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Petya has recently learned data structure named "Binary heap".
The heap he is now operating with allows the following operations:
- put the given number into the heap; - get the value of the minimum element in the ... | ```python
import heapq
lists= []
heapq.heapify(lists)
result = []
n = int(input())
for _ in range(n):
get = input()
if get[0] == "r":
if lists:
heapq.heappop(lists)
else:
result.append("insert 0")
elif get[0] == "i":
splitted = get.split()... | 0 | |
50 | A | Domino piling | PROGRAMMING | 800 | [
"greedy",
"math"
] | A. Domino piling | 2 | 256 | You are given a rectangular board of *M*<=×<=*N* squares. Also you are given an unlimited number of standard domino pieces of 2<=×<=1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as possible on the board so as to meet the following conditions:
1. Each domino completely covers ... | In a single line you are given two integers *M* and *N* — board sizes in squares (1<=≤<=*M*<=≤<=*N*<=≤<=16). | Output one number — the maximal number of dominoes, which can be placed. | [
"2 4\n",
"3 3\n"
] | [
"4\n",
"4\n"
] | none | 500 | [
{
"input": "2 4",
"output": "4"
},
{
"input": "3 3",
"output": "4"
},
{
"input": "1 5",
"output": "2"
},
{
"input": "1 6",
"output": "3"
},
{
"input": "1 15",
"output": "7"
},
{
"input": "1 16",
"output": "8"
},
{
"input": "2 5",
"outpu... | 1,667,472,284 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 62 | 0 | n = int(input())
m = int(input())
print(int(m * n / 2)) | Title: Domino piling
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
You are given a rectangular board of *M*<=×<=*N* squares. Also you are given an unlimited number of standard domino pieces of 2<=×<=1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as p... | ```python
n = int(input())
m = int(input())
print(int(m * n / 2))
``` | -1 |
732 | A | Buy a Shovel | PROGRAMMING | 800 | [
"brute force",
"constructive algorithms",
"implementation",
"math"
] | null | null | Polycarp urgently needs a shovel! He comes to the shop and chooses an appropriate one. The shovel that Policarp chooses is sold for *k* burles. Assume that there is an unlimited number of such shovels in the shop.
In his pocket Polycarp has an unlimited number of "10-burle coins" and exactly one coin of *r* burles (1<... | The single line of input contains two integers *k* and *r* (1<=≤<=*k*<=≤<=1000, 1<=≤<=*r*<=≤<=9) — the price of one shovel and the denomination of the coin in Polycarp's pocket that is different from "10-burle coins".
Remember that he has an unlimited number of coins in the denomination of 10, that is, Polycarp has e... | Print the required minimum number of shovels Polycarp has to buy so that he can pay for them without any change. | [
"117 3\n",
"237 7\n",
"15 2\n"
] | [
"9\n",
"1\n",
"2\n"
] | In the first example Polycarp can buy 9 shovels and pay 9·117 = 1053 burles. Indeed, he can pay this sum by using 10-burle coins and one 3-burle coin. He can't buy fewer shovels without any change.
In the second example it is enough for Polycarp to buy one shovel.
In the third example Polycarp should buy two shovels ... | 500 | [
{
"input": "117 3",
"output": "9"
},
{
"input": "237 7",
"output": "1"
},
{
"input": "15 2",
"output": "2"
},
{
"input": "1 1",
"output": "1"
},
{
"input": "1 9",
"output": "9"
},
{
"input": "1000 3",
"output": "1"
},
{
"input": "1000 1",
... | 1,687,252,705 | 2,147,483,647 | Python 3 | OK | TESTS | 54 | 46 | 0 | a = input().split(" ")
b = a[0]
c = int(b[-1])
r = int(a[1])
output = 10
for i in range(1,10):
if int(str(c*i)[-1]) == 0:
output = i
break
if int(str(c*i)[-1]) == r:
output = i
break
print(output) | Title: Buy a Shovel
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Polycarp urgently needs a shovel! He comes to the shop and chooses an appropriate one. The shovel that Policarp chooses is sold for *k* burles. Assume that there is an unlimited number of such shovels in the shop.
In his ... | ```python
a = input().split(" ")
b = a[0]
c = int(b[-1])
r = int(a[1])
output = 10
for i in range(1,10):
if int(str(c*i)[-1]) == 0:
output = i
break
if int(str(c*i)[-1]) == r:
output = i
break
print(output)
``` | 3 | |
245 | B | Internet Address | PROGRAMMING | 1,100 | [
"implementation",
"strings"
] | null | null | Vasya is an active Internet user. One day he came across an Internet resource he liked, so he wrote its address in the notebook. We know that the address of the written resource has format:
where:
- <protocol> can equal either "http" (without the quotes) or "ftp" (without the quotes), - <domain> is a no... | The first line contains a non-empty string that Vasya wrote out in his notebook. This line consists of lowercase English letters only.
It is guaranteed that the given string contains at most 50 letters. It is guaranteed that the given string can be obtained from some correct Internet resource address, described above... | Print a single line — the address of the Internet resource that Vasya liked. If there are several addresses that meet the problem limitations, you are allowed to print any of them. | [
"httpsunrux\n",
"ftphttprururu\n"
] | [
"http://sun.ru/x\n",
"ftp://http.ru/ruru\n"
] | In the second sample there are two more possible answers: "ftp://httpruru.ru" and "ftp://httpru.ru/ru". | 0 | [
{
"input": "httpsunrux",
"output": "http://sun.ru/x"
},
{
"input": "ftphttprururu",
"output": "ftp://http.ru/ruru"
},
{
"input": "httpuururrururruruurururrrrrurrurrurruruuruuu",
"output": "http://uu.ru/rrururruruurururrrrrurrurrurruruuruuu"
},
{
"input": "httpabuaruauabbaruru... | 1,590,385,318 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 5 | 186 | 307,200 | s = input()
flag = 0
if(s[0]=='f'):
flag=1
ind = s.find('ru')
if((flag == 1 and ind==3) or (flag==0 and ind ==4)):
ind = s[ind+2:].find('ru')
if(flag==1):
print( s[:3] + '://' + s[3:ind] + '.' + s[ind:ind+2] + ('/' + s[ind+2:] if(len(s)>=ind+2) else ''))
else:
print( s[:4] + '://' + s[4:ind] +... | Title: Internet Address
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vasya is an active Internet user. One day he came across an Internet resource he liked, so he wrote its address in the notebook. We know that the address of the written resource has format:
where:
- <protocol>... | ```python
s = input()
flag = 0
if(s[0]=='f'):
flag=1
ind = s.find('ru')
if((flag == 1 and ind==3) or (flag==0 and ind ==4)):
ind = s[ind+2:].find('ru')
if(flag==1):
print( s[:3] + '://' + s[3:ind] + '.' + s[ind:ind+2] + ('/' + s[ind+2:] if(len(s)>=ind+2) else ''))
else:
print( s[:4] + '://' + ... | 0 | |
761 | A | Dasha and Stairs | PROGRAMMING | 1,000 | [
"brute force",
"constructive algorithms",
"implementation",
"math"
] | null | null | On her way to programming school tiger Dasha faced her first test — a huge staircase!
The steps were numbered from one to infinity. As we know, tigers are very fond of all striped things, it is possible that it has something to do with their color. So on some interval of her way she calculated two values — the number ... | In the only line you are given two integers *a*, *b* (0<=≤<=*a*,<=*b*<=≤<=100) — the number of even and odd steps, accordingly. | In the only line print "YES", if the interval of steps described above exists, and "NO" otherwise. | [
"2 3\n",
"3 1\n"
] | [
"YES\n",
"NO\n"
] | In the first example one of suitable intervals is from 1 to 5. The interval contains two even steps — 2 and 4, and three odd: 1, 3 and 5. | 500 | [
{
"input": "2 3",
"output": "YES"
},
{
"input": "3 1",
"output": "NO"
},
{
"input": "5 4",
"output": "YES"
},
{
"input": "9 9",
"output": "YES"
},
{
"input": "85 95",
"output": "NO"
},
{
"input": "0 1",
"output": "YES"
},
{
"input": "89 25"... | 1,595,754,022 | 2,147,483,647 | PyPy 3 | OK | TESTS | 21 | 155 | 20,172,800 | l1 = [int(x) for x in input().split()]
if l1[0] or l1[1]:
if max(l1[0],l1[1])-min(l1[0],l1[1])>1:
print("NO")
else:
print("YES")
else:
print("NO") | Title: Dasha and Stairs
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
On her way to programming school tiger Dasha faced her first test — a huge staircase!
The steps were numbered from one to infinity. As we know, tigers are very fond of all striped things, it is possible that it has so... | ```python
l1 = [int(x) for x in input().split()]
if l1[0] or l1[1]:
if max(l1[0],l1[1])-min(l1[0],l1[1])>1:
print("NO")
else:
print("YES")
else:
print("NO")
``` | 3 | |
282 | A | Bit++ | PROGRAMMING | 800 | [
"implementation"
] | null | null | The classic programming language of Bitland is Bit++. This language is so peculiar and complicated.
The language is that peculiar as it has exactly one variable, called *x*. Also, there are two operations:
- Operation ++ increases the value of variable *x* by 1. - Operation -- decreases the value of variable *x* by... | The first line contains a single integer *n* (1<=≤<=*n*<=≤<=150) — the number of statements in the programme.
Next *n* lines contain a statement each. Each statement contains exactly one operation (++ or --) and exactly one variable *x* (denoted as letter «X»). Thus, there are no empty statements. The operation and th... | Print a single integer — the final value of *x*. | [
"1\n++X\n",
"2\nX++\n--X\n"
] | [
"1\n",
"0\n"
] | none | 500 | [
{
"input": "1\n++X",
"output": "1"
},
{
"input": "2\nX++\n--X",
"output": "0"
},
{
"input": "3\n++X\n++X\n++X",
"output": "3"
},
{
"input": "2\n--X\n--X",
"output": "-2"
},
{
"input": "5\n++X\n--X\n++X\n--X\n--X",
"output": "-1"
},
{
"input": "28\nX--\... | 1,697,368,698 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 15 | 0 | n = int(input())
x = 0
for i in range(0,n):
p = input("")
if p == "++x":
x += 1
elif p == "--x":
x -= 1
print(x) | Title: Bit++
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The classic programming language of Bitland is Bit++. This language is so peculiar and complicated.
The language is that peculiar as it has exactly one variable, called *x*. Also, there are two operations:
- Operation ++ incre... | ```python
n = int(input())
x = 0
for i in range(0,n):
p = input("")
if p == "++x":
x += 1
elif p == "--x":
x -= 1
print(x)
``` | 0 | |
670 | A | Holidays | PROGRAMMING | 900 | [
"brute force",
"constructive algorithms",
"greedy",
"math"
] | null | null | On the planet Mars a year lasts exactly *n* days (there are no leap years on Mars). But Martians have the same weeks as earthlings — 5 work days and then 2 days off. Your task is to determine the minimum possible and the maximum possible number of days off per year on Mars. | The first line of the input contains a positive integer *n* (1<=≤<=*n*<=≤<=1<=000<=000) — the number of days in a year on Mars. | Print two integers — the minimum possible and the maximum possible number of days off per year on Mars. | [
"14\n",
"2\n"
] | [
"4 4\n",
"0 2\n"
] | In the first sample there are 14 days in a year on Mars, and therefore independently of the day a year starts with there will be exactly 4 days off .
In the second sample there are only 2 days in a year on Mars, and they can both be either work days or days off. | 500 | [
{
"input": "14",
"output": "4 4"
},
{
"input": "2",
"output": "0 2"
},
{
"input": "1",
"output": "0 1"
},
{
"input": "3",
"output": "0 2"
},
{
"input": "4",
"output": "0 2"
},
{
"input": "5",
"output": "0 2"
},
{
"input": "6",
"output":... | 1,647,765,343 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 6 | 31 | 0 | n=int(input())
mi=n//7
ma=n//7
mi*=2
ma*=2
if n%7==1:
ma+=1
elif n%7>=2:
ma+=2
print(mi,ma)
| Title: Holidays
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
On the planet Mars a year lasts exactly *n* days (there are no leap years on Mars). But Martians have the same weeks as earthlings — 5 work days and then 2 days off. Your task is to determine the minimum possible and the maxim... | ```python
n=int(input())
mi=n//7
ma=n//7
mi*=2
ma*=2
if n%7==1:
ma+=1
elif n%7>=2:
ma+=2
print(mi,ma)
``` | 0 | |
189 | A | Cut Ribbon | PROGRAMMING | 1,300 | [
"brute force",
"dp"
] | null | null | Polycarpus has a ribbon, its length is *n*. He wants to cut the ribbon in a way that fulfils the following two conditions:
- After the cutting each ribbon piece should have length *a*, *b* or *c*. - After the cutting the number of ribbon pieces should be maximum.
Help Polycarpus and find the number of ribbon piece... | The first line contains four space-separated integers *n*, *a*, *b* and *c* (1<=≤<=*n*,<=*a*,<=*b*,<=*c*<=≤<=4000) — the length of the original ribbon and the acceptable lengths of the ribbon pieces after the cutting, correspondingly. The numbers *a*, *b* and *c* can coincide. | Print a single number — the maximum possible number of ribbon pieces. It is guaranteed that at least one correct ribbon cutting exists. | [
"5 5 3 2\n",
"7 5 5 2\n"
] | [
"2\n",
"2\n"
] | In the first example Polycarpus can cut the ribbon in such way: the first piece has length 2, the second piece has length 3.
In the second example Polycarpus can cut the ribbon in such way: the first piece has length 5, the second piece has length 2. | 500 | [
{
"input": "5 5 3 2",
"output": "2"
},
{
"input": "7 5 5 2",
"output": "2"
},
{
"input": "4 4 4 4",
"output": "1"
},
{
"input": "1 1 1 1",
"output": "1"
},
{
"input": "4000 1 2 3",
"output": "4000"
},
{
"input": "4000 3 4 5",
"output": "1333"
},
... | 1,686,372,537 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 4 | 171 | 1,536,000 | def max_ribbon_pieces(n, a, b, c):
return ans
n, a, b, c = map(int, input().split())
# Calculate the maximum number of ribbon pieces
ans = 0
for i in range(n + 1):
for j in range(n + 1):
rem = n - i * a - j * b
if rem % c == 0:
k = rem // c
ans = max(a... | Title: Cut Ribbon
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Polycarpus has a ribbon, its length is *n*. He wants to cut the ribbon in a way that fulfils the following two conditions:
- After the cutting each ribbon piece should have length *a*, *b* or *c*. - After the cutting the... | ```python
def max_ribbon_pieces(n, a, b, c):
return ans
n, a, b, c = map(int, input().split())
# Calculate the maximum number of ribbon pieces
ans = 0
for i in range(n + 1):
for j in range(n + 1):
rem = n - i * a - j * b
if rem % c == 0:
k = rem // c
a... | 0 | |
527 | C | Glass Carving | PROGRAMMING | 1,500 | [
"binary search",
"data structures",
"implementation"
] | null | null | Leonid wants to become a glass carver (the person who creates beautiful artworks by cutting the glass). He already has a rectangular *w* mm <=×<= *h* mm sheet of glass, a diamond glass cutter and lots of enthusiasm. What he lacks is understanding of what to carve and how.
In order not to waste time, he decided to prac... | The first line contains three integers *w*,<=*h*,<=*n* (2<=≤<=*w*,<=*h*<=≤<=200<=000, 1<=≤<=*n*<=≤<=200<=000).
Next *n* lines contain the descriptions of the cuts. Each description has the form *H* *y* or *V* *x*. In the first case Leonid makes the horizontal cut at the distance *y* millimeters (1<=≤<=*y*<=≤<=*h*<=-<=... | After each cut print on a single line the area of the maximum available glass fragment in mm2. | [
"4 3 4\nH 2\nV 2\nV 3\nV 1\n",
"7 6 5\nH 4\nV 3\nV 5\nH 2\nV 1\n"
] | [
"8\n4\n4\n2\n",
"28\n16\n12\n6\n4\n"
] | Picture for the first sample test: | 1,500 | [
{
"input": "4 3 4\nH 2\nV 2\nV 3\nV 1",
"output": "8\n4\n4\n2"
},
{
"input": "7 6 5\nH 4\nV 3\nV 5\nH 2\nV 1",
"output": "28\n16\n12\n6\n4"
},
{
"input": "2 2 1\nV 1",
"output": "2"
},
{
"input": "2 2 1\nH 1",
"output": "2"
},
{
"input": "2 2 2\nV 1\nH 1",
"ou... | 1,585,267,018 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 61 | 307,200 | w, h, n = map(int, input().split())
h_lengths = [h]
w_lengths = [w]
h_lengths_record = [h]
w_lengths_record = [w]
def get_index_split(arr, start, stop, dist):
mid = (start + stop) // 2
if mid == 0:
return 0
if dist > arr[mid - 1] and dist < arr[mid]:
return mid
return get_index_split(arr, start, mid, dist)
d... | Title: Glass Carving
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Leonid wants to become a glass carver (the person who creates beautiful artworks by cutting the glass). He already has a rectangular *w* mm <=×<= *h* mm sheet of glass, a diamond glass cutter and lots of enthusiasm. What ... | ```python
w, h, n = map(int, input().split())
h_lengths = [h]
w_lengths = [w]
h_lengths_record = [h]
w_lengths_record = [w]
def get_index_split(arr, start, stop, dist):
mid = (start + stop) // 2
if mid == 0:
return 0
if dist > arr[mid - 1] and dist < arr[mid]:
return mid
return get_index_split(arr, start, mid,... | 0 | |
61 | A | Ultra-Fast Mathematician | PROGRAMMING | 800 | [
"implementation"
] | A. Ultra-Fast Mathematician | 2 | 256 | Shapur was an extremely gifted student. He was great at everything including Combinatorics, Algebra, Number Theory, Geometry, Calculus, etc. He was not only smart but extraordinarily fast! He could manage to sum 1018 numbers in a single second.
One day in 230 AD Shapur was trying to find out if any one can possibly do... | There are two lines in each input. Each of them contains a single number. It is guaranteed that the numbers are made from 0 and 1 only and that their length is same. The numbers may start with 0. The length of each number doesn't exceed 100. | Write one line — the corresponding answer. Do not omit the leading 0s. | [
"1010100\n0100101\n",
"000\n111\n",
"1110\n1010\n",
"01110\n01100\n"
] | [
"1110001\n",
"111\n",
"0100\n",
"00010\n"
] | none | 500 | [
{
"input": "1010100\n0100101",
"output": "1110001"
},
{
"input": "000\n111",
"output": "111"
},
{
"input": "1110\n1010",
"output": "0100"
},
{
"input": "01110\n01100",
"output": "00010"
},
{
"input": "011101\n000001",
"output": "011100"
},
{
"input": "... | 1,511,259,443 | 2,147,483,647 | Python 3 | OK | TESTS | 102 | 62 | 0 | fstLine = input()
scndLine = input()
arr = []
for i,j in zip(fstLine,scndLine):
arr.append('01'[i != j])
print(''.join(arr))
'''
Sample Input:
1010100
0100101
Sample Output:
1110001
'''
| Title: Ultra-Fast Mathematician
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Shapur was an extremely gifted student. He was great at everything including Combinatorics, Algebra, Number Theory, Geometry, Calculus, etc. He was not only smart but extraordinarily fast! He could manage to sum 10... | ```python
fstLine = input()
scndLine = input()
arr = []
for i,j in zip(fstLine,scndLine):
arr.append('01'[i != j])
print(''.join(arr))
'''
Sample Input:
1010100
0100101
Sample Output:
1110001
'''
``` | 3.9845 |
991 | C | Candies | PROGRAMMING | 1,500 | [
"binary search",
"implementation"
] | null | null | After passing a test, Vasya got himself a box of $n$ candies. He decided to eat an equal amount of candies each morning until there are no more candies. However, Petya also noticed the box and decided to get some candies for himself.
This means the process of eating candies is the following: in the beginning Vasya cho... | The first line contains a single integer $n$ ($1 \leq n \leq 10^{18}$) — the initial amount of candies in the box. | Output a single integer — the minimal amount of $k$ that would allow Vasya to eat at least half of candies he got. | [
"68\n"
] | [
"3\n"
] | In the sample, the amount of candies, with $k=3$, would change in the following way (Vasya eats first):
$68 \to 65 \to 59 \to 56 \to 51 \to 48 \to 44 \to 41 \\ \to 37 \to 34 \to 31 \to 28 \to 26 \to 23 \to 21 \to 18 \to 17 \to 14 \\ \to 13 \to 10 \to 9 \to 6 \to 6 \to 3 \to 3 \to 0$.
In total, Vasya would eat $39$ ca... | 1,250 | [
{
"input": "68",
"output": "3"
},
{
"input": "1",
"output": "1"
},
{
"input": "2",
"output": "1"
},
{
"input": "42",
"output": "1"
},
{
"input": "43",
"output": "2"
},
{
"input": "756",
"output": "29"
},
{
"input": "999999972",
"output"... | 1,583,245,520 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 62 | 0 | n = int(input().strip())
k = 0
for i in range(1,int(n/2)):
s = n
a = 0
b = 0
while s > 0:
s -= i
a += i
if s//10 > 0:
b += s//10
s -= s//10
if a >= n / 2 and b < n/2:
k = i
print(k)
exit(0) | Title: Candies
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
After passing a test, Vasya got himself a box of $n$ candies. He decided to eat an equal amount of candies each morning until there are no more candies. However, Petya also noticed the box and decided to get some candies for hi... | ```python
n = int(input().strip())
k = 0
for i in range(1,int(n/2)):
s = n
a = 0
b = 0
while s > 0:
s -= i
a += i
if s//10 > 0:
b += s//10
s -= s//10
if a >= n / 2 and b < n/2:
k = i
print(k)
exit(... | 0 | |
69 | A | Young Physicist | PROGRAMMING | 1,000 | [
"implementation",
"math"
] | A. Young Physicist | 2 | 256 | A guy named Vasya attends the final grade of a high school. One day Vasya decided to watch a match of his favorite hockey team. And, as the boy loves hockey very much, even more than physics, he forgot to do the homework. Specifically, he forgot to complete his physics tasks. Next day the teacher got very angry at Vasy... | The first line contains a positive integer *n* (1<=≤<=*n*<=≤<=100), then follow *n* lines containing three integers each: the *x**i* coordinate, the *y**i* coordinate and the *z**i* coordinate of the force vector, applied to the body (<=-<=100<=≤<=*x**i*,<=*y**i*,<=*z**i*<=≤<=100). | Print the word "YES" if the body is in equilibrium, or the word "NO" if it is not. | [
"3\n4 1 7\n-2 4 -1\n1 -5 -3\n",
"3\n3 -1 7\n-5 2 -4\n2 -1 -3\n"
] | [
"NO",
"YES"
] | none | 500 | [
{
"input": "3\n4 1 7\n-2 4 -1\n1 -5 -3",
"output": "NO"
},
{
"input": "3\n3 -1 7\n-5 2 -4\n2 -1 -3",
"output": "YES"
},
{
"input": "10\n21 32 -46\n43 -35 21\n42 2 -50\n22 40 20\n-27 -9 38\n-4 1 1\n-40 6 -31\n-13 -2 34\n-21 34 -12\n-32 -29 41",
"output": "NO"
},
{
"input": "10... | 1,693,230,649 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 6 | 92 | 0 | T = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
g = A[0]+B[0]+C[0]
f = A[1]+B[1]+C[1]
e = A[2]+B[2]+C[2]
if(g==0 and f==0 and e==0):
print("YES")
else:
print("NO")
| 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
T = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
g = A[0]+B[0]+C[0]
f = A[1]+B[1]+C[1]
e = A[2]+B[2]+C[2]
if(g==0 and f==0 and e==0):
print("YES")
else:
print("NO")
``` | 0 |
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,640,790,679 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 6 | 31 | 0 | n = int(input())
s = input()
count1 = 0
for i in s:
if(i=='0'):
count1+=1
print('1'+'0'*count1) | 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())
s = input()
count1 = 0
for i in s:
if(i=='0'):
count1+=1
print('1'+'0'*count1)
``` | 0 | |
500 | A | New Year Transportation | PROGRAMMING | 1,000 | [
"dfs and similar",
"graphs",
"implementation"
] | null | null | New Year is coming in Line World! In this world, there are *n* cells numbered by integers from 1 to *n*, as a 1<=×<=*n* board. People live in cells. However, it was hard to move between distinct cells, because of the difficulty of escaping the cell. People wanted to meet people who live in other cells.
So, user tncks0... | The first line contains two space-separated integers *n* (3<=≤<=*n*<=≤<=3<=×<=104) and *t* (2<=≤<=*t*<=≤<=*n*) — the number of cells, and the index of the cell which I want to go to.
The second line contains *n*<=-<=1 space-separated integers *a*1,<=*a*2,<=...,<=*a**n*<=-<=1 (1<=≤<=*a**i*<=≤<=*n*<=-<=*i*). It is guara... | If I can go to cell *t* using the transportation system, print "YES". Otherwise, print "NO". | [
"8 4\n1 2 1 2 1 2 1\n",
"8 5\n1 2 1 2 1 1 1\n"
] | [
"YES\n",
"NO\n"
] | In the first sample, the visited cells are: 1, 2, 4; so we can successfully visit the cell 4.
In the second sample, the possible cells to visit are: 1, 2, 4, 6, 7, 8; so we can't visit the cell 5, which we want to visit. | 500 | [
{
"input": "8 4\n1 2 1 2 1 2 1",
"output": "YES"
},
{
"input": "8 5\n1 2 1 2 1 1 1",
"output": "NO"
},
{
"input": "20 19\n13 16 7 6 12 1 5 7 8 6 5 7 5 5 3 3 2 2 1",
"output": "YES"
},
{
"input": "50 49\n11 7 1 41 26 36 19 16 38 14 36 35 37 27 20 27 3 6 21 2 27 11 18 17 19 16 ... | 1,682,617,631 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 34 | 78 | 4,505,600 | n,t=map(int,input().split())
a=list(map(int,input().split()))
k=0
e=0
for i in range(n):
try:
k+=a[k]
except:
break
if k+1==t:
e=1
break
print('YES' if e==1 else 'NO') | Title: New Year Transportation
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
New Year is coming in Line World! In this world, there are *n* cells numbered by integers from 1 to *n*, as a 1<=×<=*n* board. People live in cells. However, it was hard to move between distinct cells, because o... | ```python
n,t=map(int,input().split())
a=list(map(int,input().split()))
k=0
e=0
for i in range(n):
try:
k+=a[k]
except:
break
if k+1==t:
e=1
break
print('YES' if e==1 else 'NO')
``` | 3 | |
486 | A | Calculating Function | PROGRAMMING | 800 | [
"implementation",
"math"
] | null | null | For a positive integer *n* let's define a function *f*:
*f*(*n*)<==<=<=-<=1<=+<=2<=-<=3<=+<=..<=+<=(<=-<=1)*n**n*
Your task is to calculate *f*(*n*) for a given integer *n*. | The single line contains the positive integer *n* (1<=≤<=*n*<=≤<=1015). | Print *f*(*n*) in a single line. | [
"4\n",
"5\n"
] | [
"2\n",
"-3\n"
] | *f*(4) = - 1 + 2 - 3 + 4 = 2
*f*(5) = - 1 + 2 - 3 + 4 - 5 = - 3 | 500 | [
{
"input": "4",
"output": "2"
},
{
"input": "5",
"output": "-3"
},
{
"input": "1000000000",
"output": "500000000"
},
{
"input": "1000000001",
"output": "-500000001"
},
{
"input": "1000000000000000",
"output": "500000000000000"
},
{
"input": "100",
... | 1,699,068,592 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 0 | 31 | 0 | n = int(input())
k = 2*(n//2)
somapar = k*(k+1)
somaimpar = (k//2)**2
soma = somapar - somaimpar
if n%2 != 0:
soma -= n
print(soma) | Title: Calculating Function
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
For a positive integer *n* let's define a function *f*:
*f*(*n*)<==<=<=-<=1<=+<=2<=-<=3<=+<=..<=+<=(<=-<=1)*n**n*
Your task is to calculate *f*(*n*) for a given integer *n*.
Input Specification:
The single line... | ```python
n = int(input())
k = 2*(n//2)
somapar = k*(k+1)
somaimpar = (k//2)**2
soma = somapar - somaimpar
if n%2 != 0:
soma -= n
print(soma)
``` | 0 | |
638 | A | Home Numbers | PROGRAMMING | 1,100 | [
"*special",
"constructive algorithms",
"math"
] | null | null | The main street of Berland is a straight line with *n* houses built along it (*n* is an even number). The houses are located at both sides of the street. The houses with odd numbers are at one side of the street and are numbered from 1 to *n*<=-<=1 in the order from the beginning of the street to the end (in the pictur... | The first line of the input contains two integers, *n* and *a* (1<=≤<=*a*<=≤<=*n*<=≤<=100<=000) — the number of houses on the street and the number of the house that Vasya needs to reach, correspondingly. It is guaranteed that number *n* is even. | Print a single integer — the minimum time Vasya needs to get from the beginning of the street to house *a*. | [
"4 2\n",
"8 5\n"
] | [
"2\n",
"3\n"
] | In the first sample there are only four houses on the street, two houses at each side. House 2 will be the last at Vasya's right.
The second sample corresponds to picture with *n* = 8. House 5 is the one before last at Vasya's left. | 500 | [
{
"input": "4 2",
"output": "2"
},
{
"input": "8 5",
"output": "3"
},
{
"input": "2 1",
"output": "1"
},
{
"input": "2 2",
"output": "1"
},
{
"input": "10 1",
"output": "1"
},
{
"input": "10 10",
"output": "1"
},
{
"input": "100000 100000",... | 1,458,549,011 | 73,811 | Python 3 | OK | TESTS | 69 | 62 | 4,812,800 | n, a = map(int, input().split())
if a % 2 == 0:
print((n-a)//2+1)
else:
print(a//2+1) | Title: Home Numbers
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The main street of Berland is a straight line with *n* houses built along it (*n* is an even number). The houses are located at both sides of the street. The houses with odd numbers are at one side of the street and are nu... | ```python
n, a = map(int, input().split())
if a % 2 == 0:
print((n-a)//2+1)
else:
print(a//2+1)
``` | 3 | |
58 | A | Chat room | PROGRAMMING | 1,000 | [
"greedy",
"strings"
] | A. Chat room | 1 | 256 | Vasya has recently learned to type and log on to the Internet. He immediately entered a chat room and decided to say hello to everybody. Vasya typed the word *s*. It is considered that Vasya managed to say hello if several letters can be deleted from the typed word so that it resulted in the word "hello". For example, ... | The first and only line contains the word *s*, which Vasya typed. This word consisits of small Latin letters, its length is no less that 1 and no more than 100 letters. | If Vasya managed to say hello, print "YES", otherwise print "NO". | [
"ahhellllloou\n",
"hlelo\n"
] | [
"YES\n",
"NO\n"
] | none | 500 | [
{
"input": "ahhellllloou",
"output": "YES"
},
{
"input": "hlelo",
"output": "NO"
},
{
"input": "helhcludoo",
"output": "YES"
},
{
"input": "hehwelloho",
"output": "YES"
},
{
"input": "pnnepelqomhhheollvlo",
"output": "YES"
},
{
"input": "tymbzjyqhymeda... | 1,668,331,919 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 30 | 0 | s = input()
hello = 'hello'
index = 0
found = None
for i in hello:
found = False
for j in range(index, len(s)):
print(f'{j}now')
if s[j] == i:
index = j+1
print(index)
found = True
break
if not found:
print('NO')
... | Title: Chat room
Time Limit: 1 seconds
Memory Limit: 256 megabytes
Problem Description:
Vasya has recently learned to type and log on to the Internet. He immediately entered a chat room and decided to say hello to everybody. Vasya typed the word *s*. It is considered that Vasya managed to say hello if several letter... | ```python
s = input()
hello = 'hello'
index = 0
found = None
for i in hello:
found = False
for j in range(index, len(s)):
print(f'{j}now')
if s[j] == i:
index = j+1
print(index)
found = True
break
if not found:
print('... | 0 |
235 | A | LCM Challenge | PROGRAMMING | 1,600 | [
"number theory"
] | null | null | Some days ago, I learned the concept of LCM (least common multiple). I've played with it for several times and I want to make a big number with it.
But I also don't want to use many numbers, so I'll choose three positive integers (they don't have to be distinct) which are not greater than *n*. Can you help me to find ... | The first line contains an integer *n* (1<=≤<=*n*<=≤<=106) — the *n* mentioned in the statement. | Print a single integer — the maximum possible LCM of three not necessarily distinct positive integers that are not greater than *n*. | [
"9\n",
"7\n"
] | [
"504\n",
"210\n"
] | The least common multiple of some positive integers is the least positive integer which is multiple for each of them.
The result may become very large, 32-bit integer won't be enough. So using 64-bit integers is recommended.
For the last example, we can chose numbers 7, 6, 5 and the LCM of them is 7·6·5 = 210. It is ... | 500 | [
{
"input": "9",
"output": "504"
},
{
"input": "7",
"output": "210"
},
{
"input": "1",
"output": "1"
},
{
"input": "5",
"output": "60"
},
{
"input": "6",
"output": "60"
},
{
"input": "33",
"output": "32736"
},
{
"input": "21",
"output": ... | 1,590,299,382 | 2,147,483,647 | PyPy 3 | OK | TESTS | 87 | 374 | 1,740,800 | import math
from functools import reduce
def lcm(a, b):
g = math.gcd(a, b)
return a // g * b // g * g
def solve(n):
return max(find_from_n(n), find_from_n(n - 1))
def find_from_n(n):
if n == 0:
return 1
a = [n]
for i in range(n - 1, 0, -1):
if len(a) >= 3:... | Title: LCM Challenge
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Some days ago, I learned the concept of LCM (least common multiple). I've played with it for several times and I want to make a big number with it.
But I also don't want to use many numbers, so I'll choose three positive... | ```python
import math
from functools import reduce
def lcm(a, b):
g = math.gcd(a, b)
return a // g * b // g * g
def solve(n):
return max(find_from_n(n), find_from_n(n - 1))
def find_from_n(n):
if n == 0:
return 1
a = [n]
for i in range(n - 1, 0, -1):
if le... | 3 | |
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,692,454,390 | 2,147,483,647 | PyPy 3 | RUNTIME_ERROR | TESTS | 0 | 154 | 2,048,000 | t = int(input())
while(t>0):
s = input()
l = list(s)
a = 0
for i in range(len(s)-2,-1,-1):
if l[i] == '0':
l.remove(l[i])
a+=1
break
if a == 1:
print(''.join(l))
else:
if l[-1] == '0':
l.... | 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
t = int(input())
while(t>0):
s = input()
l = list(s)
a = 0
for i in range(len(s)-2,-1,-1):
if l[i] == '0':
l.remove(l[i])
a+=1
break
if a == 1:
print(''.join(l))
else:
if l[-1] == '0':
... | -1 | |
6 | A | Triangle | PROGRAMMING | 900 | [
"brute force",
"geometry"
] | A. Triangle | 2 | 64 | Johnny has a younger sister Anne, who is very clever and smart. As she came home from the kindergarten, she told his brother about the task that her kindergartener asked her to solve. The task was just to construct a triangle out of four sticks of different colours. Naturally, one of the sticks is extra. It is not allo... | The first line of the input contains four space-separated positive integer numbers not exceeding 100 — lengthes of the sticks. | Output TRIANGLE if it is possible to construct a non-degenerate triangle. Output SEGMENT if the first case cannot take place and it is possible to construct a degenerate triangle. Output IMPOSSIBLE if it is impossible to construct any triangle. Remember that you are to use three sticks. It is not allowed to break the s... | [
"4 2 1 3\n",
"7 2 2 4\n",
"3 5 9 1\n"
] | [
"TRIANGLE\n",
"SEGMENT\n",
"IMPOSSIBLE\n"
] | none | 0 | [
{
"input": "4 2 1 3",
"output": "TRIANGLE"
},
{
"input": "7 2 2 4",
"output": "SEGMENT"
},
{
"input": "3 5 9 1",
"output": "IMPOSSIBLE"
},
{
"input": "3 1 5 1",
"output": "IMPOSSIBLE"
},
{
"input": "10 10 10 10",
"output": "TRIANGLE"
},
{
"input": "11 ... | 1,512,168,153 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 5 | 124 | 5,529,600 | def check():
n = input()
n = n.split()
for i in range(len(n)):
n[i] = int(n[i])
for i in range(len(n)):
for k in range(i + 1, len(n)):
for p in range(k + 1, len(n)):
sides = [ n[i], n[k], n[p]]
for side in sides:
other_side... | Title: Triangle
Time Limit: 2 seconds
Memory Limit: 64 megabytes
Problem Description:
Johnny has a younger sister Anne, who is very clever and smart. As she came home from the kindergarten, she told his brother about the task that her kindergartener asked her to solve. The task was just to construct a triangle out o... | ```python
def check():
n = input()
n = n.split()
for i in range(len(n)):
n[i] = int(n[i])
for i in range(len(n)):
for k in range(i + 1, len(n)):
for p in range(k + 1, len(n)):
sides = [ n[i], n[k], n[p]]
for side in sides:
... | 0 |
937 | A | Olympiad | PROGRAMMING | 800 | [
"implementation",
"sortings"
] | null | null | The recent All-Berland Olympiad in Informatics featured *n* participants with each scoring a certain amount of points.
As the head of the programming committee, you are to determine the set of participants to be awarded with diplomas with respect to the following criteria:
- At least one participant should get a di... | The first line contains a single integer *n* (1<=≤<=*n*<=≤<=100) — the number of participants.
The next line contains a sequence of *n* integers *a*1,<=*a*2,<=...,<=*a**n* (0<=≤<=*a**i*<=≤<=600) — participants' scores.
It's guaranteed that at least one participant has non-zero score. | Print a single integer — the desired number of ways. | [
"4\n1 3 3 2\n",
"3\n1 1 1\n",
"4\n42 0 0 42\n"
] | [
"3\n",
"1\n",
"1\n"
] | There are three ways to choose a subset in sample case one.
1. Only participants with 3 points will get diplomas. 1. Participants with 2 or 3 points will get diplomas. 1. Everyone will get a diploma!
The only option in sample case two is to award everyone.
Note that in sample case three participants with zero sco... | 500 | [
{
"input": "4\n1 3 3 2",
"output": "3"
},
{
"input": "3\n1 1 1",
"output": "1"
},
{
"input": "4\n42 0 0 42",
"output": "1"
},
{
"input": "10\n1 0 1 0 1 0 0 0 0 1",
"output": "1"
},
{
"input": "10\n572 471 540 163 50 30 561 510 43 200",
"output": "10"
},
{
... | 1,621,540,247 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 46 | 102,400 | from functools import reduce
n=int(input())
k=[int(k) for k in input().split()]
s=set(k)
s.remove(0)
print(len(s)) | Title: Olympiad
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The recent All-Berland Olympiad in Informatics featured *n* participants with each scoring a certain amount of points.
As the head of the programming committee, you are to determine the set of participants to be awarded with ... | ```python
from functools import reduce
n=int(input())
k=[int(k) for k in input().split()]
s=set(k)
s.remove(0)
print(len(s))
``` | -1 |
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.