source
stringclasses
4 values
task_type
stringclasses
1 value
in_source_id
stringlengths
0
138
problem
stringlengths
219
13.2k
gold_standard_solution
stringlengths
0
413k
problem_id
stringlengths
5
10
metadata
dict
verification_info
dict
taco
verifiable_code
https://codeforces.com/problemset/problem/11/E
Solve the following coding problem using the programming language python: Jack has become a soldier now. Unfortunately, he has trouble with the drill. Instead of marching beginning with the left foot and then changing legs with each step, as ordered, he keeps repeating a sequence of steps, in which he sometimes makes ...
```python def solve(): original = input() temp = [original[0]] for i in range(1, len(original)): if original[i] == original[i - 1] != 'X': temp.append('X') temp.append(original[i]) augmented = ''.join(temp) answer = 0 if augmented[0] == augmented[-1] != 'X': answer = max(rate(augmented + 'X'), rate('X' +...
vfc_89207
{ "difficulty": "very_hard", "memory_limit": "64.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/11/E", "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "RXXRLRRLRR\n", "output": "57.142857\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "RXRRXXXRXXRR\n", "output": "37.500000\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/cutting-rectangles3659/1
Solve the following coding problem using the programming language python: Given a rectangle of dimensions L x B find the minimum number (N) of identical squares of maximum side that can be cut out from that rectangle so that no residue remains in the rectangle. Also find the dimension K of that square. Example 1: Inpu...
```python import math class Solution: def minimumSquares(self, L, B): a = math.gcd(L, B) return (L * B // (a * a), a) ```
vfc_89211
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/cutting-rectangles3659/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "L = 2, B = 4", "output": "N = 2, K = 2", "type": "stdin_stdout" }, { "fn_name": null, "input": "L = 6, B = 3", "output": " N = 2, K = 3", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: IndiaHacks-2016 is going on and Tom and Jerry also came to participate in the contest. Tom and Jerry started fighting in the contest too, as always! As this is the INDIAHACKS Contest so this time the fight is on numbers. They ended up bringing a...
```python for _ in range(int(input())): n, m1, m2 = list(map(int, input().split())) x = n % (m1 + m2) if m1 == 0: print(1) elif x < m1: print(0) elif x == m1 or x >= m2: print(1) else: x /= m1 print(1 if x & 1 else 0) ```
vfc_89212
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n1 1 3\n3 3 5\n7 7 9\n13 0 2\n21 8 10\n31 5 7\n43 4 6\n57 5 7\n73 8 10\n91 0 2", "output": "1\n1\n1\n1\n1\n1\n1\n1\n1\n1", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n1 1 2\n2 1 2\n...
taco
verifiable_code
https://www.codechef.com/problems/CROSBLK
Solve the following coding problem using the programming language python: Read problem statements in [Mandarin], [Bengali], [Russian], and [Vietnamese] as well. Chef is very adventurous, so he asked Bob to give him a task. Bob gave him a sequence of blocks with heights A_{1}, A_{2}, \ldots, A_{N}. Chef is at the fir...
```python t = int(input()) for i in range(t): N = int(input()) L = list(map(int, input().split())) if L[0] < max(L): print(-1) continue stack = [] for i in range(1, N): if len(stack) == 0 or L[i] < stack[-1]: stack.append(L[i]) else: while len(stack) > 0 and stack[-1] <= L[i]: stack.pop() stac...
vfc_89216
{ "difficulty": "medium_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CROSBLK", "time_limit": "0.5 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5\n9 15 8 13 8\n9\n20 16 13 9 17 11 15 8 7", "output": "-1\n4", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/print-matrix-in-diagonal-pattern/1
Solve the following coding problem using the programming language python: Given a matrix M of n*n size, the task is to complete the function which prints its elements in a diagonal pattern as depicted below. Example 1: Input: N = 3 mat[][] = {{1 2 3},{4 5 6},{7 8 9}} Output: 1 2 4 7 5 3 6 8 9 Example 2: Input: N =...
```python class Solution: def matrixDiagonally(self, mat): n = len(mat) m = len(mat[0]) list = [[] for i in range(n + m - 1)] for i in range(n): for j in range(m): sum = i + j if sum % 2 == 0: list[sum].insert(0, mat[i][j]) else: list[sum].append(mat[i][j]) res = [] for i in list:...
vfc_89221
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/print-matrix-in-diagonal-pattern/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 3\r\nmat[][] = {{1 2 3},{4 5 6},{7 8 9}}", "output": "1 2 4 7 5 3 6 8 9", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 2\r\nmat[][] = {{1 2},{3 4}}", "output": "1 2 3 4", ...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/search-in-rotated-array-2/1
Solve the following coding problem using the programming language python: Given a sorted and rotated array A of N elements which is rotated at some point, and may contain duplicates and given an element key. Check whether the key exist in the array A or not. Example 1: Input: N = 7 A[] = {2,5,6,0,0,1,2} key = 0 Output...
```python class Solution: def Search(self, n, arr, k): if k in arr: return 1 else: return 0 ```
vfc_89222
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/search-in-rotated-array-2/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 7\r\nA[] = {2,5,6,0,0,1,2}\r\nkey = 0", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 7\r\nA[] = {2,5,6,0,0,1,2}\r\nkey = 3", "output": "0", "type": "stdin...
taco
verifiable_code
https://www.codechef.com/problems/CHEFFAV
Solve the following coding problem using the programming language python: A string S is called *Chef's favourite* if every substring chef in S must have a substring code before it. You are given a string S of size N that contains both code and chef as a substring. Please determine if S is Chef's favourite. Note: A s...
```python for _ in range(int(input())): n = int(input()) s = input() k = s.find('chef', 0, n) y = s.find('code', 0, k) if y >= 0: print('AC') else: print('WA') ```
vfc_89223
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CHEFFAV", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n8\ncodechef\n8\nchefcode\n14\nsxycodeghychef\n21\nsxychefvsvcodehghchef\n", "output": "AC\nWA\nAC\nWA\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Once a Mathematician was trapped by military people during a world war with his forty colleagues. The colleagues were without any weapons, only the mathematician had a knife. And with no weapons they were not able to fight with the military, so ...
```python ''' int main() { int t; cin>>t; while(t--) { long long a; cin>>a; if(a&(a-1)==0) cout<<"1\n"; else { long long n=a,p=2,m=0; while(p<n) { m++; p=2*p; } p=p/2; //cout<<" m->"<<m<<" p->"<<p<<endl; cout<<2*(n-p)+1<<endl;; } } } ''' t=eval(i...
vfc_89227
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "880\n56733536\n86490977\n79553416\n36985321\n11086830\n95548856\n72189915\n59190978\n70048426\n426220\n53630037\n29016399\n76126438\n29995296\n73913177\n50163456\n1925581\n36770113\n53453198\n14293189\n38114987\n28195216\n224395\n9...
taco
verifiable_code
https://codeforces.com/problemset/problem/142/E
Solve the following coding problem using the programming language python: Greg the Dwarf has been really busy recently with excavations by the Neverland Mountain. However for the well-known reasons (as you probably remember he is a very unusual dwarf and he cannot stand sunlight) Greg can only excavate at night. And i...
```python import math mas = list(map(int, input().split())) r = mas[0] h = mas[1] l = (r ** 2 + h ** 2) ** 0.5 mas = list(map(float, input().split())) x1 = mas[0] y1 = mas[1] z1 = mas[2] mas = list(map(float, input().split())) x2 = mas[0] y2 = mas[1] z2 = mas[2] s = 0 if z1 == 0 and z2 == 0: s = ((x1 - x2) ** 2 + (y1 ...
vfc_89237
{ "difficulty": "very_hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/142/E", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 2\n1.0 0.0 0.0\n-1.0 0.0 0.0\n", "output": "2.0000000000\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "939 172\n760.602725383313210 550.640076764737840 0.000000000000000\n0.00000000000...
taco
verifiable_code
https://codeforces.com/problemset/problem/1005/C
Solve the following coding problem using the programming language python: A sequence $a_1, a_2, \dots, a_n$ is called good if, for each element $a_i$, there exists an element $a_j$ ($i \ne j$) such that $a_i+a_j$ is a power of two (that is, $2^d$ for some non-negative integer $d$). For example, the following sequence...
```python from collections import defaultdict n = int(input()) a = [int(i) for i in input().split()] arr = defaultdict(int) for i in a: arr[i] += 1 powers = [1 << i for i in range(32)] count = 0 x = list(arr.items()) for (i, c) in x: good = 0 for p in powers: n = p - i if n == i: if arr[n] > 1: good = 1 ...
vfc_89242
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1005/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n4 7 1 5 4 9\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 2 3 4 5\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, ...
taco
verifiable_code
https://www.codechef.com/problems/CHEFWM
Solve the following coding problem using the programming language python: Chef recently created a new Tiling Window Manager called ChefWM. He wants to find out the maximum number of columns of windows he can fit on the screen and he needs your help. Consider the screen to be an axis-aligned rectangle in the xy-plane,...
```python def unique_prime_factors(n): count = 0 i = 2 while i ** 2 <= n: if n % i == 0: count += 1 while n % i == 0: n /= i i += 1 if n != 1: count += 1 return count t = int(input()) while t: (n, m) = map(int, input().split()) prm_fac = unique_prime_factors(m) ans = 0 i = prm_fac while i > 0:...
vfc_89246
{ "difficulty": "medium_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CHEFWM", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n8 210\n1 100\n100 5\n10 1\n9 2310\n", "output": "4\n1\n1\n0\n3\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/COOK06/problems/CHEFTEAM
Solve the following coding problem using the programming language python: Chef has N subordinates. In order to complete a very important order he will choose exactly K of them. He can't choose less than K since it will be not enough to complete the order in time. On the other hand if he chooses more than K subordinate...
```python def nCr(n, k): if k > n: return 0 k = min(k, n - k) (num, den) = (1, 1) for i in range(k): num *= n - i den *= i + 1 return num / den def Main(): for cases in range(int(input())): (a, b) = [int(x) for x in input().split()] print(nCr(a, b)) Main() ```
vfc_89250
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/COOK06/problems/CHEFTEAM", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2 1\n3 3\n10 5\n", "output": "2\n1\n252\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: The mayor of Amida, the City of Miracle, is not elected like any other city. Once exhausted by long political struggles and catastrophes, the city has decided to leave the fate of all candidates to the lottery in order to choose all candidates f...
```python while True: (n, m, a) = map(int, input().split(' ')) if n == 0 and m == 0 and (a == 0): break hl = [list(map(int, input().split(' '))) for i in range(m)] hl.sort(key=lambda x: x[0], reverse=True) vl = a for l in hl: if l[1] == vl: vl = l[2] elif l[2] == vl: vl = l[1] print(vl) ```
vfc_89254
{ "difficulty": "unknown_difficulty", "memory_limit": "134.217728 megabytes", "memory_limit_bytes": null, "problem_url": null, "time_limit": "8.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 4 1\n3 1 2\n2 2 4\n3 3 4\n1 3 4\n0 0 0", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 4 1\n3 1 2\n2 2 3\n4 3 4\n1 3 4\n0 0 0", "output": "4\n", "type": "std...
taco
verifiable_code
https://codeforces.com/problemset/problem/334/D
Solve the following coding problem using the programming language python: Gerald plays the following game. He has a checkered field of size n × n cells, where m various cells are banned. Before the game, he has to put a few chips on some border (but not corner) board cells. Then for n - 1 minutes, Gerald every minute ...
```python import os import sys from math import * from collections import * from bisect import * from io import BytesIO, IOBase def vsInput(): sys.stdin = open('input.txt', 'r') sys.stdout = open('output.txt', 'w') BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.file...
vfc_89258
{ "difficulty": "medium_hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/334/D", "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "999 0\n", "output": "1993", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 5\n2 6\n5 2\n4 3\n6 6\n2 5\n", "output": "2", "type": "stdin_stdout" }, { "fn_name": nul...
taco
verifiable_code
Solve the following coding problem using the programming language python: Dr. Asimov, a robotics researcher, released cleaning robots he developed (see Problem B). His robots soon became very popular and he got much income. Now he is pretty rich. Wonderful. First, he renovated his house. Once his house had 9 rooms th...
```python mv = ((-1, 0), (0, 1), (1, 0), (0, -1)) d2c = {0: '.', 1: 'E'} while True: (n, k) = map(int, input().split()) if n == 0: break (k, n1) = (k - 1, n - 1) if n & 1 or k >= 1 << (n >> 1): print('No\n') continue arr = [[-1 for c in range(n)] for r in range(n)] for c in range(n): arr[0][c] = k >> (n1 ...
vfc_89262
{ "difficulty": "unknown_difficulty", "memory_limit": "134.217728 megabytes", "memory_limit_bytes": null, "problem_url": null, "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 1\n2 3\n6 4\n0 0", "output": "No\n\nNo\n\n..EEEE\n..E..E\nEEE..E\nE..EEE\nE..E..\nEEEE..\n\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 1\n2 3\n6 4\n0 0", "output": "....\n.EE...
taco
verifiable_code
https://codeforces.com/problemset/problem/552/E
Solve the following coding problem using the programming language python: Vanya is doing his maths homework. He has an expression of form $x_{1} \diamond x_{2} \diamond x_{3} \diamond \ldots \diamond x_{n}$, where x_1, x_2, ..., x_{n} are digits from 1 to 9, and sign [Image] represents either a plus '+' or the multipl...
```python s = input() d = list(s.split('*')) last = 0 po = [] ki = [] for i in range(len(d)): po += [last] ki += [len(d[i]) + last] last += len(d[i]) + 1 ans = [eval(s)] for a in po: for b in ki: if a > b - 2: continue x = s[:a] + '(' + s[a:b] + ')' + s[b:] ans += [eval(x)] print(max(ans)) ```
vfc_89266
{ "difficulty": "hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/552/E", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3+5*7+8*4\n", "output": "303\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2+3*5\n", "output": "25\n", "type": "stdin_stdout" }, { "fn_name": null, "input...
taco
verifiable_code
https://www.codechef.com/problems/FREQFUN
Solve the following coding problem using the programming language python: Read problem statements in [Hindi],[Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef had a sequence $S_{0}, S_{1}, \ldots, S_{N-1}$; each element of this sequence was an integer between $0$ and $N-1$ (inclusive). Unfortun...
```python def lower(x, b): l = 0 h = len(b) - 1 d = {} while l <= h: m = (l + h) // 2 if b[m] == x: return m elif b[m] < x: l = m + 1 elif b[m] > x: d[b[m]] = m h = m - 1 k = len(d) if k > 0: mi = list(d.keys()) p = mi[k - 1] return d[p] else: return None for _ in range(int(input())):...
vfc_89271
{ "difficulty": "very_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/FREQFUN", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n3\n-1 0 -1\n0 3 0 0\n3\n2 2 1\n3 0 0 0\n3\n-1 2 -1\n1 1 1 0\n3\n-1 2 2\n0 1 1 0", "output": "1 0 2\nimpossible\n0 2 0\nimpossible", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/736/B
Solve the following coding problem using the programming language python: Mr. Funt now lives in a country with a very specific tax laws. The total income of mr. Funt during this year is equal to n (n ≥ 2) burles and the amount of tax he has to pay is calculated as the maximum divisor of n (not equal to n, of course). ...
```python def prime(n): if n == 1: return False i = 2 while i * i <= n: if n % i == 0: return False i += 1 return True n = int(input()) if prime(n): print(1) elif n % 2 == 0: print(2) elif prime(n - 2): print(2) else: print(3) ```
vfc_89275
{ "difficulty": "medium_hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/736/B", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "13\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "200000015\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "71...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/killing-spree3020/1
Solve the following coding problem using the programming language python: There are Infinite People Standing in a row, indexed from 1. A person having index 'i' has strength of (i*i). You have Strength 'P'. You need to tell what is the maximum number of People You can Kill With your Strength P. You can only Kill a per...
```python class Solution: def killinSpree(self, n): p = lambda n: n * (n + 1) * (2 * n + 1) // 6 (lo, hi) = (0, n + 1) while lo < hi: mi = lo + (hi - lo) // 2 if p(mi) > n: hi = mi else: lo = mi + 1 return lo - 1 ```
vfc_89279
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/killing-spree3020/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 14", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 10", "output": "2", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/TOTSCR
Solve the following coding problem using the programming language python: Read problems statements in [Hindi], [Mandarin Chinese], [Vietnamese], and [Bengali] as well. There are $K$ problems in a contest with $N$ participants. All the problems don't necessarily have the same points assigned to them - you are given an...
```python for _ in range(int(input())): (n, k) = map(int, input().split()) p = [int(i) for i in input().split()] for i in range(n): s = input() ans = 0 for j in range(k): if s[j] == '1': ans += p[j] print(ans) ```
vfc_89280
{ "difficulty": "medium", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/TOTSCR", "time_limit": "0.5 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2 2\n1 2\n01\n10\n2 2\n1 2\n11\n00\n2 1\n100\n0\n1", "output": "2\n1\n3\n0\n0\n100", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/serialize-and-deserialize-a-binary-tree/1
Solve the following coding problem using the programming language python: Serialization is to store a tree in an array so that it can be later restored and Deserialization is reading tree back from the array. Now your task is to complete the function serialize which stores the tree into an array A[ ] and deSerialize w...
```python from collections import deque def serialize(root, ans): if root is None: return ans queue = deque() queue.append(root) while len(queue) != 0: size = len(queue) for i in range(size): node = queue[0] queue.popleft() if node is None: ans.append(None) continue queue.append(node.left...
vfc_89284
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/serialize-and-deserialize-a-binary-tree/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\r\n / \\\r\n 2 3", "output": "2 1 3", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\r\n / \\\r\n 20 30\r\n / \\\r\n 40 60", "output": "40 20 60...
taco
verifiable_code
https://codeforces.com/problemset/problem/158/C
Solve the following coding problem using the programming language python: Vasya is writing an operating system shell, and it should have commands for working with directories. To begin with, he decided to go with just two commands: cd (change the current directory) and pwd (display the current directory). Directories...
```python def pwd(cur): if len(cur) == 0: print('/') else: print('/' + '/'.join(cur) + '/') def process(cmd, cur): cmd = cmd[3:] ds = cmd.split('/') if cmd[0] == '/': cur = [] for d in ds: if d == '..': cur.pop() elif len(d) > 0: cur.append(d) return cur n = int(input()) cur = [] while n > 0: n...
vfc_89285
{ "difficulty": "medium", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/158/C", "time_limit": "3.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "17\npwd\ncd denwxe/../jhj/rxit/ie\npwd\ncd /tmyuylvul/qev/ezqit\npwd\ncd ../gxsfgyuspg/irleht\npwd\ncd wq/pqyz/tjotsmdzja\npwd\ncd ia/hs/../u/nemol/ffhf\npwd\ncd /lrdm/mvwxwb/llib\npwd\ncd /lmhu/wloover/rqd\npwd\ncd lkwabdw/../wrqn...
taco
verifiable_code
https://codeforces.com/problemset/problem/1147/C
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 stone_piles_nr = int(input()) pile_idx___stones_nr = [int(x) for x in input().split()] min_stones_nr = min(pile_idx___stones_nr) min_count = pile_idx___stones_nr.count(min_stones_nr) if min_count > stone_piles_nr // 2: print('Bob') else: print('Alice') ```
vfc_89289
{ "difficulty": "hard", "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, "...
taco
verifiable_code
Solve the following coding problem using the programming language python: Amer cabs has released a scheme through which a user gets a free drive when he shares a reference code with another Amer app user. Given N number of app users, output total number of free drives gained by all of them. Two same users cannot share...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' t = int(input()) while t > 0: t = t-1 n = int(input()) ans = n*(n-1)/2 print(ans) ```
vfc_89298
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "684\n2924\n7062\n7105\n4716\n9111\n6913\n1421\n9429\n2378\n4540\n9243\n544\n2898\n298\n6607\n4585\n1940\n8635\n5490\n8456\n4913\n5788\n9975\n9536\n1810\n5396\n103\n7349\n438\n1916\n1105\n8690\n6767\n1869\n8552\n4652\n5591\n890\n449...
taco
verifiable_code
https://www.codechef.com/problems/INSTAGRAM
Solve the following coding problem using the programming language python: Chef categorises an instagram account as *spam*, if, the *following* count of the account is more than 10 times the count of *followers*. Given the *following* and *follower* count of an account as X and Y respectively, find whether it is a *s...
```python t = int(input()) for i in range(t): (n, m) = map(int, input().split()) if n > 10 * m: print('YES') else: print('NO') ```
vfc_89302
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/INSTAGRAM", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 10\n10 1\n11 1\n97 7\n", "output": "NO\nNO\nYES\nYES\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Aizu has an ancient legend of buried treasure. You have finally found the place where the buried treasure is buried. Since we know the depth of the buried treasure and the condition of the strata to be dug, we can reach the buried treasure at th...
```python import sys sys.setrecursionlimit(1000000) INF = 10 ** 20 def update_state(state, newx): tmp = list(state) tmp[newx] = 1 return tuple(tmp) def get_co(x, y): dc = do = 0 score = mp[y][x] if score < 0: dc = -score else: do = score return (dc, do) def minimum_cost(x, y, state, ox, goal, dic, w, m):...
vfc_89307
{ "difficulty": "unknown_difficulty", "memory_limit": "134.217728 megabytes", "memory_limit_bytes": null, "problem_url": null, "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3\n100 10 10\n-100 -20 -100\n-100 -20 -100\n-100 -20 -100\n3 3\n100 10 10\n-100 -20 -100\n-100 -20 -20\n-100 -60 -20\n3 3\n100 10 3\n-100 -20 -100\n-20 -20 -20\n-20 -100 -20\n3 3\n100 3 3\n-100 -20 -30\n-100 -20 2\n-100 -20 -20\n...
taco
verifiable_code
https://codeforces.com/problemset/problem/1068/A
Solve the following coding problem using the programming language python: Ivan is collecting coins. There are only $N$ different collectible coins, Ivan has $K$ of them. He will be celebrating his birthday soon, so all his $M$ freinds decided to gift him coins. They all agreed to three terms: Everyone must gift as ma...
```python (n, m, k, l) = map(int, input().split()) a = (l + k) // m if (l + k) % m: a += 1 if a * m > n: print(-1) else: print(a) ```
vfc_89311
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1068/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "20 15 2 3\n", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "10 11 2 4\n", "output": "-1", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/minimum-cost-to-fill-given-weight-in-a-bag1956/1
Solve the following coding problem using the programming language python: Given an array cost[] of positive integers of size N and an integer W, cost[i] represents the cost of i kg packet of oranges, the task is to find the minimum cost to buy W kgs of oranges. If it is not possible to buy exactly W kg oranges then th...
```python class Solution: def minimumCost(self, cost, n, W): def go(ind, currw): if currw > W: return 10 ** 18 if ind == n: if currw == W: return 0 return 10 ** 18 if dp[ind][currw] != -1: return dp[ind][currw] c1 = 10 ** 18 if cost[ind] != -1: c1 = cost[ind] + go(ind, currw...
vfc_89315
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/minimum-cost-to-fill-given-weight-in-a-bag1956/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 5, arr[] = {20, 10, 4, 50, 100}\r\nW = 5", "output": "14", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 5, arr[] = {-1, -1, 4, 3, -1}\r\nW = 5", "output": "-1", "type": ...
taco
verifiable_code
Solve the following coding problem using the programming language python: Ali baba did a trick on the forty thieves and was able to trap them inside a big cave which was the home of wild wolves. The thieves are without any weapons, only the chief of the thieves has knife. With no weapons they will not be able to fight...
```python def josephus_2( n ): from math import log print(2*(n - 2**(int(log(n,2))))+1) x=eval(input()) for i in range(x): y=eval(input()) josephus_2(y) ```
vfc_89324
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "852\n71842736\n72346376\n76872930\n82393580\n67660709\n69548412\n43055611\n47236096\n36164616\n39202086\n99896108\n97851014\n32631241\n18880990\n5330835\n65202736\n52048393\n29706660\n7322517\n97982497\n681492\n52368187\n61330542\n...
taco
verifiable_code
https://codeforces.com/problemset/problem/250/C
Solve the following coding problem using the programming language python: A film festival is coming up in the city N. The festival will last for exactly n days and each day will have a premiere of exactly one film. Each film has a genre — an integer from 1 to k. On the i-th day the festival will show a movie of genre...
```python (n, k) = map(int, input().split()) r = list(map(int, input().split())) dist = [] ans = [0] * (k + 1) for i in range(n): if i == 0 or r[i] != r[i - 1]: dist.append(r[i]) for i in range(len(dist)): if 0 < i < len(dist) - 1 and dist[i - 1] == dist[i + 1]: ans[dist[i]] += 2 else: ans[dist[i]] += 1 (u, v)...
vfc_89329
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/250/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10 3\n1 1 2 3 2 3 3 1 1 3\n", "output": "3", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/TWOGRS
Solve the following coding problem using the programming language python: Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well. This problem has no story, so we at least wish you good luck solving it. Consider a multiset $S$ which contains $A$ copies of the integer ...
```python for _ in range(int(input())): (a, b, c) = map(int, input().split()) if a % 2 == 0 and b % 2 == 0 and (c % 2 == 0): print('YES') elif a % 2 != 0 and b % 2 != 0 and (c % 2 == 0) or (a % 2 == 0 and b % 2 != 0 and (c % 2 != 0)): print('NO') elif a % 2 != 0 and b % 2 == 0 and (c % 2 != 0): if b != 0 or a...
vfc_89333
{ "difficulty": "hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/TWOGRS", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n3 3 3\n3 2 3\n1 1 2\n1 0 1\n1 1 1", "output": "YES\nYES\nNO\nNO\nYES", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1272/E
Solve the following coding problem using the programming language python: You are given an array $a$ consisting of $n$ integers. In one move, you can jump from the position $i$ to the position $i - a_i$ (if $1 \le i - a_i$) or to the position $i + a_i$ (if $i + a_i \le n$). For each position $i$ from $1$ to $n$ you w...
```python from copy import deepcopy from collections import defaultdict from queue import Queue n = int(input()) arr = [int(x) for x in input().split()] d = [-1] * n parity = [x % 2 for x in arr] done = Queue() lrs = defaultdict(list) for i in range(n): put = False if i - arr[i] >= 0: if parity[i] != parity[i - arr...
vfc_89337
{ "difficulty": "hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1272/E", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n4 5 7 6 7 5 4 4 6 4\n", "output": "1 1 1 2 -1 1 1 3 1 1 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "100\n10 3 10 3 5 4 10 9 9 8 7 10 3 10 8 9 7 7 8 10 7 8 3 10 4 5 10 10 3 9 10 6 ...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/deficient-number1612/1
Solve the following coding problem using the programming language python: ​Given a number x, your task is to find if this number is Deficient number or not. A number x is said to be Deficient Number if sum of all the divisors of the number denoted by divisorsSum(x) is less than twice the value of the number x. ...
```python class Solution: def isDeficient(self, x): c = 0 for i in range(1, x + 1): if x % i == 0: c += i if c < 2 * x: return 'YES' else: return 'NO' ```
vfc_89346
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/deficient-number1612/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "x = 21", "output": "YES", "type": "stdin_stdout" }, { "fn_name": null, "input": "x = 12", "output": "NO", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/337/C
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 (n, m, k) = map(int, input().split()) MOD = 1000000009 x = m - (n // k * (k - 1) + n % k) if x <= 0: print(m % MOD) return print((m - x + (pow(2, x + 1, MOD) + 2 * MOD - 2) * k - x * (k - 1)) % MOD) ```
vfc_89347
{ "difficulty": "medium_hard", "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...
taco
verifiable_code
https://www.codechef.com/problems/BREAK
Solve the following coding problem using the programming language python: Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has to cook many dishes today. In between cooking two of them, he decided to relax and play a card game with his friend. The game is p...
```python def shift(a, l, r): carry = a[l] a[l] = a[r] for i in range(l + 1, r + 1): temp = carry carry = a[i] a[i] = temp (t, s) = map(int, input().split()) ans = ['' for i in range(t)] for i in range(t): n = int(input()) arr = list(map(int, input().split())) brr = list(map(int, input().split())) arr.sort...
vfc_89355
{ "difficulty": "very_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/BREAK", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 1\n3\n2 1 1\n3 2 3\n3\n4 1 3\n3 5 2\n3\n5 4 6\n1 3 2\n2\n1 1\n1 1\n", "output": "YES\nNO\nNO\nNO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 2\n3\n2 1 1\n3 2 3\n3\n4 1 3\n3 5 2\n3\...
taco
verifiable_code
https://www.codechef.com/problems/LEBAMBOO
Solve the following coding problem using the programming language python: Read problems statements in Mandarin Chinese here ------ Problem Statement ------ Little Elephant from Zoo of Lviv likes bamboo very much. He currently has n stems of bamboo, H_{i} - height of i-th stem of bamboo (0-based numeration). Toda...
```python class Solu(object): def solve(self, N, H, D): if N == 1: return max(H[0] - D[0], -1) elif N == 2: a = H[0] - D[0] b = H[1] - D[1] if a == 0 and b == 0: return 0 elif a != b and abs(a) == abs(b): return abs(a) else: return -1 else: d = sum(D) h = sum(H) if d < h: ...
vfc_89363
{ "difficulty": "medium_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/LEBAMBOO", "time_limit": "1.88586 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1\n1\n2\n2\n1 2\n2 1\n3\n3 2 2\n4 5 3", "output": "-1\n1\n5", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/count-divisors-of-factorial4508/1
Solve the following coding problem using the programming language python: Given a number N, count total number of divisors of N!. Example 1: Input : N = 4 Output: 8 Explaination: 4! is 24. Divisors of 24 are 1, 2, 3, 4, 6, 8, 12 and 24. Example 2: Input : N = 5 Output : 16 Explaination: 5! is 120. Divisors of 120 are...
```python import math as m class Solution: def totalDivisors(self, N): primes = [True] * (N + 1) prime_factors = [] for i in range(2, N + 1): if primes[i]: j = i * i while j <= N: primes[j] = False j += i k = i count = 0 while k <= N: count += N // k k *= i prime_...
vfc_89367
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/count-divisors-of-factorial4508/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 4", "output": "8", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 5", "output": "16", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/580/B
Solve the following coding problem using the programming language python: Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the...
```python (n, d) = map(int, input().split()) l_p = list() for _ in range(n): l_p.append(list(map(int, input().split()))) l_p.sort() (l, h) = (0, 0) f = 0 f_m = 0 while h < len(l_p): if l_p[h][0] - l_p[l][0] >= d: f -= l_p[l][1] l += 1 else: f += l_p[h][1] h += 1 f_m = max(f_m, f) print(f_m) ```
vfc_89368
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/580/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 5\n75 5\n0 100\n150 20\n75 1\n", "output": "100\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 100\n0 7\n11 32\n99 10\n46 8\n87 54\n", "output": "111\n", "type": "stdin_st...
taco
verifiable_code
https://codeforces.com/problemset/problem/615/C
Solve the following coding problem using the programming language python: A boy named Ayrat lives on planet AMI-1511. Each inhabitant of this planet has a talent. Specifically, Ayrat loves running, moreover, just running is not enough for him. He is dreaming of making running a real art. First, he wants to construct ...
```python (s, t) = (input(), input()) (p, d) = ([], [[] for i in range(26)]) for (i, q) in enumerate(s): d[ord(q) - 97].append(i) (i, n) = (0, len(t)) s += '+' t += '-' while i < n: q = t[i] a = b = c = 0 for j in d[ord(q) - 97]: k = 1 while t[i + k] == s[j + k]: k += 1 if k > a: (a, b, c) = (k, j + 1, ...
vfc_89372
{ "difficulty": "hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/615/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "abc\ncbaabc\n", "output": "2\n3 1\n1 3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "aaabrytaaa\nayrat\n", "output": "3\n1 1\n6 5\n8 7\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/586/B
Solve the following coding problem using the programming language python: A little boy Laurenty has been playing his favourite game Nota for quite a while and is now very hungry. The boy wants to make sausage and cheese sandwiches, but first, he needs to buy a sausage and some cheese. The town where Laurenty lives in...
```python N = int(input()) x = [[0] * N, [0] * N] a = list(map(int, input().split())) adash = [0] for i in range(N - 1): adash.append(adash[-1] + a[i]) b = list(map(int, input().split())) bdash = [0] for i in range(N - 1): bdash.append(bdash[-1] + b[i]) c = list(map(int, input().split())) kachra = [] for i in range(N...
vfc_89377
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/586/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 2 3\n3 2 1\n3 2 2 3\n", "output": "12\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 2\n3 3\n2 1 3\n", "output": "11\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/series-x14741/1
Solve the following coding problem using the programming language python: Given a series of numbers 2, 10, 30, 68, 130.., Identify the pattern in the series. You are given an integer X you need to find out the X'th number in the series. Example 1: Input: X = 1 Output: 2 Explanation: 2 is the first number in the series...
```python class Solution: def X1Series(self, X): return pow(X, 3) + X ```
vfc_89381
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/series-x14741/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "X = 1", "output": "2", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/CSUBS
Solve the following coding problem using the programming language python: Read problems statements in [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well. Chef is playing a game where he has an array $A$ of $N$ integers, and an integer $K$. He looks at every subarray of length $K$, and writes its sum on...
```python for _ in range(int(input())): (n, k) = map(int, input().split()) t = list(map(int, input().split())) ans = 0 for i in range(k): d = {} q = i while q < n: if t[q] not in d: d[t[q]] = 1 else: d[t[q]] += 1 q += k l = list(d.values()) s = sum(l) mx = max(l) ans += s - mx print(...
vfc_89382
{ "difficulty": "hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CSUBS", "time_limit": "0.5 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3 3 \n1 2 3\n2 1\n4 6", "output": "0\n1", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Times Square in the capital city of NY has a rectangular shape with the size n × m meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the size a × a. ...
```python def ceiling(n,a): div=n/a res=n%a if res!=0: div+=1 return int(div) in1=input() lst=in1.split() n=int(lst[0]) m=int(lst[1]) a=int(lst[2]) num1=ceiling(n,a) num2=ceiling(m,a) print(num1*num2) ### ofc! multiply ```
vfc_89386
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "222 332 5", "output": "10100", "type": "stdin_stdout" }, { "fn_name": null, "input": "1001 1000 10", "output": "3015", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/BATH
Solve the following coding problem using the programming language python: A geyser has a capacity of X litres of water and a bucket has a capacity of Y litres of water. One person requires exactly 2 buckets of water to take a bath. Find the maximum number of people that can take bath using water from one completely f...
```python n = int(input()) for i in range(n): (a, b) = map(int, input().split()) p = b * 2 print(a // p) ```
vfc_89390
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/BATH", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n10 6\n25 1\n100 10\n30 40\n", "output": "0\n12\n5\n0\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Ted: Robin, get me my legal pad. It's Pros and Cons Time! There is a long list of n girls in front of Barney, and he is to calculate the optimal "happiness" he can find by selecting exactly 2 girls. (Why 2? No one knows!) Ted, as a fan of pros...
```python def HQ(h, a, A): return h + a - float(A) / 2 t = int(input()) while t > 0: t -= 1 n = int(input()) list_a = list() for i in range(n): list_a.append([int(i) for i in input().strip().split(' ')]) A = sum([i[1] for i in list_a]) H = sorted([HQ(i[0], i[1], A) for i in list_a], reverse=True) print(int...
vfc_89395
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n10\n45 19\n39 9\n42 5\n98 0\n19 14\n6 10\n75 1\n61 18\n46 6\n92 1\n10\n68 2\n38 11\n22 9\n41 15\n85 12\n68 18\n74 3\n51 3\n82 8\n5 16\n10\n34 14\n3 14\n82 16\n29 9\n9 15\n0 6\n43 3\n91 2\n15 13\n59 6\n10\n22 9\n39 19\n62 9\n55 ...
taco
verifiable_code
https://www.codechef.com/problems/PRMRANGE
Solve the following coding problem using the programming language python: Given an empty array A of infinite length and a positive integer K you have to process Q queries of type: - ! l r x: Fill the value x in all the empty places in the array from index l to r (both inclusive). - ? l r: Print the number of pri...
```python import math def distinctPrimeFactors(num): primes = set() if num == 2: primes.add(num) sqrt = int(math.sqrt(num)) for j in range(2, sqrt + 1): if num % j == 0: primes.add(j) while num % j == 0: num //= j if num > 2: primes.add(num) return primes lst = {} primes = {} rangeData = {} (k, q...
vfc_89399
{ "difficulty": "very_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/PRMRANGE", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "20 5\n? 1 5\n! 3 5 4\n? 1 5\n! 1 4 15\n? 1 5\n", "output": "0\n1\n2\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/680/D
Solve the following coding problem using the programming language python: Limak is a little polar bear. He plays by building towers from blocks. Every block is a cube with positive integer length of side. Limak has infinitely many blocks of each side length. A block with side a has volume a3. A tower consisting of bl...
```python import sys def cube_root(x): v = max(int(x ** (1.0 / 3.0)) - 1, 0) while (v + 1) ** 3 <= x: v += 1 return v def solution(x): if x <= 7: return (x, x) next_smaller = cube_root(x) ** 3 candidate = solution(x - next_smaller) candidate = (candidate[0] + 1, candidate[1] + next_smaller) prenext_smalle...
vfc_89403
{ "difficulty": "hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/680/D", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1000000000000000\n", "output": "18 999999993541753\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "994\n", "output": "12 941\n", "type": "stdin_stdout" }, { "fn_n...
taco
verifiable_code
https://www.codechef.com/EPNY2012/problems/EPI02
Solve the following coding problem using the programming language python: Once upon a time, a king and a few of his soldiers were caught by an enemy king in a war. He puts them in a circle. The first man in the circle has to kill the second man, the third man has to kill the fourth, fifth man to kill the sixth and ...
```python n = int(input()) arr = [] for i in range(1, n + 1): arr.append(i) c = 0 i = 0 f = 0 while c < n - 1: if arr[i % n] != -1 and f: arr[i % n] = -1 c = c + 1 f = 0 if arr[i % n] != -1: f = 1 i = i + 1 for i in range(0, n): if arr[i] != -1: ans = arr[i] break print(ans) ```
vfc_89408
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/EPNY2012/problems/EPI02", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "9\n", "output": "3\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: India is a cricket crazy nation. Chang also loves cricket and computations related to cricket. Chang has created a Cricket app.This app analyses the performance of a cricketer. If a cricketer under-performs, then a negative rating is awarded. If...
```python def cricketrating(arr,size): max_here=arr[0] max_sofar=arr[0] for i in range(1,size): max_here=max_here+a[i] if max_here<0: max_here=0 max_sofar=max(max_sofar,max_here) return max_sofar n=eval(input()) if(n==0): print(0) exit() a=list(map(int,input().split())) print(cricketrating(a,len(a))) ``...
vfc_89413
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8943\n-91 -11 -31 50 12 26 27 -51 -37 83 49 37 -52 -55 12 19 -14 17 -42 -48 82 92 98 96 -86 -89 99 38 -73 -51 -99 1 -96 35 -7 37 -86 -38 -16 23 -25 61 -45 -62 -24 -23 -94 30 -99 22 20 61 -90 47 91 23 -86 -72 23 31 -3 -73 -63 31 -79...
taco
verifiable_code
https://codeforces.com/problemset/problem/1358/B
Solve the following coding problem using the programming language python: Maria is the most active old lady in her house. She was tired of sitting at home. She decided to organize a ceremony against the coronavirus. She has $n$ friends who are also grannies (Maria is not included in this number). The $i$-th granny is...
```python for s in [*open(0)][2::2]: print(max((i * (x <= i) for (i, x) in enumerate(sorted(map(int, s.split())), 1))) + 1) ```
vfc_89421
{ "difficulty": "easy", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1358/B", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n5\n1 1 2 2 1\n6\n2 3 4 5 6 7\n6\n1 5 4 5 1 9\n5\n1 2 3 5 6\n", "output": "6\n1\n6\n4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "8\n1\n1\n1\n2\n1\n3\n1\n4\n1\n5\n1\n6\n1\n7\n1\n8\n"...
taco
verifiable_code
https://www.codechef.com/AUG17/problems/HILLJUMP
Solve the following coding problem using the programming language python: Chef is going to organize a hill jumping competition and he is going to be one of the judges in it. In this competition there are N hills in a row, and the initial height of i-th hill is Ai. Participants are required to demonstrate their jumping...
```python (n, q) = list(map(int, input().split())) final = [] height = list(map(int, input().split())) for k in range(0, q): b = input().split() if int(b[0]) == 1: step = int(b[1]) - 1 for k in range(0, int(b[2])): temp = 0 j = 1 while j in range(1, 101) and temp == 0 and (step + j < n): if height[st...
vfc_89438
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/AUG17/problems/HILLJUMP", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 3\n1 2 3 4 5\n1 1 2\n2 3 4 -1\n1 1 2\n", "output": "3\n4\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/rearrange-the-array5802/1
Solve the following coding problem using the programming language python: Given an array arr of n integers, task is to print the array in the order – smallest number, largest number, 2nd smallest number, 2nd largest number, 3rd smallest number, 3rd largest number and so on. Example 1: Input: n = 9 arr[] = {1, 9, 2, 8,...
```python class Solution: def rearrangeArray(self, arr, n): result = [] arr.sort() left = 0 right = n - 1 while left < right: result.append(arr[left]) result.append(arr[right]) left += 1 right -= 1 if n % 2 == 1: result.append(arr[left]) for i in range(0, n): arr[i] = result[i] ```
vfc_89442
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/rearrange-the-array5802/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "n = 9\narr[] = {1, 9, 2, 8, 3, 7, 4, 6, 5}", "output": "1 9 2 8 3 7 4 6 5", "type": "stdin_stdout" }, { "fn_name": null, "input": "n = 4\narr[] = {1, 2, 3, 4}", "output": "1 4 2 3", "type...
taco
verifiable_code
https://codeforces.com/problemset/problem/615/B
Solve the following coding problem using the programming language python: This Christmas Santa gave Masha a magic picture and a pencil. The picture consists of n points connected by m segments (they might cross in any way, that doesn't matter). No two segments connect the same pair of points, and no segment connects t...
```python (n, m) = [int(x) for x in input().split()] values = [1] * n nodes = [list() for _ in range(n)] spikes = [0] * n for _ in range(m): (n1, n2) = [int(x) for x in input().split()] if n1 > n2: (n1, n2) = (n2, n1) nodes[n1 - 1].append(n2 - 1) spikes[n1 - 1] += 1 spikes[n2 - 1] += 1 for i in range(0, n): for...
vfc_89443
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/615/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8 6\n4 5\n3 5\n2 5\n1 2\n2 8\n6 7\n", "output": "9\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n", "output": "12\n", "type": "stdin_stdout...
taco
verifiable_code
https://codeforces.com/problemset/problem/334/A
Solve the following coding problem using the programming language python: Gerald has n younger brothers and their number happens to be even. One day he bought n^2 candy bags. One bag has one candy, one bag has two candies, one bag has three candies and so on. In fact, for each integer k from 1 to n^2 he has exactly on...
```python def solve(): n = int(input()) mx = [[0] * n for _ in range(n)] for i in range(n): for j in range(n): mx[i][j] = i * n + j + 1 for i in range(n): ans = [] for j in range(n): ans.append(mx[j][(i + j) % n]) print(*ans) solve() ```
vfc_89456
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/334/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n", "output": "1 4\n2 3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n", "output": "1 16 2 15\n3 14 4 13\n5 12 6 11\n7 10 8 9\n", "type": "stdin_stdout" }, { ...
taco
verifiable_code
https://www.codechef.com/problems/NOMATCH
Solve the following coding problem using the programming language python: You are given an array with $N$ integers: $A[1], A[2], \ldots, A[N]$ (where $N$ is even). You are allowed to permute the elements however you want. Say, after permuting the elements, you end up with the array $A'[1], A'[2], \ldots, A'[N]$. Your ...
```python for i in range(int(input())): n = int(input()) m = list(map(int, input().split()))[:n] m.sort() t = 0 for j in range(n // 2): t += abs(m[j] - m[n - j - 1]) print(t) ```
vfc_89460
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/NOMATCH", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n4\n1 -3 2 -3\n", "output": "9\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.hackerrank.com/challenges/marcs-cakewalk/problem
Solve the following coding problem using the programming language python: Marc loves cupcakes, but he also likes to stay fit. Each cupcake has a calorie count, and Marc can walk a distance to expend those calories. If Marc has eaten $j$ cupcakes so far, after eating a cupcake with $\textbf{C}$ calories he must walk a...
```python import sys n = int(input().strip()) calories = list(map(int, input().strip().split(' '))) calories.sort(reverse=True) print(sum([2 ** j * calories[j] for j in range(n)])) ```
vfc_89464
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.hackerrank.com/challenges/marcs-cakewalk/problem", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 3 2\n", "output": "11\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n7 4 9 6\n", "output": "79\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/combination-sum-1587115620/1
Solve the following coding problem using the programming language python: Given an array of integers and a sum B, find all unique combinations in the array where the sum is equal to B. The same number may be chosen from the array any number of times to make B. Note: 1. All numbers will be positive integers. ...
```python class Solution: def combinationalSum(self, A, B): self.ans = [] A = list(set(A)) A.sort() def recursion(index, ds, B): if index == len(A): if B == 0: self.ans.append(ds) return if index < len(A) and A[index] <= B: recursion(index, ds + [A[index]], B - A[index]) recursion(i...
vfc_89469
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/combination-sum-1587115620/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 4\narr[] = {7,2,6,5}\nB = 16", "output": "(2 2 2 2 2 2 2 2)\n(2 2 2 2 2 6)\n(2 2 2 5 5)\n(2 2 5 7)\n(2 2 6 6)\n(2 7 7)\n(5 5 6)", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 11\nar...
taco
verifiable_code
https://codeforces.com/problemset/problem/1566/A
Solve the following coding problem using the programming language python: You are given two positive integers $n$ and $s$. Find the maximum possible median of an array of $n$ non-negative integers (not necessarily distinct), such that the sum of its elements is equal to $s$. A median of an array of integers of length...
```python from sys import stdin, stdout t = int(stdin.readline()) while t > 0: (n, s) = map(int, stdin.readline().split()) ls = s res = ls // (n - (n - 1) // 2) print(res) t = t - 1 ```
vfc_89472
{ "difficulty": "easy", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1566/A", "time_limit": "1 second" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8\n1 5\n2 5\n3 5\n2 1\n7 17\n4 14\n1 1000000000\n1000000000 1\n", "output": "5\n2\n2\n0\n4\n4\n1000000000\n0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "8\n1 5\n2 5\n3 5\n2 1\n14 17\n4...
taco
verifiable_code
https://codeforces.com/problemset/problem/489/F
Solve the following coding problem using the programming language python: An n × n square matrix is special, if: it is binary, that is, each cell contains either a 0, or a 1; the number of ones in each row and column equals 2. You are given n and the first m rows of the matrix. Print the number of special n × n ma...
```python (a, b, mod) = list(map(int, input().split())) g = [2] * a for i in range(b): t = input() for (x, y) in enumerate(t): if y == '1': g[x] -= 1 one = two = 0 for q in g: if q < 0: print(0) exit(0) if q == 1: one += 1 if q == 2: two += 1 mat = [[0] * 600 for x in range(600)] mat[0][0] = 1 for j i...
vfc_89477
{ "difficulty": "hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/489/F", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 1 1000\n011\n", "output": "2\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/number-of-subarrays-with-maximum-values-in-given-range5949/1
Solve the following coding problem using the programming language python: Given an array of N elements and L and R, print the number of sub-arrays such that the value of the maximum array element in that subarray is at least L and at most R. Example 1: Input : Arr[] = {2, 0, 11, 3, 0} L = 1 and R = 10 Output : 4 Expla...
```python def mgc(n): return n * (n + 1) // 2 class Solution: def countSubarrays(self, a, n, L, R): (fp, lp) = (0, 0) ans = 0 prev = 0 while lp < n: if a[lp] >= L and a[lp] <= R: prev = lp - fp + 1 elif a[lp] > R: prev = 0 fp = lp + 1 lp += 1 ans += prev return ans ```
vfc_89481
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/number-of-subarrays-with-maximum-values-in-given-range5949/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "Arr[] = {2, 0, 11, 3, 0}\nL = 1 and R = 10", "output": "4", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/FINALSUM
Solve the following coding problem using the programming language python: Chef has an array A of length N. In one operation, Chef can: Choose any subarray [L, R] (1 ≤ L ≤ R ≤ N); Add 1 to A_{L}, subtract 1 from A_{L+1}, add 1 to A_{L+2}, subtract 1 from A_{L+3} and so on, till A_{R}. Chef performed Q such operations...
```python for i in range(int(input())): (N, Q) = map(int, input().split()) A = list(map(int, input().split())) Ans = sum(A) for i in range(Q): (L, R) = map(int, input().split()) oe = R - L + 1 if oe % 2 == 1: Ans += 1 print(Ans) ```
vfc_89482
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/FINALSUM", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5 3\n1 3 4 4 2\n1 5\n3 4\n2 2\n1 2\n4\n1 1\n1 1\n", "output": "16\n6\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/261/A
Solve the following coding problem using the programming language python: Maxim always goes to the supermarket on Sundays. Today the supermarket has a special offer of discount systems. There are m types of discounts. We assume that the discounts are indexed from 1 to m. To use the discount number i, the customer tak...
```python def main(): input() q = min(map(int, input().split())) input() aa = sorted(map(int, input().split()), reverse=True) print(sum(aa) - sum(aa[q::q + 2]) - sum(aa[q + 1::q + 2])) main() ```
vfc_89490
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/261/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n2\n4\n50 50 100 100\n", "output": "200\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n2 3\n5\n50 50 50 50 50\n", "output": "150\n", "type": "stdin_stdout" }, { ...
taco
verifiable_code
https://www.codechef.com/CHPTRS01/problems/FUNRUN
Solve the following coding problem using the programming language python: Walter White and Jesse Pinkman (a drug addict) both love to play with chemicals. One day they were playing with some chemicals to make an energy drink. Unknowingly they made a highly powerful drink. To test the drink on others also they called s...
```python l1 = int(input()) for i in range(l1): x = int(input()) y = list(map(int, input().split())) z = list(map(int, input().split())) if max(z) != max(y): print('YES') else: print('NO') ```
vfc_89495
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/CHPTRS01/problems/FUNRUN", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n5\n1 2 3 4 5\n2 7 8 9 9\n\n", "output": "YES\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1095/A
Solve the following coding problem using the programming language python: Polycarp loves ciphers. He has invented his own cipher called repeating. Repeating cipher is used for strings. To encrypt the string $s=s_{1}s_{2} \dots s_{m}$ ($1 \le m \le 10$), Polycarp uses the following algorithm: he writes down $s_1$ o...
```python n = int(input()) s = input() i = 0 ans = '' count = 1 while i < n: ans += s[i] i = i + count count += 1 print(ans) ```
vfc_89499
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1095/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\nbaabbb\n", "output": "bab", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\nooopppssss\n", "output": "oops", "type": "stdin_stdout" }, { "fn_name": null, ...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/is-binary-number-multiple-of-30654/1
Solve the following coding problem using the programming language python: Given a number in its binary form find if the given binary number is a multiple of 3. It is recommended to finish the task using one traversal of input binary number. Example 1: Input: S = "0011" Output: 1 Explanation: "0011" is 3, which is divi...
```python class Solution: def isDivisible(self, s): n = int(s, 2) if n % 3 == 0: return 1 return 0 ```
vfc_89503
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/is-binary-number-multiple-of-30654/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "S = \"0011\"", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "S = \"100\"", "output": "0", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/FLOW006
Solve the following coding problem using the programming language python: You're given an integer N. Write a program to calculate the sum of all the digits of N. -----Input----- The first line contains an integer T, the total number of testcases. Then follow T lines, each line contains an integer N. -----Output--...
```python T = int(input()) for i in range(T): N = int(input()) sum_of_digits = 0 while N > 0: sum_of_digits += N % 10 N //= 10 print(sum_of_digits) ```
vfc_89504
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/FLOW006", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n12345\n31203\n2123\n", "output": "15\n9\n8\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 \n12345\n50368\n2123", "output": "15\n22\n8\n", "type": "stdin_stdout" }, ...
taco
verifiable_code
https://codeforces.com/problemset/problem/71/C
Solve the following coding problem using the programming language python: There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood. Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate i...
```python def gen_prime(n): prime = [] prime.append(2) prime.append(3) prime.append(4) for i in range(5, n + 1): div = False for j in prime: if not i % j: div = True break if not div: prime.append(i) return prime n = int(input()) prime = gen_prime(n) prime = prime[1:] prime.append(n) a = [int(...
vfc_89508
{ "difficulty": "medium_hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/71/C", "time_limit": "0.5 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n0 1 0 0 0 0\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\n1 1 1 1 1 1 1\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": nu...
taco
verifiable_code
https://www.codechef.com/problems/ICL1901
Solve the following coding problem using the programming language python: You were strolling outside the restaurant at the end of the universe. On a metaspiral path you stumble upon a weird device which takes a three-digit number as input and processes it. The Hitchhiker's guide to the galaxy explains that it processe...
```python for _ in range(int(input())): s = input().split() print(len(set(s[0])) ** 3) ```
vfc_89517
{ "difficulty": "medium_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/ICL1901", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n123 5\n", "output": "27\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1132/F
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 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 range(0, N): if re != s[i]: ss += re re = s[i] ss += re a = ss N = len(a) for l in range(1, N + 1): i = 0 j = l - 1 while j < N...
vfc_89525
{ "difficulty": "hard", "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...
taco
verifiable_code
https://www.codechef.com/problems/CHANGEPOS
Solve the following coding problem using the programming language python: There is a 10 \times 10 grid with rows numbered 1 to 10 from top to bottom, and columns 1 to 10 from left to right. Each cell is identified by a pair (r, c) which means that the cell is located at row r and column c. If Chef's current location ...
```python t = int(input()) for i in range(t): (a, b, c, d) = map(int, input().split()) if a == c or b == d: print('2') elif a != c and b != d: print('1') ```
vfc_89529
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CHANGEPOS", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 2 9 8\n5 5 5 7\n8 6 6 8\n3 10 8 10\n", "output": "1\n2\n1\n2\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/296/E
Solve the following coding problem using the programming language python: One day Greg and his friends were walking in the forest. Overall there were n people walking, including Greg. Soon he found himself in front of a river. The guys immediately decided to get across the river. Luckily, there was a boat by the river...
```python from collections import deque (n, k) = [int(i) for i in input().split()] a = [int(i) for i in input().split()] c50 = sum([1 for i in a if i == 50]) c100 = sum([1 for i in a if i == 100]) c = [[0] * 51 for i in range(51)] c[0][0] = 1 c[1][0] = 1 c[1][1] = 1 for x in range(2, 51): for y in range(x + 1): c[x]...
vfc_89533
{ "difficulty": "hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/296/E", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 204\n50\n", "output": "1\n1", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 123\n50 100 50 50 50\n", "output": "9\n4536", "type": "stdin_stdout" }, { "fn_name":...
taco
verifiable_code
https://www.codechef.com/problems/QUEENATTACK
Solve the following coding problem using the programming language python: Chef has started developing interest in playing chess, and was learning how the [Queen] moves. Chef has an empty N \times N chessboard. He places a Queen at (X, Y) and wonders - What are the number of cells that are under attack by the Queen? ...
```python for _ in range(int(input())): (n, x, y) = map(int, input().split()) st = 2 * n - 2 cross = 0 if x == 1 or y == 1 or x == n or (y == n): cross = n - 1 else: cross = min(x, y) - 1 + (n - max(x, y)) cross += min(x - 1, n - y) + min(n - x, y - 1) print(st + cross) ```
vfc_89537
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/QUEENATTACK", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 1 1\n3 2 2\n3 2 1\n2 2 2\n150 62 41\n", "output": "0\n8\n6\n3\n527\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/388/D
Solve the following coding problem using the programming language python: Fox Ciel studies number theory. She thinks a non-empty set S contains non-negative integers is perfect if and only if for any $a, b \in S$ (a can be equal to b), $(a \text{xor} b) \in S$. Where operation xor means exclusive or operation (http:/...
```python from math import factorial MOD = 10 ** 9 + 7 k = int(input()) bink = list(map(int, bin(k)[2:])) N = len(bink) dp = [[[0, 0] for j in range(i + 2)] for i in range(N + 1)] dp[0][0][1] = 1 for i in range(1, N + 1): for j in range(i + 1): dp[i][j][0] += 2 ** j * dp[i - 1][j][0] if j: dp[i][j][0] += dp[i -...
vfc_89542
{ "difficulty": "very_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/388/D", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n", "output": "3\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: <image> At the request of a friend who started learning abacus, you decided to create a program to display the abacus beads. Create a program that takes a certain number as input and outputs a row of abacus beads. However, the number of digits...
```python f = 0 while 1: try: n = int(input()) except: break if f: print() f = 1 a = [['*' for _ in range(5)] for _ in range(8)] for i in range(4, -1, -1): b = n % 10 a[not b // 5][i] = ' ' a[b % 5 + 3][i] = ' ' n //= 10 a[2] = '=' * 5 for i in a: print(''.join(i), end='') print() ```
vfc_89555
{ "difficulty": "unknown_difficulty", "memory_limit": "134.217728 megabytes", "memory_limit_bytes": null, "problem_url": null, "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2006\n1101", "output": "**** \n *\n=====\n * *\n**** \n* ***\n*****\n*****\n\n*****\n \n=====\n ** *\n* * \n*****\n*****\n*****\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/RC122020/problems/RECNDNOS
Solve the following coding problem using the programming language python: Chef has $N$ dishes of different types arranged in a row: $A_1, A_2, \ldots, A_N$, where $A_i$ denotes the type of the $i^{th}$ dish. He wants to choose as many dishes as possible from the given list but while satisfying two conditions: - He ca...
```python t = int(input()) f = 0 y = 0 for _ in range(t): n = int(input()) seq = [int(x) for x in input().split()] prev = seq[0] for i in range(1, len(seq)): if prev == seq[i]: seq[i] = 0 prev = seq[i] ans = 0 anss = 0 for el in seq: if el != 0: c = seq.count(el) if ans < c: ans = c anss =...
vfc_89560
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/RC122020/problems/RECNDNOS", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n5\n1 2 2 1 2\n6\n1 1 1 1 1 1\n8\n1 2 2 2 3 4 2 1\n", "output": "1\n1\n2\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/PCJ18A
Solve the following coding problem using the programming language python: Today Chef wants to evaluate the dishes of his $N$ students. He asks each one to cook a dish and present it to him. Chef loves his secret ingredient, and only likes dishes with at least $X$ grams of it. Given $N$, $X$ and the amount of secret in...
```python t = int(input()) for k in range(t): (a, b) = map(int, input().split()) c = list(map(int, input().split())) c.sort() if c[a - 1] >= b: print('YES') else: print('NO') ```
vfc_89564
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/PCJ18A", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n5 100\n11 22 33 44 55\n5 50\n10 20 30 40 50\n5 45\n12 24 36 48 60\n", "output": "NO\nYES\nYES\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.hackerrank.com/challenges/library-fine/problem
Solve the following coding problem using the programming language python: Your local library needs your help! Given the expected and actual return dates for a library book, create a program that calculates the fine (if any). The fee structure is as follows: If the book is returned on or before the expected return da...
```python def fine(actual, expected): if actual[2] > expected[2]: return 10000 elif actual[2] == expected[2]: if actual[1] > expected[1]: return 500 * (actual[1] - expected[1]) elif actual[1] == expected[1]: if actual[0] > expected[0]: return 15 * (actual[0] - expected[0]) return 0 actual_return_date...
vfc_89572
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.hackerrank.com/challenges/library-fine/problem", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "9 6 2015\n6 6 2015\n", "output": "45\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/WWALK
Solve the following coding problem using the programming language python: Alice and Bob are walking on an infinite straight street. Initially, both are at the position $X=0$ and they start walking in the direction of increasing $X$. After $N$ seconds, they stop. Let's denote Alice's speed and Bob's speed during the $i...
```python t = int(input()) i = 0 while t > i: n = int(input()) m = list(map(int, input().split())) k = list(map(int, input().split())) j = 0 l = 0 (a, b) = (0, 0) while j < n: if m[j] == k[j] and a == b: l += m[j] a += m[j] b += k[j] j += 1 print(l) i += 1 ```
vfc_89576
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/WWALK", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n4\n1 3 3 4\n1 2 4 4\n2\n2 3\n3 2\n2\n3 3\n3 3\n", "output": "5\n0\n6\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1304/B
Solve the following coding problem using the programming language python: Returning back to problem solving, Gildong is now studying about palindromes. He learned that a palindrome is a string that is the same as its reverse. For example, strings "pop", "noon", "x", and "kkkkkk" are palindromes, while strings "moon", ...
```python import sys import math def input(): return sys.stdin.readline().strip() def iinput(): return [int(x) for x in sys.stdin.readline().split()] def main(): (n, m) = iinput() s = dict() z = [] for i in range(n): a = input() b = a[::-1] if a not in s and b not in s: s[a] = 1 elif a in s: s[a]...
vfc_89580
{ "difficulty": "easy", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1304/B", "time_limit": "1 second" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3\ntab\none\nbat\n", "output": "6\ntabbat\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 2\noo\nox\nxo\nxx\n", "output": "6\noxxxxo\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/SUMTRIAN
Solve the following coding problem using the programming language python: Given an integer N, let us consider a triangle of numbers of N lines in which a number a_{11} appears in the first line, two numbers a_{21} and a_{22} appear in the second line, three numbers a_{31}, a_{32} and a_{33} appear in the third line, e...
```python x = int(input()) for i in range(x): y = int(input()) l = [] for j in range(y): p = list(map(int, input().split())) l.append(p) a = y for _ in range(y - 1, -1, -1): for k in range(0, _): l[_ - 1][k] += max(l[_][k], l[_][k + 1]) print(l[0][0]) ```
vfc_89585
{ "difficulty": "easy", "memory_limit": "5000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/SUMTRIAN", "time_limit": "3 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3\n1\n2 1\n1 2 3\n4\n1\n1 2\n4 1 2\n2 3 1 1\n", "output": "5\n9", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n3\n1\n2 1\n1 2 3\n4 \n1 \n1 2 \n4 1 2\n2 0 1 1", "output": "5\n8\n...
taco
verifiable_code
https://codeforces.com/problemset/problem/895/A
Solve the following coding problem using the programming language python: Students Vasya and Petya are studying at the BSU (Byteland State University). At one of the breaks they decided to order a pizza. In this problem pizza is a circle of some radius. The pizza was delivered already cut into n pieces. The i-th piece...
```python def diff(val): return 2 * abs(180 - val) n = int(input()) arr = input().split(' ') arr = [int(x) for x in arr] sum = 0 min_diff = 360 last_idx = 0 for a in arr: sum += a min_diff = min(min_diff, diff(sum)) while sum > 180: sum -= arr[last_idx] last_idx += 1 min_diff = min(min_diff, diff(sum)) if su...
vfc_89595
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/895/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n90 90 90 90\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n100 100 160\n", "output": "40\n", "type": "stdin_stdout" }, { "fn_name": null, ...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/close-to-perfection1525/1
Solve the following coding problem using the programming language python: Given an array arr[] of N Numbers. A Perfect Piece is defined as a subarray such that the difference between the minimum and the maximum value in that range is at most 1. Find the Maximal Length Perfect Piece. Example 1: Input: N = 4 arr[] = {...
```python class Solution: def longestPerfectPiece(self, arr, N): a = b = 0 ans = 1 for j in range(1, len(arr)): if abs(arr[j] - arr[b]) == 1: if a == b or arr[j] != arr[b - 1]: a = b b = j elif arr[j] != arr[b]: a = b = j ans = max(ans, j - a + 1) return ans ```
vfc_89599
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/close-to-perfection1525/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 4\r\narr[] = {8, 8, 8, 8}", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 11\r\narr[] = {5, 4, 5, 5, 6, 7, 8, 8, 8, 7, 6}", "output": "5", "type": "stdin_s...
taco
verifiable_code
Solve the following coding problem using the programming language python: One day, the teacher came up with the following game. The game uses n cards with one number from 1 to 10 and proceeds as follows. 1. The teacher pastes n cards on the blackboard in a horizontal row so that the numbers can be seen, and declares...
```python from functools import reduce from collections import Counter while True: (n, k) = map(int, input().split()) if n == 0: break clst = [int(input()) for _ in range(n)] acc = reduce(lambda x, y: x * y, clst[:k]) scores = [acc] for i in range(n - k): acc = acc // clst[i] * clst[i + k] scores.append(acc...
vfc_89600
{ "difficulty": "unknown_difficulty", "memory_limit": "134.217728 megabytes", "memory_limit_bytes": null, "problem_url": null, "time_limit": "3.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 2\n4\n3\n7\n5\n0 0", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 2\n1\n6\n4\n5\n0 0", "output": "6\n", "type": "stdin_stdout" }, { "fn_name":...
taco
verifiable_code
https://codeforces.com/problemset/problem/892/B
Solve the following coding problem using the programming language python: Hands that shed innocent blood! There are n guilty people in a line, the i-th of them holds a claw with length L_{i}. The bell rings and every person kills some of people in front of him. All people kill others at the same time. Namely, the i-t...
```python def main(): input() claws = list(map(int, input().split())) claws.reverse() alive = 1 kill_counter = claws[0] index = 1 while index < len(claws): if kill_counter == 0: alive += 1 else: kill_counter -= 1 if claws[index] > kill_counter: kill_counter = claws[index] index += 1 print(alive...
vfc_89608
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/892/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n0 1 0 10\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n0 0\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/pell-number1424/1
Solve the following coding problem using the programming language python: Pell numbers are numbers that are similar to the Fibonacci numbers and are generated by below formula P_{n} = 2*P_{n-1} + P_{n-2} with seeds P_{0} = 0 and P_{1} = 1 Your task is to print Nth pell number. Example 1: Input: N = 3 Output: 5 Expla...
```python class Solution: def getNthPell(self, N): if N == 0: return 0 elif N == 1: return 1 else: (a, b, m) = (0, 1, int(1000000000.0) + 7) for i in range(N - 1): c = (2 * b + a) % m a = b b = c return b ```
vfc_89613
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/pell-number1424/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 3", "output": "5", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 4", "output": "12", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Chokudai loves eating so much. However, his doctor Akensho told him that he was overweight, so he finally decided to lose his weight. Chokudai made a slimming plan of a $D$-day cycle. It is represented by $D$ integers $w_0, ..., w_{D-1}$. His w...
```python (S, T, D) = map(int, input().split()) S -= T (*W,) = map(int, input().split()) F = sum(W) if F >= 0: su = S for (i, w) in enumerate(W): su += w if su <= 0: print(i + 1) break else: print(-1) exit(0) su = 0 mi = 0 for d in W: su += d mi = min(mi, su) k = max((S + mi - F - 1) // -F, 0) S += k ...
vfc_89614
{ "difficulty": "unknown_difficulty", "memory_limit": "536.870912 megabytes", "memory_limit_bytes": null, "problem_url": null, "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "65 1 3\n-2 3 -4", "output": "64\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "60 59 1\n-68", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, ...
taco
verifiable_code
https://www.codechef.com/problems/REMONE
Solve the following coding problem using the programming language python: Alice has an array A consisting of N distinct integers. Bob takes exactly N - 1 elements from this array and adds a positive integer X (i.e. X > 0) to each of these numbers and then shuffles them to form a new array B of length N - 1. You are ...
```python for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) a.sort() b.sort() m = min(b) - min(a) M = max(b) - max(a) if M <= 0: print(m) elif n == 2: print(min(m, M)) elif b[0] - a[1] == M: print(M) else: print(m) ```
vfc_89622
{ "difficulty": "medium_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/REMONE", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n4\n1 4 3 8\n15 8 11\n2\n4 8\n10\n2\n2 4\n3", "output": "7\n2\n1", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/DIVEO
Solve the following coding problem using the programming language python: Chef has an integer N. He repeats the following operation until N becomes 1. - Chef chooses an integer X such that X > 1 and X is a divisor of N and then divides N by X (the new value of N becomes N/X). If X is even, Chef gets A points otherwis...
```python def snek(n): even = 0 odd = 0 while n % 2 == 0: n //= 2 even += 1 for j in range(3, int(n ** 0.5) + 1, 2): if n % j == 0: while n % j == 0: n //= j odd += 1 if n != 1: odd += 1 return [even, odd] t = int(input()) for i in range(t): (n, a, b) = map(int, input().split()) ans = snek(n)...
vfc_89634
{ "difficulty": "medium_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/DIVEO", "time_limit": "0.5 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n10 2 3\n15 5 -2\n12 2 3\n8 -1 0\n", "output": "5\n-2\n7\n-1\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1428/D
Solve the following coding problem using the programming language python: To improve the boomerang throwing skills of the animals, Zookeeper has set up an $n \times n$ grid with some targets, where each row and each column has at most $2$ targets each. The rows are numbered from $1$ to $n$ from top to bottom, and the ...
```python from __future__ import division, print_function from fractions import Fraction import sys import os from io import BytesIO, IOBase from heapq import * from math import gcd, factorial, floor, ceil from copy import deepcopy from collections import deque from bisect import bisect_left as bl from bisect import bi...
vfc_89642
{ "difficulty": "hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1428/D", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n2 0 3 0 1 1\n", "output": "5\n1 1\n1 6\n2 3\n2 5\n3 5\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/483/B
Solve the following coding problem using the programming language python: You have two friends. You want to present each of them several positive integers. You want to present cnt_1 numbers to the first friend and cnt_2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also me...
```python (c1, c2, x, y) = list(map(int, input().split())) def get(n): if n - n // (x * y) >= c1 + c2 and n - n // x >= c1 and (n - n // y >= c2): return True else: return False l = 0 r = c1 * x + c2 * y while r - l > 1: m = (l + r) // 2 if get(m): r = m else: l = m print(r) ```
vfc_89647
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/483/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 1 2 3\n", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 3 2 3\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": ...
taco
verifiable_code
https://www.codechef.com/problems/SWAP10HG
Solve the following coding problem using the programming language python: You are given two binary strings $S$ and $P$, each with length $N$. A binary string contains only characters '0' and '1'. For each valid $i$, let's denote the $i$-th character of $S$ by $S_i$. You have to convert the string $S$ into $P$ using ze...
```python def solve(s, p): diffs = 0 for (x, y) in zip(s, p): if x == y: continue if x == '0': if diffs < 1: return 'No' diffs -= 1 else: diffs += 1 return 'Yes' if diffs == 0 else 'No' for _ in range(int(input())): l = int(input()) s = input().strip() p = input().strip() print(solve(s, p))...
vfc_89651
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/SWAP10HG", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2\n00\n00\n3\n101\n010\n4\n0110\n0011\n", "output": "Yes\nNo\nYes\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1039/B
Solve the following coding problem using the programming language python: This is an interactive problem. In the Wonderful Metropolis of the Future, there is no need in subway train drivers. Due to the technological progress, they were replaced by the Artificial Intelligence (AI). Unfortunately, one day the predictio...
```python import sys, random (n, k) = map(int, input().split()) l = 1 r = n count = 0 while True: if l + 200 < r: try1 = (l + r) // 2 print(l, try1, flush=True) s = input() if s == 'Yes': r = min(try1 + 10, n) l = max(1, l - 10) else: l = max(1, try1 - 10) r = min(n, r + 10) else: guess = rand...
vfc_89655
{ "difficulty": "hard", "memory_limit": "512.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1039/B", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 2\n\nYes\n\nNo\n\nYes\n\nseY\n", "output": "1 1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 4\n\nseY\n\npN\n\nYes\n\nsdY\n", "output": "1 1\n1 1\n1 1\n", "type": "stdin...
taco
verifiable_code
https://codeforces.com/problemset/problem/288/C
Solve the following coding problem using the programming language python: Little penguin Polo likes permutations. But most of all he likes permutations of integers from 0 to n, inclusive. For permutation p = p_0, p_1, ..., p_{n}, Polo has defined its beauty — number $(0 \oplus p_{0}) +(1 \oplus p_{1}) + \cdots +(n \o...
```python s = n = int(input()) + 1 (t, r) = ([], list(range(n))[::-1]) k = 2 ** 20 while s: while k >= 2 * s: k //= 2 t = r[n - s:n + s - k] + t s = k - s print(n * n - n) print(' '.join(map(str, t))) ```
vfc_89665
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/288/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n", "output": "20\n0 2 1 4 3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\n", "output": "56\n7 6 5 4 3 2 1 0\n", "type": "stdin_stdout" }, { "fn_name": nul...
taco
verifiable_code
https://www.codechef.com/problems/EDIT
Solve the following coding problem using the programming language python: Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. Sergey has an uppercase Latin letter string S, which he wants to make equal to another uppercase Latin letter string T. However, he is only allowed to do the follow...
```python for _ in range(int(input())): s = input() t = input() (ins, de, sw) = map(int, input().split()) a = [] for _ in range(26): a.append(list(map(int, input().split()))) ls = len(s) lt = len(t) ans = 0 b = [] if ls <= lt: for i in range(ls): if s[i] != t[i]: ans += 1 if ins + de < a[ord(s[...
vfc_89669
{ "difficulty": "very_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/EDIT", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\nJDCJPGROIE\nYFGWDIYAFVMMA\n23 32 4\n0 34 26 11 18 27 14 28 21 22 13 16 14 15 17 25 28 25 24 31 26 39 28 25 25 32\n17 0 18 24 23 21 20 22 24 23 29 11 20 18 13 24 21 21 27 23 27 11 10 13 24 16\n25 30 0 15 38 33 22 26 24 11 34 24 1...
taco
verifiable_code
Solve the following coding problem using the programming language python: Chirag wanted to prepare a Programmin round. He's already got one problem and he wants to set a time limit (TL) on it. Chirag has written n correct solutions. For each correct solution, he knows its running time (in seconds). Chirag has also wr...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' #print 'Hello World!' n = list(map(int,input().split())) a = list(map(int,input().split())) b = list(map(int,input().split())) a.sort() b.sort() magic = max(2*a[0], a[len(a)-1]...
vfc_89673
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8 4\n1 2 49 99 99 95 78 98\n100 100 100 100", "output": "99", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 6\n4 5 3\n8 9 7 10 7 11", "output": "6", "type": "stdin_stdout" ...
taco
verifiable_code
https://codeforces.com/problemset/problem/658/D
Solve the following coding problem using the programming language python: Limak is a little polar bear. He doesn't have many toys and thus he often plays with polynomials. He considers a polynomial valid if its degree is n and its coefficients are integers not exceeding k by the absolute value. More formally: Let a0...
```python def convert_to_binary(coef): res = [] n = len(coef) carry = 0 i = 0 while i < n + 1000: if i >= n and (not carry): break cur = carry if i < n: cur += coef[i] mod = cur % 2 div = cur // 2 res.append(mod) carry = div i += 1 return (res, carry) (n, k) = map(int, input().split()) coef ...
vfc_89677
{ "difficulty": "hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/658/D", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 2\n-1 0 -2\n", "output": "0", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 2\n1 1 -2\n", "output": "0", "type": "stdin_stdout" }, { "fn_name": null, "inp...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/type-of-input5910/1
Solve the following coding problem using the programming language python: Given an input A , print the data type of the input A. eg:-Sequence of digits -- int Sequence of digits with a dot -- float Sequence of chars -- string Single non-digit char --- char Example 1: Input: A = "12" Output: "int" ...
```python class Solution: def FindInputType(self, str): if str.isdigit(): return 'int' if '.' in str: p = str.split('.') if p[-1].isdigit() and p[-2].isdigit() and (len(p) == 2) or (p[-1].isdigit() and p[-2] == '' and (len(p) == 2)): return 'float' elif len(str) > 1: return 'string' if len(s...
vfc_89686
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/type-of-input5910/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "A = \"12\"", "output": "\"int\"", "type": "stdin_stdout" }, { "fn_name": null, "input": "A = \"gfg\"", "output": "\"string\"", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/CLBATH
Solve the following coding problem using the programming language python: It's winter and taking a bath is a delicate matter. Chef has two buckets of water. The first bucket has $v_1$ volume of cold water at temperature $t_1$. The second has $v_2$ volume of hot water at temperature $t_2$. Chef wants to take a bath wit...
```python for _ in range(int(input())): (v1, t1, v2, t2, v3, t3) = map(int, input().split()) if t3 > t2 or t3 < t1: print('NO') continue x = v3 * ((t2 - t3) / (t2 - t1)) y = v3 - x if x <= v1 and y <= v2: print('YES') else: print('NO') ```
vfc_89687
{ "difficulty": "medium_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CLBATH", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n5 10 5 20 8 15\n5 10 5 20 1 30\n5 10 5 20 5 20\n", "output": "YES\nNO\nYES\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1604/B
Solve the following coding problem using the programming language python: YouKn0wWho has an integer sequence $a_1, a_2, \ldots a_n$. Now he will split the sequence $a$ into one or more consecutive subarrays so that each element of $a$ belongs to exactly one subarray. Let $k$ be the number of resulting subarrays, and $...
```python t = int(input()) for _ in range(t): n = int(input()) a = list(map(int, input().split())) if len(a) % 2 == 0: print('YES') else: flag = False for i in range(1, len(a)): if a[i - 1] >= a[i]: print('YES') flag = True break if not flag: print('NO') ```
vfc_89699
{ "difficulty": "easy", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1604/B", "time_limit": "1 second" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n7\n1 3 4 2 2 1 5\n3\n1 3 4\n5\n1 3 2 4 2\n4\n4 3 2 1\n", "output": "YES\nNO\nYES\nYES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n7\n1 4 4 2 2 1 5\n3\n1 3 4\n5\n1 3 2 4 2\n4\n4 3...
taco
verifiable_code
https://codeforces.com/problemset/problem/1511/E
Solve the following coding problem using the programming language python: You have a large rectangular board which is divided into $n \times m$ cells (the board has $n$ rows and $m$ columns). Each cell is either white or black. You paint each white cell either red or blue. Obviously, the number of different ways to p...
```python MOD = 998244353 def power(a, b): res = 1 while b > 0: if b % 2 == 1: res = res * a % MOD a = a * a % MOD b //= 2 return res def inverse(n): return power(n, MOD - 2) (h, w) = map(int, input().split()) grid = [input() for _ in range(h)] prob = [0, 0] for c in range(2, max(h, w) + 1): prob.append...
vfc_89703
{ "difficulty": "hard", "memory_limit": "512 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1511/E", "time_limit": "3 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 4\n**oo\noo*o\n**oo\n", "output": "144\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 4\n**oo\noo**\n**oo\n", "output": "48\n", "type": "stdin_stdout" }, { "...