source
stringclasses
4 values
task_type
stringclasses
1 value
in_source_id
stringlengths
0
138
problem_statement
stringlengths
219
13.2k
gold_standard_solution
stringlengths
0
413k
problem_id
stringlengths
5
10
metadata
dict
verification_info
dict
apps
verifiable_code
156
Solve the following coding problem using the programming language python: Today, Osama gave Fadi an integer $X$, and Fadi was wondering about the minimum possible value of $max(a, b)$ such that $LCM(a, b)$ equals $X$. Both $a$ and $b$ should be positive integers. $LCM(a, b)$ is the smallest positive integer that is d...
```python import math x = int(input()) ans = 10**13 ab = [1, 1] for i in range(1, int(x**(1/2))+1): if x % i == 0: a = x//i b = i g = math.gcd(a, b) a *= g b *= g if ans > max(a, b): ans = max(a, b) ab = [a, b] print(ab[0], ab[1]) ```
vfc_10378
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1285/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n", "output": "1 2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n", "output": "2 3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n", ...
apps
verifiable_code
157
Solve the following coding problem using the programming language python: Nikolay has a lemons, b apples and c pears. He decided to cook a compote. According to the recipe the fruits should be in the ratio 1: 2: 4. It means that for each lemon in the compote should be exactly 2 apples and exactly 4 pears. You can't cr...
```python n1 = int( input() ) n2 = int( input() ) n3 = int( input() ) print( min( n1 , n2 // 2 , n3 // 4 ) * 7 ) ```
vfc_10382
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/746/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5\n7\n", "output": "7\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n7\n13\n", "output": "21\n", "type": "stdin_stdout" }, { "fn_name": null, "input"...
apps
verifiable_code
158
Solve the following coding problem using the programming language python: Berland annual chess tournament is coming! Organizers have gathered 2·n chess players who should be divided into two teams with n people each. The first team is sponsored by BerOil and the second team is sponsored by BerMobile. Obviously, organ...
```python n = int(input()) z = list(map(int, input().split())) z.sort() if z[n - 1] < z[n]: print("YES") else: print("NO") ```
vfc_10386
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/845/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1 3 2 4\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n3 3\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "inp...
apps
verifiable_code
159
Solve the following coding problem using the programming language python: You are given an array of n elements, you must make it a co-prime array in as few moves as possible. In each move you can insert any positive integral number you want not greater than 10^9 in any place in the array. An array is co-prime if any...
```python import fractions n = int(input()) A = [int(x) for x in input().split()] B = [] for i in range(n-1): B.append(A[i]) if fractions.gcd(A[i], A[i+1]) != 1: B.append(1) B.append(A[-1]) print(len(B) - n) print(' '.join(map(str, B))) ```
vfc_10390
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/660/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2 7 28\n", "output": "1\n2 7 1 28\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n1\n", "output": "0\n1\n", "type": "stdin_stdout" }, { "fn_name": null, ...
apps
verifiable_code
160
Solve the following coding problem using the programming language python: We have a sequence of N integers: A_1, A_2, \cdots, A_N. You can perform the following operation between 0 and K times (inclusive): - Choose two integers i and j such that i \neq j, each between 1 and N (inclusive). Add 1 to A_i and -1 to A_j, ...
```python # 割り切る数は、Aの総和の約数である # 自分自身を除く約数について大きい順にすべて試して、当てはまるものがあれば答え # 8,20を7の倍数に近づけるとき、 # 8 -> mod 7が1であり、-1か+6で7の倍数になる # 20 -> mod 7が6であり、-6か+1で7の倍数になる # -1と+1をペアにすることが出来て、この操作回数1をK = 3から引くと2となり、これが偶数ならOK import sys readline = sys.stdin.readline N,K = map(int,readline().split()) A = list(map(int,readline().split...
vfc_10394
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://atcoder.jp/contests/abc136/tasks/abc136_e", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 3\n8 20\n", "output": "7\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 10\n3 5\n", "output": "8\n", "type": "stdin_stdout" }, { "fn_name": null, "inpu...
apps
verifiable_code
161
Solve the following coding problem using the programming language python: Cat Furrier Transform is a popular algorithm among cat programmers to create longcats. As one of the greatest cat programmers ever exist, Neko wants to utilize this algorithm to create the perfect longcat. Assume that we have a cat with a numbe...
```python def main(): x = int(input()) n = x.bit_length() t = 0 ans = [] while True: if (x + 1) & (x) == 0: break if t & 1: x += 1 else: for i in range(n - 1, -1, -1): if not (1 << i) & x: ans.append(i + ...
vfc_10398
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1152/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "39\n", "output": "4\n5 3 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\n", ...
apps
verifiable_code
162
Solve the following coding problem using the programming language python: Luba thinks about watering her garden. The garden can be represented as a segment of length k. Luba has got n buckets, the i-th bucket allows her to water some continuous subsegment of garden of length exactly a_{i} each hour. Luba can't water a...
```python n, k = map(int, input().split()) a = list(map(int, input().split())) maxd = -1 for x in a: if k % x == 0: maxd = max(maxd, x) print(k // maxd) ```
vfc_10402
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/915/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 6\n2 3 5\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 7\n1 2 3 4 5 6\n", "output": "7\n", "type": "stdin_stdout" }, { "fn_name": null, ...
apps
verifiable_code
163
Solve the following coding problem using the programming language python: On the way to Rio de Janeiro Ostap kills time playing with a grasshopper he took with him in a special box. Ostap builds a line of length n such that some cells of this line are empty and some contain obstacles. Then, he places his grasshopper t...
```python from math import * from sys import * from queue import * from decimal import * n,k=(int(z) for z in input().split()) s=input() i=0 while i<len(s) and s[i] not in ["G","T"]: i+=1 i+=k while i<len(s) and s[i] not in ["G","T","#"]: i+=k if i>=len(s) or s[i]=="#": print("NO") else: print("YES") ```
vfc_10406
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/735/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 2\n#G#T#\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 1\nT....G\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, ...
apps
verifiable_code
164
Solve the following coding problem using the programming language python: It's a beautiful April day and Wallace is playing football with his friends. But his friends do not know that Wallace actually stayed home with Gromit and sent them his robotic self instead. Robo-Wallace has several advantages over the other guy...
```python y1, y2, w, x, y, r = map(int, input().strip().split()) w -= r y1 = 2 * w - y1 - y - r y2 = 2 * w - y2 - y if x * x * (y2 - y1) * (y2 - y1) <= (y1 * y1 + x * x) * r * r: print(-1) else: print(f"{x * (y1 + y - w) / y1:.10f}") ```
vfc_10410
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/248/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 10 13 10 3 1\n", "output": "4.3750000000\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 4 6 2 2 1\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name"...
apps
verifiable_code
165
Solve the following coding problem using the programming language python: Vasiliy spent his vacation in a sanatorium, came back and found that he completely forgot details of his vacation! Every day there was a breakfast, a dinner and a supper in a dining room of the sanatorium (of course, in this order). The only t...
```python a = list(map(int, input().split())) m = max(a) ans = 0 for i in range(3): if a[i] < m - 1: ans += (m - 1) - a[i] a[i] = m - 1 print(ans) ```
vfc_10414
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/732/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2 1\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 0 0\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 1...
apps
verifiable_code
166
Solve the following coding problem using the programming language python: There is a matrix A of size x × y filled with integers. For every $i \in [ 1 . . x ]$, $j \in [ 1 . . y ]$ A_{i}, j = y(i - 1) + j. Obviously, every integer from [1..xy] occurs exactly once in this matrix. You have traversed some path in this ...
```python MAXN = 1000000000 n = int(input()) a = list(map(int, input().split())) def solve1(): for i in range(n-1): if abs(a[i]-a[i+1]) != 1: return False print("YES\n%d %d" % (MAXN, 1)) return True def solve2(): w = -1 for i in range(n-1): d = abs(a[i]-a[i+1]) if d != 1: if w == -1: w = d e...
vfc_10418
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/954/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8\n1 2 3 6 9 8 5 2\n", "output": "YES\n1000000000 3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n1 2 1 2 5 3\n", "output": "NO\n", "type": "stdin_stdout" }, { ...
apps
verifiable_code
167
Solve the following coding problem using the programming language python: You are given two strings a and b. You have to remove the minimum possible number of consecutive (standing one after another) characters from string b in such a way that it becomes a subsequence of string a. It can happen that you will not need ...
```python def get_substr_ends(haystack, needle): ans = [-1] index = 0 for char in needle: while index < len(haystack) and char != haystack[index]: index += 1 ans.append(index) if index < len(haystack): index += 1 return ans haystack = input() needle = input() pref = get_substr_ends(haystack, needle) s...
vfc_10422
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/762/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "hi\nbob\n", "output": "-\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "abca\naccepted\n", "output": "ac\n", "type": "stdin_stdout" }, { "fn_name": null, "...
apps
verifiable_code
168
Solve the following coding problem using the programming language python: Vasya has a pile, that consists of some number of stones. $n$ times he either took one stone from the pile or added one stone to the pile. The pile was non-empty before each operation of taking one stone from the pile. You are given $n$ operati...
```python n = int(input()) s = input() b = 0 for i in s: if i == '+': b += 1 else: b -= 1 b = max(b, 0) print(b) ```
vfc_10426
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1159/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n---\n", "output": "0", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n++++\n", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n-...
apps
verifiable_code
169
Solve the following coding problem using the programming language python: Kolya Gerasimov loves kefir very much. He lives in year 1984 and knows all the details of buying this delicious drink. One day, as you probably know, he found himself in year 2084, and buying kefir there is much more complicated. Kolya is hungr...
```python n=int(input()) a=int(input()) b=int(input()) c=int(input()) r=n//a if n > c: r=max(r,(r-b+c)//a+1,(n-c)//(b-c)+((n-c)%(b-c)+c)//a) print(r) ```
vfc_10430
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/625/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n11\n9\n8\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n5\n6\n1\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, ...
apps
verifiable_code
170
Solve the following coding problem using the programming language python: Two bored soldiers are playing card war. Their card deck consists of exactly n cards, numbered from 1 to n, all values are different. They divide cards between them in some manner, it's possible that they have different number of cards. Then the...
```python n = int(input()) k1 = list(map(int, input().split()[1:])) k2 = list(map(int, input().split()[1:])) i = 0 while True: if len(k1) == 0 or len(k2) == 0: break if i > 10000: break if k1[0] > k2[0]: k1 = k1[1:] + k2[0:1] + k1[0:1] k2 = k2[1:] else: k2 = k2[1...
vfc_10434
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/546/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n2 1 3\n2 4 2\n", "output": "6 2", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 2\n2 1 3\n", "output": "-1", "type": "stdin_stdout" }, { "fn_name": null, ...
apps
verifiable_code
171
Solve the following coding problem using the programming language python: You have probably registered on Internet sites many times. And each time you should enter your invented password. Usually the registration form automatically checks the password's crypt resistance. If the user's password isn't complex enough, a ...
```python s = input().strip() flag1 = len(s) >= 5 d1 = 'qwertyuiopasdfghjklzxcvbnm' d2 = 'QWERTYUIOPASDFGHJKLZXCVBNM' d3 = '123456789' flag2 = False flag3 = False flag4 = False for i in d1: if i in s: flag2 = True for i in d2: if i in s: flag3 = True for i in d3: if i in s: flag4 = ...
vfc_10438
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/411/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "abacaba\n", "output": "Too weak\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "X12345\n", "output": "Too weak\n", "type": "stdin_stdout" }, { "fn_name": null, ...
apps
verifiable_code
172
Solve the following coding problem using the programming language python: In Berland each high school student is characterized by academic performance — integer value between 1 and 5. In high school 0xFF there are two groups of pupils: the group A and the group B. Each group consists of exactly n students. An academi...
```python n = int(input()) A = list(map(int,input().split())) B = list(map(int,input().split())) a = [0] * 5 b = [0] * 5 for j in range(n): a[A[j]-1] += 1 b[B[j]-1] +=1 per = 0 for j in range(5): if (a[j] + b[j]) % 2 == 1: per = 1 break if per == 1: print(-1) else: ans = 0 for j ...
vfc_10442
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/779/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n5 4 4 4\n5 5 4 5\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n1 1 1 1 1 1\n5 5 5 5 5 5\n", "output": "3\n", "type": "stdin_stdout" }, { ...
apps
verifiable_code
173
Solve the following coding problem using the programming language python: Imagine a city with n horizontal streets crossing m vertical streets, forming an (n - 1) × (m - 1) grid. In order to increase the traffic flow, mayor of the city has decided to make each street one way. This means in each horizontal street, the ...
```python a, b = list(map(int, input().split(' '))) hor = input() ver = input() if (hor[0], ver[0]) == ('>', 'v') or (hor[0], ver[-1]) == ('<', 'v'): print("NO") elif (hor[-1], ver[0]) == ('>', '^') or (hor[-1], ver[-1]) == ('<', '^'): print("NO") else: print("YES") ```
vfc_10446
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/475/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3\n><>\nv^v\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 6\n<><>\nv^v^v^\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": nu...
apps
verifiable_code
174
Solve the following coding problem using the programming language python: Implication is a function of two logical arguments, its value is false if and only if the value of the first argument is true and the value of the second argument is false. Implication is written by using character '$\rightarrow$', and the arg...
```python x = int(input()) seq = list(map(int, input().split(' '))) if seq == [0]: print("YES") print(0) elif seq == [0, 0]: print("NO") elif seq == [1, 0]: print("YES") print('1->0') elif seq == [0, 0, 0]: print("YES") print("(0->0)->0") elif seq == [1, 0, 0]: print("NO") elif se...
vfc_10450
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/550/E", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n0 1 1 0\n", "output": "YES\n0->1->1->0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n1 1\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null...
apps
verifiable_code
175
Solve the following coding problem using the programming language python: You have two variables a and b. Consider the following sequence of actions performed with these variables: If a = 0 or b = 0, end the process. Otherwise, go to step 2; If a ≥ 2·b, then set the value of a to a - 2·b, and repeat step 1. Otherwise,...
```python a, b = [int(v) for v in input().split()] while a > 0 and b > 0: if a >= 2 * b: a %= 2 * b elif b >= 2 * a: b %= 2 * a else: break print(a, b) ```
vfc_10454
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/946/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "12 5\n", "output": "0 1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "31 12\n", "output": "7 12\n", "type": "stdin_stdout" }, { "fn_name": null, "input": ...
apps
verifiable_code
176
Solve the following coding problem using the programming language python: Find the number of k-divisible numbers on the segment [a, b]. In other words you need to find the number of such integer values x that a ≤ x ≤ b and x is divisible by k. -----Input----- The only line contains three space-separated integers k,...
```python s=input() ast=[int(i) for i in s.split(' ')] k,a,b=ast[0],ast[1],ast[2] s1=(a-1)//k s2=b//k print(s2-s1) ```
vfc_10458
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/597/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 1 10\n", "output": "10\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 -4 4\n", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "...
apps
verifiable_code
177
Solve the following coding problem using the programming language python: Let's write all the positive integer numbers one after another from $1$ without any delimiters (i.e. as a single string). It will be the infinite sequence starting with 123456789101112131415161718192021222324252627282930313233343536... Your tas...
```python a = int(input()) s = "" for i in range(1, a+1): s += str(i) print(s[a-1]) ```
vfc_10462
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1177/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7\n", "output": "7\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "21\n", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n", ...
apps
verifiable_code
178
Solve the following coding problem using the programming language python: A telephone number is a sequence of exactly $11$ digits such that its first digit is 8. Vasya and Petya are playing a game. Initially they have a string $s$ of length $n$ ($n$ is odd) consisting of digits. Vasya makes the first move, then playe...
```python n, s = int(input()), input() cnt = (n - 11) // 2 cnt_8 = len(s[:n - 10].split('8')) - 1 if (cnt >= cnt_8): print ("NO") else: print ("YES") ```
vfc_10466
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1155/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "13\n8380011223344\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "15\n807345619350641\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_nam...
apps
verifiable_code
179
Solve the following coding problem using the programming language python: Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in ...
```python MOD = 1000000007 def f(n, cnt): """ n! / (n - cnt)! """ ans = 1 for _ in range(cnt): ans = (ans * n) % MOD n -= 1 return ans def main(): n, x, pos = list(map(int, input().split())) chk1 = 0 chk_r = 0 left = 0 right = n while left < right: ...
vfc_10470
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1436/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 1 2\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "123 42 24\n", "output": "824071958\n", "type": "stdin_stdout" }, { "fn_name": null, "...
apps
verifiable_code
180
Solve the following coding problem using the programming language python: Andrey received a postcard from Irina. It contained only the words "Hello, Andrey!", and a strange string consisting of lowercase Latin letters, snowflakes and candy canes. Andrey thought that this string is an encrypted message, and decided to ...
```python s = input() k = int(input()) c = 0 p = 0 has_star = False for i in range(len(s)): if s[i] in ['*', '?']: if s[i] == '*': has_star = True c -= 1 else: p += 1 c += 1 if k < c: print("Impossible") elif (not has_star) and (k > p): print("Impossible") els...
vfc_10474
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1099/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "hw?ap*yn?eww*ye*ar\n12\n", "output": "hwapppyewyar", "type": "stdin_stdout" }, { "fn_name": null, "input": "ab?a\n2\n", "output": "aa", "type": "stdin_stdout" }, { "fn_name"...
apps
verifiable_code
181
Solve the following coding problem using the programming language python: Vasya started working in a machine vision company of IT City. Vasya's team creates software and hardware for identification of people by their face. One of the project's know-how is a camera rotating around its optical axis on shooting. People ...
```python n = (-int(input())) % 360 ret, opt = 4, 361 for i in range(4): x = (n+90*i)%360 x = min(x, 360-x) if (x, i) < (opt, ret): opt, ret = x, i print(ret) ```
vfc_10478
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/630/M", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "60\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "-60\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "0\n", ...
apps
verifiable_code
182
Solve the following coding problem using the programming language python: Carl is a beginner magician. He has a blue, b violet and c orange magic spheres. In one move he can transform two spheres of the same color into one sphere of any other color. To make a spell that has never been seen before, he needs at least x ...
```python a, b, c = list(map(int, input().split())) x, y, z = list(map(int, input().split())) col = max(0, x - a) + max(0, y - b) + max(0, z - c) sum = max(0, (a - x) // 2) + max(0, (b - y) // 2) + max(0, (c - z) // 2) if sum >= col: print('Yes') else: print('No') ```
vfc_10482
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/606/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 4 0\n2 1 2\n", "output": "Yes\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 6 1\n2 7 2\n", "output": "No\n", "type": "stdin_stdout" }, { "fn_name": null, ...
apps
verifiable_code
183
Solve the following coding problem using the programming language python: Amr doesn't like Maths as he finds it really boring, so he usually sleeps in Maths lectures. But one day the teacher suspected that Amr is sleeping and asked him a question to make sure he wasn't. First he gave Amr two positive integers n and k...
```python n,k,m=list(map(int,input().split())) d,r,p,P=0,0,1%k,(10**(n-1))*9 F=[0]*k F[0]=1 while d<n: d+=1 P//=10 E=[0]*k if P==0:P=1 i=1 # print("E=",E) # print("F=",F) while i<10: j=(-i*p)%k f=0 while f<k: E[f]+=F[j] f+=1 j+=1 if j==k:j=0 i+=1 r+=E[0]*P p=p*10%k E[0]=0 i=1 while i<k: ...
vfc_10486
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/507/D", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 2 1000\n", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 2 1000\n", "output": "45", "type": "stdin_stdout" }, { "fn_name": null, "input": "...
apps
verifiable_code
184
Solve the following coding problem using the programming language python: 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...
```python import base64 import zlib pro = base64.decodebytes("""eJxtUUFuwyAQvPOKVarKkDhOm2MlX/uC3qqqAhs7KBgswGr6+y4QrLqqL7DD7OzMWk2zdQFGGWbu PVG59N/rdeLhUu6Om95OpVJBumCtXqlCedkFQgalpYcW3twiSS/FMmLxyrWXhKihzGrwXLx0lEHb QjU4e5HmWgHOgKTwQgC/0p/EIoDeGh96ZRC0szR0F6QPjTI7lt4fCsMuoVCqREGgqqH6qjIxBSZo cADdTZTXIFie6dCZM8BhDwJOp...
vfc_10490
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/950/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 4 2\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 5 5\n", "output": "14\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "0 ...
apps
verifiable_code
185
Solve the following coding problem using the programming language python: Finished her homework, Nastya decided to play computer games. Passing levels one by one, Nastya eventually faced a problem. Her mission is to leave a room, where a lot of monsters live, as quickly as possible. There are $n$ manholes in the room...
```python n, k = list(map(int,input().split())) if k == 1 or k == n: print(3 * n) else: print(3 * n + min(k - 1, n - k)) ```
vfc_10494
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1136/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 2\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 2\n", "output": "13\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 1\n"...
apps
verifiable_code
186
Solve the following coding problem using the programming language python: Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks. Th...
```python n, m = list(map(int, input().split())) start = 0 end = 10**10 while (end - start > 1): mid = (end + start) // 2 two = mid // 2 - mid // 6 three = mid // 3 - mid // 6 six = mid // 6 nn = n mm = m nn -= two mm -= three nn = max(nn, 0) mm = max(mm, 0) if (six >= nn ...
vfc_10498
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/626/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 3\n", "output": "9\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 2\n", "output": "8\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 0\n",...
apps
verifiable_code
187
Solve the following coding problem using the programming language python: Petya and Vasya decided to play a game. They have n cards (n is an even number). A single integer is written on each card. Before the game Petya will choose an integer and after that Vasya will choose another integer (different from the number ...
```python def list_input(): return list(map(int,input().split())) def map_input(): return map(int,input().split()) def map_string(): return input().split() n = int(input()) a = [] for _ in range(n): a.append(int(input())) b = list(set(a[::])) if(len(b) == 2 and a.count(a[0]) == n//2): print("YES"...
vfc_10502
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/864/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n11\n27\n27\n11\n", "output": "YES\n11 27\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n6\n6\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": n...
apps
verifiable_code
188
Solve the following coding problem using the programming language python: Daenerys Targaryen has an army consisting of k groups of soldiers, the i-th group contains a_{i} soldiers. She wants to bring her army to the other side of the sea to get the Iron Throne. She has recently bought an airplane to carry her army thr...
```python import sys def r(): return list(map(int, input().split())) n, k = list(map(int, input().split())) a = r() cnt4 = n cnt2 = 2*n cnt1 = 0 for i in range(k): x = min((a[i]+1)//4, cnt4) cnt4 -= x a[i] = max(0, a[i]-4*x) cnt2 += cnt4 cnt1 += cnt4 for i in range(k): x = min(a[i]//2, cnt2) ...
vfc_10506
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/839/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 2\n5 8\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 2\n7 1\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "inp...
apps
verifiable_code
189
Solve the following coding problem using the programming language python: Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \ldots, a_n$. For every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length fro...
```python n = int(input()) a = list(map(int,input().split())) t = 0 mn = 1000000000 for i in range(1,100): cur = 0 for j in range(n): cur += max(0,abs(i-a[j])-1) if cur < mn: mn = cur t = i print(t,mn) ```
vfc_10510
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1105/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n10 1 4\n", "output": "3 7\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 1 2 2 3\n", "output": "2 0\n", "type": "stdin_stdout" }, { "fn_name": null, ...
apps
verifiable_code
190
Solve the following coding problem using the programming language python: Карта звёздного неба представляет собой прямоугольное поле, состоящее из n строк по m символов в каждой строке. Каждый символ — это либо «.» (означает пустой участок неба), либо «*» (означает то, что в этом месте на небе есть звезда). Новое из...
```python n, m = input().split() n = int(n) m = int(m) a = [] N = n for i in range(n) : a.append(input().split()) for i in range(n) : if a[i][0].find('*') == -1 : n-=1 else : break if n != 1 : for i in range(len(a)-1,-1,-1) : if a[i][0].find('*') == -1 : n-=1 ...
vfc_10514
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/647/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 4\n....\n..*.\n...*\n..**\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 3\n*.*\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": ...
apps
verifiable_code
191
Solve the following coding problem using the programming language python: A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her. Given an array $a$ of length $n$, consisting only of the numbers $0$ and $1...
```python N, T = list(map(int, input().split())) A = [int(a) for a in input().split()] if sum(A) > N//2: A = [1-a for a in A][::-1] K = sum(A) S = sum(A[-K:]) M = K + 1 P = 10**9+7 inv = pow(N*(N-1)//2, P-2, P) X = [[0]*M for _ in range(M)] for i in range(M): if i > 0: X[i-1][i] = ((K-i+1)**2*inv)%P if i < ...
vfc_10518
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1151/F", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2\n0 1 0\n", "output": "333333336", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 1\n1 1 1 0 0\n", "output": "0", "type": "stdin_stdout" }, { "fn_name": null, ...
apps
verifiable_code
192
Solve the following coding problem using the programming language python: Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y. In a single second...
```python x, y = list(map(int, input().split())) x, y = y, x A = x B = x curr = x count = 0 while curr < y: curr = B + A - 1 A, B = B, curr count += 1 count += 2 print(count) ```
vfc_10522
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/712/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 3\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "8 5\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "22 4\n"...
apps
verifiable_code
193
Solve the following coding problem using the programming language python: The determinant of a matrix 2 × 2 is defined as follows:$\operatorname{det} \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right) = a d - b c$ A matrix is called degenerate if its determinant is equal to zero. The norm ||A|| of a m...
```python def seg(x, y, h): A = [x - h, x + h] B = [y - h, y + h] Z = [] for a in A: for b in B: Z.append(a * b) Z.sort() return (Z[0], Z[-1]) def check(a, b, c, d, h): x1, y1 = seg(a, d, h) x2, y2 = seg(b, c, h) return max(x1, x2) <= min(y1, y2) a, b = list(map...
vfc_10526
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/549/H", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 2\n3 4\n", "output": "0.2000000000\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 0\n0 1\n", "output": "0.5000000000\n", "type": "stdin_stdout" }, { "fn_name...
apps
verifiable_code
194
Solve the following coding problem using the programming language python: In a small restaurant there are a tables for one person and b tables for two persons. It it known that n groups of people come today, each consisting of one or two people. If a group consist of one person, it is seated at a vacant one-seater...
```python n, a, b = list(map(int,input().split())) l = input().split() o = 0 c = 0 for i in l: if i == '2': if b > 0: b -= 1 else: o += 2 if i == '1': if a > 0: a -= 1 elif b > 0: b -= 1 c += 1 elif c > 0: ...
vfc_10530
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/828/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 1 2\n1 2 1 1\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 1 1\n1 1 2 1\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, ...
apps
verifiable_code
195
Solve the following coding problem using the programming language python: Each student eagerly awaits the day he would pass the exams successfully. Thus, Vasya was ready to celebrate, but, alas, he didn't pass it. However, many of Vasya's fellow students from the same group were more successful and celebrated after th...
```python a,b,c,n=list(map(int,input().split())) x=a+b-c print(n-x if c<=a and c<=b and x<n else -1) ```
vfc_10534
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/991/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10 10 5 20\n", "output": "5", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 2 0 4\n", "output": "-1", "type": "stdin_stdout" }, { "fn_name": null, "input": ...
apps
verifiable_code
196
Solve the following coding problem using the programming language python: Nastya received a gift on New Year — a magic wardrobe. It is magic because in the end of each month the number of dresses in it doubles (i.e. the number of dresses becomes twice as large as it is in the beginning of the month). Unfortunately, r...
```python x, k = map(int, input().split()) if x == 0: print(0) else: mod = 10 ** 9 + 7 p = pow(2, k, mod) ans = (x * (p * 2) - (p - 1)) % mod print(ans) ```
vfc_10538
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/992/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 0\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 1\n", "output": "7\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 2\n",...
apps
verifiable_code
197
Solve the following coding problem using the programming language python: An online contest will soon be held on ForceCoders, a large competitive programming platform. The authors have prepared $n$ problems; and since the platform is very popular, $998244351$ coder from all over the world is going to solve them. For ...
```python from bisect import bisect_left M = 998244353 def pw(x, y): if y == 0: return 1 res = pw(x, y//2) res = res * res % M if y % 2 == 1: res = res * x % M return res def cal(x, y): y += x - 1 res = 1 for i in range(1, x + 1): res = res * (y - i + 1) ...
vfc_10542
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1295/F", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 2\n1 2\n1 2\n", "output": "499122177\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n42 1337\n13 420\n", "output": "578894053\n", "type": "stdin_stdout" }, { ...
apps
verifiable_code
198
Solve the following coding problem using the programming language python: Pasha has a wooden stick of some positive integer length n. He wants to perform exactly three cuts to get four parts of the stick. Each part must have some positive integer length and the sum of these lengths will obviously be n. Pasha likes r...
```python x = int(input()) if x%2==1: print(0) quit() if x%2 ==0: x//=2 if x%2==0: print(x//2-1) else: print(x//2) ```
vfc_10546
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/610/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "20\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n", ...
apps
verifiable_code
199
Solve the following coding problem using the programming language python: The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut l...
```python def doit(): xx = input().split() n = int(xx[0]) s = int(xx[1]) v = [int(k) for k in input().split()] S = sum(v) newS = S - s if newS < 0: return -1 return min(newS//n, min(v)) print(doit()) ```
vfc_10550
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1084/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3\n4 3 5\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 4\n5 3 4\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "in...
apps
verifiable_code
200
Solve the following coding problem using the programming language python: The 9-th grade student Gabriel noticed a caterpillar on a tree when walking around in a forest after the classes. The caterpillar was on the height h_1 cm from the ground. On the height h_2 cm (h_2 > h_1) on the same tree hung an apple and the c...
```python from math import * h1, h2 = [int(i) for i in input().split()] a, b = [int(i) for i in input().split()] a *= 12 b *= 12 if a <= b and h2 - h1 > (a // 12 * 8): print(-1) return h1 += (a // 12 * 8) if h1 >= h2: print(0) return day = int(ceil((h2 - h1) / (a - b))) print(day) ```
vfc_10554
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/652/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10 30\n2 1\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 13\n1 1\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "in...
apps
verifiable_code
201
Solve the following coding problem using the programming language python: A sweet little monster Om Nom loves candies very much. One day he found himself in a rather tricky situation that required him to think a bit in order to enjoy candies the most. Would you succeed with the same task if you were on his place? [Ima...
```python import sys f = sys.stdin C, Hr, Hb, Wr, Wb = map(int, f.readline().strip().split()) if Hr/Wr < Hb/Wb: Hr, Hb, Wr, Wb = Hb, Hr, Wb, Wr if (C % Wr) == 0 and (C // Wr) > 0: print((C // Wr)*Hr) elif (C // Wr) == 0: print((C // Wb)*Hb) else: nmax = (C // Wr) pmax = nmax*Hr + ((C - nma...
vfc_10558
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/526/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10 3 5 2 3\n", "output": "16\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 3 1 6 7\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "in...
apps
verifiable_code
202
Solve the following coding problem using the programming language python: Professor GukiZ makes a new robot. The robot are in the point with coordinates (x_1, y_1) and should go to the point (x_2, y_2). In a single step the robot can change any of its coordinates (maybe both of them) by one (decrease or increase). So ...
```python a, b = map(int, input().split()) d, c = map(int, input().split()) print(max(abs(a - d), abs(b - c))) ```
vfc_10562
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/620/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "0 0\n4 5\n", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 4\n6 1\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input"...
apps
verifiable_code
203
Solve the following coding problem using the programming language python: There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote. Each of the employees belongs to one of two fractions:...
```python n = int(input()) s = input() countr = s.count('R') countd = n - countr cr = 0 cd = 0 i = 0 news = [] while countr != 0 and countd != 0: if s[i] == 'D': if cd == 0: cr += 1 countr -= 1 news.append('D') else: cd -= 1 else: if cr == ...
vfc_10566
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/749/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\nDDRRR\n", "output": "D\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\nDDRRRR\n", "output": "R\n", "type": "stdin_stdout" }, { "fn_name": null, "input...
apps
verifiable_code
204
Solve the following coding problem using the programming language python: Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than $a$ and screen height not greater than $b$. Monocarp is also used to TV ...
```python def gcd(a, b): while b: a, b = b, a % b return a a, b, x, y = list(map(int, input().split())) g = gcd(x, y) x //= g y //= g print(min(a // x, b // y)) ```
vfc_10570
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1041/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "17 15 5 3\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "14 16 7 22\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "inp...
apps
verifiable_code
205
Solve the following coding problem using the programming language python: The number "zero" is called "love" (or "l'oeuf" to be precise, literally means "egg" in French), for example when denoting the zero score in a game of tennis. Aki is fond of numbers, especially those with trailing zeros. For example, the numbe...
```python n, k = map(int, input().split()) a = [] i = 2 while (i * i <= k): if (k % i == 0): a.append([i, 0]) while (k % i == 0): a[len(a) - 1][1] += 1 k //= i i += 1 if (k > 1): a.append([k, 1]) ans = 10 ** 20 for i in a: cnt = 0 x = i[0] while (x <= n): ...
vfc_10574
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1114/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 9\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "38 11\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 2\n...
apps
verifiable_code
206
Solve the following coding problem using the programming language python: A frog is initially at position $0$ on the number line. The frog has two positive integers $a$ and $b$. From a position $k$, it can either jump to position $k+a$ or $k-b$. Let $f(x)$ be the number of distinct integers the frog can reach if it n...
```python import math m,a,b=map(int,input().split()) g=math.gcd(a,b) a1=a//g b1=b//g alls=g*(a1+b1-1) dists=[0]+[-1]*(a1+b1-1) dist=0 far=0 while dist!=b1: if dist<b1: dist+=a1 far=max(dist,far) else: dist-=b1 if dists[dist]==-1: dists[dist]=far tot=0 for i in range(a1+b1): ...
vfc_10578
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1146/D", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7 5 3\n", "output": "19\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1000000000 1 2019\n", "output": "500000001500000001\n", "type": "stdin_stdout" }, { "fn_na...
apps
verifiable_code
207
Solve the following coding problem using the programming language python: Where do odds begin, and where do they end? Where does hope emerge, and will they ever break? Given an integer sequence a_1, a_2, ..., a_{n} of length n. Decide whether it is possible to divide it into an odd number of non-empty subsegments, th...
```python def read_ints(): return [int(i) for i in input().split()] n = read_ints() a = read_ints() if len(a) % 2 and a[0] % 2 and a[-1] % 2: print('Yes') else: print('No') ```
vfc_10582
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/849/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 3 5\n", "output": "Yes\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 0 1 5 1\n", "output": "Yes\n", "type": "stdin_stdout" }, { "fn_name": null, ...
apps
verifiable_code
208
Solve the following coding problem using the programming language python: Pashmak has fallen in love with an attractive girl called Parmida since one year ago... Today, Pashmak set up a meeting with his partner in a romantic garden. Unfortunately, Pashmak has forgotten where the garden is. But he remembers that the g...
```python x1, y1, x2, y2 = map(int, input().split()) #diagonal if x1 != x2 and y1 != y2: if abs(x1 - x2) == abs(y1 - y2): print(x1, y2, x2, y1) else: print(-1) #same side elif x1 == x2: aux = abs(y2 - y1) print(x1 + aux, y1, x1 + aux, y2) elif y1 == y2: aux = abs(x2 - x1) print(x...
vfc_10586
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/459/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "0 0 0 1\n", "output": "1 0 1 1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "0 0 1 1\n", "output": "0 1 1 0\n", "type": "stdin_stdout" }, { "fn_name": null, ...
apps
verifiable_code
209
Solve the following coding problem using the programming language python: Jzzhu has invented a kind of sequences, they meet the following property:$f_{1} = x ; f_{2} = y ; \forall i(i \geq 2), f_{i} = f_{i - 1} + f_{i + 1}$ You are given x and y, please calculate f_{n} modulo 1000000007 (10^9 + 7). -----Input----- ...
```python def main(): x, y = [int(i) for i in input().split()] n = int(input()) result = [x, y, y - x, -x, -y, x - y][(n - 1) % 6] print(result % 1000000007) main() ```
vfc_10590
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/450/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 3\n3\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "0 -1\n2\n", "output": "1000000006\n", "type": "stdin_stdout" }, { "fn_name": null, "...
apps
verifiable_code
210
Solve the following coding problem using the programming language python: One spring day on his way to university Lesha found an array A. Lesha likes to split arrays into several parts. This time Lesha decided to split the array A into several, possibly one, new arrays so that the sum of elements in each of the new ar...
```python from sys import stdin n = int(input()) a = [int(x) for x in input().split()] f = False for i in range(len(a)): if a[i] != 0: ln = i f = True break if not f: print('NO') else: print('YES') l = 0 i = ln + 1 ans = [] while i < len(a): if a[i] == 0: ...
vfc_10594
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/754/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 2 -3\n", "output": "YES\n3\n1 1\n2 2\n3 3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "8\n9 -12 3 4 -4 -10 7 3\n", "output": "YES\n8\n1 1\n2 2\n3 3\n4 4\n5 5\n6 6\n7 7\n8 8\n...
apps
verifiable_code
211
Solve the following coding problem using the programming language python: Manao is taking part in a quiz. The quiz consists of n consecutive questions. A correct answer gives one point to the player. The game also has a counter of consecutive correct answers. When the player answers a question correctly, the number on...
```python MOD = 1000000009 n,m,k = [int(x) for x in input().split()] num0 = n-m num1fin = num0*(k-1) if num1fin >= m: print(m) else: num1open = m-num1fin sets = num1open//k rem = num1open%k print(((pow(2,sets,MOD)-1)*2*k+rem+num1fin)%MOD) ```
vfc_10598
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/337/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 3 2\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 4 2\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "300...
apps
verifiable_code
212
Solve the following coding problem using the programming language python: You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes. Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any...
```python n1 = input() n = [] for i in n1: n.append(int(i)) k = len(n) for i in range(k): if (n[i] % 8) == 0: print("YES") print(n[i]) return if k > 1: for i in range(k): t = n[i] * 10 for j in range(i+1, k): if (t+n[j]) % 8 == 0: print("...
vfc_10602
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/550/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3454\n", "output": "YES\n344\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n", "output": "YES\n0\n", "type": "stdin_stdout" }, { "fn_name": null, "inpu...
apps
verifiable_code
213
Solve the following coding problem using the programming language python: In a building where Polycarp lives there are equal number of flats on each floor. Unfortunately, Polycarp don't remember how many flats are on each floor, but he remembers that the flats are numbered from 1 from lower to upper floors. That is, t...
```python def floo(num, k): return (num - 1) // k + 1 def main(): n, m = map(int, input().split()) low = 1 high = 10**9 if (m == 0): if (n == 1): print(1) else: print(-1) return for i in range(m): k, f = map(int, input().split()) low = max(low, (k + f - 1) // f) if (f > 1): high = min(high...
vfc_10606
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/858/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10 3\n6 2\n2 1\n7 3\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "8 4\n3 1\n6 2\n5 2\n2 1\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn...
apps
verifiable_code
214
Solve the following coding problem using the programming language python: Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any s...
```python f = [] for i in range(2): f.append(list(input())) answer = 0 n = len(f[0]) for i in range(n): if f[0][i] == f[1][i] == '0' and i + 1 < n: if f[0][i + 1] == '0': answer += 1 f[0][i + 1] = 'X' elif f[1][i + 1] == '0': answer += 1 f[1][i ...
vfc_10610
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/991/D", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "00\n00\n", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "00X00X0XXX0\n0XXX0X00X00\n", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, ...
apps
verifiable_code
215
Solve the following coding problem using the programming language python: Polycarp loves lowercase letters and dislikes uppercase ones. Once he got a string s consisting only of lowercase and uppercase Latin letters. Let A be a set of positions in the string. Let's call it pretty if following conditions are met: let...
```python def list_input(): return list(map(int,input().split())) def map_input(): return map(int,input().split()) def map_string(): return input().split() n = int(input()) a = list(input()) ans = 0 for i in range(n): for j in range(i,n): b = a[i:j+1] for k in b: if k.lower() != k: brea...
vfc_10614
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/864/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "11\naaaaBaabAbA\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "12\nzACaAbbaazzC\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null...
apps
verifiable_code
216
Solve the following coding problem using the programming language python: You are given a sequence a consisting of n integers. You may partition this sequence into two sequences b and c in such a way that every element belongs exactly to one of these sequences. Let B be the sum of elements belonging to b, and C be t...
```python n=int(input()) arr= list(map(int,input().strip().split(' '))) s = 0 for i in range(n): s+=abs(arr[i]) print(s) ```
vfc_10618
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/946/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 -2 0\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n16 23 16 15 42 8\n", "output": "120\n", "type": "stdin_stdout" }, { "fn_name": null,...
apps
verifiable_code
217
Solve the following coding problem using the programming language python: 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 im...
```python def list_input(): return list(map(int,input().split())) def map_input(): return map(int,input().split()) def map_string(): return input().split() a,b,f,k = map_input() tot = a*k s = 2*a-f cur = 0 cnt = b go = 0 ans = 0 while cur < tot: go = 1-go if(go == 1): if cnt < s and cnt < tot-cur: ...
vfc_10622
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/864/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 9 2 4\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 10 2 4\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input":...
apps
verifiable_code
218
Solve the following coding problem using the programming language python: You are given the string s of length n and the numbers p, q. Split the string s to pieces of length p and q. For example, the string "Hello" for p = 2, q = 3 can be split to the two strings "Hel" and "lo" or to the two strings "He" and "llo". ...
```python a, b, c = map(int, input().split(' ')) x = input() for i in range(105): for j in range(105): if i*b+j*c == a: print(i+j) for k in range(i): print(x[:b]) x = x[b:] for l in range(j): print(x[:c]) x =...
vfc_10626
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/612/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 2 3\nHello\n", "output": "2\nHe\nllo\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 9 5\nCodeforces\n", "output": "2\nCodef\norces\n", "type": "stdin_stdout" }, {...
apps
verifiable_code
219
Solve the following coding problem using the programming language python: A sportsman starts from point x_{start} = 0 and runs to point with coordinate x_{finish} = m (on a straight line). Also, the sportsman can jump — to jump, he should first take a run of length of not less than s meters (in this case for these s m...
```python n, m, s, d = list(map(int, input().split())) beg = [float('-inf')] end = [float('-inf')] a = [int(i) for i in input().split()] for x in sorted(a): if (x - end[-1] > s + 1): beg.append(x) end.append(x) else: end[-1] = x last = 0 R = [] J = [] for i in range(1, len(beg)): R.append(beg[i] - 1 - las...
vfc_10630
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/637/D", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 10 1 3\n3 4 7\n", "output": "RUN 2\nJUMP 3\nRUN 1\nJUMP 2\nRUN 2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 9 2 3\n6 4\n", "output": "IMPOSSIBLE\n", "type": "stdin_std...
apps
verifiable_code
220
Solve the following coding problem using the programming language python: Two positive integers a and b have a sum of s and a bitwise XOR of x. How many possible values are there for the ordered pair (a, b)? -----Input----- The first line of the input contains two integers s and x (2 ≤ s ≤ 10^12, 0 ≤ x ≤ 10^12), th...
```python s, x = list(map(int, input().split())) rem = int(s == x) * 2 p, t, cur = [], 0, 1 for i in range(64): if x % 2: t += 1 s -= cur else: p.append(cur * 2) cur *= 2 x //= 2 for i in p[::-1]: if s >= i: s -= i ans = 0 if s else 2 ** t - rem print(ans) ```
vfc_10634
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/627/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "9 5\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 3\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 2\n",...
apps
verifiable_code
221
Solve the following coding problem using the programming language python: Long story short, shashlik is Miroslav's favorite food. Shashlik is prepared on several skewers simultaneously. There are two states for each skewer: initial and turned over. This time Miroslav laid out $n$ skewers parallel to each other, and e...
```python n, k = map(int, input().split()) if n <= k + k + 1: print(1) print((n + 1) // 2) else: answer = -1 answer_n = 10**100 for i in range(min(k + 1, n)): t = n - (k + i + 1) if t % (k + k + 1) >= k + 1: if 2 + t // (k + k + 1) < answer_n: answer = i +...
vfc_10638
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1040/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7 2\n", "output": "2\n1 6 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 1\n", "output": "2\n1 4 \n", "type": "stdin_stdout" }, { "fn_name": null, "inpu...
apps
verifiable_code
222
Solve the following coding problem using the programming language python: You are given a positive integer $n$, written without leading zeroes (for example, the number 04 is incorrect). In one operation you can delete any digit of the given integer so that the result remains a positive integer without leading zeros....
```python ar=[] for i in range(1,10**5): if(i*i>2*10**9):break ar.append(i*i) s=input() ans=len(s) for x in ar: s2=str(x) i=0 for x in range(len(s)): if i<len(s2) and s[x]==s2[i]: i+=1 if(i==len(s2)): ans=min(ans,len(s)-i) if(ans==len(s)): print(-1) else: prin...
vfc_10642
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/962/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8314\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "625\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "333\n"...
apps
verifiable_code
223
Solve the following coding problem using the programming language python: Let's define a function $f(p)$ on a permutation $p$ as follows. Let $g_i$ be the greatest common divisor (GCD) of elements $p_1$, $p_2$, ..., $p_i$ (in other words, it is the GCD of the prefix of length $i$). Then $f(p)$ is the number of distinc...
```python p=10**9+7 import math def inv(k,p): prod=1 while k>1: prod*=(p//k+1) k=(k*(p//k+1))%p return prod%p n=int(input()) a=[] k=int(math.log2(n)) x=n while x>0: y=x//2 a.append(x-y) x=y c=[sum(a[i:]) for i in range(k+1)] b=[n//(3*2**i)-n//(6*2**i) for i in range(k+1)] d=[n//2...
vfc_10646
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1174/E", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n", "ou...
apps
verifiable_code
224
Solve the following coding problem using the programming language python: One day, the Grasshopper was jumping on the lawn and found a piece of paper with a string. Grasshopper became interested what is the minimum jump ability he should have in order to be able to reach the far end of the string, jumping only on vowe...
```python # You lost the game. s = str(input()) n = len(s) d = -1 r = 0 V = "AEIOUY" for i in range(n): if V.count(s[i]): r = max(r,i-d) d = i print(max(r, n-d)) ```
vfc_10650
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/733/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "ABABBBACFEYUKOTT\n", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "AAA\n", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input":...
apps
verifiable_code
225
Solve the following coding problem using the programming language python: Dawid has four bags of candies. The $i$-th of them contains $a_i$ candies. Also, Dawid has two friends. He wants to give each bag to one of his two friends. Is it possible to distribute the bags in such a way that each friend receives the same a...
```python l=list(map(int,input().split())) for i in range(16): cur1,cur2=0,0 for j in range(4): if (i&(1<<j))==0: cur1+=l[j] else: cur2+=l[j] if cur1==cur2: print("YES") quit() print("NO") ```
vfc_10654
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1230/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 7 11 5\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7 3 2 5\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "inpu...
apps
verifiable_code
226
Solve the following coding problem using the programming language python: You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie,...
```python n = int(input()) a = list(map(int, input().split())) a = a[::-1] d = 0 for i in range(len(a)): d = max(0 + d, a[i] + (sum(a[:i]) - d)) print(sum(a)-d, d) ```
vfc_10658
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/859/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n141 592 653\n", "output": "653 733\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n10 21 10 21 10\n", "output": "31 41\n", "type": "stdin_stdout" }, { "fn_n...
apps
verifiable_code
227
Solve the following coding problem using the programming language python: You've got a positive integer sequence a_1, a_2, ..., a_{n}. All numbers in the sequence are distinct. Let's fix the set of variables b_1, b_2, ..., b_{m}. Initially each variable b_{i} (1 ≤ i ≤ m) contains the value of zero. Consider the follow...
```python def Solve(x,B): if((X,x,B) in Mem): return Mem[(X,x,B)] if(len(B)>X): return False if(x==len(L)): return True if(Form(L[x],B)): A=list(B) for e in range(len(B)): r=A[e] A[e]=L[x] if(Solve(x+1,tuple(sorted(A)))): ...
vfc_10662
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/279/D", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 2 3 6 8\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n3 6 5\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "i...
apps
verifiable_code
228
Solve the following coding problem using the programming language python: Alice and Bob are playing a game with $n$ piles of stones. It is guaranteed that $n$ is an even number. The $i$-th pile has $a_i$ stones. Alice and Bob will play a game alternating turns with Alice going first. On a player's turn, they must ch...
```python n=int(input()) s=list(map(int,input().split())) print("Bob"if s.count(min(s))>n/2 else"Alice") ```
vfc_10666
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1147/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n8 8\n", "output": "Bob\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n3 1 4 1\n", "output": "Alice\n", "type": "stdin_stdout" }, { "fn_name": null, "...
apps
verifiable_code
229
Solve the following coding problem using the programming language python: Today, hedgehog Filya went to school for the very first time! Teacher gave him a homework which Filya was unable to complete without your help. Filya is given an array of non-negative integers a_1, a_2, ..., a_{n}. First, he pick an integer x a...
```python read = lambda: list(map(int, input().split())) n = int(input()) a = list(read()) s = set() for i in a: s.add(i) f1 = len(s) < 3 f2 = len(s) == 3 and max(s) + min(s) == 2 * sorted(s)[1] print('YES' if f1 or f2 else 'NO') ```
vfc_10670
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/714/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 3 3 2 1\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 2 3 4 5\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, ...
apps
verifiable_code
230
Solve the following coding problem using the programming language python: Given is a string S of length N. Find the maximum length of a non-empty string that occurs twice or more in S as contiguous substrings without overlapping. More formally, find the maximum positive integer len such that there exist integers l_1 a...
```python n = int(input()) s = input() j = 1 result = [] for i in range(n): while (j < n-1) and (s[i:j] in s[j:]): j += 1 result.append(j-i-1) print(max(result)) ```
vfc_10674
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://atcoder.jp/contests/abc141/tasks/abc141_e", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\nababa\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\nxy\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "...
apps
verifiable_code
231
Solve the following coding problem using the programming language python: The main street of Berland is a straight line with n houses built along it (n is an even number). The houses are located at both sides of the street. The houses with odd numbers are at one side of the street and are numbered from 1 to n - 1 in t...
```python n, a = list(map(int,input().split())) if a % 2 == 1: print(a // 2 + 1) else: print((n-a) // 2 + 1) ```
vfc_10678
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/638/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 2\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "8 5\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 1\n",...
apps
verifiable_code
232
Solve the following coding problem using the programming language python: There is unrest in the Galactic Senate. Several thousand solar systems have declared their intentions to leave the Republic. Master Heidi needs to select the Jedi Knights who will go on peacekeeping missions throughout the galaxy. It is well-kno...
```python s = input().split() n, m = int(s[0]), int(s[1]) cl = list(map(int, input().split())) com = list(map(int, input().split())) res = False for i in range(n): for j in range(i, n): e = True t = cl[i:j+1] for k in range(1, m+1): e = t.count(k)==com[k-1] and e if e: res = True bre...
vfc_10682
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/958/F1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 2\n1 1 2 2 1\n1 2\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 1\n1\n1\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": nul...
apps
verifiable_code
233
Solve the following coding problem using the programming language python: Mishka is a little polar bear. As known, little bears loves spending their free time playing dice for chocolates. Once in a wonderful sunny morning, walking around blocks of ice, Mishka met her friend Chris, and they started playing the game. R...
```python x = 0 y = 0 for _ in range(int(input())): a, b = list(map(int, input().split())) x += (a > b) y += (b > a) if x > y: print("Mishka") elif y > x: print("Chris") else: print("Friendship is magic!^^") ```
vfc_10686
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/703/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3 5\n2 1\n4 2\n", "output": "Mishka", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n6 1\n1 6\n", "output": "Friendship is magic!^^", "type": "stdin_stdout" }, { ...
apps
verifiable_code
234
Solve the following coding problem using the programming language python: One day Alex decided to remember childhood when computers were not too powerful and lots of people played only default games. Alex enjoyed playing Minesweeper that time. He imagined that he saved world from bombs planted by terrorists, but he ra...
```python r, c = list(map(int, input().split())) b = [list(input()) for i in range(r)] for y in range(r): for x in range(c): if b[y][x] == '.': b[y][x] = '0' ok = True for Y in range(r): for X in range(c): if not b[Y][X].isdigit(): continue p = 0 for dy ...
vfc_10690
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/984/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3\n111\n1*1\n111\n", "output": "YES", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 4\n*.*.\n1211\n", "output": "NO", "type": "stdin_stdout" }, { "fn_name": nul...
apps
verifiable_code
235
Solve the following coding problem using the programming language python: After passing a test, Vasya got himself a box of $n$ candies. He decided to eat an equal amount of candies each morning until there are no more candies. However, Petya also noticed the box and decided to get some candies for himself. This means...
```python def can(n, k): total = n s = 0 while n > 0: cur = min(n, k) s += cur n -= cur n -= n // 10 return s * 2 >= total n = int(input()) le = 0 rg = n while rg - le > 1: mid = (rg + le) // 2 if can(n, mid): rg = mid else: le = mid pr...
vfc_10694
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/991/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "68\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n", ...
apps
verifiable_code
236
Solve the following coding problem using the programming language python: A necklace can be described as a string of links ('-') and pearls ('o'), with the last link or pearl connected to the first one. $0$ You can remove a link or a pearl and insert it between two other existing links or pearls (or between a link a...
```python def main(): s = input() links = s.count('-') pearls = s.count('o') if pearls == 0 or links % pearls == 0: print('YES') else: print('NO') main() ```
vfc_10698
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/980/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "-o-o--\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "-o---\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input":...
apps
verifiable_code
237
Solve the following coding problem using the programming language python: n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's ...
```python n, m, k = map(int, input().split()) ans = 1 m -= n left = k - 1 right = n - k put = 1 while (m >= put): m -= put ans += 1 put += (left > 0) + (right > 0) if (left): left -= 1 if (right): right -= 1 if (left == right == 0): ans += (m // put) break print(ans) ```
vfc_10702
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/760/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 6 2\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 10 3\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 ...
apps
verifiable_code
238
Solve the following coding problem using the programming language python: You are given an array $a_1, a_2, \dots , a_n$ and two integers $m$ and $k$. You can choose some subarray $a_l, a_{l+1}, \dots, a_{r-1}, a_r$. The cost of subarray $a_l, a_{l+1}, \dots, a_{r-1}, a_r$ is equal to $\sum\limits_{i=l}^{r} a_i - k...
```python N, M, K = list(map(int, input().split())) A = [int(a) for a in input().split()] S = [0] for a in A: S.append(S[-1]+M*a-K) MI = [(10**50)] * M ans = 0 for i in range(N+1): MI[i%M] = min(MI[i%M], S[i]) for j in range(M): ans = max(ans, (S[i]-MI[(i-j)%M] - K*((-j)%M))//M) print(ans) ```
vfc_10706
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1197/D", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7 3 10\n2 -4 15 -3 4 8 3\n", "output": "7\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 2 1000\n-13 -4 -9 -20 -11\n", "output": "0\n", "type": "stdin_stdout" }, { ...
apps
verifiable_code
239
Solve the following coding problem using the programming language python: You are given a rectangular grid of lattice points from (0, 0) to (n, m) inclusive. You have to choose exactly 4 different points to build a polyline possibly with self-intersections and self-touching. This polyline should be as long as possible...
```python import math n, m = list(map(int, input().split())) if n == 0 : print(0, 1) print(0, m) print(0, 0) print(0, m - 1) elif m == 0 : print(1, 0) print(n, 0) print(0, 0) print(n - 1, 0) else : l = math.sqrt((n - 1) ** 2 + m ** 2) + math.sqrt(n ** 2 + m ** 2) + math.sqrt(n ** 2...
vfc_10710
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/452/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 1\n", "output": "1 1\n0 0\n1 0\n0 1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "0 10\n", "output": "0 1\n0 10\n0 0\n0 9\n", "type": "stdin_stdout" }, { "fn_...
apps
verifiable_code
240
Solve the following coding problem using the programming language python: Vasya decided to pass a very large integer n to Kate. First, he wrote that number as a string, then he appended to the right integer k — the number of digits in n. Magically, all the numbers were shuffled in arbitrary order while this note was...
```python import math from collections import Counter s = list(map(int, input())) substr = input().rstrip() t = list(map(int, substr)) m = len(s) x, y = 0, m z = (x + y) // 2 while z != x: if z + math.floor(math.log10(z)) + 1 <= m: x = z else: y = z z = (x + y)//2 m1 = z k = math.floor(mat...
vfc_10714
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/670/F", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "003512\n021\n", "output": "30021\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "199966633300\n63\n", "output": "3036366999\n", "type": "stdin_stdout" }, { "fn_na...
apps
verifiable_code
241
Solve the following coding problem using the programming language python: Not so long ago company R2 bought company R1 and consequently, all its developments in the field of multicore processors. Now the R2 laboratory is testing one of the R1 processors. The testing goes in n steps, at each step the processor gets so...
```python def main(): n, m, mn, mx = map(int, input().split()) A = list(map(int, input().split())) a = min(A) b = max(A) if a < mn or b > mx: print("Incorrect") return cnt = 0 if a > mn: cnt += 1 if b < mx: cnt += 1 if m + cnt <= n: print("Correct") else: print("Incorrect") main() ```
vfc_10718
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/413/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 1 1 2\n1\n", "output": "Correct\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 1 1 3\n2\n", "output": "Correct\n", "type": "stdin_stdout" }, { "fn_name": nul...
apps
verifiable_code
242
Solve the following coding problem using the programming language python: Mr. Santa asks all the great programmers of the world to solve a trivial problem. He gives them an integer m and asks for the number of positive integers n, such that the factorial of n ends with exactly m zeroes. Are you among those great progr...
```python m = int(input()) a = 0 while m > 0: a += 5 b = a c = 0 while b % 5 == 0: b //= 5 c += 1 m -= c if m < 0: print(0) else: print(5) print(a, a + 1, a + 2, a + 3, a + 4) ```
vfc_10722
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/633/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n", "output": "5\n5 6 7 8 9 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n", "output": "0", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n...
apps
verifiable_code
243
Solve the following coding problem using the programming language python: Chouti was tired of the tedious homework, so he opened up an old programming problem he created years ago. You are given a connected undirected graph with $n$ vertices and $m$ weighted edges. There are $k$ special vertices: $x_1, x_2, \ldots, x...
```python def g(): return list(map(int,input().split())) n,m,k=g() p=list(range(n+1)) z=[0]*(n+1) for x in g(): z[x]=1 e=[] for i in range(m): u,v,w=g() e+=[(w,u,v)] e=sorted(e) def q(x): if x!=p[x]: p[x]=q(p[x]) return p[x] for w,u,v in e: u=q(u);v=q(v) if u!=v: if u%5==3: u,v=v,u p[u]=v;z[v]+=z[u] ...
vfc_10726
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1081/D", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 3 2\n2 1\n1 2 3\n1 2 2\n2 2 1\n", "output": "2 2 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 5 3\n1 2 3\n1 2 5\n4 2 1\n2 3 2\n1 4 4\n1 3 3\n", "output": "3 3 3 \n", "t...
apps
verifiable_code
244
Solve the following coding problem using the programming language python: Bomboslav likes to look out of the window in his room and watch lads outside playing famous shell game. The game is played by two persons: operator and player. Operator takes three similar opaque shells and places a ball beneath one of them. The...
```python def main(): n = int(input()) k = int(input()) n %= 6 a = [0, 1, 2] for i in range(1, n + 1): if (i % 2 == 1): a[0], a[1] = a[1], a[0] else: a[1], a[2] = a[2], a[1] print(a[k]) main() ```
vfc_10730
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/777/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n2\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n1\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n2\...
apps
verifiable_code
245
Solve the following coding problem using the programming language python: You are given n rectangles. The corners of rectangles have integer coordinates and their edges are parallel to the Ox and Oy axes. The rectangles may touch each other, but they do not overlap (that is, there are no points that belong to the inte...
```python n = int(input()) s = 0 INF = 10**9 minx = miny = INF maxx = maxy = -INF for i in range(n): x1, y1, x2, y2 = list(map(int, input().split())) s += abs(x1 - x2) * abs(y1 - y2) minx = min(minx, x1, x2) maxx = max(maxx, x1, x2) miny = min(miny, y1, y2) maxy = max(maxy, y1, y2) if (maxx - ...
vfc_10734
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/325/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n0 0 2 3\n0 3 3 5\n2 0 5 2\n3 2 5 5\n2 2 3 3\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n0 0 2 3\n0 3 3 5\n2 0 5 2\n3 2 5 5\n", "output": "NO\n", "t...
apps
verifiable_code
246
Solve the following coding problem using the programming language python: Ivan likes to learn different things about numbers, but he is especially interested in really big numbers. Ivan thinks that a positive integer number x is really big if the difference between x and the sum of its digits (in decimal representatio...
```python def check(x, s): k = 0 for i in str(x): k += int(i) return x - k >= s n, s = map(int, input().split()) l = 0 r = n while r - l > 1: m = (l + r) // 2 if check(m, s): r = m else: l = m if check(r, s): print(n - r + 1) else: print(0) ```
vfc_10738
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/817/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "12 1\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "25 20\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 9...
apps
verifiable_code
247
Solve the following coding problem using the programming language python: You are given n points on Cartesian plane. Every point is a lattice point (i. e. both of its coordinates are integers), and all points are distinct. You may draw two straight lines (not necessarily distinct). Is it possible to do this in such a...
```python n = int(input()) L = [(0, 0)] * n for i in range(n): t = input().split(' ') a = int(t[0]) b = int(t[1]) L[i] = (a, b) if n <= 4: print("YES") else: b0 = True b1 = True b2 = True L0 = [] L1 = [] L2 = [] for j in range(n): if (L[0][0]-L[1][0])*(L[0][1]-L[j...
vfc_10742
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/961/D", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n0 0\n0 1\n1 1\n1 -1\n2 2\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n0 0\n1 0\n2 1\n1 1\n2 3\n", "output": "NO\n", "type": "stdin_stdout" }, ...
apps
verifiable_code
248
Solve the following coding problem using the programming language python: Memory and his friend Lexa are competing to get higher score in one popular computer game. Memory starts with score a and Lexa starts with score b. In a single turn, both Memory and Lexa get some integer in the range [ - k;k] (i.e. one integer a...
```python mod=10**9+7 f=[0]*500000 def POW(a,b): if(b==0): return 1 if(b&1): return POW(a,b//2)**2*a%mod else: return POW(a,b//2)**2 def C(n,m): if(m>n): return 0 t=f[n]*POW(f[m],mod-2)%mod*POW(f[n-m],mod-2)%mod return t f[0]=1 for i in range(1,500000): f[i]=f[i-1]*i%mod a,b,k,t=list(map(int,input()....
vfc_10746
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/712/D", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 2 2 1\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 1 1 2\n", "output": "31\n", "type": "stdin_stdout" }, { "fn_name": null, "input":...
apps
verifiable_code
249
Solve the following coding problem using the programming language python: Valery is a PE teacher at a school in Berland. Soon the students are going to take a test in long jumps, and Valery has lost his favorite ruler! However, there is no reason for disappointment, as Valery has found another ruler, its length is l...
```python import itertools import math def can_measure(a, d): return any(i + d in a for i in a) def main(): n, l, x, y = list(map(int, input().split())) a = set(map(int, input().split())) can_x = can_measure(a, x) can_y = can_measure(a, y) if can_x and can_y: print(0) elif can_x: print(1) print(y) eli...
vfc_10750
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/479/D", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 250 185 230\n0 185 250\n", "output": "1\n230\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 250 185 230\n0 20 185 250\n", "output": "0\n", "type": "stdin_stdout" }, ...
apps
verifiable_code
250
Solve the following coding problem using the programming language python: As you know, every birthday party has a cake! This time, Babaei is going to prepare the very special birthday party's cake. Simple cake is a cylinder of some radius and height. The volume of the simple cake is equal to the volume of correspondi...
```python import math from functools import reduce class SegmentTree(): def __init__(self, L, function = lambda x,y: x+y): self.function = function N = self.size = len(L) M = 1 << N.bit_length() self.margin = 2*M - N self.L = [None for i in range(self.margin)] + L for...
vfc_10754
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/629/D", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n100 30\n40 10\n", "output": "942477.796077000\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1 1\n9 7\n1 4\n10 7\n", "output": "3983.539484752\n", "type": "stdin_stdout"...
apps
verifiable_code
251
Solve the following coding problem using the programming language python: There is a toy building consisting of $n$ towers. Each tower consists of several cubes standing on each other. The $i$-th tower consists of $h_i$ cubes, so it has height $h_i$. Let's define operation slice on some height $H$ as following: for e...
```python def ii(): return int(input()) def mi(): return list(map(int, input().split())) def li(): return list(mi()) n, k = mi() h = li() m = max(h) f = [0] * (m + 1) for hi in h: f[hi] += 1 for i in range(m - 1, 0, -1): f[i] += f[i + 1] ans = 0 i = m while i > 0: if f[i] == n: break ...
vfc_10758
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1065/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 5\n3 1 2 2 4\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 5\n2 3 4 5\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, ...
apps
verifiable_code
252
Solve the following coding problem using the programming language python: Alice and Bob are playing yet another card game. This time the rules are the following. There are $n$ cards lying in a row in front of them. The $i$-th card has value $a_i$. First, Alice chooses a non-empty consecutive segment of cards $[l; r]...
```python n = int(input()) l = list(map(int,input().split())) curr = 0 best = 0 prevs = [0] * 31 for v in l: curr += v if v >= 0: for i in range(0, v): prevs[i] = curr for i in range(v, 31): best = max(curr - prevs[i] - i, best) else: for i in range(31): ...
vfc_10762
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1359/D", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n5 -2 10 -1 4\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "8\n5 2 5 3 -30 -30 6 9\n", "output": "10\n", "type": "stdin_stdout" }, { "fn_name...
apps
verifiable_code
253
Solve the following coding problem using the programming language python: Mishka is decorating the Christmas tree. He has got three garlands, and all of them will be put on the tree. After that Mishka will switch these garlands on. When a garland is switched on, it periodically changes its state — sometimes it is lit...
```python a, b, c = sorted(map(int, input().split())) if a > 3: print('NO') elif a == 3: if b > 3: print('NO') elif b == 3: if c > 3: print('NO') else: print("YES") elif a == 1: print('YES') else: if b == 2: print('YES') elif b > 4: print('NO') elif b == 4: if c == 4: print('YES') else: ...
vfc_10766
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/911/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 2 3\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 2 3\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "...
apps
verifiable_code
254
Solve the following coding problem using the programming language python: You are given a string $s$ of length $n$ consisting of lowercase Latin letters. You may apply some operations to this string: in one operation you can delete some contiguous substring of this string, if all letters in the substring you delete ar...
```python #credits https://www.geeksforgeeks.org/minimum-steps-to-delete-a-ssing-after-repeated-deletion-of-palindrome-subssings/ n=int(input()) s=input() N = len(s) dp = [[0 for x in range(N + 1)] for y in range(N + 1)] D = [[[] for x in range(N + 1)] for y in range(N + 1)] ss="" re="" for i in ...
vfc_10770
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1132/F", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\nabaca\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "8\nabcddcba\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "inp...
apps
verifiable_code
255
Solve the following coding problem using the programming language python: The Berland State University is hosting a ballroom dance in celebration of its 100500-th anniversary! n boys and m girls are already busy rehearsing waltz, minuet, polonaise and quadrille moves. We know that several boy&girl pairs are going to ...
```python n=int(input()) a=sorted(map(int,input().split())) m=int(input()) b=sorted(map(int,input().split())) c=0 for i in range(n): for j in range(m): if abs(a[i]-b[j]) <= 1: b[j]=-10 c+=1 break print(c) ```
vfc_10774
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/489/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 4 6 2\n5\n5 1 5 7 9\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1 2 3 4\n4\n10 11 12 13\n", "output": "0\n", "type": "stdin_stdout" }, { ...