contestId int64 0 1.01k | index stringclasses 55
values | name stringlengths 2 58 | type stringclasses 2
values | rating int64 0 3.5k | tags listlengths 0 7 | title stringclasses 495
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 5 65.5k | instruction_seed stringlengths 262 8.2k | response stringlengths 19 65.5k | score float64 -1 3.99 | _source stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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,651,945,658 | 2,147,483,647 | Python 3 | OK | TESTS | 30 | 92 | 0 | s = str(input())
b = len([i for i in s if i.isupper()])
b1 = len(s) - b
if b <= b1:
print(s.lower())
else:
print(s.upper()) | Title: Word
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Vasya is very upset that many people on the Net mix uppercase and lowercase letters in one word. That's why he decided to invent an extension for his favorite browser that would change the letters' register in every word so that it ei... | ```python
s = str(input())
b = len([i for i in s if i.isupper()])
b1 = len(s) - b
if b <= b1:
print(s.lower())
else:
print(s.upper())
``` | 3.977 | MatrixStudio/Codeforces-Python-Submissions |
581 | A | Vasya the Hipster | PROGRAMMING | 800 | [
"implementation",
"math"
] | null | null | One day Vasya the Hipster decided to count how many socks he had. It turned out that he had *a* red socks and *b* blue socks.
According to the latest fashion, hipsters should wear the socks of different colors: a red one on the left foot, a blue one on the right foot.
Every day Vasya puts on new socks in the morning ... | The single line of the input contains two positive integers *a* and *b* (1<=≤<=*a*,<=*b*<=≤<=100) — the number of red and blue socks that Vasya's got. | Print two space-separated integers — the maximum number of days when Vasya can wear different socks and the number of days when he can wear the same socks until he either runs out of socks or cannot make a single pair from the socks he's got.
Keep in mind that at the end of the day Vasya throws away the socks that he'... | [
"3 1\n",
"2 3\n",
"7 3\n"
] | [
"1 1\n",
"2 0\n",
"3 2\n"
] | In the first sample Vasya can first put on one pair of different socks, after that he has two red socks left to wear on the second day. | 500 | [
{
"input": "3 1",
"output": "1 1"
},
{
"input": "2 3",
"output": "2 0"
},
{
"input": "7 3",
"output": "3 2"
},
{
"input": "100 100",
"output": "100 0"
},
{
"input": "4 10",
"output": "4 3"
},
{
"input": "6 10",
"output": "6 2"
},
{
"input":... | 1,689,679,769 | 2,147,483,647 | Python 3 | OK | TESTS | 30 | 46 | 0 | s=input().split()
x=int(s[0])
y=int(s[1])
n=min(x,y)
m=max(x,y)
print(n,end=' ')
print((m-n)//2) | Title: Vasya the Hipster
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
One day Vasya the Hipster decided to count how many socks he had. It turned out that he had *a* red socks and *b* blue socks.
According to the latest fashion, hipsters should wear the socks of different colors: a red... | ```python
s=input().split()
x=int(s[0])
y=int(s[1])
n=min(x,y)
m=max(x,y)
print(n,end=' ')
print((m-n)//2)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
460 | A | Vasya and Socks | PROGRAMMING | 900 | [
"brute force",
"implementation",
"math"
] | null | null | Vasya has *n* pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When he comes home in the evening, Vasya takes off the used socks and throws them away. Every *m*-th day (at days with numbers *m*,<=2*m*,<=3*m*,<=...) mom buys a pair of socks to Vasya. She does it la... | The single line contains two integers *n* and *m* (1<=≤<=*n*<=≤<=100; 2<=≤<=*m*<=≤<=100), separated by a space. | Print a single integer — the answer to the problem. | [
"2 2\n",
"9 3\n"
] | [
"3\n",
"13\n"
] | In the first sample Vasya spends the first two days wearing the socks that he had initially. Then on day three he puts on the socks that were bought on day two.
In the second sample Vasya spends the first nine days wearing the socks that he had initially. Then he spends three days wearing the socks that were bought on... | 500 | [
{
"input": "2 2",
"output": "3"
},
{
"input": "9 3",
"output": "13"
},
{
"input": "1 2",
"output": "1"
},
{
"input": "2 3",
"output": "2"
},
{
"input": "1 99",
"output": "1"
},
{
"input": "4 4",
"output": "5"
},
{
"input": "10 2",
"outp... | 1,650,389,712 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 30 | 0 | n = int(input())
m = int(input())
k = 0
day = 0
while n > 0:
n -= 1
day += 1
if day % m == 0:
n += 1
print(day)
| Title: Vasya and Socks
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vasya has *n* pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When he comes home in the evening, Vasya takes off the used socks and throws them away. Every *m*-th... | ```python
n = int(input())
m = int(input())
k = 0
day = 0
while n > 0:
n -= 1
day += 1
if day % m == 0:
n += 1
print(day)
``` | -1 | MatrixStudio/Codeforces-Python-Submissions | |
271 | A | Beautiful Year | PROGRAMMING | 800 | [
"brute force"
] | null | null | It seems like the year of 2013 came only yesterday. Do you know a curious fact? The year of 2013 is the first year after the old 1987 with only distinct digits.
Now you are suggested to solve the following problem: given a year number, find the minimum year number which is strictly larger than the given one and has on... | The single line contains integer *y* (1000<=≤<=*y*<=≤<=9000) — the year number. | Print a single integer — the minimum year number that is strictly larger than *y* and all it's digits are distinct. It is guaranteed that the answer exists. | [
"1987\n",
"2013\n"
] | [
"2013\n",
"2014\n"
] | none | 500 | [
{
"input": "1987",
"output": "2013"
},
{
"input": "2013",
"output": "2014"
},
{
"input": "1000",
"output": "1023"
},
{
"input": "1001",
"output": "1023"
},
{
"input": "1234",
"output": "1235"
},
{
"input": "5555",
"output": "5601"
},
{
"inp... | 1,693,256,799 | 2,147,483,647 | Python 3 | OK | TESTS | 27 | 92 | 0 | y = int(input()) # Input year
def has_distinct_digits(year):
return len(set(str(year))) == len(str(year))
next_year = y + 1
while not has_distinct_digits(next_year):
next_year += 1
print(next_year) | Title: Beautiful Year
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
It seems like the year of 2013 came only yesterday. Do you know a curious fact? The year of 2013 is the first year after the old 1987 with only distinct digits.
Now you are suggested to solve the following problem: give... | ```python
y = int(input()) # Input year
def has_distinct_digits(year):
return len(set(str(year))) == len(str(year))
next_year = y + 1
while not has_distinct_digits(next_year):
next_year += 1
print(next_year)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
922 | A | Cloning Toys | PROGRAMMING | 1,300 | [
"implementation"
] | null | null | Imp likes his plush toy a lot.
Recently, he found a machine that can clone plush toys. Imp knows that if he applies the machine to an original toy, he additionally gets one more original toy and one copy, and if he applies the machine to a copied toy, he gets two additional copies.
Initially, Imp has only one origina... | The only line contains two integers *x* and *y* (0<=≤<=*x*,<=*y*<=≤<=109) — the number of copies and the number of original toys Imp wants to get (including the initial one). | Print "Yes", if the desired configuration is possible, and "No" otherwise.
You can print each letter in arbitrary case (upper or lower). | [
"6 3\n",
"4 2\n",
"1000 1001\n"
] | [
"Yes\n",
"No\n",
"Yes\n"
] | In the first example, Imp has to apply the machine twice to original toys and then twice to copies. | 500 | [
{
"input": "6 3",
"output": "Yes"
},
{
"input": "4 2",
"output": "No"
},
{
"input": "1000 1001",
"output": "Yes"
},
{
"input": "1000000000 999999999",
"output": "Yes"
},
{
"input": "81452244 81452247",
"output": "No"
},
{
"input": "188032448 86524683",... | 1,592,651,942 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 20 | 186 | 0 | #https://codeforces.com/problemset/problem/922/A
c,o=map(int,input().split())
o-=1
if o<1:
print('No')
elif c>=o and c-o&1==0:
print('Yes')
else:
print('No')
| Title: Cloning Toys
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Imp likes his plush toy a lot.
Recently, he found a machine that can clone plush toys. Imp knows that if he applies the machine to an original toy, he additionally gets one more original toy and one copy, and if he applie... | ```python
#https://codeforces.com/problemset/problem/922/A
c,o=map(int,input().split())
o-=1
if o<1:
print('No')
elif c>=o and c-o&1==0:
print('Yes')
else:
print('No')
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
26 | A | Almost Prime | PROGRAMMING | 900 | [
"number theory"
] | A. Almost Prime | 2 | 256 | A number is called almost prime if it has exactly two distinct prime divisors. For example, numbers 6, 18, 24 are almost prime, while 4, 8, 9, 42 are not. Find the amount of almost prime numbers which are between 1 and *n*, inclusive. | Input contains one integer number *n* (1<=≤<=*n*<=≤<=3000). | Output the amount of almost prime numbers between 1 and *n*, inclusive. | [
"10\n",
"21\n"
] | [
"2\n",
"8\n"
] | none | 500 | [
{
"input": "10",
"output": "2"
},
{
"input": "21",
"output": "8"
},
{
"input": "1",
"output": "0"
},
{
"input": "2",
"output": "0"
},
{
"input": "4",
"output": "0"
},
{
"input": "3",
"output": "0"
},
{
"input": "8",
"output": "1"
},
... | 1,680,343,125 | 2,147,483,647 | Python 3 | OK | TESTS | 23 | 684 | 0 | import math
def prime(n):
if n<=0:
return 0
c=int(math.sqrt(n))
for i in range(2,c+1):
if n%i==0:
return 0
return 1
def fun(n):
c=0
for i in range(2,n):
if n%i==0 and prime(i):
c+=1
if c==2:
return 1
else:
r... | 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
import math
def prime(n):
if n<=0:
return 0
c=int(math.sqrt(n))
for i in range(2,c+1):
if n%i==0:
return 0
return 1
def fun(n):
c=0
for i in range(2,n):
if n%i==0 and prime(i):
c+=1
if c==2:
return 1
else:
... | 3.829 | MatrixStudio/Codeforces-Python-Submissions |
4 | A | Watermelon | PROGRAMMING | 800 | [
"brute force",
"math"
] | A. Watermelon | 1 | 64 | One hot summer day Pete and his friend Billy decided to buy a watermelon. They chose the biggest and the ripest one, in their opinion. After that the watermelon was weighed, and the scales showed *w* kilos. They rushed home, dying of thirst, and decided to divide the berry, however they faced a hard problem.
Pete and ... | The first (and the only) input line contains integer number *w* (1<=≤<=*w*<=≤<=100) — the weight of the watermelon bought by the boys. | Print YES, if the boys can divide the watermelon into two parts, each of them weighing even number of kilos; and NO in the opposite case. | [
"8\n"
] | [
"YES\n"
] | For example, the boys can divide the watermelon into two parts of 2 and 6 kilos respectively (another variant — two parts of 4 and 4 kilos). | 0 | [
{
"input": "8",
"output": "YES"
},
{
"input": "5",
"output": "NO"
},
{
"input": "4",
"output": "YES"
},
{
"input": "3",
"output": "NO"
},
{
"input": "2",
"output": "NO"
},
{
"input": "1",
"output": "NO"
},
{
"input": "7",
"output": "NO"... | 1,692,607,793 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 7 | 124 | 0 | w = input()
integer = int(w)
if 0 <= integer <100 and integer%2==0 and (integer/2)%2==0:
print("YES")
elif 0 <= integer <100 and integer%2==1 or 0 <= integer <100 and (integer/2)%2==1 :
print("NO")
else:
False
| Title: Watermelon
Time Limit: 1 seconds
Memory Limit: 64 megabytes
Problem Description:
One hot summer day Pete and his friend Billy decided to buy a watermelon. They chose the biggest and the ripest one, in their opinion. After that the watermelon was weighed, and the scales showed *w* kilos. They rushed home, dyin... | ```python
w = input()
integer = int(w)
if 0 <= integer <100 and integer%2==0 and (integer/2)%2==0:
print("YES")
elif 0 <= integer <100 and integer%2==1 or 0 <= integer <100 and (integer/2)%2==1 :
print("NO")
else:
False
``` | 0 | MatrixStudio/Codeforces-Python-Submissions |
864 | C | Bus | PROGRAMMING | 1,500 | [
"greedy",
"implementation",
"math"
] | null | null | A bus moves along the coordinate line *Ox* from the point *x*<==<=0 to the point *x*<==<=*a*. After starting from the point *x*<==<=0, it reaches the point *x*<==<=*a*, immediately turns back and then moves to the point *x*<==<=0. After returning to the point *x*<==<=0 it immediately goes back to the point *x*<==<=*a* ... | The first line contains four integers *a*, *b*, *f*, *k* (0<=<<=*f*<=<<=*a*<=≤<=106, 1<=≤<=*b*<=≤<=109, 1<=≤<=*k*<=≤<=104) — the endpoint of the first bus journey, the capacity of the fuel tank of the bus, the point where the gas station is located, and the required number of journeys. | Print the minimum number of times the bus needs to refuel to make *k* journeys. If it is impossible for the bus to make *k* journeys, print -1. | [
"6 9 2 4\n",
"6 10 2 4\n",
"6 5 4 3\n"
] | [
"4\n",
"2\n",
"-1\n"
] | In the first example the bus needs to refuel during each journey.
In the second example the bus can pass 10 units of distance without refueling. So the bus makes the whole first journey, passes 4 units of the distance of the second journey and arrives at the point with the gas station. Then it can refuel its tank, fin... | 1,500 | [
{
"input": "6 9 2 4",
"output": "4"
},
{
"input": "6 10 2 4",
"output": "2"
},
{
"input": "6 5 4 3",
"output": "-1"
},
{
"input": "2 2 1 1",
"output": "0"
},
{
"input": "10 4 6 10",
"output": "-1"
},
{
"input": "3 1 1 1",
"output": "-1"
},
{
... | 1,698,930,919 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 6 | 77 | 0 | a,b,f,k=map(int,input().split())
if f*2>b or (a-f)*2>b:
print(-1)
else:
ans=0
s=b-f
for _ in range(k):
t=[(a-f)*2,f*2][_&1]
if _==k-1:
t-=[f,a-f][k&1]
if s<t:
ans+=1
s=b-t
else:
s-=a
print(ans) | Title: Bus
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
A bus moves along the coordinate line *Ox* from the point *x*<==<=0 to the point *x*<==<=*a*. After starting from the point *x*<==<=0, it reaches the point *x*<==<=*a*, immediately turns back and then moves to the point *x*<==<=0. ... | ```python
a,b,f,k=map(int,input().split())
if f*2>b or (a-f)*2>b:
print(-1)
else:
ans=0
s=b-f
for _ in range(k):
t=[(a-f)*2,f*2][_&1]
if _==k-1:
t-=[f,a-f][k&1]
if s<t:
ans+=1
s=b-t
else:
s-=a
print(ans)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
222 | A | Shooshuns and Sequence | PROGRAMMING | 1,200 | [
"brute force",
"implementation"
] | null | null | One day shooshuns found a sequence of *n* integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps:
1. Find the number that goes *k*-th in the current sequence and add the same number to the end of the sequence; 1. Delete the first number of the current ... | The first line contains two space-separated integers *n* and *k* (1<=≤<=*k*<=≤<=*n*<=≤<=105).
The second line contains *n* space-separated integers: *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=105) — the sequence that the shooshuns found. | Print the minimum number of operations, required for all numbers on the blackboard to become the same. If it is impossible to achieve, print -1. | [
"3 2\n3 1 1\n",
"3 1\n3 1 1\n"
] | [
"1\n",
"-1\n"
] | In the first test case after the first operation the blackboard will have sequence [1, 1, 1]. So, one operation is enough to make all numbers the same. Thus, the answer equals one.
In the second test case the sequence will never consist of the same numbers. It will always contain at least two distinct numbers 3 and 1.... | 500 | [
{
"input": "3 2\n3 1 1",
"output": "1"
},
{
"input": "3 1\n3 1 1",
"output": "-1"
},
{
"input": "1 1\n1",
"output": "0"
},
{
"input": "2 1\n1 1",
"output": "0"
},
{
"input": "2 1\n2 1",
"output": "-1"
},
{
"input": "4 4\n1 2 3 4",
"output": "3"
}... | 1,692,337,153 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 5 | 92 | 0 | def dup(lst):
return len(lst) != len(set(lst))
operations = 0
n, k = map(int, input().split(" "))
l = list(map(int, input().split(" ")))
while dup(l) and len(set(l)) != 1:
val = l.pop(k - 1)
l.append(val)
l.pop(0)
operations += 1
a = list(set(l))
if len(a) == 1:
print(operati... | Title: Shooshuns and Sequence
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
One day shooshuns found a sequence of *n* integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps:
1. Find the number that goes *k*-th in the cur... | ```python
def dup(lst):
return len(lst) != len(set(lst))
operations = 0
n, k = map(int, input().split(" "))
l = list(map(int, input().split(" ")))
while dup(l) and len(set(l)) != 1:
val = l.pop(k - 1)
l.append(val)
l.pop(0)
operations += 1
a = list(set(l))
if len(a) == 1:
pri... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
80 | A | Panoramix's Prediction | PROGRAMMING | 800 | [
"brute force"
] | A. Panoramix's Prediction | 2 | 256 | A prime number is a number which has exactly two distinct divisors: one and itself. For example, numbers 2, 7, 3 are prime, and 1, 6, 4 are not.
The next prime number after *x* is the smallest prime number greater than *x*. For example, the next prime number after 2 is 3, and the next prime number after 3 is 5. Note t... | The first and only input line contains two positive integers — *n* and *m* (2<=≤<=*n*<=<<=*m*<=≤<=50). It is guaranteed that *n* is prime.
Pretests contain all the cases with restrictions 2<=≤<=*n*<=<<=*m*<=≤<=4. | Print YES, if *m* is the next prime number after *n*, or NO otherwise. | [
"3 5\n",
"7 11\n",
"7 9\n"
] | [
"YES",
"YES",
"NO"
] | none | 500 | [
{
"input": "3 5",
"output": "YES"
},
{
"input": "7 11",
"output": "YES"
},
{
"input": "7 9",
"output": "NO"
},
{
"input": "2 3",
"output": "YES"
},
{
"input": "2 4",
"output": "NO"
},
{
"input": "3 4",
"output": "NO"
},
{
"input": "3 5",
... | 1,609,923,005 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 186 | 0 | # import os
# import math
def is_prime(n):
r = True
if n < 2:
return False
for i in range(2, n//2):
if n % i == 0:
r = False
break
return r
n, m = map(int, input())
while True:
n += 1
if is_prime(n):
break
if n == m:
... | Title: Panoramix's Prediction
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
A prime number is a number which has exactly two distinct divisors: one and itself. For example, numbers 2, 7, 3 are prime, and 1, 6, 4 are not.
The next prime number after *x* is the smallest prime number greater t... | ```python
# import os
# import math
def is_prime(n):
r = True
if n < 2:
return False
for i in range(2, n//2):
if n % i == 0:
r = False
break
return r
n, m = map(int, input())
while True:
n += 1
if is_prime(n):
break
if n... | -1 | MatrixStudio/Codeforces-Python-Submissions |
887 | A | Div. 64 | PROGRAMMING | 1,000 | [
"implementation"
] | null | null | Top-model Izabella participates in the competition. She wants to impress judges and show her mathematical skills.
Her problem is following: for given string, consisting of only 0 and 1, tell if it's possible to remove some digits in such a way, that remaining number is a representation of some positive integer, divisi... | In the only line given a non-empty binary string *s* with length up to 100. | Print «yes» (without quotes) if it's possible to remove digits required way and «no» otherwise. | [
"100010001\n",
"100\n"
] | [
"yes",
"no"
] | In the first test case, you can get string 1 000 000 after removing two ones which is a representation of number 64 in the binary numerical system.
You can read more about binary numeral system representation here: [https://en.wikipedia.org/wiki/Binary_system](https://en.wikipedia.org/wiki/Binary_system) | 500 | [
{
"input": "100010001",
"output": "yes"
},
{
"input": "100",
"output": "no"
},
{
"input": "0000001000000",
"output": "yes"
},
{
"input": "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111",
"output": "no"
},
{
"in... | 1,619,628,202 | 2,147,483,647 | Python 3 | OK | TESTS | 98 | 77 | 0 | x=input()
if "1" in x:
ind=x.index("1")
x=x[ind:]
x=x.count("0")
if x>=6:
print("yes")
else:
print("no")
else:
print("no") | Title: Div. 64
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Top-model Izabella participates in the competition. She wants to impress judges and show her mathematical skills.
Her problem is following: for given string, consisting of only 0 and 1, tell if it's possible to remove some dig... | ```python
x=input()
if "1" in x:
ind=x.index("1")
x=x[ind:]
x=x.count("0")
if x>=6:
print("yes")
else:
print("no")
else:
print("no")
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
883 | M | Quadcopter Competition | PROGRAMMING | 1,100 | [
"greedy",
"math"
] | null | null | Polycarp takes part in a quadcopter competition. According to the rules a flying robot should:
- start the race from some point of a field, - go around the flag, - close cycle returning back to the starting point.
Polycarp knows the coordinates of the starting point (*x*1,<=*y*1) and the coordinates of the point w... | The first line contains two integer numbers *x*1 and *y*1 (<=-<=100<=≤<=*x*1,<=*y*1<=≤<=100) — coordinates of the quadcopter starting (and finishing) point.
The second line contains two integer numbers *x*2 and *y*2 (<=-<=100<=≤<=*x*2,<=*y*2<=≤<=100) — coordinates of the flag.
It is guaranteed that the quadcopter sta... | Print the length of minimal path of the quadcopter to surround the flag and return back. | [
"1 5\n5 2\n",
"0 1\n0 0\n"
] | [
"18\n",
"8\n"
] | none | 0 | [
{
"input": "1 5\n5 2",
"output": "18"
},
{
"input": "0 1\n0 0",
"output": "8"
},
{
"input": "-100 -100\n100 100",
"output": "804"
},
{
"input": "-100 -100\n-100 100",
"output": "406"
},
{
"input": "-100 -100\n100 -100",
"output": "406"
},
{
"input": "1... | 1,508,573,382 | 282 | Python 3 | OK | TESTS1 | 42 | 62 | 5,529,600 | Q = input().split(" ")
F = input().split(" ")
xQ = int(Q[0])
yQ = int(Q[1])
xF = int(F[0])
yF = int(F[1])
if xQ == xF:
print((abs(yQ-yF)+1)*2+4)
elif yQ == yF:
print((abs(xQ-xF)+1)*2+4)
else:
print((abs(xQ-xF)+1)*2+(abs(yQ-yF)+1)*2)
| Title: Quadcopter Competition
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Polycarp takes part in a quadcopter competition. According to the rules a flying robot should:
- start the race from some point of a field, - go around the flag, - close cycle returning back to the starting p... | ```python
Q = input().split(" ")
F = input().split(" ")
xQ = int(Q[0])
yQ = int(Q[1])
xF = int(F[0])
yF = int(F[1])
if xQ == xF:
print((abs(yQ-yF)+1)*2+4)
elif yQ == yF:
print((abs(xQ-xF)+1)*2+4)
else:
print((abs(xQ-xF)+1)*2+(abs(yQ-yF)+1)*2)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
248 | A | Cupboards | PROGRAMMING | 800 | [
"implementation"
] | null | null | One foggy Stockholm morning, Karlsson decided to snack on some jam in his friend Lillebror Svantenson's house. Fortunately for Karlsson, there wasn't anybody in his friend's house. Karlsson was not going to be hungry any longer, so he decided to get some food in the house.
Karlsson's gaze immediately fell on *n* woode... | The first input line contains a single integer *n* — the number of cupboards in the kitchen (2<=≤<=*n*<=≤<=104). Then follow *n* lines, each containing two integers *l**i* and *r**i* (0<=≤<=*l**i*,<=*r**i*<=≤<=1). Number *l**i* equals one, if the left door of the *i*-th cupboard is opened, otherwise number *l**i* equal... | In the only output line print a single integer *t* — the minimum number of seconds Karlsson needs to change the doors of all cupboards to the position he needs. | [
"5\n0 1\n1 0\n0 1\n1 1\n0 1\n"
] | [
"3\n"
] | none | 500 | [
{
"input": "5\n0 1\n1 0\n0 1\n1 1\n0 1",
"output": "3"
},
{
"input": "2\n0 0\n0 0",
"output": "0"
},
{
"input": "3\n0 1\n1 1\n1 1",
"output": "1"
},
{
"input": "8\n0 1\n1 0\n0 1\n1 1\n0 1\n1 0\n0 1\n1 0",
"output": "7"
},
{
"input": "8\n1 0\n1 0\n1 0\n0 1\n0 1\n1 ... | 1,680,177,173 | 2,147,483,647 | Python 3 | OK | TESTS | 57 | 124 | 0 | N=int(input())
x=0
y=0
for i in range(N):
a,b=map(int,input().split(" ",1))
if a==0:
x=x+1
if b==0:
y=y+1
x=min(N-x,x)
y=min(N-y,y)
print(x+y)
| Title: Cupboards
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
One foggy Stockholm morning, Karlsson decided to snack on some jam in his friend Lillebror Svantenson's house. Fortunately for Karlsson, there wasn't anybody in his friend's house. Karlsson was not going to be hungry any long... | ```python
N=int(input())
x=0
y=0
for i in range(N):
a,b=map(int,input().split(" ",1))
if a==0:
x=x+1
if b==0:
y=y+1
x=min(N-x,x)
y=min(N-y,y)
print(x+y)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
570 | A | Elections | PROGRAMMING | 1,100 | [
"implementation"
] | null | null | The country of Byalechinsk is running elections involving *n* candidates. The country consists of *m* cities. We know how many people in each city voted for each candidate.
The electoral system in the country is pretty unusual. At the first stage of elections the votes are counted for each city: it is assumed that in ... | The first line of the input contains two integers *n*, *m* (1<=≤<=*n*,<=*m*<=≤<=100) — the number of candidates and of cities, respectively.
Each of the next *m* lines contains *n* non-negative integers, the *j*-th number in the *i*-th line *a**ij* (1<=≤<=*j*<=≤<=*n*, 1<=≤<=*i*<=≤<=*m*, 0<=≤<=*a**ij*<=≤<=109) denotes ... | Print a single number — the index of the candidate who won the elections. The candidates are indexed starting from one. | [
"3 3\n1 2 3\n2 3 1\n1 2 1\n",
"3 4\n10 10 3\n5 1 6\n2 2 2\n1 5 7\n"
] | [
"2",
"1"
] | Note to the first sample test. At the first stage city 1 chosen candidate 3, city 2 chosen candidate 2, city 3 chosen candidate 2. The winner is candidate 2, he gained 2 votes.
Note to the second sample test. At the first stage in city 1 candidates 1 and 2 got the same maximum number of votes, but candidate 1 has a sm... | 500 | [
{
"input": "3 3\n1 2 3\n2 3 1\n1 2 1",
"output": "2"
},
{
"input": "3 4\n10 10 3\n5 1 6\n2 2 2\n1 5 7",
"output": "1"
},
{
"input": "1 3\n5\n3\n2",
"output": "1"
},
{
"input": "3 1\n1 2 3",
"output": "3"
},
{
"input": "3 1\n100 100 100",
"output": "1"
},
{... | 1,545,056,174 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 15 | 124 | 0 | n, m = map(int, input().split())
L = []
for i in range(m):
v = list(map(int, input().split()))
c = v.index(max(v))
L += [c+1]
m = 0
C = 101
for i in L:
a = L.count(i)
if m <= a:
m = a
if i < C:
C = i
else:
continue
print(C)
| Title: Elections
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The country of Byalechinsk is running elections involving *n* candidates. The country consists of *m* cities. We know how many people in each city voted for each candidate.
The electoral system in the country is pretty unusu... | ```python
n, m = map(int, input().split())
L = []
for i in range(m):
v = list(map(int, input().split()))
c = v.index(max(v))
L += [c+1]
m = 0
C = 101
for i in L:
a = L.count(i)
if m <= a:
m = a
if i < C:
C = i
else:
continue
print(C)
... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
884 | A | Book Reading | PROGRAMMING | 800 | [
"implementation"
] | null | null | Recently Luba bought a very interesting book. She knows that it will take *t* seconds to read the book. Luba wants to finish reading as fast as she can.
But she has some work to do in each of *n* next days. The number of seconds that Luba has to spend working during *i*-th day is *a**i*. If some free time remains, she... | The first line contains two integers *n* and *t* (1<=≤<=*n*<=≤<=100, 1<=≤<=*t*<=≤<=106) — the number of days and the time required to read the book.
The second line contains *n* integers *a**i* (0<=≤<=*a**i*<=≤<=86400) — the time Luba has to spend on her work during *i*-th day. | Print the minimum day Luba can finish reading the book.
It is guaranteed that answer doesn't exceed *n*. | [
"2 2\n86400 86398\n",
"2 86400\n0 86400\n"
] | [
"2\n",
"1\n"
] | none | 0 | [
{
"input": "2 2\n86400 86398",
"output": "2"
},
{
"input": "2 86400\n0 86400",
"output": "1"
},
{
"input": "2 86400\n1 86399",
"output": "2"
},
{
"input": "100 1000000\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0... | 1,604,848,827 | 2,147,483,647 | Python 3 | OK | TESTS | 16 | 93 | 0 |
if __name__ == '__main__':
n, t = list(map(int, input().split()))
one_day = 86400
arr = list(map(int, input().split()))
time_acc = 0
for i in range(len(arr)):
time_acc+=(one_day-arr[i])
if time_acc>=t:
print(i+1)
break | Title: Book Reading
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Recently Luba bought a very interesting book. She knows that it will take *t* seconds to read the book. Luba wants to finish reading as fast as she can.
But she has some work to do in each of *n* next days. The number of ... | ```python
if __name__ == '__main__':
n, t = list(map(int, input().split()))
one_day = 86400
arr = list(map(int, input().split()))
time_acc = 0
for i in range(len(arr)):
time_acc+=(one_day-arr[i])
if time_acc>=t:
print(i+1)
break
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
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,665,665,945 | 2,147,483,647 | Python 3 | OK | TESTS | 42 | 92 | 0 | arr = input()
arr = arr.split(" ")
r = int(arr[0])
c = int(arr[1])
row = []
col = []
for i in range(r):
text = input()
for j in range(c):
if text[j] == "S":
if j not in col:
col.append(j)
if i not in row:
row.append(i)
print((r-len(row))*c + (c-len(col))*r - ((r-len(row))*(c-len(col)... | 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
arr = input()
arr = arr.split(" ")
r = int(arr[0])
c = int(arr[1])
row = []
col = []
for i in range(r):
text = input()
for j in range(c):
if text[j] == "S":
if j not in col:
col.append(j)
if i not in row:
row.append(i)
print((r-len(row))*c + (c-len(col))*r - ((r-len(row))*(... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
116 | A | Tram | PROGRAMMING | 800 | [
"implementation"
] | null | null | Linear Kingdom has exactly one tram line. It has *n* stops, numbered from 1 to *n* in the order of tram's movement. At the *i*-th stop *a**i* passengers exit the tram, while *b**i* passengers enter it. The tram is empty before it arrives at the first stop. Also, when the tram arrives at the last stop, all passengers ex... | The first line contains a single number *n* (2<=≤<=*n*<=≤<=1000) — the number of the tram's stops.
Then *n* lines follow, each contains two integers *a**i* and *b**i* (0<=≤<=*a**i*,<=*b**i*<=≤<=1000) — the number of passengers that exits the tram at the *i*-th stop, and the number of passengers that enter the tram at... | Print a single integer denoting the minimum possible capacity of the tram (0 is allowed). | [
"4\n0 3\n2 5\n4 2\n4 0\n"
] | [
"6\n"
] | For the first example, a capacity of 6 is sufficient:
- At the first stop, the number of passengers inside the tram before arriving is 0. Then, 3 passengers enter the tram, and the number of passengers inside the tram becomes 3. - At the second stop, 2 passengers exit the tram (1 passenger remains inside). Then, 5 ... | 500 | [
{
"input": "4\n0 3\n2 5\n4 2\n4 0",
"output": "6"
},
{
"input": "5\n0 4\n4 6\n6 5\n5 4\n4 0",
"output": "6"
},
{
"input": "10\n0 5\n1 7\n10 8\n5 3\n0 5\n3 3\n8 8\n0 6\n10 1\n9 0",
"output": "18"
},
{
"input": "3\n0 1\n1 1\n1 0",
"output": "1"
},
{
"input": "4\n0 1... | 1,690,390,021 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 71 | 310 | 1,740,800 | stops_num = int(input())
peoples_nums = [0]
for _ in range(stops_num):
a, b = map(int, input().split())
peoples_nums.append(peoples_nums[-1] - a + b)
print(max(peoples_nums, default=0))
| Title: Tram
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Linear Kingdom has exactly one tram line. It has *n* stops, numbered from 1 to *n* in the order of tram's movement. At the *i*-th stop *a**i* passengers exit the tram, while *b**i* passengers enter it. The tram is empty before it ... | ```python
stops_num = int(input())
peoples_nums = [0]
for _ in range(stops_num):
a, b = map(int, input().split())
peoples_nums.append(peoples_nums[-1] - a + b)
print(max(peoples_nums, default=0))
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
47 | B | Coins | PROGRAMMING | 1,200 | [
"implementation"
] | B. Coins | 2 | 256 | One day Vasya came across three Berland coins. They didn't have any numbers that's why Vasya didn't understand how their denominations differ. He supposed that if one coin is heavier than the other one, then it should be worth more. Vasya weighed all the three pairs of coins on pan balance scales and told you the resul... | The input data contains the results of all the weighting, one result on each line. It is guaranteed that every coin pair was weighted exactly once. Vasya labelled the coins with letters «A», «B» and «C». Each result is a line that appears as (letter)(> or < sign)(letter). For example, if coin "A" proved lighter t... | It the results are contradictory, print Impossible. Otherwise, print without spaces the rearrangement of letters «A», «B» and «C» which represent the coins in the increasing order of their weights. | [
"A>B\nC<B\nA>C\n",
"A<B\nB>C\nC>A\n"
] | [
"CBA",
"ACB"
] | none | 1,000 | [
{
"input": "A>B\nC<B\nA>C",
"output": "CBA"
},
{
"input": "A<B\nB>C\nC>A",
"output": "ACB"
},
{
"input": "A<C\nB<A\nB>C",
"output": "Impossible"
},
{
"input": "A<B\nA<C\nB>C",
"output": "ACB"
},
{
"input": "B>A\nC<B\nC>A",
"output": "ACB"
},
{
"input":... | 1,693,390,624 | 2,147,483,647 | Python 3 | OK | TESTS | 50 | 92 | 0 | def solve(weights):
# Initialize relationships dictionary
relationships = {'A': set(), 'B': set(), 'C': set()}
# Process the given comparisons
for weight in weights:
coin1, compare, coin2 = weight
if compare == '>':
relationships[coin1].add(coin2)
else:
... | Title: Coins
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
One day Vasya came across three Berland coins. They didn't have any numbers that's why Vasya didn't understand how their denominations differ. He supposed that if one coin is heavier than the other one, then it should be worth more. ... | ```python
def solve(weights):
# Initialize relationships dictionary
relationships = {'A': set(), 'B': set(), 'C': set()}
# Process the given comparisons
for weight in weights:
coin1, compare, coin2 = weight
if compare == '>':
relationships[coin1].add(coin2)
... | 3.977 | MatrixStudio/Codeforces-Python-Submissions |
920 | C | Swap Adjacent Elements | PROGRAMMING | 1,400 | [
"dfs and similar",
"greedy",
"math",
"sortings",
"two pointers"
] | null | null | You have an array *a* consisting of *n* integers. Each integer from 1 to *n* appears exactly once in this array.
For some indices *i* (1<=≤<=*i*<=≤<=*n*<=-<=1) it is possible to swap *i*-th element with (*i*<=+<=1)-th, for other indices it is not possible. You may perform any number of swapping operations any order. T... | The first line contains one integer *n* (2<=≤<=*n*<=≤<=200000) — the number of elements in the array.
The second line contains *n* integers *a*1, *a*2, ..., *a**n* (1<=≤<=*a**i*<=≤<=200000) — the elements of the array. Each integer from 1 to *n* appears exactly once.
The third line contains a string of *n*<=-<=1 char... | If it is possible to sort the array in ascending order using any sequence of swaps you are allowed to make, print YES. Otherwise, print NO. | [
"6\n1 2 5 3 4 6\n01110\n",
"6\n1 2 5 3 4 6\n01010\n"
] | [
"YES\n",
"NO\n"
] | In the first example you may swap *a*<sub class="lower-index">3</sub> and *a*<sub class="lower-index">4</sub>, and then swap *a*<sub class="lower-index">4</sub> and *a*<sub class="lower-index">5</sub>. | 0 | [
{
"input": "6\n1 2 5 3 4 6\n01110",
"output": "YES"
},
{
"input": "6\n1 2 5 3 4 6\n01010",
"output": "NO"
},
{
"input": "6\n1 6 3 4 5 2\n01101",
"output": "NO"
},
{
"input": "6\n2 3 1 4 5 6\n01111",
"output": "NO"
},
{
"input": "4\n2 3 1 4\n011",
"output": "NO... | 1,619,940,737 | 2,147,483,647 | Python 3 | OK | TESTS | 139 | 483 | 24,064,000 | n=int(input())
a=list(map(int,input().split()))
s=input()
i=0
j=0
c=[]
while i<n-1:
if s[i]=='0':
c.append([j,i])
j=i+1
i+=1
c.append([j,n-1])
j=0
f=1
for i in range(n):
if i>c[j][1]:
j+=1
if a[i]<c[j][0]+1 or a[i]>c[j][1]+1:
f=0
break
if f==1:... | Title: Swap Adjacent Elements
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You have an array *a* consisting of *n* integers. Each integer from 1 to *n* appears exactly once in this array.
For some indices *i* (1<=≤<=*i*<=≤<=*n*<=-<=1) it is possible to swap *i*-th element with (*i*<=+<... | ```python
n=int(input())
a=list(map(int,input().split()))
s=input()
i=0
j=0
c=[]
while i<n-1:
if s[i]=='0':
c.append([j,i])
j=i+1
i+=1
c.append([j,n-1])
j=0
f=1
for i in range(n):
if i>c[j][1]:
j+=1
if a[i]<c[j][0]+1 or a[i]>c[j][1]+1:
f=0
break... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
496 | A | Minimum Difficulty | PROGRAMMING | 900 | [
"brute force",
"implementation",
"math"
] | null | null | Mike is trying rock climbing but he is awful at it.
There are *n* holds on the wall, *i*-th hold is at height *a**i* off the ground. Besides, let the sequence *a**i* increase, that is, *a**i*<=<<=*a**i*<=+<=1 for all *i* from 1 to *n*<=-<=1; we will call such sequence a track. Mike thinks that the track *a*1, ...,... | The first line contains a single integer *n* (3<=≤<=*n*<=≤<=100) — the number of holds.
The next line contains *n* space-separated integers *a**i* (1<=≤<=*a**i*<=≤<=1000), where *a**i* is the height where the hold number *i* hangs. The sequence *a**i* is increasing (i.e. each element except for the first one is strict... | Print a single number — the minimum difficulty of the track after removing a single hold. | [
"3\n1 4 6\n",
"5\n1 2 3 4 5\n",
"5\n1 2 3 7 8\n"
] | [
"5\n",
"2\n",
"4\n"
] | In the first sample you can remove only the second hold, then the sequence looks like (1, 6), the maximum difference of the neighboring elements equals 5.
In the second test after removing every hold the difficulty equals 2.
In the third test you can obtain sequences (1, 3, 7, 8), (1, 2, 7, 8), (1, 2, 3, 8), for whic... | 500 | [
{
"input": "3\n1 4 6",
"output": "5"
},
{
"input": "5\n1 2 3 4 5",
"output": "2"
},
{
"input": "5\n1 2 3 7 8",
"output": "4"
},
{
"input": "3\n1 500 1000",
"output": "999"
},
{
"input": "10\n1 2 3 4 5 6 7 8 9 10",
"output": "2"
},
{
"input": "10\n1 4 9... | 1,580,630,291 | 2,147,483,647 | PyPy 3 | OK | TESTS | 19 | 483 | 11,571,200 | import sys
import math
import bisect
import itertools
import random
import re
def main():
n = int(input())
A = list(map(int, input().split()))
B = []
s = set()
for i in range(1, n):
B.append(A[i] - A[i-1])
min_val = 10 ** 18
for i in range(1, len(B)):
C = []
... | Title: Minimum Difficulty
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Mike is trying rock climbing but he is awful at it.
There are *n* holds on the wall, *i*-th hold is at height *a**i* off the ground. Besides, let the sequence *a**i* increase, that is, *a**i*<=<<=*a**i*<=+<=1 fo... | ```python
import sys
import math
import bisect
import itertools
import random
import re
def main():
n = int(input())
A = list(map(int, input().split()))
B = []
s = set()
for i in range(1, n):
B.append(A[i] - A[i-1])
min_val = 10 ** 18
for i in range(1, len(B)):
... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
750 | A | New Year and Hurry | PROGRAMMING | 800 | [
"binary search",
"brute force",
"implementation",
"math"
] | null | null | Limak is going to participate in a contest on the last day of the 2016. The contest will start at 20:00 and will last four hours, exactly until midnight. There will be *n* problems, sorted by difficulty, i.e. problem 1 is the easiest and problem *n* is the hardest. Limak knows it will take him 5·*i* minutes to solve th... | The only line of the input contains two integers *n* and *k* (1<=≤<=*n*<=≤<=10, 1<=≤<=*k*<=≤<=240) — the number of the problems in the contest and the number of minutes Limak needs to get to the party from his house. | Print one integer, denoting the maximum possible number of problems Limak can solve so that he could get to the party at midnight or earlier. | [
"3 222\n",
"4 190\n",
"7 1\n"
] | [
"2\n",
"4\n",
"7\n"
] | In the first sample, there are 3 problems and Limak needs 222 minutes to get to the party. The three problems require 5, 10 and 15 minutes respectively. Limak can spend 5 + 10 = 15 minutes to solve first two problems. Then, at 20:15 he can leave his house to get to the party at 23:57 (after 222 minutes). In this scenar... | 500 | [
{
"input": "3 222",
"output": "2"
},
{
"input": "4 190",
"output": "4"
},
{
"input": "7 1",
"output": "7"
},
{
"input": "10 135",
"output": "6"
},
{
"input": "10 136",
"output": "5"
},
{
"input": "1 1",
"output": "1"
},
{
"input": "1 240",
... | 1,682,008,355 | 2,147,483,647 | Python 3 | OK | TESTS | 52 | 46 | 0 | # We have a pool og 4 * 60 mins
# Going to the party is non negotiable so remove the transit time
# from the party minute to get the solution time we have
def calculate_solution_capacity(time_left: int, num_of_questions: int) -> int:
solved_questions:int = 0
for i in range(1 ,num_of_questions + 1):
... | Title: New Year and Hurry
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Limak is going to participate in a contest on the last day of the 2016. The contest will start at 20:00 and will last four hours, exactly until midnight. There will be *n* problems, sorted by difficulty, i.e. problem... | ```python
# We have a pool og 4 * 60 mins
# Going to the party is non negotiable so remove the transit time
# from the party minute to get the solution time we have
def calculate_solution_capacity(time_left: int, num_of_questions: int) -> int:
solved_questions:int = 0
for i in range(1 ,num_of_questions + 1... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
403 | D | Beautiful Pairs of Numbers | PROGRAMMING | 2,300 | [
"combinatorics",
"dp"
] | null | null | The sequence of integer pairs (*a*1,<=*b*1),<=(*a*2,<=*b*2),<=...,<=(*a**k*,<=*b**k*) is beautiful, if the following statements are fulfilled:
- 1<=≤<=*a*1<=≤<=*b*1<=<<=*a*2<=≤<=*b*2<=<<=...<=<<=*a**k*<=≤<=*b**k*<=≤<=*n*, where *n* is a given positive integer; - all numbers *b*1<=-<=*a*1, *b*2<=-<=*a*2, ..... | The first line contains integer *t* (1<=≤<=*t*<=≤<=<=2·105) — the number of the test data.
Each of the next *t* lines contains two integers *n* and *k* (1<=≤<=*k*<=≤<=*n*<=≤<=1000). | For each test from the input print the answer to the problem modulo 1000000007 (109<=+<=7). Print the answers to the tests in the order in which the tests are given in the input. | [
"6\n1 1\n2 1\n2 2\n3 1\n3 2\n3 3\n"
] | [
"1\n3\n0\n6\n2\n0\n"
] | In the first test sample there is exactly one beautiful sequence: (1, 1).
In the second test sample, the following sequences are beautiful:
- (1, 1); - (1, 2); - (2, 2).
In the fourth test sample, the following sequences are beautiful:
- (1, 1); - (1, 2); - (1, 3); - (2, 2); - (2, 3); - (3, 3).
In the f... | 1,500 | [
{
"input": "6\n1 1\n2 1\n2 2\n3 1\n3 2\n3 3",
"output": "1\n3\n0\n6\n2\n0"
}
] | 1,654,184,836 | 2,147,483,647 | PyPy 3 | RUNTIME_ERROR | TESTS | 0 | 77 | 2,150,400 | from math import comb, factorial
t = int(input())
for case in range(t):
n,k = map(int, input().split())
print(factorial(k)*factorial(k-1)*comb(n-(k-1)-k*(k-1)//2+2*k+1-1-1, 2*k)) | Title: Beautiful Pairs of Numbers
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The sequence of integer pairs (*a*1,<=*b*1),<=(*a*2,<=*b*2),<=...,<=(*a**k*,<=*b**k*) is beautiful, if the following statements are fulfilled:
- 1<=≤<=*a*1<=≤<=*b*1<=<<=*a*2<=≤<=*b*2<=<<=...<=<<=*... | ```python
from math import comb, factorial
t = int(input())
for case in range(t):
n,k = map(int, input().split())
print(factorial(k)*factorial(k-1)*comb(n-(k-1)-k*(k-1)//2+2*k+1-1-1, 2*k))
``` | -1 | MatrixStudio/Codeforces-Python-Submissions | |
961 | A | Tetris | PROGRAMMING | 900 | [
"implementation"
] | null | null | You are given a following process.
There is a platform with $n$ columns. $1 \times 1$ squares are appearing one after another in some columns on this platform. If there are no squares in the column, a square will occupy the bottom row. Otherwise a square will appear at the top of the highest square of this column.
... | The first line of input contain 2 integer numbers $n$ and $m$ ($1 \le n, m \le 1000$) — the length of the platform and the number of the squares.
The next line contain $m$ integer numbers $c_1, c_2, \dots, c_m$ ($1 \le c_i \le n$) — column in which $i$-th square will appear. | Print one integer — the amount of points you will receive. | [
"3 9\n1 1 2 2 2 3 1 2 3\n"
] | [
"2\n"
] | In the sample case the answer will be equal to $2$ because after the appearing of $6$-th square will be removed one row (counts of the squares on the platform will look like $[2~ 3~ 1]$, and after removing one row will be $[1~ 2~ 0]$).
After the appearing of $9$-th square counts will be $[2~ 3~ 1]$, and after removing... | 0 | [
{
"input": "3 9\n1 1 2 2 2 3 1 2 3",
"output": "2"
},
{
"input": "1 7\n1 1 1 1 1 1 1",
"output": "7"
},
{
"input": "1 1\n1",
"output": "1"
},
{
"input": "3 5\n1 1 1 2 3",
"output": "1"
},
{
"input": "4 6\n4 4 4 4 4 4",
"output": "0"
},
{
"input": "4 6\... | 1,660,938,373 | 2,147,483,647 | Python 3 | OK | TESTS | 29 | 46 | 0 | colluns, n = map(int, input().split())
entry = input().split()
col = [0] * colluns
for i in range(n):
entry[i] = int(entry[i])
for i in entry:
col[i-1] += 1
print(min(col))
| Title: Tetris
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given a following process.
There is a platform with $n$ columns. $1 \times 1$ squares are appearing one after another in some columns on this platform. If there are no squares in the column, a square will occupy the bo... | ```python
colluns, n = map(int, input().split())
entry = input().split()
col = [0] * colluns
for i in range(n):
entry[i] = int(entry[i])
for i in entry:
col[i-1] += 1
print(min(col))
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
102 | B | Sum of Digits | PROGRAMMING | 1,000 | [
"implementation"
] | B. Sum of Digits | 2 | 265 | Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number *n*. How many times can Gerald put a spell on it until the number becomes one-... | The first line contains the only integer *n* (0<=≤<=*n*<=≤<=10100000). It is guaranteed that *n* doesn't contain any leading zeroes. | Print the number of times a number can be replaced by the sum of its digits until it only contains one digit. | [
"0\n",
"10\n",
"991\n"
] | [
"0\n",
"1\n",
"3\n"
] | In the first sample the number already is one-digit — Herald can't cast a spell.
The second test contains number 10. After one casting of a spell it becomes 1, and here the process is completed. Thus, Gerald can only cast the spell once.
The third test contains number 991. As one casts a spell the following transform... | 1,000 | [
{
"input": "0",
"output": "0"
},
{
"input": "10",
"output": "1"
},
{
"input": "991",
"output": "3"
},
{
"input": "99",
"output": "2"
},
{
"input": "100",
"output": "1"
},
{
"input": "123456789",
"output": "2"
},
{
"input": "32",
"output... | 1,656,137,640 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 3 | 62 | 0 | x = list(input())
while len(x) != 1:
temp = 0
for i in range(len(x)):
temp += int(i)
x = list(str(temp))
print(x[0])
| Title: Sum of Digits
Time Limit: 2 seconds
Memory Limit: 265 megabytes
Problem Description:
Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came... | ```python
x = list(input())
while len(x) != 1:
temp = 0
for i in range(len(x)):
temp += int(i)
x = list(str(temp))
print(x[0])
``` | 0 | MatrixStudio/Codeforces-Python-Submissions |
27 | A | Next Test | PROGRAMMING | 1,200 | [
"implementation",
"sortings"
] | A. Next Test | 2 | 256 | «Polygon» is a system which allows to create programming tasks in a simple and professional way. When you add a test to the problem, the corresponding form asks you for the test index. As in most cases it is clear which index the next test will have, the system suggests the default value of the index. It is calculated ... | The first line contains one integer *n* (1<=≤<=*n*<=≤<=3000) — the amount of previously added tests. The second line contains *n* distinct integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=3000) — indexes of these tests. | Output the required default value for the next test index. | [
"3\n1 7 2\n"
] | [
"3\n"
] | none | 500 | [
{
"input": "1\n1",
"output": "2"
},
{
"input": "2\n2 1",
"output": "3"
},
{
"input": "3\n3 4 1",
"output": "2"
},
{
"input": "4\n6 4 3 5",
"output": "1"
},
{
"input": "5\n3 2 1 7 4",
"output": "5"
},
{
"input": "6\n4 1 2 5 3 7",
"output": "6"
},
... | 1,620,704,835 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 3 | 124 | 6,758,400 | def test(indexes):
while(True):
if(min(indexes)+1 not in indexes):
return(min(indexes)+1)
else:
indexes.remove(min(indexes))
continue
n=int(input())
indexes=list(map(int,input().split()))
result=test(indexes)
print(result) | Title: Next Test
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
«Polygon» is a system which allows to create programming tasks in a simple and professional way. When you add a test to the problem, the corresponding form asks you for the test index. As in most cases it is clear which index the... | ```python
def test(indexes):
while(True):
if(min(indexes)+1 not in indexes):
return(min(indexes)+1)
else:
indexes.remove(min(indexes))
continue
n=int(input())
indexes=list(map(int,input().split()))
result=test(indexes)
print(result)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions |
202 | A | LLPS | PROGRAMMING | 800 | [
"binary search",
"bitmasks",
"brute force",
"greedy",
"implementation",
"strings"
] | null | null | This problem's actual name, "Lexicographically Largest Palindromic Subsequence" is too long to fit into the page headline.
You are given string *s* consisting of lowercase English letters only. Find its lexicographically largest palindromic subsequence.
We'll call a non-empty string *s*[*p*1*p*2... *p**k*] = *s**p*1*... | The only input line contains a non-empty string *s* consisting of lowercase English letters only. Its length does not exceed 10. | Print the lexicographically largest palindromic subsequence of string *s*. | [
"radar\n",
"bowwowwow\n",
"codeforces\n",
"mississipp\n"
] | [
"rr\n",
"wwwww\n",
"s\n",
"ssss\n"
] | Among all distinct subsequences of string "radar" the following ones are palindromes: "a", "d", "r", "aa", "rr", "ada", "rar", "rdr", "raar" and "radar". The lexicographically largest of them is "rr". | 500 | [
{
"input": "radar",
"output": "rr"
},
{
"input": "bowwowwow",
"output": "wwwww"
},
{
"input": "codeforces",
"output": "s"
},
{
"input": "mississipp",
"output": "ssss"
},
{
"input": "tourist",
"output": "u"
},
{
"input": "romka",
"output": "r"
},
... | 1,658,452,255 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 54 | 186 | 2,867,200 | import string
from bisect import bisect, bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from functools import cache, lru_cache
from math import *
from sys import stdin, stdout
input = stdin.readline
MOD = 10**9+7
def add(a, b):
return a+b-MOD if a+b > MOD else a+b
def sub(a, b):... | Title: LLPS
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
This problem's actual name, "Lexicographically Largest Palindromic Subsequence" is too long to fit into the page headline.
You are given string *s* consisting of lowercase English letters only. Find its lexicographically largest ... | ```python
import string
from bisect import bisect, bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from functools import cache, lru_cache
from math import *
from sys import stdin, stdout
input = stdin.readline
MOD = 10**9+7
def add(a, b):
return a+b-MOD if a+b > MOD else a+b
def ... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
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,619,469,352 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 1 | 77 | 0 | times = int(input())
nums = [int(num) for num in input().split()]
sort = sorted(nums)
score = 0
for i in range(times):
if len(sort) == 2:
score += sort[0] + sort[1]
else:
score += sum(sort)
score += sort[0]
sort.remove(sort[0])
print(score)
| 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
times = int(input())
nums = [int(num) for num in input().split()]
sort = sorted(nums)
score = 0
for i in range(times):
if len(sort) == 2:
score += sort[0] + sort[1]
else:
score += sum(sort)
score += sort[0]
sort.remove(sort[0])
print(score)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
834 | B | The Festive Evening | PROGRAMMING | 1,100 | [
"data structures",
"implementation"
] | null | null | It's the end of July – the time when a festive evening is held at Jelly Castle! Guests from all over the kingdom gather here to discuss new trends in the world of confectionery. Yet some of the things discussed here are not supposed to be disclosed to the general public: the information can cause discord in the kingdom... | Two integers are given in the first string: the number of guests *n* and the number of guards *k* (1<=≤<=*n*<=≤<=106, 1<=≤<=*k*<=≤<=26).
In the second string, *n* uppercase English letters *s*1*s*2... *s**n* are given, where *s**i* is the entrance used by the *i*-th guest. | Output «YES» if at least one door was unguarded during some time, and «NO» otherwise.
You can output each letter in arbitrary case (upper or lower). | [
"5 1\nAABBB\n",
"5 1\nABABB\n"
] | [
"NO\n",
"YES\n"
] | In the first sample case, the door A is opened right before the first guest's arrival and closed when the second guest enters the castle. The door B is opened right before the arrival of the third guest, and closed after the fifth one arrives. One guard can handle both doors, as the first one is closed before the secon... | 1,000 | [
{
"input": "5 1\nAABBB",
"output": "NO"
},
{
"input": "5 1\nABABB",
"output": "YES"
},
{
"input": "26 1\nABCDEFGHIJKLMNOPQRSTUVWXYZ",
"output": "NO"
},
{
"input": "27 1\nABCDEFGHIJKLMNOPQRSTUVWXYZA",
"output": "YES"
},
{
"input": "5 2\nABACA",
"output": "NO"
... | 1,617,459,185 | 2,147,483,647 | PyPy 3 | OK | TESTS | 34 | 327 | 31,744,000 |
n, k = map(int, input().split())
a = input()
n = [0] * n
s = set(a)
for i in s:
for j in range(a.find(i), a.rfind(i) + 1):
n[j] += 1
if max(n) > k:
print('YES')
else:
print('NO') | Title: The Festive Evening
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
It's the end of July – the time when a festive evening is held at Jelly Castle! Guests from all over the kingdom gather here to discuss new trends in the world of confectionery. Yet some of the things discussed here... | ```python
n, k = map(int, input().split())
a = input()
n = [0] * n
s = set(a)
for i in s:
for j in range(a.find(i), a.rfind(i) + 1):
n[j] += 1
if max(n) > k:
print('YES')
else:
print('NO')
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
981 | A | Antipalindrome | PROGRAMMING | 900 | [
"brute force",
"implementation",
"strings"
] | null | null | A string is a palindrome if it reads the same from the left to the right and from the right to the left. For example, the strings "kek", "abacaba", "r" and "papicipap" are palindromes, while the strings "abb" and "iq" are not.
A substring $s[l \ldots r]$ ($1<=\leq<=l<=\leq<=r<=\leq<=|s|$) of a string $s<==<=s_{1}s_{2}... | The first line contains a non-empty string $s$ with length at most $50$ characters, containing lowercase English letters only. | If there is such a substring in $s$ that is not a palindrome, print the maximum length of such a substring. Otherwise print $0$.
Note that there can be multiple longest substrings that are not palindromes, but their length is unique. | [
"mew\n",
"wuffuw\n",
"qqqqqqqq\n"
] | [
"3\n",
"5\n",
"0\n"
] | "mew" is not a palindrome, so the longest substring of it that is not a palindrome, is the string "mew" itself. Thus, the answer for the first example is $3$.
The string "uffuw" is one of the longest non-palindrome substrings (of length $5$) of the string "wuffuw", so the answer for the second example is $5$.
All sub... | 500 | [
{
"input": "mew",
"output": "3"
},
{
"input": "wuffuw",
"output": "5"
},
{
"input": "qqqqqqqq",
"output": "0"
},
{
"input": "ijvji",
"output": "4"
},
{
"input": "iiiiiii",
"output": "0"
},
{
"input": "wobervhvvkihcuyjtmqhaaigvvgiaahqmtjyuchikvvhvrebow"... | 1,664,722,534 | 2,147,483,647 | Python 3 | OK | TESTS | 133 | 46 | 0 | s = input()
out = ''
if len(set(s)) == 1:
out = 0
elif s == s[::-1]:
out = len(s) - 1
else:
out = len(s)
print(out)
| Title: Antipalindrome
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
A string is a palindrome if it reads the same from the left to the right and from the right to the left. For example, the strings "kek", "abacaba", "r" and "papicipap" are palindromes, while the strings "abb" and "iq" ar... | ```python
s = input()
out = ''
if len(set(s)) == 1:
out = 0
elif s == s[::-1]:
out = len(s) - 1
else:
out = len(s)
print(out)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
770 | B | Maximize Sum of Digits | PROGRAMMING | 1,300 | [
"*special",
"implementation",
"math"
] | null | null | Anton has the integer *x*. He is interested what positive integer, which doesn't exceed *x*, has the maximum sum of digits.
Your task is to help Anton and to find the integer that interests him. If there are several such integers, determine the biggest of them. | The first line contains the positive integer *x* (1<=≤<=*x*<=≤<=1018) — the integer which Anton has. | Print the positive integer which doesn't exceed *x* and has the maximum sum of digits. If there are several such integers, print the biggest of them. Printed integer must not contain leading zeros. | [
"100\n",
"48\n",
"521\n"
] | [
"99\n",
"48\n",
"499\n"
] | none | 1,000 | [
{
"input": "100",
"output": "99"
},
{
"input": "48",
"output": "48"
},
{
"input": "521",
"output": "499"
},
{
"input": "1",
"output": "1"
},
{
"input": "2",
"output": "2"
},
{
"input": "3",
"output": "3"
},
{
"input": "39188",
"output":... | 1,618,547,497 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 6 | 92 | 0 | from math import floor , sqrt
from sys import stdin
# input = stdin.readline
for _ in range(1):
n = input()
currSum = 0
for i in range(len(n)):
currSum += int(n[i])
# print(max(currSum , (len(n)-1)*9 + int(n[0]) - 1))
if currSum >= (len(n)-1)*9 + int(n[0]) - 1:
prin... | Title: Maximize Sum of Digits
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Anton has the integer *x*. He is interested what positive integer, which doesn't exceed *x*, has the maximum sum of digits.
Your task is to help Anton and to find the integer that interests him. If there are sev... | ```python
from math import floor , sqrt
from sys import stdin
# input = stdin.readline
for _ in range(1):
n = input()
currSum = 0
for i in range(len(n)):
currSum += int(n[i])
# print(max(currSum , (len(n)-1)*9 + int(n[0]) - 1))
if currSum >= (len(n)-1)*9 + int(n[0]) - 1:
... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
697 | B | Barnicle | PROGRAMMING | 1,400 | [
"brute force",
"implementation",
"math",
"strings"
] | null | null | Barney is standing in a bar and starring at a pretty girl. He wants to shoot her with his heart arrow but he needs to know the distance between him and the girl to make his shot accurate.
Barney asked the bar tender Carl about this distance value, but Carl was so busy talking to the customers so he wrote the distance ... | The first and only line of input contains a single string of form *a*.*deb* where *a*, *d* and *b* are integers and *e* is usual character 'e' (0<=≤<=*a*<=≤<=9,<=0<=≤<=*d*<=<<=10100,<=0<=≤<=*b*<=≤<=100) — the scientific notation of the desired distance value.
*a* and *b* contain no leading zeros and *d* contains no... | Print the only real number *x* (the desired distance value) in the only line in its decimal notation.
Thus if *x* is an integer, print it's integer value without decimal part and decimal point and without leading zeroes.
Otherwise print *x* in a form of *p*.*q* such that *p* is an integer that have no leading zeroe... | [
"8.549e2\n",
"8.549e3\n",
"0.33e0\n"
] | [
"854.9\n",
"8549\n",
"0.33\n"
] | none | 1,000 | [
{
"input": "8.549e2",
"output": "854.9"
},
{
"input": "8.549e3",
"output": "8549"
},
{
"input": "0.33e0",
"output": "0.33"
},
{
"input": "1.31e1",
"output": "13.1"
},
{
"input": "1.038e0",
"output": "1.038"
},
{
"input": "8.25983e5",
"output": "825... | 1,580,045,454 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 3 | 140 | 0 | a = input()
idx=a.find("e")
integer = a[:-(len(a)-idx)]
power = a[idx+1:]
res= float(integer)*(10**int(power))
temp=round(res)
if temp==res:
print(temp)
else:
print(res) | Title: Barnicle
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Barney is standing in a bar and starring at a pretty girl. He wants to shoot her with his heart arrow but he needs to know the distance between him and the girl to make his shot accurate.
Barney asked the bar tender Carl abou... | ```python
a = input()
idx=a.find("e")
integer = a[:-(len(a)-idx)]
power = a[idx+1:]
res= float(integer)*(10**int(power))
temp=round(res)
if temp==res:
print(temp)
else:
print(res)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
621 | B | Wet Shark and Bishops | PROGRAMMING | 1,300 | [
"combinatorics",
"implementation"
] | null | null | Today, Wet Shark is given *n* bishops on a 1000 by 1000 grid. Both rows and columns of the grid are numbered from 1 to 1000. Rows are numbered from top to bottom, while columns are numbered from left to right.
Wet Shark thinks that two bishops attack each other if they share the same diagonal. Note, that this is the o... | The first line of the input contains *n* (1<=≤<=*n*<=≤<=200<=000) — the number of bishops.
Each of next *n* lines contains two space separated integers *x**i* and *y**i* (1<=≤<=*x**i*,<=*y**i*<=≤<=1000) — the number of row and the number of column where *i*-th bishop is positioned. It's guaranteed that no two bishops ... | Output one integer — the number of pairs of bishops which attack each other. | [
"5\n1 1\n1 5\n3 3\n5 1\n5 5\n",
"3\n1 1\n2 3\n3 5\n"
] | [
"6\n",
"0\n"
] | In the first sample following pairs of bishops attack each other: (1, 3), (1, 5), (2, 3), (2, 4), (3, 4) and (3, 5). Pairs (1, 2), (1, 4), (2, 5) and (4, 5) do not attack each other because they do not share the same diagonal. | 1,000 | [
{
"input": "5\n1 1\n1 5\n3 3\n5 1\n5 5",
"output": "6"
},
{
"input": "3\n1 1\n2 3\n3 5",
"output": "0"
},
{
"input": "3\n859 96\n634 248\n808 72",
"output": "0"
},
{
"input": "3\n987 237\n891 429\n358 145",
"output": "0"
},
{
"input": "3\n411 81\n149 907\n611 114"... | 1,509,657,256 | 2,147,483,647 | PyPy 3 | COMPILATION_ERROR | TESTS | 0 | 0 | 0 | def soma(n):
s=0
for i in xrange(n,0,-1):s+=i
return s
t=int(raw_input())
s,p=0,{}
for i in xrange(t):
x,y=map(int,raw_input().split())
t1,t2=x-y,x+y
if t1 not in p.keys():p[t1]=0
else:p[t1]+=1
if t2 not in p.keys():p[t2]=0
else:p[t2]+=1
for i in sorted(p.values(),revers... | Title: Wet Shark and Bishops
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Today, Wet Shark is given *n* bishops on a 1000 by 1000 grid. Both rows and columns of the grid are numbered from 1 to 1000. Rows are numbered from top to bottom, while columns are numbered from left to right.
We... | ```python
def soma(n):
s=0
for i in xrange(n,0,-1):s+=i
return s
t=int(raw_input())
s,p=0,{}
for i in xrange(t):
x,y=map(int,raw_input().split())
t1,t2=x-y,x+y
if t1 not in p.keys():p[t1]=0
else:p[t1]+=1
if t2 not in p.keys():p[t2]=0
else:p[t2]+=1
for i in sorted(p.value... | -1 | MatrixStudio/Codeforces-Python-Submissions | |
748 | C | Santa Claus and Robot | PROGRAMMING | 1,400 | [
"constructive algorithms",
"math"
] | null | null | Santa Claus has Robot which lives on the infinite grid and can move along its lines. He can also, having a sequence of *m* points *p*1,<=*p*2,<=...,<=*p**m* with integer coordinates, do the following: denote its initial location by *p*0. First, the robot will move from *p*0 to *p*1 along one of the shortest paths betwe... | The first line of input contains the only positive integer *n* (1<=≤<=*n*<=≤<=2·105) which equals the number of unit segments the robot traveled. The second line contains the movements protocol, which consists of *n* letters, each being equal either L, or R, or U, or D. *k*-th letter stands for the direction which Robo... | The only line of input should contain the minimum possible length of the sequence. | [
"4\nRURD\n",
"6\nRRULDD\n",
"26\nRRRULURURUULULLLDLDDRDRDLD\n",
"3\nRLL\n",
"4\nLRLR\n"
] | [
"2\n",
"2\n",
"7\n",
"2\n",
"4\n"
] | The illustrations to the first three tests are given below.
<img class="tex-graphics" src="https://espresso.codeforces.com/832fb8f97a482be815e0f87edde26c9791a0d330.png" style="max-width: 100.0%;max-height: 100.0%;"/> <img class="tex-graphics" src="https://espresso.codeforces.com/119a8ba68772b2c2bf76f2acdc58027f6c5cde1... | 1,500 | [
{
"input": "4\nRURD",
"output": "2"
},
{
"input": "6\nRRULDD",
"output": "2"
},
{
"input": "26\nRRRULURURUULULLLDLDDRDRDLD",
"output": "7"
},
{
"input": "3\nRLL",
"output": "2"
},
{
"input": "4\nLRLR",
"output": "4"
},
{
"input": "5\nLRDLR",
"outpu... | 1,666,447,095 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 9 | 77 | 2,662,400 | t=1
while t>0:
t-=1
n=int(input())
s=input()
mp=dict()
mp['R']=0
mp['L']=0
mp['U']=0
mp['D']=0
ans=0
for i in s:
mp[i]+=1
if mp['R']>=1 and mp['L']>=1:
ans+=1
mp['R']=0
mp['L']=0
mp['U']=0
... | Title: Santa Claus and Robot
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Santa Claus has Robot which lives on the infinite grid and can move along its lines. He can also, having a sequence of *m* points *p*1,<=*p*2,<=...,<=*p**m* with integer coordinates, do the following: denote its i... | ```python
t=1
while t>0:
t-=1
n=int(input())
s=input()
mp=dict()
mp['R']=0
mp['L']=0
mp['U']=0
mp['D']=0
ans=0
for i in s:
mp[i]+=1
if mp['R']>=1 and mp['L']>=1:
ans+=1
mp['R']=0
mp['L']=0
mp['U']=0
... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
34 | B | Sale | PROGRAMMING | 900 | [
"greedy",
"sortings"
] | B. Sale | 2 | 256 | Once Bob got to a sale of old TV sets. There were *n* TV sets at that sale. TV set with index *i* costs *a**i* bellars. Some TV sets have a negative price — their owners are ready to pay Bob if he buys their useless apparatus. Bob can «buy» any TV sets he wants. Though he's very strong, Bob can carry at most *m* TV set... | The first line contains two space-separated integers *n* and *m* (1<=≤<=*m*<=≤<=*n*<=≤<=100) — amount of TV sets at the sale, and amount of TV sets that Bob can carry. The following line contains *n* space-separated integers *a**i* (<=-<=1000<=≤<=*a**i*<=≤<=1000) — prices of the TV sets. | Output the only number — the maximum sum of money that Bob can earn, given that he can carry at most *m* TV sets. | [
"5 3\n-6 0 35 -2 4\n",
"4 2\n7 0 0 -7\n"
] | [
"8\n",
"7\n"
] | none | 1,000 | [
{
"input": "5 3\n-6 0 35 -2 4",
"output": "8"
},
{
"input": "4 2\n7 0 0 -7",
"output": "7"
},
{
"input": "6 6\n756 -611 251 -66 572 -818",
"output": "1495"
},
{
"input": "5 5\n976 437 937 788 518",
"output": "0"
},
{
"input": "5 3\n-2 -2 -2 -2 -2",
"output": "... | 1,641,724,594 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 3 | 92 | 0 | s = input().split()
(n,m) = (int(i) for i in s)
s = input().split()
s = [int(i) for i in s]
s.sort()
res = 0
for i in range(m):
if(s[i]<0):
res += s[i]
if(res == 0):
print(-1*s[0])
else:
print(-1*res)
| Title: Sale
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Once Bob got to a sale of old TV sets. There were *n* TV sets at that sale. TV set with index *i* costs *a**i* bellars. Some TV sets have a negative price — their owners are ready to pay Bob if he buys their useless apparatus. Bob can... | ```python
s = input().split()
(n,m) = (int(i) for i in s)
s = input().split()
s = [int(i) for i in s]
s.sort()
res = 0
for i in range(m):
if(s[i]<0):
res += s[i]
if(res == 0):
print(-1*s[0])
else:
print(-1*res)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions |
616 | A | Comparing Two Long Integers | PROGRAMMING | 900 | [
"implementation",
"strings"
] | null | null | You are given two very long integers *a*,<=*b* (leading zeroes are allowed). You should check what number *a* or *b* is greater or determine that they are equal.
The input size is very large so don't use the reading of symbols one by one. Instead of that use the reading of a whole line or token.
As input/output can r... | The first line contains a non-negative integer *a*.
The second line contains a non-negative integer *b*.
The numbers *a*,<=*b* may contain leading zeroes. Each of them contains no more than 106 digits. | Print the symbol "<" if *a*<=<<=*b* and the symbol ">" if *a*<=><=*b*. If the numbers are equal print the symbol "=". | [
"9\n10\n",
"11\n10\n",
"00012345\n12345\n",
"0123\n9\n",
"0123\n111\n"
] | [
"<\n",
">\n",
"=\n",
">\n",
">\n"
] | none | 0 | [
{
"input": "9\n10",
"output": "<"
},
{
"input": "11\n10",
"output": ">"
},
{
"input": "00012345\n12345",
"output": "="
},
{
"input": "0123\n9",
"output": ">"
},
{
"input": "0123\n111",
"output": ">"
},
{
"input": "9\n9",
"output": "="
},
{
... | 1,665,420,250 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 120 | 124 | 38,502,400 | from sys import stdin
input=lambda :stdin.readline()[:-1]
a=[int(i) for i in input()]
b=[int(i) for i in input()]
a=a[::-1]
while a and a[-1]==0:
a.pop()
a=a[::-1]
b=b[::-1]
while b and b[-1]==0:
b.pop()
b=b[::-1]
if len(a)>len(b):
print('>')
exit()
if len(a)<len(b):
print('<')
exit()
m=... | Title: Comparing Two Long Integers
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given two very long integers *a*,<=*b* (leading zeroes are allowed). You should check what number *a* or *b* is greater or determine that they are equal.
The input size is very large so don't use th... | ```python
from sys import stdin
input=lambda :stdin.readline()[:-1]
a=[int(i) for i in input()]
b=[int(i) for i in input()]
a=a[::-1]
while a and a[-1]==0:
a.pop()
a=a[::-1]
b=b[::-1]
while b and b[-1]==0:
b.pop()
b=b[::-1]
if len(a)>len(b):
print('>')
exit()
if len(a)<len(b):
print('<')
... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
588 | A | Duff and Meat | PROGRAMMING | 900 | [
"greedy"
] | null | null | Duff is addicted to meat! Malek wants to keep her happy for *n* days. In order to be happy in *i*-th day, she needs to eat exactly *a**i* kilograms of meat.
There is a big shop uptown and Malek wants to buy meat for her from there. In *i*-th day, they sell meat for *p**i* dollars per kilogram. Malek knows all numbers ... | The first line of input contains integer *n* (1<=≤<=*n*<=≤<=105), the number of days.
In the next *n* lines, *i*-th line contains two integers *a**i* and *p**i* (1<=≤<=*a**i*,<=*p**i*<=≤<=100), the amount of meat Duff needs and the cost of meat in that day. | Print the minimum money needed to keep Duff happy for *n* days, in one line. | [
"3\n1 3\n2 2\n3 1\n",
"3\n1 3\n2 1\n3 2\n"
] | [
"10\n",
"8\n"
] | In the first sample case: An optimal way would be to buy 1 kg on the first day, 2 kg on the second day and 3 kg on the third day.
In the second sample case: An optimal way would be to buy 1 kg on the first day and 5 kg (needed meat for the second and third day) on the second day. | 750 | [
{
"input": "3\n1 3\n2 2\n3 1",
"output": "10"
},
{
"input": "3\n1 3\n2 1\n3 2",
"output": "8"
},
{
"input": "1\n39 52",
"output": "2028"
},
{
"input": "2\n25 56\n94 17",
"output": "2998"
},
{
"input": "5\n39 21\n95 89\n73 90\n9 55\n85 32",
"output": "6321"
}... | 1,577,107,864 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 4 | 109 | 307,200 | x=int(input())
l=[];k=[]
for i in range(x):
a,b=map(int,input().split())
l.append(a)
k.append(b)
s=0
for i in range(len(l)-1):
if k[i]<k[i+1]:
s+=(l[i]+l[i+1])*k[i]
l[i+1]=0
else:
s+=l[i]*k[i]
print(s+l[-1]*k[-1]) | Title: Duff and Meat
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Duff is addicted to meat! Malek wants to keep her happy for *n* days. In order to be happy in *i*-th day, she needs to eat exactly *a**i* kilograms of meat.
There is a big shop uptown and Malek wants to buy meat for her ... | ```python
x=int(input())
l=[];k=[]
for i in range(x):
a,b=map(int,input().split())
l.append(a)
k.append(b)
s=0
for i in range(len(l)-1):
if k[i]<k[i+1]:
s+=(l[i]+l[i+1])*k[i]
l[i+1]=0
else:
s+=l[i]*k[i]
print(s+l[-1]*k[-1])
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
231 | A | Team | PROGRAMMING | 800 | [
"brute force",
"greedy"
] | null | null | One day three best friends Petya, Vasya and Tonya decided to form a team and take part in programming contests. Participants are usually offered several problems during programming contests. Long before the start the friends decided that they will implement a problem if at least two of them are sure about the solution.... | The first input line contains a single integer *n* (1<=≤<=*n*<=≤<=1000) — the number of problems in the contest. Then *n* lines contain three integers each, each integer is either 0 or 1. If the first number in the line equals 1, then Petya is sure about the problem's solution, otherwise he isn't sure. The second numbe... | Print a single integer — the number of problems the friends will implement on the contest. | [
"3\n1 1 0\n1 1 1\n1 0 0\n",
"2\n1 0 0\n0 1 1\n"
] | [
"2\n",
"1\n"
] | In the first sample Petya and Vasya are sure that they know how to solve the first problem and all three of them know how to solve the second problem. That means that they will write solutions for these problems. Only Petya is sure about the solution for the third problem, but that isn't enough, so the friends won't ta... | 500 | [
{
"input": "3\n1 1 0\n1 1 1\n1 0 0",
"output": "2"
},
{
"input": "2\n1 0 0\n0 1 1",
"output": "1"
},
{
"input": "1\n1 0 0",
"output": "0"
},
{
"input": "2\n1 0 0\n1 1 1",
"output": "1"
},
{
"input": "5\n1 0 0\n0 1 0\n1 1 1\n0 0 1\n0 0 0",
"output": "1"
},
... | 1,697,815,103 | 2,147,483,647 | Python 3 | OK | TESTS | 21 | 92 | 0 | n=int(input())
d=0
while n>0:
n -=1
s = input()
a=s[0]; b=s[2]; c=s[4]
k= int(a)+int(b)+int(c)
if k>1: d +=1
print(d)
| Title: Team
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
One day three best friends Petya, Vasya and Tonya decided to form a team and take part in programming contests. Participants are usually offered several problems during programming contests. Long before the start the friends decid... | ```python
n=int(input())
d=0
while n>0:
n -=1
s = input()
a=s[0]; b=s[2]; c=s[4]
k= int(a)+int(b)+int(c)
if k>1: d +=1
print(d)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
884 | A | Book Reading | PROGRAMMING | 800 | [
"implementation"
] | null | null | Recently Luba bought a very interesting book. She knows that it will take *t* seconds to read the book. Luba wants to finish reading as fast as she can.
But she has some work to do in each of *n* next days. The number of seconds that Luba has to spend working during *i*-th day is *a**i*. If some free time remains, she... | The first line contains two integers *n* and *t* (1<=≤<=*n*<=≤<=100, 1<=≤<=*t*<=≤<=106) — the number of days and the time required to read the book.
The second line contains *n* integers *a**i* (0<=≤<=*a**i*<=≤<=86400) — the time Luba has to spend on her work during *i*-th day. | Print the minimum day Luba can finish reading the book.
It is guaranteed that answer doesn't exceed *n*. | [
"2 2\n86400 86398\n",
"2 86400\n0 86400\n"
] | [
"2\n",
"1\n"
] | none | 0 | [
{
"input": "2 2\n86400 86398",
"output": "2"
},
{
"input": "2 86400\n0 86400",
"output": "1"
},
{
"input": "2 86400\n1 86399",
"output": "2"
},
{
"input": "100 1000000\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0... | 1,656,152,805 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 30 | 0 | a,b=map(int,input().strip().split())
lst=list(map(int,input().strip().split()))
count=1
for i in range(len(lst)):
diff=86400-lst[i]
if diff>b:
count=count+1
print(count) | Title: Book Reading
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Recently Luba bought a very interesting book. She knows that it will take *t* seconds to read the book. Luba wants to finish reading as fast as she can.
But she has some work to do in each of *n* next days. The number of ... | ```python
a,b=map(int,input().strip().split())
lst=list(map(int,input().strip().split()))
count=1
for i in range(len(lst)):
diff=86400-lst[i]
if diff>b:
count=count+1
print(count)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
817 | D | Imbalanced Array | PROGRAMMING | 1,900 | [
"data structures",
"divide and conquer",
"dsu",
"sortings"
] | null | null | You are given an array *a* consisting of *n* elements. The imbalance value of some subsegment of this array is the difference between the maximum and minimum element from this segment. The imbalance value of the array is the sum of imbalance values of all subsegments of this array.
For example, the imbalance value of ... | The first line contains one integer *n* (1<=≤<=*n*<=≤<=106) — size of the array *a*.
The second line contains *n* integers *a*1,<=*a*2... *a**n* (1<=≤<=*a**i*<=≤<=106) — elements of the array. | Print one integer — the imbalance value of *a*. | [
"3\n1 4 1\n"
] | [
"9\n"
] | none | 0 | [
{
"input": "3\n1 4 1",
"output": "9"
},
{
"input": "10\n1 1 1 1 1 1 1 1 1 1",
"output": "0"
},
{
"input": "10\n1 4 4 3 5 2 4 2 4 5",
"output": "123"
},
{
"input": "10\n9 6 8 5 5 2 8 9 2 2",
"output": "245"
},
{
"input": "30\n4 5 2 2 5 2 3 4 3 3 2 1 3 4 4 5 3 3 1 5... | 1,497,673,690 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 46 | 0 | n=int(input())
arr=[int(x) for x in input().strip().split()]
i,j,count=0,0,0
for i in range(0,n):
maxnum,minnum=arr[i],arr[i]
for j in range(i+1,n):
maxnum=(maxnum if maxnum>=arr[j] else arr[j])
minmum=(minnum if minnum<=arr[j] else arr[j])
count+=maxnum-minnum
print(count) | Title: Imbalanced Array
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given an array *a* consisting of *n* elements. The imbalance value of some subsegment of this array is the difference between the maximum and minimum element from this segment. The imbalance value of the array ... | ```python
n=int(input())
arr=[int(x) for x in input().strip().split()]
i,j,count=0,0,0
for i in range(0,n):
maxnum,minnum=arr[i],arr[i]
for j in range(i+1,n):
maxnum=(maxnum if maxnum>=arr[j] else arr[j])
minmum=(minnum if minnum<=arr[j] else arr[j])
count+=maxnum-minnum
print(c... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
356 | A | Knight Tournament | PROGRAMMING | 1,500 | [
"data structures",
"dsu"
] | null | null | Hooray! Berl II, the king of Berland is making a knight tournament. The king has already sent the message to all knights in the kingdom and they in turn agreed to participate in this grand event.
As for you, you're just a simple peasant. There's no surprise that you slept in this morning and were late for the tourname... | The first line contains two integers *n*, *m* (2<=≤<=*n*<=≤<=3·105; 1<=≤<=*m*<=≤<=3·105) — the number of knights and the number of fights. Each of the following *m* lines contains three integers *l**i*,<=*r**i*,<=*x**i* (1<=≤<=*l**i*<=<<=*r**i*<=≤<=*n*; *l**i*<=≤<=*x**i*<=≤<=*r**i*) — the description of the *i*-th f... | Print *n* integers. If the *i*-th knight lost, then the *i*-th number should equal the number of the knight that beat the knight number *i*. If the *i*-th knight is the winner, then the *i*-th number must equal 0. | [
"4 3\n1 2 1\n1 3 3\n1 4 4\n",
"8 4\n3 5 4\n3 7 6\n2 8 8\n1 8 1\n"
] | [
"3 1 4 0 ",
"0 8 4 6 4 8 6 1 "
] | Consider the first test case. Knights 1 and 2 fought the first fight and knight 1 won. Knights 1 and 3 fought the second fight and knight 3 won. The last fight was between knights 3 and 4, knight 4 won. | 500 | [
{
"input": "4 3\n1 2 1\n1 3 3\n1 4 4",
"output": "3 1 4 0 "
},
{
"input": "8 4\n3 5 4\n3 7 6\n2 8 8\n1 8 1",
"output": "0 8 4 6 4 8 6 1 "
},
{
"input": "2 1\n1 2 1",
"output": "0 1 "
},
{
"input": "2 1\n1 2 2",
"output": "2 0 "
},
{
"input": "3 1\n1 3 1",
"out... | 1,645,937,170 | 2,147,483,647 | PyPy 3-64 | TIME_LIMIT_EXCEEDED | TESTS | 10 | 3,000 | 44,236,800 | # 2022-02-27 12:35:39.649431
# https://codeforces.com/problemset/problem/356/A
import sys
_DEBUG = False
if not _DEBUG:
input = sys.stdin.readline
print = sys.stdout.write
def proc(n, m, fights):
t = [0] * (n + 1)
next = list(range(n + 1))
for lo, hi, wi in fights:
for i i... | Title: Knight Tournament
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Hooray! Berl II, the king of Berland is making a knight tournament. The king has already sent the message to all knights in the kingdom and they in turn agreed to participate in this grand event.
As for you, you're j... | ```python
# 2022-02-27 12:35:39.649431
# https://codeforces.com/problemset/problem/356/A
import sys
_DEBUG = False
if not _DEBUG:
input = sys.stdin.readline
print = sys.stdout.write
def proc(n, m, fights):
t = [0] * (n + 1)
next = list(range(n + 1))
for lo, hi, wi in fights:
... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
825 | B | Five-In-a-Row | PROGRAMMING | 1,600 | [
"brute force",
"implementation"
] | null | null | Alice and Bob play 5-in-a-row game. They have a playing field of size 10<=×<=10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts.
In current match they have made some turns and now it's Alice's turn. She wonders if she can put cross in such empty cell that she wins i... | You are given matrix 10<=×<=10 (10 lines of 10 characters each) with capital Latin letters 'X' being a cross, letters 'O' being a nought and '.' being an empty cell. The number of 'X' cells is equal to the number of 'O' cells and there is at least one of each type. There is at least one empty cell.
It is guaranteed th... | Print 'YES' if it's possible for Alice to win in one turn by putting cross in some empty cell. Otherwise print 'NO'. | [
"XX.XX.....\n.....OOOO.\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n",
"XXOXX.....\nOO.O......\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n"
] | [
"YES\n",
"NO\n"
] | none | 0 | [
{
"input": "O.......O.\n.....O.X..\n......O...\n....X.O...\n.O.O.....X\n.XO.....XX\n...X...X.O\n........O.\n........O.\n.X.X.....X",
"output": "NO"
},
{
"input": "....OX....\n..........\n.O..X...X.\nXXO..XO..O\nO.......X.\n...XX.....\n..O.O...OX\n.........X\n.....X..OO\n........O.",
"output": "N... | 1,516,682,061 | 2,001 | Python 3 | WRONG_ANSWER | TESTS | 2 | 62 | 5,632,000 | m = []
for x in range(10):
m.append(input())
t = False
for y in range(10):
for x in range(10):
if(x<6):
if(m[y][x+1] == m[y][x+2] == m[y][x+3] == m[y][x+4]=="X" and m[y][x]!="O"):
print("YES")
t = True
break
if(x>0 and x<7):
... | Title: Five-In-a-Row
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Alice and Bob play 5-in-a-row game. They have a playing field of size 10<=×<=10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts.
In current match they have made some t... | ```python
m = []
for x in range(10):
m.append(input())
t = False
for y in range(10):
for x in range(10):
if(x<6):
if(m[y][x+1] == m[y][x+2] == m[y][x+3] == m[y][x+4]=="X" and m[y][x]!="O"):
print("YES")
t = True
break
if(x>0 ... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
4 | A | Watermelon | PROGRAMMING | 800 | [
"brute force",
"math"
] | A. Watermelon | 1 | 64 | One hot summer day Pete and his friend Billy decided to buy a watermelon. They chose the biggest and the ripest one, in their opinion. After that the watermelon was weighed, and the scales showed *w* kilos. They rushed home, dying of thirst, and decided to divide the berry, however they faced a hard problem.
Pete and ... | The first (and the only) input line contains integer number *w* (1<=≤<=*w*<=≤<=100) — the weight of the watermelon bought by the boys. | Print YES, if the boys can divide the watermelon into two parts, each of them weighing even number of kilos; and NO in the opposite case. | [
"8\n"
] | [
"YES\n"
] | For example, the boys can divide the watermelon into two parts of 2 and 6 kilos respectively (another variant — two parts of 4 and 4 kilos). | 0 | [
{
"input": "8",
"output": "YES"
},
{
"input": "5",
"output": "NO"
},
{
"input": "4",
"output": "YES"
},
{
"input": "3",
"output": "NO"
},
{
"input": "2",
"output": "NO"
},
{
"input": "1",
"output": "NO"
},
{
"input": "7",
"output": "NO"... | 1,693,233,442 | 2,147,483,647 | Python 3 | OK | TESTS | 20 | 92 | 0 | w = int(input())
if(w > 3 and w % 2 == 0):print('YES')
else:print('NO') | Title: Watermelon
Time Limit: 1 seconds
Memory Limit: 64 megabytes
Problem Description:
One hot summer day Pete and his friend Billy decided to buy a watermelon. They chose the biggest and the ripest one, in their opinion. After that the watermelon was weighed, and the scales showed *w* kilos. They rushed home, dyin... | ```python
w = int(input())
if(w > 3 and w % 2 == 0):print('YES')
else:print('NO')
``` | 3.954 | MatrixStudio/Codeforces-Python-Submissions |
579 | A | Raising Bacteria | PROGRAMMING | 1,000 | [
"bitmasks"
] | null | null | You are a lover of bacteria. You want to raise some bacteria in a box.
Initially, the box is empty. Each morning, you can put any number of bacteria into the box. And each night, every bacterium in the box will split into two bacteria. You hope to see exactly *x* bacteria in the box at some moment.
What is the mini... | The only line containing one integer *x* (1<=≤<=*x*<=≤<=109). | The only line containing one integer: the answer. | [
"5\n",
"8\n"
] | [
"2\n",
"1\n"
] | For the first sample, we can add one bacterium in the box in the first day morning and at the third morning there will be 4 bacteria in the box. Now we put one more resulting 5 in the box. We added 2 bacteria in the process so the answer is 2.
For the second sample, we can put one in the first morning and in the 4-th ... | 250 | [
{
"input": "5",
"output": "2"
},
{
"input": "8",
"output": "1"
},
{
"input": "536870911",
"output": "29"
},
{
"input": "1",
"output": "1"
},
{
"input": "343000816",
"output": "14"
},
{
"input": "559980448",
"output": "12"
},
{
"input": "697... | 1,692,381,420 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 31 | 0 | def main():
x = int(input())
bac = 0
pot = 1
while x >= pot:
pot *= 2
bac = 1 + x - (pot//2)
print(bac)
main()
| Title: Raising Bacteria
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are a lover of bacteria. You want to raise some bacteria in a box.
Initially, the box is empty. Each morning, you can put any number of bacteria into the box. And each night, every bacterium in the box will split... | ```python
def main():
x = int(input())
bac = 0
pot = 1
while x >= pot:
pot *= 2
bac = 1 + x - (pot//2)
print(bac)
main()
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
137 | B | Permutation | PROGRAMMING | 1,000 | [
"greedy"
] | null | null | "Hey, it's homework time" — thought Polycarpus and of course he started with his favourite subject, IT. Polycarpus managed to solve all tasks but for the last one in 20 minutes. However, as he failed to solve the last task after some considerable time, the boy asked you to help him.
The sequence of *n* integers is cal... | The first line of the input data contains an integer *n* (1<=≤<=*n*<=≤<=5000) which represents how many numbers are in the sequence. The second line contains a sequence of integers *a**i* (1<=≤<=*a**i*<=≤<=5000,<=1<=≤<=*i*<=≤<=*n*). | Print the only number — the minimum number of changes needed to get the permutation. | [
"3\n3 1 2\n",
"2\n2 2\n",
"5\n5 3 3 3 1\n"
] | [
"0\n",
"1\n",
"2\n"
] | The first sample contains the permutation, which is why no replacements are required.
In the second sample it is enough to replace the first element with the number 1 and that will make the sequence the needed permutation.
In the third sample we can replace the second element with number 4 and the fourth element with... | 1,000 | [
{
"input": "3\n3 1 2",
"output": "0"
},
{
"input": "2\n2 2",
"output": "1"
},
{
"input": "5\n5 3 3 3 1",
"output": "2"
},
{
"input": "5\n6 6 6 6 6",
"output": "5"
},
{
"input": "10\n1 1 2 2 8 8 7 7 9 9",
"output": "5"
},
{
"input": "8\n9 8 7 6 5 4 3 2"... | 1,441,914,347 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 3 | 92 | 0 | n = int(input())
a = list(map(int, input().split()))
p = [0] * n
for i in range(n):
p[a[i] - 1] += 1
sum = 0
for i in range(n):
if p[i] == 0:
sum += 1
print(sum)
| Title: Permutation
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
"Hey, it's homework time" — thought Polycarpus and of course he started with his favourite subject, IT. Polycarpus managed to solve all tasks but for the last one in 20 minutes. However, as he failed to solve the last task ... | ```python
n = int(input())
a = list(map(int, input().split()))
p = [0] * n
for i in range(n):
p[a[i] - 1] += 1
sum = 0
for i in range(n):
if p[i] == 0:
sum += 1
print(sum)
``` | -1 | MatrixStudio/Codeforces-Python-Submissions | |
27 | A | Next Test | PROGRAMMING | 1,200 | [
"implementation",
"sortings"
] | A. Next Test | 2 | 256 | «Polygon» is a system which allows to create programming tasks in a simple and professional way. When you add a test to the problem, the corresponding form asks you for the test index. As in most cases it is clear which index the next test will have, the system suggests the default value of the index. It is calculated ... | The first line contains one integer *n* (1<=≤<=*n*<=≤<=3000) — the amount of previously added tests. The second line contains *n* distinct integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=3000) — indexes of these tests. | Output the required default value for the next test index. | [
"3\n1 7 2\n"
] | [
"3\n"
] | none | 500 | [
{
"input": "1\n1",
"output": "2"
},
{
"input": "2\n2 1",
"output": "3"
},
{
"input": "3\n3 4 1",
"output": "2"
},
{
"input": "4\n6 4 3 5",
"output": "1"
},
{
"input": "5\n3 2 1 7 4",
"output": "5"
},
{
"input": "6\n4 1 2 5 3 7",
"output": "6"
},
... | 1,626,505,971 | 2,147,483,647 | PyPy 3 | RUNTIME_ERROR | TESTS | 0 | 186 | 22,220,800 | t = int(input())
arr = list(map(int, input().split()))
ans = -1
arr.sort()
for i in range(1, arr[-1], 1):
if i == arr[i-1]:
continue
else:
ans = i
break
if ans == -1:
print(ans[-1] + 1)
else:
print(ans) | Title: Next Test
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
«Polygon» is a system which allows to create programming tasks in a simple and professional way. When you add a test to the problem, the corresponding form asks you for the test index. As in most cases it is clear which index the... | ```python
t = int(input())
arr = list(map(int, input().split()))
ans = -1
arr.sort()
for i in range(1, arr[-1], 1):
if i == arr[i-1]:
continue
else:
ans = i
break
if ans == -1:
print(ans[-1] + 1)
else:
print(ans)
``` | -1 | MatrixStudio/Codeforces-Python-Submissions |
164 | C | Machine Programming | PROGRAMMING | 2,400 | [
"flows",
"graphs"
] | null | null | One remarkable day company "X" received *k* machines. And they were not simple machines, they were mechanical programmers! This was the last unsuccessful step before switching to android programmers, but that's another story.
The company has now *n* tasks, for each of them we know the start time of its execution *s**i... | The first line contains two integer numbers *n* and *k* (1<=≤<=*n*<=≤<=1000, 1<=≤<=*k*<=≤<=50) — the numbers of tasks and machines, correspondingly.
The next *n* lines contain space-separated groups of three integers *s**i*,<=*t**i*,<=*c**i* (1<=≤<=*s**i*,<=*t**i*<=≤<=109, 1<=≤<=*c**i*<=≤<=106), *s**i* is the time whe... | Print *n* integers *x*1,<=*x*2,<=...,<=*x**n*. Number *x**i* should equal 1, if task *i* should be completed and otherwise it should equal 0.
If there are several optimal solutions, print any of them. | [
"3 1\n2 7 5\n1 3 3\n4 1 3\n",
"5 2\n1 5 4\n1 4 5\n1 3 2\n4 1 2\n5 6 1\n"
] | [
"0 1 1\n",
"1 1 0 0 1\n"
] | In the first sample the tasks need to be executed at moments of time 2 ... 8, 1 ... 3 and 4 ... 4, correspondingly. The first task overlaps with the second and the third ones, so we can execute either task one (profit 5) or tasks two and three (profit 6). | 1,500 | [] | 1,693,579,119 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 0 | 92 | 0 | print("_RANDOM_GUESS_1693579119.0453897")# 1693579119.0454056 | Title: Machine Programming
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
One remarkable day company "X" received *k* machines. And they were not simple machines, they were mechanical programmers! This was the last unsuccessful step before switching to android programmers, but that's anot... | ```python
print("_RANDOM_GUESS_1693579119.0453897")# 1693579119.0454056
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
122 | A | Lucky Division | PROGRAMMING | 1,000 | [
"brute force",
"number theory"
] | null | null | Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya calls a number almost lucky if it could be evenly divided by some lucky number. Help him find ... | The single line contains an integer *n* (1<=≤<=*n*<=≤<=1000) — the number that needs to be checked. | In the only line print "YES" (without the quotes), if number *n* is almost lucky. Otherwise, print "NO" (without the quotes). | [
"47\n",
"16\n",
"78\n"
] | [
"YES\n",
"YES\n",
"NO\n"
] | Note that all lucky numbers are almost lucky as any number is evenly divisible by itself.
In the first sample 47 is a lucky number. In the second sample 16 is divisible by 4. | 500 | [
{
"input": "47",
"output": "YES"
},
{
"input": "16",
"output": "YES"
},
{
"input": "78",
"output": "NO"
},
{
"input": "48",
"output": "YES"
},
{
"input": "100",
"output": "YES"
},
{
"input": "107",
"output": "NO"
},
{
"input": "77",
"ou... | 1,689,073,578 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 13 | 92 | 0 | all = [4,7,47,744,477]
x = 0
n = int(input())
for i in all:
if n % i == 0:
print("YES")
x += 1
if x == 0:
print("NO") | Title: Lucky Division
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
... | ```python
all = [4,7,47,744,477]
x = 0
n = int(input())
for i in all:
if n % i == 0:
print("YES")
x += 1
if x == 0:
print("NO")
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
439 | A | Devu, the Singer and Churu, the Joker | PROGRAMMING | 900 | [
"greedy",
"implementation"
] | null | null | Devu is a renowned classical singer. He is invited to many big functions/festivals. Recently he was invited to "All World Classical Singing Festival". Other than Devu, comedian Churu was also invited.
Devu has provided organizers a list of the songs and required time for singing them. He will sing *n* songs, *i**th* s... | The first line contains two space separated integers *n*, *d* (1<=≤<=*n*<=≤<=100; 1<=≤<=*d*<=≤<=10000). The second line contains *n* space-separated integers: *t*1,<=*t*2,<=...,<=*t**n* (1<=≤<=*t**i*<=≤<=100). | If there is no way to conduct all the songs of Devu, output -1. Otherwise output the maximum number of jokes that Churu can crack in the grand event. | [
"3 30\n2 2 1\n",
"3 20\n2 1 1\n"
] | [
"5\n",
"-1\n"
] | Consider the first example. The duration of the event is 30 minutes. There could be maximum 5 jokes in the following way:
- First Churu cracks a joke in 5 minutes. - Then Devu performs the first song for 2 minutes. - Then Churu cracks 2 jokes in 10 minutes. - Now Devu performs second song for 2 minutes. - Then Ch... | 500 | [
{
"input": "3 30\n2 2 1",
"output": "5"
},
{
"input": "3 20\n2 1 1",
"output": "-1"
},
{
"input": "50 10000\n5 4 10 9 9 6 7 7 7 3 3 7 7 4 7 4 10 10 1 7 10 3 1 4 5 7 2 10 10 10 2 3 4 7 6 1 8 4 7 3 8 8 4 10 1 1 9 2 6 1",
"output": "1943"
},
{
"input": "50 10000\n4 7 15 9 11 12 ... | 1,593,323,085 | 2,147,483,647 | Python 3 | OK | TESTS | 26 | 109 | 6,656,000 | # Devu, the Singer and Churu, the Joker(439A)
n,t = map(int,input().split())
l = list(map(int,input().split()))
churu = (n-1)*10
sm = sum(l)
if t < (sm + churu):
print(-1)
else:
print((t-sm) // 5)
| Title: Devu, the Singer and Churu, the Joker
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Devu is a renowned classical singer. He is invited to many big functions/festivals. Recently he was invited to "All World Classical Singing Festival". Other than Devu, comedian Churu was also invit... | ```python
# Devu, the Singer and Churu, the Joker(439A)
n,t = map(int,input().split())
l = list(map(int,input().split()))
churu = (n-1)*10
sm = sum(l)
if t < (sm + churu):
print(-1)
else:
print((t-sm) // 5)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
519 | B | A and B and Compilation Errors | PROGRAMMING | 1,100 | [
"data structures",
"implementation",
"sortings"
] | null | null | A and B are preparing themselves for programming contests.
B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code.
Initially, the compiler displayed *n* compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix... | The first line of the input contains integer *n* (3<=≤<=*n*<=≤<=105) — the initial number of compilation errors.
The second line contains *n* space-separated integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=109) — the errors the compiler displayed for the first time.
The third line contains *n*<=-<=1 space-sepa... | Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively. | [
"5\n1 5 8 123 7\n123 7 5 1\n5 1 7\n",
"6\n1 4 3 3 5 7\n3 7 5 4 3\n4 3 7 5\n"
] | [
"8\n123\n",
"1\n3\n"
] | In the first test sample B first corrects the error number 8, then the error number 123.
In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. | 1,000 | [
{
"input": "5\n1 5 8 123 7\n123 7 5 1\n5 1 7",
"output": "8\n123"
},
{
"input": "6\n1 4 3 3 5 7\n3 7 5 4 3\n4 3 7 5",
"output": "1\n3"
},
{
"input": "3\n1 2 3\n3 2\n2",
"output": "1\n3"
},
{
"input": "10\n460626451 802090732 277246428 661369649 388684428 784303821 376287098 6... | 1,680,716,925 | 2,147,483,647 | PyPy 3-64 | OK | TESTS | 33 | 171 | 28,569,600 | n = int(input())
first = input().split()
first = [int(first[i]) for i in range(n)]
second = input().split()
second = [int(second[j]) for j in range(n-1)]
third = input().split()
third = [int(third[k]) for k in range(n-2)]
first.sort()
second.sort()
third.sort()
for l in range(n):
if l == n-1:
break
el... | Title: A and B and Compilation Errors
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
A and B are preparing themselves for programming contests.
B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code.
Initially, the compiler disp... | ```python
n = int(input())
first = input().split()
first = [int(first[i]) for i in range(n)]
second = input().split()
second = [int(second[j]) for j in range(n-1)]
third = input().split()
third = [int(third[k]) for k in range(n-2)]
first.sort()
second.sort()
third.sort()
for l in range(n):
if l == n-1:
br... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
146 | A | Lucky Ticket | PROGRAMMING | 800 | [
"implementation"
] | null | null | Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya loves tickets very much. As we know, each ticket has a number that is a positive integer. It... | The first line contains an even integer *n* (2<=≤<=*n*<=≤<=50) — the length of the ticket number that needs to be checked. The second line contains an integer whose length equals exactly *n* — the ticket number. The number may contain leading zeros. | On the first line print "YES" if the given ticket number is lucky. Otherwise, print "NO" (without the quotes). | [
"2\n47\n",
"4\n4738\n",
"4\n4774\n"
] | [
"NO\n",
"NO\n",
"YES\n"
] | In the first sample the sum of digits in the first half does not equal the sum of digits in the second half (4 ≠ 7).
In the second sample the ticket number is not the lucky number. | 500 | [
{
"input": "2\n47",
"output": "NO"
},
{
"input": "4\n4738",
"output": "NO"
},
{
"input": "4\n4774",
"output": "YES"
},
{
"input": "4\n4570",
"output": "NO"
},
{
"input": "6\n477477",
"output": "YES"
},
{
"input": "6\n777777",
"output": "YES"
},
... | 1,659,463,087 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 62 | 0 | n = int(input())
x = int(input())
x = str(x)
lista = list(x)
soma1 = 0
soma2 = 0
ok = 0
for i in range(0,n):
lista[i] = int(lista[i])
if i < n/2:
soma1 = soma1 + lista[i]
if i >= n/2:
soma2 = soma2 + lista[i]
if ((lista[i] != 4) and (lista[i] != 7)):
ok = ok + 1
if soma1 != soma2 or ok != 0:
print... | Title: Lucky Ticket
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
... | ```python
n = int(input())
x = int(input())
x = str(x)
lista = list(x)
soma1 = 0
soma2 = 0
ok = 0
for i in range(0,n):
lista[i] = int(lista[i])
if i < n/2:
soma1 = soma1 + lista[i]
if i >= n/2:
soma2 = soma2 + lista[i]
if ((lista[i] != 4) and (lista[i] != 7)):
ok = ok + 1
if soma1 != soma2 or ok != ... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
996 | A | Hit the Lottery | PROGRAMMING | 800 | [
"dp",
"greedy"
] | null | null | Allen has a LOT of money. He has $n$ dollars in the bank. For security reasons, he wants to withdraw it in cash (we will not disclose the reasons here). The denominations for dollar bills are $1$, $5$, $10$, $20$, $100$. What is the minimum number of bills Allen could receive after withdrawing his entire balance? | The first and only line of input contains a single integer $n$ ($1 \le n \le 10^9$). | Output the minimum number of bills that Allen could receive. | [
"125\n",
"43\n",
"1000000000\n"
] | [
"3\n",
"5\n",
"10000000\n"
] | In the first sample case, Allen can withdraw this with a $100$ dollar bill, a $20$ dollar bill, and a $5$ dollar bill. There is no way for Allen to receive $125$ dollars in one or two bills.
In the second sample case, Allen can withdraw two $20$ dollar bills and three $1$ dollar bills.
In the third sample case, Allen... | 500 | [
{
"input": "125",
"output": "3"
},
{
"input": "43",
"output": "5"
},
{
"input": "1000000000",
"output": "10000000"
},
{
"input": "4",
"output": "4"
},
{
"input": "5",
"output": "1"
},
{
"input": "1",
"output": "1"
},
{
"input": "74",
"o... | 1,699,207,459 | 2,147,483,647 | Python 3 | OK | TESTS | 49 | 46 | 0 | a=int(input());print(a//100+a%100//20+a%100%20//10+a%100%20%10//5+a%100%20%10%5) | Title: Hit the Lottery
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Allen has a LOT of money. He has $n$ dollars in the bank. For security reasons, he wants to withdraw it in cash (we will not disclose the reasons here). The denominations for dollar bills are $1$, $5$, $10$, $20$, $100$... | ```python
a=int(input());print(a//100+a%100//20+a%100%20//10+a%100%20%10//5+a%100%20%10%5)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
796 | D | Police Stations | PROGRAMMING | 2,100 | [
"constructive algorithms",
"dfs and similar",
"dp",
"graphs",
"shortest paths",
"trees"
] | null | null | Inzane finally found Zane with a lot of money to spare, so they together decided to establish a country of their own.
Ruling a country is not an easy job. Thieves and terrorists are always ready to ruin the country's peace. To fight back, Zane and Inzane have enacted a very effective law: from each city it must be pos... | The first line contains three integers *n*, *k*, and *d* (2<=≤<=*n*<=≤<=3·105, 1<=≤<=*k*<=≤<=3·105, 0<=≤<=*d*<=≤<=*n*<=-<=1) — the number of cities, the number of police stations, and the distance limitation in kilometers, respectively.
The second line contains *k* integers *p*1,<=*p*2,<=...,<=*p**k* (1<=≤<=*p**i*<=≤<... | In the first line, print one integer *s* that denotes the maximum number of roads that can be shut down.
In the second line, print *s* distinct integers, the indices of such roads, in any order.
If there are multiple answers, print any of them. | [
"6 2 4\n1 6\n1 2\n2 3\n3 4\n4 5\n5 6\n",
"6 3 2\n1 5 6\n1 2\n1 3\n1 4\n1 5\n5 6\n"
] | [
"1\n5\n",
"2\n4 5 "
] | In the first sample, if you shut down road 5, all cities can still reach a police station within *k* = 4 kilometers.
In the second sample, although this is the only largest valid set of roads that can be shut down, you can print either 4 5 or 5 4 in the second line. | 1,500 | [
{
"input": "6 2 4\n1 6\n1 2\n2 3\n3 4\n4 5\n5 6",
"output": "1\n3 "
},
{
"input": "6 3 2\n1 5 6\n1 2\n1 3\n1 4\n1 5\n5 6",
"output": "2\n4 5 "
},
{
"input": "10 1 5\n5\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10",
"output": "0"
},
{
"input": "11 1 5\n6\n1 2\n2 3\n3 4\n4 5\n... | 1,670,433,748 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 5 | 2,000 | 215,040,000 | from collections import defaultdict, Counter, deque
import sys
import threading
from sys import stdin, stdout
import heapq
from functools import lru_cache
sys.setrecursionlimit(1 << 30)
threading.stack_size(1 << 27)
# def find(node, parents):
# if node == parents[node]:
# return node
# ... | Title: Police Stations
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Inzane finally found Zane with a lot of money to spare, so they together decided to establish a country of their own.
Ruling a country is not an easy job. Thieves and terrorists are always ready to ruin the country's p... | ```python
from collections import defaultdict, Counter, deque
import sys
import threading
from sys import stdin, stdout
import heapq
from functools import lru_cache
sys.setrecursionlimit(1 << 30)
threading.stack_size(1 << 27)
# def find(node, parents):
# if node == parents[node]:
# return ... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
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,531,824,850 | 2,147,483,647 | Python 3 | OK | TESTS | 32 | 218 | 0 | input()
a = [int(i) % 2 for i in input().split()]
print(a.index(a.count(0) > 1) + 1) | Title: IQ test
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given *n* numbers differs from the others. Bob observed that one number usually differs from the others in evenness. Help Bob — t... | ```python
input()
a = [int(i) % 2 for i in input().split()]
print(a.index(a.count(0) > 1) + 1)
``` | 3.9455 | MatrixStudio/Codeforces-Python-Submissions |
883 | I | Photo Processing | PROGRAMMING | 1,900 | [
"binary search",
"dp"
] | null | null | Evlampiy has found one more cool application to process photos. However the application has certain limitations.
Each photo *i* has a contrast *v**i*. In order for the processing to be truly of high quality, the application must receive at least *k* photos with contrasts which differ as little as possible.
Evlampiy a... | The first line contains two integers *n* and *k* (1<=≤<=*k*<=≤<=*n*<=≤<=3·105) — number of photos and minimum size of a group.
The second line contains *n* integers *v*1,<=*v*2,<=...,<=*v**n* (1<=≤<=*v**i*<=≤<=109), where *v**i* is the contrast of the *i*-th photo. | Print the minimal processing time of the division into groups. | [
"5 2\n50 110 130 40 120\n",
"4 1\n2 3 4 1\n"
] | [
"20\n",
"0\n"
] | In the first example the photos should be split into 2 groups: [40, 50] and [110, 120, 130]. The processing time of the first group is 10, and the processing time of the second group is 20. Maximum among 10 and 20 is 20. It is impossible to split the photos into groups in a such way that the processing time of division... | 0 | [
{
"input": "5 2\n50 110 130 40 120",
"output": "20"
},
{
"input": "4 1\n2 3 4 1",
"output": "0"
},
{
"input": "1 1\n4",
"output": "0"
},
{
"input": "2 2\n7 5",
"output": "2"
},
{
"input": "3 2\n34 3 75",
"output": "72"
},
{
"input": "5 2\n932 328 886 9... | 1,683,774,986 | 2,147,483,647 | PyPy 3-64 | WRONG_ANSWER | TESTS | 9 | 61 | 0 | import sys
from bisect import bisect_left
input = lambda: sys.stdin.readline().rstrip("\r\n")
def I():
return input()
def ii():
return int(input())
def li():
return list(input().split())
def mi():
return map(int, input().split())
def lii():
return list(map(int, inpu... | Title: Photo Processing
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Evlampiy has found one more cool application to process photos. However the application has certain limitations.
Each photo *i* has a contrast *v**i*. In order for the processing to be truly of high quality, the appli... | ```python
import sys
from bisect import bisect_left
input = lambda: sys.stdin.readline().rstrip("\r\n")
def I():
return input()
def ii():
return int(input())
def li():
return list(input().split())
def mi():
return map(int, input().split())
def lii():
return list(map... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
581 | A | Vasya the Hipster | PROGRAMMING | 800 | [
"implementation",
"math"
] | null | null | One day Vasya the Hipster decided to count how many socks he had. It turned out that he had *a* red socks and *b* blue socks.
According to the latest fashion, hipsters should wear the socks of different colors: a red one on the left foot, a blue one on the right foot.
Every day Vasya puts on new socks in the morning ... | The single line of the input contains two positive integers *a* and *b* (1<=≤<=*a*,<=*b*<=≤<=100) — the number of red and blue socks that Vasya's got. | Print two space-separated integers — the maximum number of days when Vasya can wear different socks and the number of days when he can wear the same socks until he either runs out of socks or cannot make a single pair from the socks he's got.
Keep in mind that at the end of the day Vasya throws away the socks that he'... | [
"3 1\n",
"2 3\n",
"7 3\n"
] | [
"1 1\n",
"2 0\n",
"3 2\n"
] | In the first sample Vasya can first put on one pair of different socks, after that he has two red socks left to wear on the second day. | 500 | [
{
"input": "3 1",
"output": "1 1"
},
{
"input": "2 3",
"output": "2 0"
},
{
"input": "7 3",
"output": "3 2"
},
{
"input": "100 100",
"output": "100 0"
},
{
"input": "4 10",
"output": "4 3"
},
{
"input": "6 10",
"output": "6 2"
},
{
"input":... | 1,699,661,011 | 2,147,483,647 | PyPy 3 | OK | TESTS | 30 | 93 | 0 | a, b = sorted(map(int, input().split()))
x = a
y = (b - a) // 2
print(x, y)
| Title: Vasya the Hipster
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
One day Vasya the Hipster decided to count how many socks he had. It turned out that he had *a* red socks and *b* blue socks.
According to the latest fashion, hipsters should wear the socks of different colors: a red... | ```python
a, b = sorted(map(int, input().split()))
x = a
y = (b - a) // 2
print(x, y)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
177 | B2 | Rectangular Game | PROGRAMMING | 1,200 | [
"number theory"
] | null | null | The Smart Beaver from ABBYY decided to have a day off. But doing nothing the whole day turned out to be too boring, and he decided to play a game with pebbles. Initially, the Beaver has *n* pebbles. He arranges them in *a* equal rows, each row has *b* pebbles (*a*<=><=1). Note that the Beaver must use all the pebble... | The single line of the input contains a single integer *n* — the initial number of pebbles the Smart Beaver has.
The input limitations for getting 30 points are:
- 2<=≤<=*n*<=≤<=50
The input limitations for getting 100 points are:
- 2<=≤<=*n*<=≤<=109 | Print a single number — the maximum possible result of the game. | [
"10\n",
"8\n"
] | [
"16\n",
"15\n"
] | Consider the first example (*c*<sub class="lower-index">1</sub> = 10). The possible options for the game development are:
- Arrange the pebbles in 10 rows, one pebble per row. Then *c*<sub class="lower-index">2</sub> = 1, and the game ends after the first move with the result of 11. - Arrange the pebbles in 5 rows, ... | 70 | [
{
"input": "10",
"output": "16"
},
{
"input": "8",
"output": "15"
},
{
"input": "4",
"output": "7"
},
{
"input": "36",
"output": "67"
},
{
"input": "32",
"output": "63"
},
{
"input": "46",
"output": "70"
},
{
"input": "6",
"output": "10... | 1,647,600,762 | 2,147,483,647 | Python 3 | OK | TESTS2 | 54 | 124 | 0 | def fun(n):
h=int(n**0.5)+1
for i in range(2,h):
if n%i==0:return i
return n
n=int(input())
c=n
while n>1:
k=fun(n)
c+=n//k
n=n//k
print(c)
| Title: Rectangular Game
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The Smart Beaver from ABBYY decided to have a day off. But doing nothing the whole day turned out to be too boring, and he decided to play a game with pebbles. Initially, the Beaver has *n* pebbles. He arranges them in... | ```python
def fun(n):
h=int(n**0.5)+1
for i in range(2,h):
if n%i==0:return i
return n
n=int(input())
c=n
while n>1:
k=fun(n)
c+=n//k
n=n//k
print(c)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
614 | B | Gena's Code | PROGRAMMING | 1,400 | [
"implementation",
"math"
] | null | null | It's the year 4527 and the tanks game that we all know and love still exists. There also exists Great Gena's code, written in 2016. The problem this code solves is: given the number of tanks that go into the battle from each country, find their product. If it is turns to be too large, then the servers might have not en... | The first line of the input contains the number of countries *n* (1<=≤<=*n*<=≤<=100<=000). The second line contains *n* non-negative integers *a**i* without leading zeroes — the number of tanks of the *i*-th country.
It is guaranteed that the second line contains at least *n*<=-<=1 beautiful numbers and the total leng... | Print a single number without leading zeroes — the product of the number of tanks presented by each country. | [
"3\n5 10 1\n",
"4\n1 1 10 11\n",
"5\n0 3 1 100 1\n"
] | [
"50",
"110",
"0"
] | In sample 1 numbers 10 and 1 are beautiful, number 5 is not not.
In sample 2 number 11 is not beautiful (contains two '1's), all others are beautiful.
In sample 3 number 3 is not beautiful, all others are beautiful. | 1,000 | [
{
"input": "3\n5 10 1",
"output": "50"
},
{
"input": "4\n1 1 10 11",
"output": "110"
},
{
"input": "5\n0 3 1 100 1",
"output": "0"
},
{
"input": "40\n10 100 10 1 10 10 100 10 10 100 10 100 100 10 1824868942 100 100 1 10 100 100 10 100 100 10 100 10 1 10 100 100 100 10 1 10 1 ... | 1,502,444,384 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 9 | 500 | 5,734,400 | n = int(input())
tanks = list(map(int, input().split()))
a = 1
for x in tanks:
a *= x
print(a) | Title: Gena's Code
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
It's the year 4527 and the tanks game that we all know and love still exists. There also exists Great Gena's code, written in 2016. The problem this code solves is: given the number of tanks that go into the battle from eac... | ```python
n = int(input())
tanks = list(map(int, input().split()))
a = 1
for x in tanks:
a *= x
print(a)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
464 | E | The Classic Problem | PROGRAMMING | 3,000 | [
"data structures",
"graphs",
"shortest paths"
] | null | null | You are given a weighted undirected graph on *n* vertices and *m* edges. Find the shortest path from vertex *s* to vertex *t* or else state that such path doesn't exist. | The first line of the input contains two space-separated integers — *n* and *m* (1<=≤<=*n*<=≤<=105; 0<=≤<=*m*<=≤<=105).
Next *m* lines contain the description of the graph edges. The *i*-th line contains three space-separated integers — *u**i*, *v**i*, *x**i* (1<=≤<=*u**i*,<=*v**i*<=≤<=*n*; 0<=≤<=*x**i*<=≤<=105). That... | In the first line print the remainder after dividing the length of the shortest path by 1000000007 (109<=+<=7) if the path exists, and -1 if the path doesn't exist.
If the path exists print in the second line integer *k* — the number of vertices in the shortest path from vertex *s* to vertex *t*; in the third line pri... | [
"4 4\n1 4 2\n1 2 0\n2 3 0\n3 4 0\n1 4\n",
"4 3\n1 2 4\n2 3 5\n3 4 6\n1 4\n",
"4 2\n1 2 0\n3 4 1\n1 4\n"
] | [
"3\n4\n1 2 3 4 \n",
"112\n4\n1 2 3 4 \n",
"-1\n"
] | A path from vertex *s* to vertex *t* is a sequence *v*<sub class="lower-index">0</sub>, ..., *v*<sub class="lower-index">*k*</sub>, such that *v*<sub class="lower-index">0</sub> = *s*, *v*<sub class="lower-index">*k*</sub> = *t*, and for any *i* from 0 to *k* - 1 vertices *v*<sub class="lower-index">*i*</sub> and *v*<s... | 2,500 | [] | 1,621,673,941 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 8 | 5,000 | 3,584,000 | import sys
def solve():
n,m = [int(x) for x in input().split()]
n = n+1
neighbours = [[] for i in range(n)]
for i in range(m):
a,b, dist = [int(x) for x in input().split()]
#dist is the exponent of 2. actual cost would be 2**dist
neighbours[a].append([b,dist])
... | Title: The Classic Problem
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given a weighted undirected graph on *n* vertices and *m* edges. Find the shortest path from vertex *s* to vertex *t* or else state that such path doesn't exist.
Input Specification:
The first line of the i... | ```python
import sys
def solve():
n,m = [int(x) for x in input().split()]
n = n+1
neighbours = [[] for i in range(n)]
for i in range(m):
a,b, dist = [int(x) for x in input().split()]
#dist is the exponent of 2. actual cost would be 2**dist
neighbours[a].append([b,dist])... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
160 | A | Twins | PROGRAMMING | 900 | [
"greedy",
"sortings"
] | null | null | Imagine that you have a twin brother or sister. Having another person that looks exactly like you seems very unusual. It's hard to say if having something of an alter ego is good or bad. And if you do have a twin, then you very well know what it's like.
Now let's imagine a typical morning in your family. You haven't w... | The first line contains integer *n* (1<=≤<=*n*<=≤<=100) — the number of coins. The second line contains a sequence of *n* integers *a*1, *a*2, ..., *a**n* (1<=≤<=*a**i*<=≤<=100) — the coins' values. All numbers are separated with spaces. | In the single line print the single number — the minimum needed number of coins. | [
"2\n3 3\n",
"3\n2 1 2\n"
] | [
"2\n",
"2\n"
] | In the first sample you will have to take 2 coins (you and your twin have sums equal to 6, 0 correspondingly). If you take 1 coin, you get sums 3, 3. If you take 0 coins, you get sums 0, 6. Those variants do not satisfy you as your sum should be strictly more that your twins' sum.
In the second sample one coin isn't e... | 500 | [
{
"input": "2\n3 3",
"output": "2"
},
{
"input": "3\n2 1 2",
"output": "2"
},
{
"input": "1\n5",
"output": "1"
},
{
"input": "5\n4 2 2 2 2",
"output": "3"
},
{
"input": "7\n1 10 1 2 1 1 1",
"output": "1"
},
{
"input": "5\n3 2 3 3 1",
"output": "3"
... | 1,696,923,310 | 2,147,483,647 | Python 3 | OK | TESTS | 29 | 122 | 0 | n = int(input())
ls = list(map(int,input().split()))
ls.sort(reverse=True)
demand = sum(ls) // 2 + 1
i = 0
s = 0
while s < demand:
s += ls[i]
i += 1
print(i) | Title: Twins
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Imagine that you have a twin brother or sister. Having another person that looks exactly like you seems very unusual. It's hard to say if having something of an alter ego is good or bad. And if you do have a twin, then you very w... | ```python
n = int(input())
ls = list(map(int,input().split()))
ls.sort(reverse=True)
demand = sum(ls) // 2 + 1
i = 0
s = 0
while s < demand:
s += ls[i]
i += 1
print(i)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
678 | A | Johny Likes Numbers | PROGRAMMING | 800 | [
"implementation",
"math"
] | null | null | Johny likes numbers *n* and *k* very much. Now Johny wants to find the smallest integer *x* greater than *n*, so it is divisible by the number *k*. | The only line contains two integers *n* and *k* (1<=≤<=*n*,<=*k*<=≤<=109). | Print the smallest integer *x*<=><=*n*, so it is divisible by the number *k*. | [
"5 3\n",
"25 13\n",
"26 13\n"
] | [
"6\n",
"26\n",
"39\n"
] | none | 0 | [
{
"input": "5 3",
"output": "6"
},
{
"input": "25 13",
"output": "26"
},
{
"input": "26 13",
"output": "39"
},
{
"input": "1 1",
"output": "2"
},
{
"input": "8 8",
"output": "16"
},
{
"input": "14 15",
"output": "15"
},
{
"input": "197 894"... | 1,604,564,264 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 92 | 0 | n = int(input())
k = int(input())
for i in range(n+1, n+k+1):
if i%k==0:
print(i)
break
| Title: Johny Likes Numbers
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Johny likes numbers *n* and *k* very much. Now Johny wants to find the smallest integer *x* greater than *n*, so it is divisible by the number *k*.
Input Specification:
The only line contains two integers *n* and *... | ```python
n = int(input())
k = int(input())
for i in range(n+1, n+k+1):
if i%k==0:
print(i)
break
``` | -1 | MatrixStudio/Codeforces-Python-Submissions | |
556 | A | Case of the Zeros and Ones | PROGRAMMING | 900 | [
"greedy"
] | null | null | Andrewid the Android is a galaxy-famous detective. In his free time he likes to think about strings containing zeros and ones.
Once he thought about a string of length *n* consisting of zeroes and ones. Consider the following operation: we choose any two adjacent positions in the string, and if one them contains 0, an... | First line of the input contains a single integer *n* (1<=≤<=*n*<=≤<=2·105), the length of the string that Andreid has.
The second line contains the string of length *n* consisting only from zeros and ones. | Output the minimum length of the string that may remain after applying the described operations several times. | [
"4\n1100\n",
"5\n01010\n",
"8\n11101111\n"
] | [
"0\n",
"1\n",
"6\n"
] | In the first sample test it is possible to change the string like the following: <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/10df55364c21c6e8d5da31b6ab6f6294c4fc26b3.png" style="max-width: 100.0%;max-height: 100.0%;"/>.
In the second sample test it is possible to change the string like... | 250 | [
{
"input": "4\n1100",
"output": "0"
},
{
"input": "5\n01010",
"output": "1"
},
{
"input": "8\n11101111",
"output": "6"
},
{
"input": "1\n0",
"output": "1"
},
{
"input": "1\n1",
"output": "1"
},
{
"input": "2\n00",
"output": "2"
},
{
"input"... | 1,613,658,418 | 2,147,483,647 | Python 3 | TIME_LIMIT_EXCEEDED | TESTS | 6 | 1,000 | 0 | n = int(input())
s = input()
while (i := s.count("10")) != 0:
n -= 2 * i
s = s.replace("10", "")
while (i := s.count("01")) != 0:
n -= 2 * i
s = s.replace("10", "")
print(n) | Title: Case of the Zeros and Ones
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Andrewid the Android is a galaxy-famous detective. In his free time he likes to think about strings containing zeros and ones.
Once he thought about a string of length *n* consisting of zeroes and ones. Cons... | ```python
n = int(input())
s = input()
while (i := s.count("10")) != 0:
n -= 2 * i
s = s.replace("10", "")
while (i := s.count("01")) != 0:
n -= 2 * i
s = s.replace("10", "")
print(n)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
641 | A | Little Artem and Grasshopper | PROGRAMMING | 1,000 | [
"implementation"
] | null | null | Little Artem found a grasshopper. He brought it to his house and constructed a jumping area for him.
The area looks like a strip of cells 1<=×<=*n*. Each cell contains the direction for the next jump and the length of that jump. Grasshopper starts in the first cell and follows the instructions written on the cells. Gr... | The first line of the input contains a single integer *n* (1<=≤<=*n*<=≤<=100<=000) — length of the strip.
Next line contains a string of length *n* which consists of characters "<" and ">" only, that provide the direction of the jump from the corresponding cell. Next line contains *n* integers *d**i* (1<=≤<=*d*... | Print "INFINITE" (without quotes) if grasshopper will continue his jumps forever. Otherwise print "FINITE" (without quotes). | [
"2\n><\n1 2\n",
"3\n>><\n2 1 1\n"
] | [
"FINITE\n",
"INFINITE"
] | In the first sample grasshopper starts from the first cell and jumps to the right on the next cell. When he is in the second cell he needs to jump two cells left so he will jump out of the strip.
Second sample grasshopper path is 1 - 3 - 2 - 3 - 2 - 3 and so on. The path is infinite. | 500 | [
{
"input": "2\n><\n1 2",
"output": "FINITE"
},
{
"input": "3\n>><\n2 1 1",
"output": "INFINITE"
},
{
"input": "1\n>\n1000000000",
"output": "FINITE"
},
{
"input": "1\n<\n1000000000",
"output": "FINITE"
},
{
"input": "2\n>>\n1 1",
"output": "FINITE"
},
{
... | 1,626,843,715 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 28 | 155 | 14,336,000 | n = int(input())
d = input()
u = list(map(int, input().split()))
f = 0
for i in range(n):
p = 0
if d[i] == "<":
p = i - u[i]
if d[i] == ">":
p = i + u[i]
if p < 0 or p > n - 1:
print("FINITE")
f = 1
break
if f == 0:
print("INFINITE")
| Title: Little Artem and Grasshopper
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Little Artem found a grasshopper. He brought it to his house and constructed a jumping area for him.
The area looks like a strip of cells 1<=×<=*n*. Each cell contains the direction for the next jump and t... | ```python
n = int(input())
d = input()
u = list(map(int, input().split()))
f = 0
for i in range(n):
p = 0
if d[i] == "<":
p = i - u[i]
if d[i] == ">":
p = i + u[i]
if p < 0 or p > n - 1:
print("FINITE")
f = 1
break
if f == 0:
print("INFINITE")
... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
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,638,812,872 | 2,147,483,647 | PyPy 3 | OK | TESTS | 102 | 108 | 0 | s=input()
t=input()
c=''
for i in range(len(s)):
if s[i]==t[i]: c+='0'
else: c+='1'
print(c)
| 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
s=input()
t=input()
c=''
for i in range(len(s)):
if s[i]==t[i]: c+='0'
else: c+='1'
print(c)
``` | 3.973 | MatrixStudio/Codeforces-Python-Submissions |
358 | A | Dima and Continuous Line | PROGRAMMING | 1,400 | [
"brute force",
"implementation"
] | null | null | Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework.
The teacher gave Seryozha the coordinates of *n* distinct points on the abscissa axis and asked to consecutively connect th... | The first line contains a single integer *n* (1<=≤<=*n*<=≤<=103). The second line contains *n* distinct integers *x*1,<=*x*2,<=...,<=*x**n* (<=-<=106<=≤<=*x**i*<=≤<=106) — the *i*-th point has coordinates (*x**i*,<=0). The points are not necessarily sorted by their *x* coordinate. | In the single line print "yes" (without the quotes), if the line has self-intersections. Otherwise, print "no" (without the quotes). | [
"4\n0 10 5 15\n",
"4\n0 15 5 10\n"
] | [
"yes\n",
"no\n"
] | The first test from the statement is on the picture to the left, the second test is on the picture to the right. | 500 | [
{
"input": "4\n0 10 5 15",
"output": "yes"
},
{
"input": "4\n0 15 5 10",
"output": "no"
},
{
"input": "5\n0 1000 2000 3000 1500",
"output": "yes"
},
{
"input": "5\n-724093 710736 -383722 -359011 439613",
"output": "no"
},
{
"input": "50\n384672 661179 -775591 -989... | 1,608,011,449 | 2,147,483,647 | Python 3 | OK | TESTS | 37 | 1,341 | 307,200 | n=int(input())
a=list(map(int,input().split()))
for i in range(n-1):
for j in range(n-1):
x,y=(sorted([a[i],a[i+1]]))
m,t=sorted([a[j],a[j+1]])
if x<m<y<t or m<x<t<y:
print("yes")
exit(0)
print("no")
| Title: Dima and Continuous Line
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework.
The teacher g... | ```python
n=int(input())
a=list(map(int,input().split()))
for i in range(n-1):
for j in range(n-1):
x,y=(sorted([a[i],a[i+1]]))
m,t=sorted([a[j],a[j+1]])
if x<m<y<t or m<x<t<y:
print("yes")
exit(0)
print("no")
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
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,600,345,318 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 186 | 307,200 | #!/usr/bin/env python3
import sys
if __name__ == "__main__":
n, m = map(int, sys.stdin.readline().split())
ais = list(map(int, sys.stdin.readline().split()))
bis = list(map(int, sys.stdin.readline().split()))
maxx = max(ais)
minn = min(ais)
flag = 0
if minn* 2 <= maxx:
print(maxx)
else:
i = 10
bmin = min... | 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
#!/usr/bin/env python3
import sys
if __name__ == "__main__":
n, m = map(int, sys.stdin.readline().split())
ais = list(map(int, sys.stdin.readline().split()))
bis = list(map(int, sys.stdin.readline().split()))
maxx = max(ais)
minn = min(ais)
flag = 0
if minn* 2 <= maxx:
print(maxx)
else:
i = 10
... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
665 | C | Simple Strings | PROGRAMMING | 1,300 | [
"dp",
"greedy",
"strings"
] | null | null | zscoder loves simple strings! A string *t* is called simple if every pair of adjacent characters are distinct. For example ab, aba, zscoder are simple whereas aa, add are not simple.
zscoder is given a string *s*. He wants to change a minimum number of characters so that the string *s* becomes simple. Help him with th... | The only line contains the string *s* (1<=≤<=|*s*|<=≤<=2·105) — the string given to zscoder. The string *s* consists of only lowercase English letters. | Print the simple string *s*' — the string *s* after the minimal number of changes. If there are multiple solutions, you may output any of them.
Note that the string *s*' should also consist of only lowercase English letters. | [
"aab\n",
"caaab\n",
"zscoder\n"
] | [
"bab\n",
"cabab\n",
"zscoder\n"
] | none | 0 | [
{
"input": "aab",
"output": "bab"
},
{
"input": "caaab",
"output": "cabab"
},
{
"input": "zscoder",
"output": "zscoder"
},
{
"input": "u",
"output": "u"
},
{
"input": "h",
"output": "h"
},
{
"input": "dtottttotd",
"output": "dtotataotd"
},
{
... | 1,587,644,136 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 11 | 187 | 10,342,400 | import sys
s=list(input())
if len(s)==1:
print(s[0])
sys.exit()
for i in range(1,len(s)-1):
if s[i]==s[i-1]:
if ord(s[i+1])+1 >122:
s[i]="a"
else:
s[i]=chr(ord(s[i+1])+1)
if s[-1]==s[-2]:
if ord(s[-2])+1>122:
s[-1]="a"
else:
s[-1... | Title: Simple Strings
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
zscoder loves simple strings! A string *t* is called simple if every pair of adjacent characters are distinct. For example ab, aba, zscoder are simple whereas aa, add are not simple.
zscoder is given a string *s*. He wa... | ```python
import sys
s=list(input())
if len(s)==1:
print(s[0])
sys.exit()
for i in range(1,len(s)-1):
if s[i]==s[i-1]:
if ord(s[i+1])+1 >122:
s[i]="a"
else:
s[i]=chr(ord(s[i+1])+1)
if s[-1]==s[-2]:
if ord(s[-2])+1>122:
s[-1]="a"
else:
... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
762 | A | k-th divisor | PROGRAMMING | 1,400 | [
"math",
"number theory"
] | null | null | You are given two integers *n* and *k*. Find *k*-th smallest divisor of *n*, or report that it doesn't exist.
Divisor of *n* is any such natural number, that *n* can be divided by it without remainder. | The first line contains two integers *n* and *k* (1<=≤<=*n*<=≤<=1015, 1<=≤<=*k*<=≤<=109). | If *n* has less than *k* divisors, output -1.
Otherwise, output the *k*-th smallest divisor of *n*. | [
"4 2\n",
"5 3\n",
"12 5\n"
] | [
"2\n",
"-1\n",
"6\n"
] | In the first example, number 4 has three divisors: 1, 2 and 4. The second one is 2.
In the second example, number 5 has only two divisors: 1 and 5. The third divisor doesn't exist, so the answer is -1. | 0 | [
{
"input": "4 2",
"output": "2"
},
{
"input": "5 3",
"output": "-1"
},
{
"input": "12 5",
"output": "6"
},
{
"input": "1 1",
"output": "1"
},
{
"input": "866421317361600 26880",
"output": "866421317361600"
},
{
"input": "866421317361600 26881",
"ou... | 1,679,408,734 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 31 | 0 | a,b=[int(i) for i in input().split()]
x=[]
for i in range(1,int(a**0.5)+1):
if a%i==0:
x+=[i]
x+=[a]
if len(x)+1==b:
print(-1)
else:
print(x[b-1])
| Title: k-th divisor
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are given two integers *n* and *k*. Find *k*-th smallest divisor of *n*, or report that it doesn't exist.
Divisor of *n* is any such natural number, that *n* can be divided by it without remainder.
Input Specificatio... | ```python
a,b=[int(i) for i in input().split()]
x=[]
for i in range(1,int(a**0.5)+1):
if a%i==0:
x+=[i]
x+=[a]
if len(x)+1==b:
print(-1)
else:
print(x[b-1])
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
1,011 | A | Stages | PROGRAMMING | 900 | [
"greedy",
"implementation",
"sortings"
] | null | null | Natasha is going to fly to Mars. She needs to build a rocket, which consists of several stages in some order. Each of the stages is defined by a lowercase Latin letter. This way, the rocket can be described by the string — concatenation of letters, which correspond to the stages.
There are $n$ stages available. The ro... | The first line of input contains two integers — $n$ and $k$ ($1 \le k \le n \le 50$) – the number of available stages and the number of stages to use in the rocket.
The second line contains string $s$, which consists of exactly $n$ lowercase Latin letters. Each letter defines a new stage, which can be used to build th... | Print a single integer — the minimal total weight of the rocket or -1, if it is impossible to build the rocket at all. | [
"5 3\nxyabd\n",
"7 4\nproblem\n",
"2 2\nab\n",
"12 1\nabaabbaaabbb\n"
] | [
"29",
"34",
"-1",
"1"
] | In the first example, the following rockets satisfy the condition:
- "adx" (weight is $1+4+24=29$);- "ady" (weight is $1+4+25=30$);- "bdx" (weight is $2+4+24=30$);- "bdy" (weight is $2+4+25=31$).
Rocket "adx" has the minimal weight, so the answer is $29$.
In the second example, target rocket is "belo". Its weight ... | 500 | [
{
"input": "5 3\nxyabd",
"output": "29"
},
{
"input": "7 4\nproblem",
"output": "34"
},
{
"input": "2 2\nab",
"output": "-1"
},
{
"input": "12 1\nabaabbaaabbb",
"output": "1"
},
{
"input": "50 13\nqwertyuiopasdfghjklzxcvbnmaaaaaaaaaaaaaaaaaaaaaaaa",
"output": ... | 1,533,026,867 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 4 | 108 | 0 | n, k = map(int, input().split())
a = sorted([ord(i) - ord('a') + 1 for i in input()])
w = 0
while k > 0:
if len(a) == 0:
w = -1
break
w += a[0]
if a[1] == a[0] + 1:
a = a[2:]
else:
a = a[1:]
k -= 1
print(w)
| Title: Stages
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Natasha is going to fly to Mars. She needs to build a rocket, which consists of several stages in some order. Each of the stages is defined by a lowercase Latin letter. This way, the rocket can be described by the string — conca... | ```python
n, k = map(int, input().split())
a = sorted([ord(i) - ord('a') + 1 for i in input()])
w = 0
while k > 0:
if len(a) == 0:
w = -1
break
w += a[0]
if a[1] == a[0] + 1:
a = a[2:]
else:
a = a[1:]
k -= 1
print(w)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
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,624,591,518 | 2,147,483,647 | Python 3 | OK | TESTS | 35 | 124 | 0 |
str = list(input().split(' ')) #number of participants
m = int(str[0]) #number of participants
n = int(str[-1]) #k-th finisher score
print((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
str = list(input().split(' ')) #number of participants
m = int(str[0]) #number of participants
n = int(str[-1]) #k-th finisher score
print((m*n)//2)
``` | 3.969 | MatrixStudio/Codeforces-Python-Submissions |
1 | C | Ancient Berland Circus | PROGRAMMING | 2,100 | [
"geometry",
"math"
] | C. Ancient Berland Circus | 2 | 64 | Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things were different.
In Ancient Berland arenas in circuses were shaped as a regular (equiangular) polygon, the size and the number of angles could vary from one circus to another. In each corner of the arena there was a spec... | The input file consists of three lines, each of them contains a pair of numbers –– coordinates of the pillar. Any coordinate doesn't exceed 1000 by absolute value, and is given with at most six digits after decimal point. | Output the smallest possible area of the ancient arena. This number should be accurate to at least 6 digits after the decimal point. It's guaranteed that the number of angles in the optimal polygon is not larger than 100. | [
"0.000000 0.000000\n1.000000 1.000000\n0.000000 1.000000\n"
] | [
"1.00000000\n"
] | 0 | [
{
"input": "0.000000 0.000000\n1.000000 1.000000\n0.000000 1.000000",
"output": "1.00000000"
},
{
"input": "71.756151 7.532275\n-48.634784 100.159986\n91.778633 158.107739",
"output": "9991.27897663"
},
{
"input": "18.716839 40.852752\n66.147248 -4.083161\n111.083161 43.347248",
"out... | 1,695,436,769 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 1 | 62 | 102,400 | import math
# Function to find the center and radius of the circumcircle of a triangle
def find_circle(a, b, c):
d = 2 * (a[0] * (b[1] - c[1]) + b[0] * (c[1] - a[1]) + c[0] * (a[1] - b[1]))
ux = ((a[0] * a[0] + a[1] * a[1]) * (b[1] - c[1]) + (b[0] * b[0] + b[1] * b[1]) * (c[1] - a[1]) + (c[0] * c[0] + c[1... | Title: Ancient Berland Circus
Time Limit: 2 seconds
Memory Limit: 64 megabytes
Problem Description:
Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things were different.
In Ancient Berland arenas in circuses were shaped as a regular (equiangular) polygon, the size and t... | ```python
import math
# Function to find the center and radius of the circumcircle of a triangle
def find_circle(a, b, c):
d = 2 * (a[0] * (b[1] - c[1]) + b[0] * (c[1] - a[1]) + c[0] * (a[1] - b[1]))
ux = ((a[0] * a[0] + a[1] * a[1]) * (b[1] - c[1]) + (b[0] * b[0] + b[1] * b[1]) * (c[1] - a[1]) + (c[0] * ... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
758 | A | Holiday Of Equality | PROGRAMMING | 800 | [
"implementation",
"math"
] | null | null | In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury.
Totally in Berland there are *n* citizens, the welfare of each of them is estimated as the integer in *a**i* burles (burle is the currency in Berl... | The first line contains the integer *n* (1<=≤<=*n*<=≤<=100) — the number of citizens in the kingdom.
The second line contains *n* integers *a*1,<=*a*2,<=...,<=*a**n*, where *a**i* (0<=≤<=*a**i*<=≤<=106) — the welfare of the *i*-th citizen. | In the only line print the integer *S* — the minimum number of burles which are had to spend. | [
"5\n0 1 2 3 4\n",
"5\n1 1 0 1 1\n",
"3\n1 3 1\n",
"1\n12\n"
] | [
"10",
"1",
"4",
"0"
] | In the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.
In the second example it is enough to give one burle to the third citizen.
In the third example it is necessary to give two burles to the first and the thi... | 500 | [
{
"input": "5\n0 1 2 3 4",
"output": "10"
},
{
"input": "5\n1 1 0 1 1",
"output": "1"
},
{
"input": "3\n1 3 1",
"output": "4"
},
{
"input": "1\n12",
"output": "0"
},
{
"input": "3\n1 2 3",
"output": "3"
},
{
"input": "14\n52518 718438 358883 462189 853... | 1,660,637,351 | 2,147,483,647 | Python 3 | OK | TESTS | 41 | 46 | 0 | n = int(input())
arr = list(map(int,input().split()))
c = max(arr)
d = 0
for i in arr:
d = d + abs(c - i)
print(d) | Title: Holiday Of Equality
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury.
Totally in Berland there are *n* citizens... | ```python
n = int(input())
arr = list(map(int,input().split()))
c = max(arr)
d = 0
for i in arr:
d = d + abs(c - i)
print(d)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
248 | B | Chilly Willy | PROGRAMMING | 1,400 | [
"math",
"number theory"
] | null | null | Chilly Willy loves playing with numbers. He only knows prime numbers that are digits yet. These numbers are 2, 3, 5 and 7. But Willy grew rather bored of such numbers, so he came up with a few games that were connected with them.
Chilly Willy wants to find the minimum number of length *n*, such that it is simultaneous... | A single input line contains a single integer *n* (1<=≤<=*n*<=≤<=105). | Print a single integer — the answer to the problem without leading zeroes, or "-1" (without the quotes), if the number that meet the problem condition does not exist. | [
"1\n",
"5\n"
] | [
"-1\n",
"10080"
] | none | 1,000 | [
{
"input": "1",
"output": "-1"
},
{
"input": "5",
"output": "10080"
},
{
"input": "6",
"output": "100170"
},
{
"input": "4",
"output": "1050"
},
{
"input": "15",
"output": "100000000000110"
},
{
"input": "16",
"output": "1000000000000050"
},
{
... | 1,558,494,969 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 186 | 0 | n = int(input())
if n==1 and n==2:
print("-1")
else:
if n==3:
print("210")
else:
n = n-1
p = pow(10,n)
print(p+210-p%210) | Title: Chilly Willy
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Chilly Willy loves playing with numbers. He only knows prime numbers that are digits yet. These numbers are 2, 3, 5 and 7. But Willy grew rather bored of such numbers, so he came up with a few games that were connected wit... | ```python
n = int(input())
if n==1 and n==2:
print("-1")
else:
if n==3:
print("210")
else:
n = n-1
p = pow(10,n)
print(p+210-p%210)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
63 | A | Sinking Ship | PROGRAMMING | 900 | [
"implementation",
"sortings",
"strings"
] | A. Sinking Ship | 2 | 256 | The ship crashed into a reef and is sinking. Now the entire crew must be evacuated. All *n* crew members have already lined up in a row (for convenience let's label them all from left to right with positive integers from 1 to *n*) and await further instructions. However, one should evacuate the crew properly, in a stri... | The first line contains an integer *n*, which is the number of people in the crew (1<=≤<=*n*<=≤<=100). Then follow *n* lines. The *i*-th of those lines contains two words — the name of the crew member who is *i*-th in line, and his status on the ship. The words are separated by exactly one space. There are no other spa... | Print *n* lines. The *i*-th of them should contain the name of the crew member who must be the *i*-th one to leave the ship. | [
"6\nJack captain\nAlice woman\nCharlie man\nTeddy rat\nBob child\nJulia woman\n"
] | [
"Teddy\nAlice\nBob\nJulia\nCharlie\nJack\n"
] | none | 500 | [
{
"input": "6\nJack captain\nAlice woman\nCharlie man\nTeddy rat\nBob child\nJulia woman",
"output": "Teddy\nAlice\nBob\nJulia\nCharlie\nJack"
},
{
"input": "1\nA captain",
"output": "A"
},
{
"input": "1\nAbcdefjhij captain",
"output": "Abcdefjhij"
},
{
"input": "5\nA captain... | 1,599,027,365 | 2,147,483,647 | Python 3 | OK | TESTS | 26 | 218 | 307,200 | t=int(input())
dict1={
"rat":[],
"wochild" : [],
"man":[],
"captain":[]
}
for i in range(t):
a=input().split()
if a[1]=="rat":
dict1["rat"].append(a[0])
elif a[1] == "child" or a[1]=="woman":
dict1["wochild"].append(a[0])
elif a[1] == "man":
dict1["man"].append(a[0])
else:
dict1["captai... | Title: Sinking Ship
Time Limit: 2 seconds
Memory Limit: 256 megabytes
Problem Description:
The ship crashed into a reef and is sinking. Now the entire crew must be evacuated. All *n* crew members have already lined up in a row (for convenience let's label them all from left to right with positive integers from 1 to ... | ```python
t=int(input())
dict1={
"rat":[],
"wochild" : [],
"man":[],
"captain":[]
}
for i in range(t):
a=input().split()
if a[1]=="rat":
dict1["rat"].append(a[0])
elif a[1] == "child" or a[1]=="woman":
dict1["wochild"].append(a[0])
elif a[1] == "man":
dict1["man"].append(a[0])
else:
dic... | 3.944928 | MatrixStudio/Codeforces-Python-Submissions |
292 | A | SMSC | PROGRAMMING | 1,100 | [
"implementation"
] | null | null | Some large corporation where Polycarpus works has its own short message service center (SMSC). The center's task is to send all sorts of crucial information. Polycarpus decided to check the efficiency of the SMSC.
For that, he asked to give him the statistics of the performance of the SMSC for some period of time. In... | The first line contains a single integer *n* (1<=≤<=*n*<=≤<=103) — the number of tasks of the SMSC. Next *n* lines contain the tasks' descriptions: the *i*-th line contains two space-separated integers *t**i* and *c**i* (1<=≤<=*t**i*,<=*c**i*<=≤<=106) — the time (the second) when the *i*-th task was received and the nu... | In a single line print two space-separated integers — the time when the last text message was sent and the maximum queue size at a certain moment of time. | [
"2\n1 1\n2 1\n",
"1\n1000000 10\n",
"3\n3 3\n4 3\n5 3\n"
] | [
"3 1\n",
"1000010 10\n",
"12 7\n"
] | In the first test sample:
- second 1: the first message has appeared in the queue, the queue's size is 1; - second 2: the first message is sent, the second message has been received, the queue's size is 1; - second 3: the second message is sent, the queue's size is 0,
Thus, the maximum size of the queue is 1, the... | 1,000 | [
{
"input": "2\n1 1\n2 1",
"output": "3 1"
},
{
"input": "1\n1000000 10",
"output": "1000010 10"
},
{
"input": "3\n3 3\n4 3\n5 3",
"output": "12 7"
},
{
"input": "1\n1 1",
"output": "2 1"
},
{
"input": "2\n1 11\n100 10",
"output": "110 11"
},
{
"input":... | 1,580,643,614 | 2,147,483,647 | Python 3 | OK | TESTS | 38 | 218 | 307,200 | max_q = q = 0
t0 = 0
for _ in range(int(input())):
t, c = map(int, input().split())
q = max(0, t0-t+q) + c
max_q = max(q, max_q)
t0 = t
print(t+q, max_q) | Title: SMSC
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Some large corporation where Polycarpus works has its own short message service center (SMSC). The center's task is to send all sorts of crucial information. Polycarpus decided to check the efficiency of the SMSC.
For that, he a... | ```python
max_q = q = 0
t0 = 0
for _ in range(int(input())):
t, c = map(int, input().split())
q = max(0, t0-t+q) + c
max_q = max(q, max_q)
t0 = t
print(t+q, max_q)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
2 | A | Winner | PROGRAMMING | 1,500 | [
"hashing",
"implementation"
] | A. Winner | 1 | 64 | The winner of the card game popular in Berland "Berlogging" is determined according to the following rules. If at the end of the game there is only one player with the maximum number of points, he is the winner. The situation becomes more difficult if the number of such players is more than one. During each round a pla... | The first line contains an integer number *n* (1<=<=≤<=<=*n*<=<=≤<=<=1000), *n* is the number of rounds played. Then follow *n* lines, containing the information about the rounds in "name score" format in chronological order, where name is a string of lower-case Latin letters with the length from 1 to 32, and score is ... | Print the name of the winner. | [
"3\nmike 3\nandrew 5\nmike 2\n",
"3\nandrew 3\nandrew 2\nmike 5\n"
] | [
"andrew\n",
"andrew\n"
] | none | 0 | [
{
"input": "3\nmike 3\nandrew 5\nmike 2",
"output": "andrew"
},
{
"input": "3\nandrew 3\nandrew 2\nmike 5",
"output": "andrew"
},
{
"input": "5\nkaxqybeultn -352\nmgochgrmeyieyskhuourfg -910\nkaxqybeultn 691\nmgochgrmeyieyskhuourfg -76\nkaxqybeultn -303",
"output": "kaxqybeultn"
},... | 1,568,578,425 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 5 | 216 | 0 | n = int(input())
lst = []
d = {}
for i in range(n):
a,b = input().split()
b = int(b)
lst.append([a,b])
if a in d:
d[a] += b
else:
d[a] = b
max1 = - 1000001
for i in d.values():
if i > max1:
max1 = i
b = set()
for i in d.keys():
if d[i] == max1:
... | Title: Winner
Time Limit: 1 seconds
Memory Limit: 64 megabytes
Problem Description:
The winner of the card game popular in Berland "Berlogging" is determined according to the following rules. If at the end of the game there is only one player with the maximum number of points, he is the winner. The situation becomes... | ```python
n = int(input())
lst = []
d = {}
for i in range(n):
a,b = input().split()
b = int(b)
lst.append([a,b])
if a in d:
d[a] += b
else:
d[a] = b
max1 = - 1000001
for i in d.values():
if i > max1:
max1 = i
b = set()
for i in d.keys():
if d[i] == ma... | 0 | MatrixStudio/Codeforces-Python-Submissions |
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,576,139,807 | 2,147,483,647 | PyPy 3 | OK | TESTS | 47 | 155 | 1,433,600 | n,m=map(int,input().split())
s=input()
li=[]
slist=[]
for i in s:
slist.append(i)
for i in range(m):
a=input().split()
li.append(a)
for i in range(m):
for j in range(int(li[i][0])-1,int(li[i][1])):
if(slist[j]==li[i][2]):
slist[j]=li[i][3]
s=''
... | 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=map(int,input().split())
s=input()
li=[]
slist=[]
for i in s:
slist.append(i)
for i in range(m):
a=input().split()
li.append(a)
for i in range(m):
for j in range(int(li[i][0])-1,int(li[i][1])):
if(slist[j]==li[i][2]):
slist[j]=li[i][3]
... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
233 | A | Perfect Permutation | PROGRAMMING | 800 | [
"implementation",
"math"
] | null | null | A permutation is a sequence of integers *p*1,<=*p*2,<=...,<=*p**n*, consisting of *n* distinct positive integers, each of them doesn't exceed *n*. Let's denote the *i*-th element of permutation *p* as *p**i*. We'll call number *n* the size of permutation *p*1,<=*p*2,<=...,<=*p**n*.
Nickolas adores permutations. He lik... | A single line contains a single integer *n* (1<=≤<=*n*<=≤<=100) — the permutation size. | If a perfect permutation of size *n* doesn't exist, print a single integer -1. Otherwise print *n* distinct integers from 1 to *n*, *p*1,<=*p*2,<=...,<=*p**n* — permutation *p*, that is perfect. Separate printed numbers by whitespaces. | [
"1\n",
"2\n",
"4\n"
] | [
"-1\n",
"2 1 \n",
"2 1 4 3 \n"
] | none | 500 | [
{
"input": "1",
"output": "-1"
},
{
"input": "2",
"output": "2 1 "
},
{
"input": "4",
"output": "2 1 4 3 "
},
{
"input": "3",
"output": "-1"
},
{
"input": "5",
"output": "-1"
},
{
"input": "6",
"output": "2 1 4 3 6 5 "
},
{
"input": "7",
... | 1,637,252,525 | 2,147,483,647 | Python 3 | OK | TESTS | 30 | 92 | 0 | import sys
def main():
N = int(sys.stdin.readline())
if N % 2:
print(-1)
else:
print("2 1", end = " ")
for i in range(3, N, 2):
print(str(i + 1) + " " + str(i) + " ")
print()
if __name__ == "__main__":
main()
| Title: Perfect Permutation
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
A permutation is a sequence of integers *p*1,<=*p*2,<=...,<=*p**n*, consisting of *n* distinct positive integers, each of them doesn't exceed *n*. Let's denote the *i*-th element of permutation *p* as *p**i*. We'll ... | ```python
import sys
def main():
N = int(sys.stdin.readline())
if N % 2:
print(-1)
else:
print("2 1", end = " ")
for i in range(3, N, 2):
print(str(i + 1) + " " + str(i) + " ")
print()
if __name__ == "__main__":
main()
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
192 | B | Walking in the Rain | PROGRAMMING | 1,100 | [
"brute force",
"implementation"
] | null | null | In Berland the opposition is going to arrange mass walking on the boulevard. The boulevard consists of *n* tiles that are lain in a row and are numbered from 1 to *n* from right to left. The opposition should start walking on the tile number 1 and the finish on the tile number *n*. During the walk it is allowed to move... | The first line contains integer *n* (1<=≤<=*n*<=≤<=103) — the boulevard's length in tiles.
The second line contains *n* space-separated integers *a**i* — the number of days after which the *i*-th tile gets destroyed (1<=≤<=*a**i*<=≤<=103). | Print a single number — the sought number of days. | [
"4\n10 3 5 10\n",
"5\n10 2 8 3 5\n"
] | [
"5\n",
"5\n"
] | In the first sample the second tile gets destroyed after day three, and the only path left is 1 → 3 → 4. After day five there is a two-tile gap between the first and the last tile, you can't jump over it.
In the second sample path 1 → 3 → 5 is available up to day five, inclusive. On day six the last tile is destroyed ... | 1,000 | [
{
"input": "4\n10 3 5 10",
"output": "5"
},
{
"input": "5\n10 2 8 3 5",
"output": "5"
},
{
"input": "10\n10 3 1 6 7 1 3 3 8 1",
"output": "1"
},
{
"input": "10\n26 72 10 52 2 5 61 2 39 64",
"output": "5"
},
{
"input": "100\n8 2 1 2 8 3 5 8 5 1 9 3 4 1 5 6 4 2 9 10... | 1,639,209,950 | 2,147,483,647 | Python 3 | COMPILATION_ERROR | TESTS | 0 | 0 | 0 | #include<bits/stdc++.h>
using namespace std;
int main(){
vector<int>v;
int t;
cin>>t;
for(int i=0;i<t;i++){
int z;cin>>z;
v.push_back(z);
}
int ans=v[0];
int j=0;
while(j<t-1){
vector<pair<int,int>>p;
for(int k=j+1;k<=min(t,j+2);k++){
p.push_back(make_pair(v[k],k));
}
sort(p.begi... | Title: Walking in the Rain
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
In Berland the opposition is going to arrange mass walking on the boulevard. The boulevard consists of *n* tiles that are lain in a row and are numbered from 1 to *n* from right to left. The opposition should start ... | ```python
#include<bits/stdc++.h>
using namespace std;
int main(){
vector<int>v;
int t;
cin>>t;
for(int i=0;i<t;i++){
int z;cin>>z;
v.push_back(z);
}
int ans=v[0];
int j=0;
while(j<t-1){
vector<pair<int,int>>p;
for(int k=j+1;k<=min(t,j+2);k++){
p.push_back(make_pair(v[k],k));
}
s... | -1 | MatrixStudio/Codeforces-Python-Submissions | |
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,742,644 | 2,147,483,647 | Python 3 | OK | TESTS | 35 | 122 | 6,758,400 | a,b = map(int, input().split())
result = int(a * b / 2)
print(result) | 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
a,b = map(int, input().split())
result = int(a * b / 2)
print(result)
``` | 3.956911 | MatrixStudio/Codeforces-Python-Submissions |
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,690,614,961 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 31 | 0 | s=input()
l=len(s)
n=' '
if s.isupper():
print(s)
elif s[0].isupper() and s[1:].islower():
print(s)
else:
for i in s:
if i.isupper():
n+=i.lower()
else:
n+=i.upper()
print(n)
| 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
s=input()
l=len(s)
n=' '
if s.isupper():
print(s)
elif s[0].isupper() and s[1:].islower():
print(s)
else:
for i in s:
if i.isupper():
n+=i.lower()
else:
n+=i.upper()
print(n)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
950 | A | Left-handers, Right-handers and Ambidexters | PROGRAMMING | 800 | [
"implementation",
"math"
] | null | null | You are at a water bowling training. There are *l* people who play with their left hand, *r* people, who play with their right hand, and *a* ambidexters, who can play with left or right hand.
The coach decided to form a team of even number of players, exactly half of the players should play with their right hand, and ... | The only line contains three integers *l*, *r* and *a* (0<=≤<=*l*,<=*r*,<=*a*<=≤<=100) — the number of left-handers, the number of right-handers and the number of ambidexters at the training. | Print a single even integer — the maximum number of players in the team. It is possible that the team can only have zero number of players. | [
"1 4 2\n",
"5 5 5\n",
"0 2 0\n"
] | [
"6\n",
"14\n",
"0\n"
] | In the first example you can form a team of 6 players. You should take the only left-hander and two ambidexters to play with left hand, and three right-handers to play with right hand. The only person left can't be taken into the team.
In the second example you can form a team of 14 people. You have to take all five l... | 500 | [
{
"input": "1 4 2",
"output": "6"
},
{
"input": "5 5 5",
"output": "14"
},
{
"input": "0 2 0",
"output": "0"
},
{
"input": "30 70 34",
"output": "128"
},
{
"input": "89 32 24",
"output": "112"
},
{
"input": "89 44 77",
"output": "210"
},
{
... | 1,544,194,472 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 0 | 92 | 0 | x=list(map(int,input().split()))
if x[2]==0 or 1:
if x[0]<x[1]:
answer=x[0]*2
else:
answer=x[1]*2
while x[2]>1 :
if x[0]<x[1]:
x[0]=x[0]+1
x[2]=x[2]-1
answer=x[0]*2
else:
x[1]+=1
x[2]-=1
answer=x[1]*2
if x[0]==0 or x[1]==0:
answer=0
print(answer)
| Title: Left-handers, Right-handers and Ambidexters
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
You are at a water bowling training. There are *l* people who play with their left hand, *r* people, who play with their right hand, and *a* ambidexters, who can play with left or right hand.... | ```python
x=list(map(int,input().split()))
if x[2]==0 or 1:
if x[0]<x[1]:
answer=x[0]*2
else:
answer=x[1]*2
while x[2]>1 :
if x[0]<x[1]:
x[0]=x[0]+1
x[2]=x[2]-1
answer=x[0]*2
else:
x[1]+=1
x[2]-=1
answer=x[1]*2
if x[0]==0 or x[1]==0:
answer=0
print(answer)
... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
519 | B | A and B and Compilation Errors | PROGRAMMING | 1,100 | [
"data structures",
"implementation",
"sortings"
] | null | null | A and B are preparing themselves for programming contests.
B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code.
Initially, the compiler displayed *n* compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix... | The first line of the input contains integer *n* (3<=≤<=*n*<=≤<=105) — the initial number of compilation errors.
The second line contains *n* space-separated integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=109) — the errors the compiler displayed for the first time.
The third line contains *n*<=-<=1 space-sepa... | Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively. | [
"5\n1 5 8 123 7\n123 7 5 1\n5 1 7\n",
"6\n1 4 3 3 5 7\n3 7 5 4 3\n4 3 7 5\n"
] | [
"8\n123\n",
"1\n3\n"
] | In the first test sample B first corrects the error number 8, then the error number 123.
In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. | 1,000 | [
{
"input": "5\n1 5 8 123 7\n123 7 5 1\n5 1 7",
"output": "8\n123"
},
{
"input": "6\n1 4 3 3 5 7\n3 7 5 4 3\n4 3 7 5",
"output": "1\n3"
},
{
"input": "3\n1 2 3\n3 2\n2",
"output": "1\n3"
},
{
"input": "10\n460626451 802090732 277246428 661369649 388684428 784303821 376287098 6... | 1,642,109,867 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 4 | 61 | 0 | n=int(input())
l1=input().split()
s1=input().split()
s2=input().split()
list=[]
for i in l1:
if l1.count(i) != s2.count(i):
list.append(i)
for o in range(2):
if list[o] not in s1:
print(list[o])
print(list[o-1]) | Title: A and B and Compilation Errors
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
A and B are preparing themselves for programming contests.
B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code.
Initially, the compiler disp... | ```python
n=int(input())
l1=input().split()
s1=input().split()
s2=input().split()
list=[]
for i in l1:
if l1.count(i) != s2.count(i):
list.append(i)
for o in range(2):
if list[o] not in s1:
print(list[o])
print(list[o-1])
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
879 | A | Borya's Diagnosis | PROGRAMMING | 900 | [
"implementation"
] | null | null | It seems that Borya is seriously sick. He is going visit *n* doctors to find out the exact diagnosis. Each of the doctors needs the information about all previous visits, so Borya has to visit them in the prescribed order (i.e. Borya should first visit doctor 1, then doctor 2, then doctor 3 and so on). Borya will get t... | First line contains an integer *n* — number of doctors (1<=≤<=*n*<=≤<=1000).
Next *n* lines contain two numbers *s**i* and *d**i* (1<=≤<=*s**i*,<=*d**i*<=≤<=1000). | Output a single integer — the minimum day at which Borya can visit the last doctor. | [
"3\n2 2\n1 2\n2 2\n",
"2\n10 1\n6 5\n"
] | [
"4\n",
"11\n"
] | In the first sample case, Borya can visit all doctors on days 2, 3 and 4.
In the second sample case, Borya can visit all doctors on days 10 and 11. | 500 | [
{
"input": "3\n2 2\n1 2\n2 2",
"output": "4"
},
{
"input": "2\n10 1\n6 5",
"output": "11"
},
{
"input": "3\n6 10\n3 3\n8 2",
"output": "10"
},
{
"input": "4\n4 8\n10 10\n4 2\n8 2",
"output": "14"
},
{
"input": "5\n7 1\n5 1\n6 1\n1 6\n6 8",
"output": "14"
},
... | 1,521,466,451 | 2,147,483,647 | Python 3 | OK | TESTS | 51 | 93 | 7,065,600 | n=int(input())
x=int(input().split()[0])
for i in range(n-1):
c,d=map(int,input().split())
if c<=x:x=c+((x-c)//d+1)*d
else :x=c
print(x) | Title: Borya's Diagnosis
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
It seems that Borya is seriously sick. He is going visit *n* doctors to find out the exact diagnosis. Each of the doctors needs the information about all previous visits, so Borya has to visit them in the prescribed o... | ```python
n=int(input())
x=int(input().split()[0])
for i in range(n-1):
c,d=map(int,input().split())
if c<=x:x=c+((x-c)//d+1)*d
else :x=c
print(x)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
143 | B | Help Kingdom of Far Far Away 2 | PROGRAMMING | 1,200 | [
"implementation",
"strings"
] | null | null | For some time the program of rounding numbers that had been developed by the Codeforces participants during one of the previous rounds, helped the citizens of Far Far Away to convert numbers into a more easily readable format. However, as time went by, the economy of the Far Far Away developed and the scale of operatio... | The input contains a number that needs to be converted into financial format. The number's notation length does not exceed 100 characters, including (possible) signs "-" (minus) and "." (decimal point). The number's notation is correct, that is:
- The number's notation only contains characters from the set {"0" – "9... | Print the number given in the input in the financial format by the rules described in the problem statement. | [
"2012\n",
"0.000\n",
"-0.00987654321\n",
"-12345678.9\n"
] | [
"$2,012.00",
"$0.00",
"($0.00)",
"($12,345,678.90)"
] | Pay attention to the second and third sample tests. They show that the sign of a number in the financial format (and consequently, the presence or absence of brackets) is determined solely by the sign of the initial number. It does not depend on the sign of the number you got after translating the number to the financi... | 1,000 | [
{
"input": "2012",
"output": "$2,012.00"
},
{
"input": "0.000",
"output": "$0.00"
},
{
"input": "-0.00987654321",
"output": "($0.00)"
},
{
"input": "-12345678.9",
"output": "($12,345,678.90)"
},
{
"input": "0.99999999999999999999",
"output": "$0.99"
},
{
... | 1,576,784,910 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 5 | 280 | 0 | s=input()
str=""
b=0
if s[0]=='-':
b=1
d=""
t=len(s)
for i in range(len(s)):
if s[i]=='.':
t=i
break
if t<len(s):
if t<len(s)-2:
d+=s[t+1]+s[t+2]
else:
d+=s[t+1]+'0'
else:
d="00"
for i in range(t-1,-1,-1):
if s[i]=='-':
break
str=s[... | Title: Help Kingdom of Far Far Away 2
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
For some time the program of rounding numbers that had been developed by the Codeforces participants during one of the previous rounds, helped the citizens of Far Far Away to convert numbers into a more e... | ```python
s=input()
str=""
b=0
if s[0]=='-':
b=1
d=""
t=len(s)
for i in range(len(s)):
if s[i]=='.':
t=i
break
if t<len(s):
if t<len(s)-2:
d+=s[t+1]+s[t+2]
else:
d+=s[t+1]+'0'
else:
d="00"
for i in range(t-1,-1,-1):
if s[i]=='-':
break
... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
289 | B | Polo the Penguin and Matrix | PROGRAMMING | 1,400 | [
"brute force",
"dp",
"implementation",
"sortings",
"ternary search"
] | null | null | Little penguin Polo has an *n*<=×<=*m* matrix, consisting of integers. Let's index the matrix rows from 1 to *n* from top to bottom and let's index the columns from 1 to *m* from left to right. Let's represent the matrix element on the intersection of row *i* and column *j* as *a**ij*.
In one move the penguin can add ... | The first line contains three integers *n*, *m* and *d* (1<=≤<=*n*,<=*m*<=≤<=100,<=1<=≤<=*d*<=≤<=104) — the matrix sizes and the *d* parameter. Next *n* lines contain the matrix: the *j*-th integer in the *i*-th row is the matrix element *a**ij* (1<=≤<=*a**ij*<=≤<=104). | In a single line print a single integer — the minimum number of moves the penguin needs to make all matrix elements equal. If that is impossible, print "-1" (without the quotes). | [
"2 2 2\n2 4\n6 8\n",
"1 2 7\n6 7\n"
] | [
"4\n",
"-1\n"
] | none | 1,000 | [
{
"input": "2 2 2\n2 4\n6 8",
"output": "4"
},
{
"input": "1 2 7\n6 7",
"output": "-1"
},
{
"input": "3 2 1\n5 7\n1 2\n5 100",
"output": "104"
},
{
"input": "3 3 3\n5 8 5\n11 11 17\n14 5 2",
"output": "12"
},
{
"input": "3 3 3\n5 8 5\n11 11 17\n14 5 3",
"outpu... | 1,529,946,390 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 154 | 0 | def solve(array, d):
for i in range(len(array)):
if array[i] % d:
return -1
array[i] //= d
avg = round(sum(array)/len(array))
moves = 0
for i in range(len(array)):
moves += abs(avg - array[i])
return moves
line = input()
n, m, d = map(int, line.strip().split(... | Title: Polo the Penguin and Matrix
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Little penguin Polo has an *n*<=×<=*m* matrix, consisting of integers. Let's index the matrix rows from 1 to *n* from top to bottom and let's index the columns from 1 to *m* from left to right. Let's represe... | ```python
def solve(array, d):
for i in range(len(array)):
if array[i] % d:
return -1
array[i] //= d
avg = round(sum(array)/len(array))
moves = 0
for i in range(len(array)):
moves += abs(avg - array[i])
return moves
line = input()
n, m, d = map(int, line.stri... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
769 | B | News About Credit | PROGRAMMING | 1,200 | [
"*special",
"greedy",
"two pointers"
] | null | null | Polycarp studies at the university in the group which consists of *n* students (including himself). All they are registrated in the social net "TheContacnt!".
Not all students are equally sociable. About each student you know the value *a**i* — the maximum number of messages which the *i*-th student is agree to send p... | The first line contains the positive integer *n* (2<=≤<=*n*<=≤<=100) — the number of students.
The second line contains the sequence *a*1,<=*a*2,<=...,<=*a**n* (0<=≤<=*a**i*<=≤<=100), where *a**i* equals to the maximum number of messages which can the *i*-th student agree to send. Consider that Polycarp always has th... | Print -1 to the first line if it is impossible to inform all students about credit.
Otherwise, in the first line print the integer *k* — the number of messages which will be sent. In each of the next *k* lines print two distinct integers *f* and *t*, meaning that the student number *f* sent the message with news to t... | [
"4\n1 2 1 0\n",
"6\n2 0 1 3 2 0\n",
"3\n0 2 2\n"
] | [
"3\n1 2\n2 4\n2 3\n",
"6\n1 3\n3 4\n1 2\n4 5\n5 6\n4 6\n",
"-1\n"
] | In the first test Polycarp (the student number 1) can send the message to the student number 2, who after that can send the message to students number 3 and 4. Thus, all students knew about the credit. | 1,000 | [
{
"input": "4\n1 2 1 0",
"output": "3\n1 2\n2 3\n2 4"
},
{
"input": "6\n2 0 1 3 2 0",
"output": "5\n1 4\n1 5\n4 3\n4 2\n4 6"
},
{
"input": "3\n0 2 2",
"output": "-1"
},
{
"input": "2\n0 0",
"output": "-1"
},
{
"input": "2\n1 0",
"output": "1\n1 2"
},
{
... | 1,488,631,525 | 2,725 | Python 3 | OK | TESTS | 60 | 62 | 4,710,400 | input()
power = list(map(int, input().split()))
n = len(power)
ps = [0] + sorted(range(1, n), key=lambda i: -power[i])
out = []
bonus = [0] * power[0]
i = 1
while i < n and bonus:
out.append((bonus.pop(), ps[i]))
bonus.extend([ps[i]] * max(0, power[ps[i]]))
i += 1
if i != n:
print(-1)
else:
print... | Title: News About Credit
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Polycarp studies at the university in the group which consists of *n* students (including himself). All they are registrated in the social net "TheContacnt!".
Not all students are equally sociable. About each student... | ```python
input()
power = list(map(int, input().split()))
n = len(power)
ps = [0] + sorted(range(1, n), key=lambda i: -power[i])
out = []
bonus = [0] * power[0]
i = 1
while i < n and bonus:
out.append((bonus.pop(), ps[i]))
bonus.extend([ps[i]] * max(0, power[ps[i]]))
i += 1
if i != n:
print(-1)
else:... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
540 | A | Combination Lock | PROGRAMMING | 800 | [
"implementation"
] | null | null | Scrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to put there the treasures that he's earned fair and square, he has to open the lock.
The combination lock is represented by *n* rotating disks with digits from 0 to 9 written on them. Scrooge McDuck has to turn ... | The first line contains a single integer *n* (1<=≤<=*n*<=≤<=1000) — the number of disks on the combination lock.
The second line contains a string of *n* digits — the original state of the disks.
The third line contains a string of *n* digits — Scrooge McDuck's combination that opens the lock. | Print a single integer — the minimum number of moves Scrooge McDuck needs to open the lock. | [
"5\n82195\n64723\n"
] | [
"13\n"
] | In the sample he needs 13 moves:
- 1 disk: <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/b8967f65a723782358b93eff9ce69f336817cf70.png" style="max-width: 100.0%;max-height: 100.0%;"/> - 2 disk: <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/07fa58573ece0d32... | 500 | [
{
"input": "5\n82195\n64723",
"output": "13"
},
{
"input": "12\n102021090898\n010212908089",
"output": "16"
},
{
"input": "1\n8\n1",
"output": "3"
},
{
"input": "2\n83\n57",
"output": "7"
},
{
"input": "10\n0728592530\n1362615763",
"output": "27"
},
{
... | 1,689,229,623 | 2,147,483,647 | Python 3 | OK | TESTS | 43 | 46 | 0 | n = int(input())
a = input()
b = input()
sum = 0
for i in range(n) :
x = int(a[i])
y = int(b[i])
z = abs(x-y)
if z<=5 :
sum += z
else :
sum += (10-z)
print(sum) | Title: Combination Lock
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Scrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to put there the treasures that he's earned fair and square, he has to open the lock.
The combination lock is ... | ```python
n = int(input())
a = input()
b = input()
sum = 0
for i in range(n) :
x = int(a[i])
y = int(b[i])
z = abs(x-y)
if z<=5 :
sum += z
else :
sum += (10-z)
print(sum)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
358 | B | Dima and Text Messages | PROGRAMMING | 1,500 | [
"brute force",
"strings"
] | null | null | Seryozha has a very changeable character. This time he refused to leave the room to Dima and his girlfriend (her hame is Inna, by the way). However, the two lovebirds can always find a way to communicate. Today they are writing text messages to each other.
Dima and Inna are using a secret code in their text messages. ... | The first line contains integer *n* (1<=≤<=*n*<=≤<=105) — the number of words in Dima's message. Next *n* lines contain non-empty words, one word per line. The words only consist of small English letters. The total length of all words doesn't exceed 105.
The last line contains non-empty text message that Inna has got... | In a single line, print "yes" (without the quotes), if Dima decoded the text message correctly, and "no" (without the quotes) otherwise. | [
"3\ni\nlove\nyou\n<3i<3love<23you<3\n",
"7\ni\nam\nnot\nmain\nin\nthe\nfamily\n<3i<>3am<3the<3<main<3in<3the<3><3family<3\n"
] | [
"yes\n",
"no\n"
] | Please note that Dima got a good old kick in the pants for the second sample from the statement. | 1,000 | [
{
"input": "3\ni\nlove\nyou\n<3i<3love<23you<3",
"output": "yes"
},
{
"input": "7\ni\nam\nnot\nmain\nin\nthe\nfamily\n<3i<>3am<3the<3<main<3in<3the<3><3family<3",
"output": "no"
},
{
"input": "3\ni\nlove\nyou\n<3i<3lo<3ve<3y<<<<<<<ou3<3",
"output": "yes"
},
{
"input": "4\na\n... | 1,382,718,673 | 3,673 | Python 3 | RUNTIME_ERROR | PRETESTS | 0 | 0 | 0 | a = int(input())
b = int(input())
c = int(input())
if a > 0:
ans = a - b
if ans <= 0:
ans += c - 1
if ans >= 0:
ans += 1
else:
ans += c
else:
ans = a - b
ans += c
if ans >= 0:
ans += 1
print(ans)
| Title: Dima and Text Messages
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Seryozha has a very changeable character. This time he refused to leave the room to Dima and his girlfriend (her hame is Inna, by the way). However, the two lovebirds can always find a way to communicate. Today t... | ```python
a = int(input())
b = int(input())
c = int(input())
if a > 0:
ans = a - b
if ans <= 0:
ans += c - 1
if ans >= 0:
ans += 1
else:
ans += c
else:
ans = a - b
ans += c
if ans >= 0:
ans += 1
print(ans)
``` | -1 | MatrixStudio/Codeforces-Python-Submissions | |
776 | B | Sherlock and his girlfriend | PROGRAMMING | 1,200 | [
"constructive algorithms",
"number theory"
] | null | null | Sherlock has a new girlfriend (so unlike him!). Valentine's day is coming and he wants to gift her some jewelry.
He bought *n* pieces of jewelry. The *i*-th piece has price equal to *i*<=+<=1, that is, the prices of the jewelry are 2,<=3,<=4,<=... *n*<=+<=1.
Watson gave Sherlock a challenge to color these jewelry pie... | The only line contains single integer *n* (1<=≤<=*n*<=≤<=100000) — the number of jewelry pieces. | The first line of output should contain a single integer *k*, the minimum number of colors that can be used to color the pieces of jewelry with the given constraints.
The next line should consist of *n* space-separated integers (between 1 and *k*) that specify the color of each piece in the order of increasing price.
... | [
"3\n",
"4\n"
] | [
"2\n1 1 2 ",
"2\n2 1 1 2\n"
] | In the first input, the colors for first, second and third pieces of jewelry having respective prices 2, 3 and 4 are 1, 1 and 2 respectively.
In this case, as 2 is a prime divisor of 4, colors of jewelry having prices 2 and 4 must be distinct. | 1,000 | [
{
"input": "3",
"output": "2\n1 1 2 "
},
{
"input": "4",
"output": "2\n1 1 2 1 "
},
{
"input": "17",
"output": "2\n1 1 2 1 2 1 2 2 2 1 2 1 2 2 2 1 2 "
},
{
"input": "25",
"output": "2\n1 1 2 1 2 1 2 2 2 1 2 1 2 2 2 1 2 1 2 2 2 1 2 2 2 "
},
{
"input": "85",
"ou... | 1,607,094,591 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 93 | 307,200 | def clr_count(n):
li = [1]*(n+2)
c = 1
for i in range(2,int((n+2)**(1/2)) + 1):
for j in range(i*i,len(li),i):
if c == li[j]:
c += 1
li[j] = c
print(c)
for i in li[2:]:
print(i,end=' ')
n = int(input())
clr_count(n) | Title: Sherlock and his girlfriend
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Sherlock has a new girlfriend (so unlike him!). Valentine's day is coming and he wants to gift her some jewelry.
He bought *n* pieces of jewelry. The *i*-th piece has price equal to *i*<=+<=1, that is, the ... | ```python
def clr_count(n):
li = [1]*(n+2)
c = 1
for i in range(2,int((n+2)**(1/2)) + 1):
for j in range(i*i,len(li),i):
if c == li[j]:
c += 1
li[j] = c
print(c)
for i in li[2:]:
print(i,end=' ')
n = int(input())
clr_count(n)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
208 | A | Dubstep | PROGRAMMING | 900 | [
"strings"
] | null | null | Vasya works as a DJ in the best Berland nightclub, and he often uses dubstep music in his performance. Recently, he has decided to take a couple of old songs and make dubstep remixes from them.
Let's assume that a song consists of some number of words. To make the dubstep remix of this song, Vasya inserts a certain nu... | The input consists of a single non-empty string, consisting only of uppercase English letters, the string's length doesn't exceed 200 characters. It is guaranteed that before Vasya remixed the song, no word contained substring "WUB" in it; Vasya didn't change the word order. It is also guaranteed that initially the son... | Print the words of the initial song that Vasya used to make a dubsteb remix. Separate the words with a space. | [
"WUBWUBABCWUB\n",
"WUBWEWUBAREWUBWUBTHEWUBCHAMPIONSWUBMYWUBFRIENDWUB\n"
] | [
"ABC ",
"WE ARE THE CHAMPIONS MY FRIEND "
] | In the first sample: "WUBWUBABCWUB" = "WUB" + "WUB" + "ABC" + "WUB". That means that the song originally consisted of a single word "ABC", and all words "WUB" were added by Vasya.
In the second sample Vasya added a single word "WUB" between all neighbouring words, in the beginning and in the end, except for words "ARE... | 500 | [
{
"input": "WUBWUBABCWUB",
"output": "ABC "
},
{
"input": "WUBWEWUBAREWUBWUBTHEWUBCHAMPIONSWUBMYWUBFRIENDWUB",
"output": "WE ARE THE CHAMPIONS MY FRIEND "
},
{
"input": "WUBWUBWUBSR",
"output": "SR "
},
{
"input": "RWUBWUBWUBLWUB",
"output": "R L "
},
{
"input": "... | 1,687,023,887 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 62 | 0 | remix = input()
original_song = ""
original_song_list = []
while "WUB" in remix:
target_index = remix.find("WUB")
original_song_list.append(remix[:target_index])
remix = remix[target_index + 3:]
for word in original_song_list:
if word != "":
# print(word, end = " ")
original_song += word + " "
... | Title: Dubstep
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vasya works as a DJ in the best Berland nightclub, and he often uses dubstep music in his performance. Recently, he has decided to take a couple of old songs and make dubstep remixes from them.
Let's assume that a song consist... | ```python
remix = input()
original_song = ""
original_song_list = []
while "WUB" in remix:
target_index = remix.find("WUB")
original_song_list.append(remix[:target_index])
remix = remix[target_index + 3:]
for word in original_song_list:
if word != "":
# print(word, end = " ")
original_song += w... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
552 | B | Vanya and Books | PROGRAMMING | 1,200 | [
"implementation",
"math"
] | null | null | Vanya got an important task — he should enumerate books in the library and label each book with its number. Each of the *n* books should be assigned with a number from 1 to *n*. Naturally, distinct books should be assigned distinct numbers.
Vanya wants to know how many digits he will have to write down as he labels th... | The first line contains integer *n* (1<=≤<=*n*<=≤<=109) — the number of books in the library. | Print the number of digits needed to number all the books. | [
"13\n",
"4\n"
] | [
"17\n",
"4\n"
] | Note to the first test. The books get numbers 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, which totals to 17 digits.
Note to the second sample. The books get numbers 1, 2, 3, 4, which totals to 4 digits. | 1,000 | [
{
"input": "13",
"output": "17"
},
{
"input": "4",
"output": "4"
},
{
"input": "100",
"output": "192"
},
{
"input": "99",
"output": "189"
},
{
"input": "1000000000",
"output": "8888888899"
},
{
"input": "1000000",
"output": "5888896"
},
{
"... | 1,629,001,972 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 46 | 6,963,200 | n=int(input())
li=[]
while n>0:
li.append(n%10)
n=n//10
ans=0
t=0
if len(li)==1:
print(li[0])
else:
for i in range(len(li)):
if i==0:
ans+=9
t+=li[i]
else:
t+=10*li[i]
x=10**(i)
x-=1
ans+=(t-x)*(i+1... | Title: Vanya and Books
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vanya got an important task — he should enumerate books in the library and label each book with its number. Each of the *n* books should be assigned with a number from 1 to *n*. Naturally, distinct books should be assig... | ```python
n=int(input())
li=[]
while n>0:
li.append(n%10)
n=n//10
ans=0
t=0
if len(li)==1:
print(li[0])
else:
for i in range(len(li)):
if i==0:
ans+=9
t+=li[i]
else:
t+=10*li[i]
x=10**(i)
x-=1
ans+=... | 0 | MatrixStudio/Codeforces-Python-Submissions | |
734 | A | Anton and Danik | PROGRAMMING | 800 | [
"implementation",
"strings"
] | null | null | Anton likes to play chess, and so does his friend Danik.
Once they have played *n* games in a row. For each game it's known who was the winner — Anton or Danik. None of the games ended with a tie.
Now Anton wonders, who won more games, he or Danik? Help him determine this. | The first line of the input contains a single integer *n* (1<=≤<=*n*<=≤<=100<=000) — the number of games played.
The second line contains a string *s*, consisting of *n* uppercase English letters 'A' and 'D' — the outcome of each of the games. The *i*-th character of the string is equal to 'A' if the Anton won the *i*... | If Anton won more games than Danik, print "Anton" (without quotes) in the only line of the output.
If Danik won more games than Anton, print "Danik" (without quotes) in the only line of the output.
If Anton and Danik won the same number of games, print "Friendship" (without quotes). | [
"6\nADAAAA\n",
"7\nDDDAADA\n",
"6\nDADADA\n"
] | [
"Anton\n",
"Danik\n",
"Friendship\n"
] | In the first sample, Anton won 6 games, while Danik — only 1. Hence, the answer is "Anton".
In the second sample, Anton won 3 games and Danik won 4 games, so the answer is "Danik".
In the third sample, both Anton and Danik won 3 games and the answer is "Friendship". | 500 | [
{
"input": "6\nADAAAA",
"output": "Anton"
},
{
"input": "7\nDDDAADA",
"output": "Danik"
},
{
"input": "6\nDADADA",
"output": "Friendship"
},
{
"input": "10\nDDDDADDADD",
"output": "Danik"
},
{
"input": "40\nAAAAAAAAADDAAAAAAAAAAADADDAAAAAAAAAAADAA",
"output": ... | 1,695,256,906 | 2,147,483,647 | Python 3 | OK | TESTS | 25 | 46 | 102,400 | if __name__ == '__main__':
n = int(input())
games = input()
count_A = 0
for letter in games:
if letter == 'A':
count_A = count_A + 1
count_B = n - count_A
if count_A > count_B:
print('Anton')
elif count_A < count_B:
print('Danik')
else:
... | Title: Anton and Danik
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Anton likes to play chess, and so does his friend Danik.
Once they have played *n* games in a row. For each game it's known who was the winner — Anton or Danik. None of the games ended with a tie.
Now Anton wonders, w... | ```python
if __name__ == '__main__':
n = int(input())
games = input()
count_A = 0
for letter in games:
if letter == 'A':
count_A = count_A + 1
count_B = n - count_A
if count_A > count_B:
print('Anton')
elif count_A < count_B:
print('Danik')
... | 3 | MatrixStudio/Codeforces-Python-Submissions | |
981 | A | Antipalindrome | PROGRAMMING | 900 | [
"brute force",
"implementation",
"strings"
] | null | null | A string is a palindrome if it reads the same from the left to the right and from the right to the left. For example, the strings "kek", "abacaba", "r" and "papicipap" are palindromes, while the strings "abb" and "iq" are not.
A substring $s[l \ldots r]$ ($1<=\leq<=l<=\leq<=r<=\leq<=|s|$) of a string $s<==<=s_{1}s_{2}... | The first line contains a non-empty string $s$ with length at most $50$ characters, containing lowercase English letters only. | If there is such a substring in $s$ that is not a palindrome, print the maximum length of such a substring. Otherwise print $0$.
Note that there can be multiple longest substrings that are not palindromes, but their length is unique. | [
"mew\n",
"wuffuw\n",
"qqqqqqqq\n"
] | [
"3\n",
"5\n",
"0\n"
] | "mew" is not a palindrome, so the longest substring of it that is not a palindrome, is the string "mew" itself. Thus, the answer for the first example is $3$.
The string "uffuw" is one of the longest non-palindrome substrings (of length $5$) of the string "wuffuw", so the answer for the second example is $5$.
All sub... | 500 | [
{
"input": "mew",
"output": "3"
},
{
"input": "wuffuw",
"output": "5"
},
{
"input": "qqqqqqqq",
"output": "0"
},
{
"input": "ijvji",
"output": "4"
},
{
"input": "iiiiiii",
"output": "0"
},
{
"input": "wobervhvvkihcuyjtmqhaaigvvgiaahqmtjyuchikvvhvrebow"... | 1,628,424,628 | 2,147,483,647 | PyPy 3 | OK | TESTS | 133 | 124 | 22,016,000 | def f(s):
for i in range(len(s)):
for j in range(len(s), 0, -1):
if s[i:j] != ''.join(reversed(s[i:j])):
print(j - i)
return
print(0)
s = input()
f(s) | Title: Antipalindrome
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
A string is a palindrome if it reads the same from the left to the right and from the right to the left. For example, the strings "kek", "abacaba", "r" and "papicipap" are palindromes, while the strings "abb" and "iq" ar... | ```python
def f(s):
for i in range(len(s)):
for j in range(len(s), 0, -1):
if s[i:j] != ''.join(reversed(s[i:j])):
print(j - i)
return
print(0)
s = input()
f(s)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
171 | A | Mysterious numbers - 1 | PROGRAMMING | 1,200 | [
"*special",
"constructive algorithms"
] | null | null | The input contains two integers *a*1,<=*a*2 (0<=≤<=*a**i*<=≤<=109), separated by a single space.
Output a single integer. | The input contains two integers *a*1,<=*a*2 (0<=≤<=*a**i*<=≤<=109), separated by a single space. | Output a single integer. | [
"3 14\n",
"27 12\n",
"100 200\n"
] | [
"44\n",
"48\n",
"102\n"
] | none | 0 | [
{
"input": "3 14",
"output": "44"
},
{
"input": "27 12",
"output": "48"
},
{
"input": "100 200",
"output": "102"
},
{
"input": "0 0",
"output": "0"
},
{
"input": "31415 92653",
"output": "67044"
},
{
"input": "1000000000 0",
"output": "1000000000"
... | 1,522,316,947 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 0 | 124 | 7,065,600 | a = int(input())
if a == 1 :
print (1)
elif a == 2 :
print (2)
elif a == 3 :
print (1)
elif a == 4 :
print (3)
elif a == 5 :
print (3)
| Title: Mysterious numbers - 1
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
The input contains two integers *a*1,<=*a*2 (0<=≤<=*a**i*<=≤<=109), separated by a single space.
Output a single integer.
Input Specification:
The input contains two integers *a*1,<=*a*2 (0<=≤<=*a**i*<=≤<=109),... | ```python
a = int(input())
if a == 1 :
print (1)
elif a == 2 :
print (2)
elif a == 3 :
print (1)
elif a == 4 :
print (3)
elif a == 5 :
print (3)
``` | -1 | MatrixStudio/Codeforces-Python-Submissions | |
586 | A | Alena's Schedule | PROGRAMMING | 900 | [
"implementation"
] | null | null | Alena has successfully passed the entrance exams to the university and is now looking forward to start studying.
One two-hour lesson at the Russian university is traditionally called a pair, it lasts for two academic hours (an academic hour is equal to 45 minutes).
The University works in such a way that every day it... | The first line of the input contains a positive integer *n* (1<=≤<=*n*<=≤<=100) — the number of lessons at the university.
The second line contains *n* numbers *a**i* (0<=≤<=*a**i*<=≤<=1). Number *a**i* equals 0, if Alena doesn't have the *i*-th pairs, otherwise it is equal to 1. Numbers *a*1,<=*a*2,<=...,<=*a**n* ar... | Print a single number — the number of pairs during which Alena stays at the university. | [
"5\n0 1 0 1 1\n",
"7\n1 0 1 0 0 1 0\n",
"1\n0\n"
] | [
"4\n",
"4\n",
"0\n"
] | In the first sample Alena stays at the university from the second to the fifth pair, inclusive, during the third pair she will be it the university waiting for the next pair.
In the last sample Alena doesn't have a single pair, so she spends all the time at home. | 500 | [
{
"input": "5\n0 1 0 1 1",
"output": "4"
},
{
"input": "7\n1 0 1 0 0 1 0",
"output": "4"
},
{
"input": "1\n0",
"output": "0"
},
{
"input": "1\n1",
"output": "1"
},
{
"input": "2\n0 0",
"output": "0"
},
{
"input": "2\n0 1",
"output": "1"
},
{
... | 1,484,425,477 | 2,147,483,647 | Python 3 | RUNTIME_ERROR | TESTS | 2 | 46 | 4,608,000 | n = int(input())
l = list(map(int, input().split()))
while l[0] == 0:
l.pop(0)
while l[-1] == 0:
l.pop()
cont = 1
res = 0
for i in range(len(l)):
if l[i] == 0 and l[i+1] == 0 :
cont += 1
elif cont > 1:
res = res + cont
cont = 1
print(len(l) - ... | Title: Alena's Schedule
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Alena has successfully passed the entrance exams to the university and is now looking forward to start studying.
One two-hour lesson at the Russian university is traditionally called a pair, it lasts for two academic ... | ```python
n = int(input())
l = list(map(int, input().split()))
while l[0] == 0:
l.pop(0)
while l[-1] == 0:
l.pop()
cont = 1
res = 0
for i in range(len(l)):
if l[i] == 0 and l[i+1] == 0 :
cont += 1
elif cont > 1:
res = res + cont
cont = 1
print... | -1 | MatrixStudio/Codeforces-Python-Submissions | |
898 | A | Rounding | PROGRAMMING | 800 | [
"implementation",
"math"
] | null | null | Vasya has a non-negative integer *n*. He wants to round it to nearest integer, which ends up with 0. If *n* already ends up with 0, Vasya considers it already rounded.
For example, if *n*<==<=4722 answer is 4720. If *n*<==<=5 Vasya can round it to 0 or to 10. Both ways are correct.
For given *n* find out to which int... | The first line contains single integer *n* (0<=≤<=*n*<=≤<=109) — number that Vasya has. | Print result of rounding *n*. Pay attention that in some cases answer isn't unique. In that case print any correct answer. | [
"5\n",
"113\n",
"1000000000\n",
"5432359\n"
] | [
"0\n",
"110\n",
"1000000000\n",
"5432360\n"
] | In the first example *n* = 5. Nearest integers, that ends up with zero are 0 and 10. Any of these answers is correct, so you can print 0 or 10. | 500 | [
{
"input": "5",
"output": "0"
},
{
"input": "113",
"output": "110"
},
{
"input": "1000000000",
"output": "1000000000"
},
{
"input": "5432359",
"output": "5432360"
},
{
"input": "999999994",
"output": "999999990"
},
{
"input": "10",
"output": "10"
... | 1,612,433,601 | 2,147,483,647 | PyPy 3 | OK | TESTS | 64 | 93 | 0 | n=int(input())
if(n%10<5):
print(n-n%10)
else:
print(n+(10-n%10)) | Title: Rounding
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Vasya has a non-negative integer *n*. He wants to round it to nearest integer, which ends up with 0. If *n* already ends up with 0, Vasya considers it already rounded.
For example, if *n*<==<=4722 answer is 4720. If *n*<==<=5... | ```python
n=int(input())
if(n%10<5):
print(n-n%10)
else:
print(n+(10-n%10))
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
281 | A | Word Capitalization | PROGRAMMING | 800 | [
"implementation",
"strings"
] | null | null | Capitalization is writing a word with its first letter as a capital letter. Your task is to capitalize the given word.
Note, that during capitalization all the letters except the first one remains unchanged. | A single line contains a non-empty word. This word consists of lowercase and uppercase English letters. The length of the word will not exceed 103. | Output the given word after capitalization. | [
"ApPLe\n",
"konjac\n"
] | [
"ApPLe\n",
"Konjac\n"
] | none | 500 | [
{
"input": "ApPLe",
"output": "ApPLe"
},
{
"input": "konjac",
"output": "Konjac"
},
{
"input": "a",
"output": "A"
},
{
"input": "A",
"output": "A"
},
{
"input": "z",
"output": "Z"
},
{
"input": "ABACABA",
"output": "ABACABA"
},
{
"input": "... | 1,697,612,075 | 2,147,483,647 | Python 3 | OK | TESTS | 25 | 92 | 0 | s = input()
x = list(s)
a = x[0]
p = a.upper()
x[0] = p
po = ''.join(x)
print(po)
| Title: Word Capitalization
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Capitalization is writing a word with its first letter as a capital letter. Your task is to capitalize the given word.
Note, that during capitalization all the letters except the first one remains unchanged.
Input... | ```python
s = input()
x = list(s)
a = x[0]
p = a.upper()
x[0] = p
po = ''.join(x)
print(po)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
431 | A | Black Square | PROGRAMMING | 800 | [
"implementation"
] | null | null | Quite recently, a very smart student named Jury decided that lectures are boring, so he downloaded a game called "Black Square" on his super cool touchscreen phone.
In this game, the phone's screen is divided into four vertical strips. Each second, a black square appears on some of the strips. According to the rules o... | The first line contains four space-separated integers *a*1, *a*2, *a*3, *a*4 (0<=≤<=*a*1,<=*a*2,<=*a*3,<=*a*4<=≤<=104).
The second line contains string *s* (1<=≤<=|*s*|<=≤<=105), where the *і*-th character of the string equals "1", if on the *i*-th second of the game the square appears on the first strip, "2", if it a... | Print a single integer — the total number of calories that Jury wastes. | [
"1 2 3 4\n123214\n",
"1 5 3 2\n11221\n"
] | [
"13\n",
"13\n"
] | none | 500 | [
{
"input": "1 2 3 4\n123214",
"output": "13"
},
{
"input": "1 5 3 2\n11221",
"output": "13"
},
{
"input": "5 5 5 1\n3422",
"output": "16"
},
{
"input": "4 3 2 1\n2",
"output": "3"
},
{
"input": "5651 6882 6954 4733\n2442313421",
"output": "60055"
},
{
... | 1,669,356,456 | 2,147,483,647 | Python 3 | OK | TESTS | 49 | 77 | 0 | a = list(map(int, input().split(' ')))
c = 0
for i in input():
c += a[int(i)-1]
print(c)
| Title: Black Square
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Quite recently, a very smart student named Jury decided that lectures are boring, so he downloaded a game called "Black Square" on his super cool touchscreen phone.
In this game, the phone's screen is divided into four ve... | ```python
a = list(map(int, input().split(' ')))
c = 0
for i in input():
c += a[int(i)-1]
print(c)
``` | 3 | MatrixStudio/Codeforces-Python-Submissions | |
439 | B | Devu, the Dumb Guy | PROGRAMMING | 1,200 | [
"implementation",
"sortings"
] | null | null | Devu is a dumb guy, his learning curve is very slow. You are supposed to teach him *n* subjects, the *i**th* subject has *c**i* chapters. When you teach him, you are supposed to teach all the chapters of a subject continuously.
Let us say that his initial per chapter learning power of a subject is *x* hours. In other ... | The first line will contain two space separated integers *n*, *x* (1<=≤<=*n*,<=*x*<=≤<=105). The next line will contain *n* space separated integers: *c*1,<=*c*2,<=...,<=*c**n* (1<=≤<=*c**i*<=≤<=105). | Output a single integer representing the answer to the problem. | [
"2 3\n4 1\n",
"4 2\n5 1 2 1\n",
"3 3\n1 1 1\n"
] | [
"11\n",
"10\n",
"6\n"
] | Look at the first example. Consider the order of subjects: 1, 2. When you teach Devu the first subject, it will take him 3 hours per chapter, so it will take 12 hours to teach first subject. After teaching first subject, his per chapter learning time will be 2 hours. Now teaching him second subject will take 2 × 1 = 2 ... | 1,000 | [
{
"input": "2 3\n4 1",
"output": "11"
},
{
"input": "4 2\n5 1 2 1",
"output": "10"
},
{
"input": "3 3\n1 1 1",
"output": "6"
},
{
"input": "20 4\n1 1 3 5 5 1 3 4 2 5 2 4 3 1 3 3 3 3 4 3",
"output": "65"
},
{
"input": "20 10\n6 6 1 2 6 4 5 3 6 5 4 5 6 5 4 6 6 2 3 3... | 1,597,095,081 | 2,147,483,647 | PyPy 3 | WRONG_ANSWER | TESTS | 1 | 124 | 20,172,800 | a,b=map(int,input().split())
r=list(map(int,input().split()))
r.sort()
s=0
for i in range(len(r)):
s+=r[i]*(b-i)
print(s) | Title: Devu, the Dumb Guy
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
Devu is a dumb guy, his learning curve is very slow. You are supposed to teach him *n* subjects, the *i**th* subject has *c**i* chapters. When you teach him, you are supposed to teach all the chapters of a subject co... | ```python
a,b=map(int,input().split())
r=list(map(int,input().split()))
r.sort()
s=0
for i in range(len(r)):
s+=r[i]*(b-i)
print(s)
``` | 0 | MatrixStudio/Codeforces-Python-Submissions | |
723 | A | The New Year: Meeting Friends | PROGRAMMING | 800 | [
"implementation",
"math",
"sortings"
] | null | null | There are three friend living on the straight line *Ox* in Lineland. The first friend lives at the point *x*1, the second friend lives at the point *x*2, and the third friend lives at the point *x*3. They plan to celebrate the New Year together, so they need to meet at one point. What is the minimum total distance they... | The first line of the input contains three distinct integers *x*1, *x*2 and *x*3 (1<=≤<=*x*1,<=*x*2,<=*x*3<=≤<=100) — the coordinates of the houses of the first, the second and the third friends respectively. | Print one integer — the minimum total distance the friends need to travel in order to meet together. | [
"7 1 4\n",
"30 20 10\n"
] | [
"6\n",
"20\n"
] | In the first sample, friends should meet at the point 4. Thus, the first friend has to travel the distance of 3 (from the point 7 to the point 4), the second friend also has to travel the distance of 3 (from the point 1 to the point 4), while the third friend should not go anywhere because he lives at the point 4. | 500 | [
{
"input": "7 1 4",
"output": "6"
},
{
"input": "30 20 10",
"output": "20"
},
{
"input": "1 4 100",
"output": "99"
},
{
"input": "100 1 91",
"output": "99"
},
{
"input": "1 45 100",
"output": "99"
},
{
"input": "1 2 3",
"output": "2"
},
{
"... | 1,679,237,684 | 2,147,483,647 | Python 3 | WRONG_ANSWER | TESTS | 2 | 31 | 0 | def main():
x1, x2, x3 = (int(_) for _ in input().split())
point = int((x1 + x2 + x3) / 3)
distance = abs(x1 - point) + abs(x2 - point) + abs(x3 - point)
print(distance)
if __name__ == "__main__":
main()
| Title: The New Year: Meeting Friends
Time Limit: None seconds
Memory Limit: None megabytes
Problem Description:
There are three friend living on the straight line *Ox* in Lineland. The first friend lives at the point *x*1, the second friend lives at the point *x*2, and the third friend lives at the point *x*3. They ... | ```python
def main():
x1, x2, x3 = (int(_) for _ in input().split())
point = int((x1 + x2 + x3) / 3)
distance = abs(x1 - point) + abs(x2 - point) + abs(x3 - point)
print(distance)
if __name__ == "__main__":
main()
``` | 0 | MatrixStudio/Codeforces-Python-Submissions |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.