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://practice.geeksforgeeks.org/problems/assignment-problem3016/1
Solve the following coding problem using the programming language python: You are the head of a firm and you have to assign jobs to people. You have N persons working under you and you have N jobs that are to be done by these persons. Each person has to do exactly one job and each job has to be done by exactly one per...
```python class Solution: def assignmentProblem(self, Arr, N): n = N l = Arr m = [] mybeg = [] for i in range(n): m.append(l[i * n:(i + 1) * n]) mybeg.append(l[i * n:(i + 1) * n]) def util(): (u, v, ind) = ([0] * n, [0] * n, [-1] * n) for i in range(n): (links, mins, visited) = ([-1] * n,...
vfc_136093
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/assignment-problem3016/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 2\r\nArr[] = {3, 5, 10, 1}", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 3\r\nArr[] = {2, 1, 2, 9, 8, 1, 1, 1, 1}", "output": "3", "type": "stdin_stdout"...
taco
verifiable_code
https://www.codechef.com/problems/MEANMEDIAN
Solve the following coding problem using the programming language python: Chef has two numbers X and Y. Chef wants to find three integers A, B, and C such that: -1000 ≤ A, B, C ≤ 1000 mean([A, B, C]) = X median([A, B, C]) = Y Can you help Chef find such three integers? As a reminder, mean([P, Q, R]) = \frac{P + Q + ...
```python T = int(input()) for i in range(T): line = input().split(' ') X = int(line[0]) B = Y = int(line[1]) if X == Y: print(line[0] + ' ' + line[0] + ' ' + line[0]) else: if B > 0: A = 0 elif B == 0: A = -1 else: A = 2 * B C = 3 * X - A - B while C < B: if C <= A: A = A - (B - C) ...
vfc_136098
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/MEANMEDIAN", "time_limit": "0.5 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n5 5\n67 100\n4 5\n", "output": "5 5 5\n0 100 101\n0 5 7", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/PROC2020/problems/VC711
Solve the following coding problem using the programming language python: Chuck Norris just created a universe. He has already started the space-time continuum. Now he needs to fill the universe with matter and antimatter for the avatar cycle to start. He created $N$ distinct pairs of elementary matter and their corre...
```python for i in range(int(input())): n = int(input()) if n <= 2 or n > 1000000007: print('0') else: prod = 1 for i in range(2, n): prod *= i if prod > 1000000007: prod = prod % 1000000007 print(prod * (n * prod - 2) % 1000000007) ```
vfc_136102
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/PROC2020/problems/VC711", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n3\nSample output :\n8\n", "output": "", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/BULLBEAR
Solve the following coding problem using the programming language python: Chef is on his way to become the new big bull of the stock market but is a bit weak at calculating whether he made a profit or a loss on his deal. Given that Chef bought the stock at value X and sold it at value Y. Help him calculate whether he...
```python T = int(input()) for _ in range(T): (X, Y) = map(int, input().split()) if X is Y: print('NEUTRAL') elif X > Y: print('LOSS') else: print('PROFIT') ```
vfc_136106
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/BULLBEAR", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n4 2\n8 8\n3 4\n2 1\n", "output": "LOSS\nNEUTRAL\nPROFIT\nLOSS\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/LOCMAR16/problems/MOD
Solve the following coding problem using the programming language python: You have an array A of size N containing only positive numbers. You have to output the maximum possible value of A[i]%A[j] where 1<=i,j<=N. -----Input----- The first line of each test case contains a single integer N denoting the size of the a...
```python n = int(input()) a = [] for i in range(n): a.append(int(input())) m1 = 0 m2 = 0 for e in a: if e > m1: m2 = m1 m1 = e elif e > m2 and e != m1: m2 = e ans = 0 for e in a: temp = m1 % e if temp > ans: ans = temp print(max(m2 % m1, ans)) ```
vfc_136110
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/LOCMAR16/problems/MOD", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1\n2\n", "output": "1\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1109/A
Solve the following coding problem using the programming language python: Sasha likes programming. Once, during a very long contest, Sasha decided that he was a bit tired and needed to relax. So he did. But since Sasha isn't an ordinary guy, he prefers to relax unusually. During leisure time Sasha likes to upsolve uns...
```python def main(): n = int(input()) a = map(int, input().split()) cnt = [{} for _ in range(2)] xor = 0 result = 0 cnt[1][0] = 1 for (i, x) in enumerate(a): xor ^= x index = i & 1 result += int(cnt[index].get(xor) or 0) cnt[index][xor] = int(cnt[index].get(xor) or 0) + 1 print(result) main() ```
vfc_136114
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1109/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 2 3 4 5\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n3 2 2 3 7 6\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, ...
taco
verifiable_code
https://codeforces.com/problemset/problem/228/B
Solve the following coding problem using the programming language python: You've got two rectangular tables with sizes na × ma and nb × mb cells. The tables consist of zeroes and ones. We will consider the rows and columns of both tables indexed starting from 1. Then we will define the element of the first table, loca...
```python def mi(): return map(int, input().split()) def mi1(): return map(int, list(input())) (na, ma) = mi() a = [0] * na for i in range(na): a[i] = list(mi1()) (nb, mb) = mi() b = [0] * nb for i in range(nb): b[i] = list(mi1()) ans = -10 ** 10 (ax, ay) = (0, 0) (n, m) = (max(na, nb), max(ma, mb)) for x in range...
vfc_136119
{ "difficulty": "medium", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/228/B", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 14\n11110101110010\n50 3\n101\n011\n010\n100\n011\n011\n100\n100\n110\n101\n000\n111\n100\n010\n000\n001\n101\n111\n110\n111\n100\n011\n110\n110\n100\n001\n011\n100\n100\n010\n110\n100\n100\n010\n001\n010\n110\n101\n110\n110\n010...
taco
verifiable_code
https://www.codechef.com/problems/SQRTCBRT
Solve the following coding problem using the programming language python: Kulyash loves perfect squares and hates perfect cubes. For any natural number N, F(N) = \texttt{number of perfect squares smaller than or equal to } N - \texttt{number of positive perfect cubes smaller than or equal to } N. Kulyash gives y...
```python import math t = int(input()) while t > 0: x = int(input()) start = x end = 10 ** 10 mid = (start + end) // 2 ans = 10 ** 20 while start <= end: sq = mid zz = mid * mid cb = int(zz ** (1 / 3)) val = cb + 1 val = val ** 3 if val == zz: cb += 1 dif = sq - cb if dif >= x: ans = min(ans...
vfc_136124
{ "difficulty": "hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/SQRTCBRT", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1\n3\n3151\n", "output": "4\n25\n11397376\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/pair-with-greatest-product-in-array3342/1
Solve the following coding problem using the programming language python: Given an array A of N elements. The task is to find the greatest number S such that it is product of two elements of given array (S cannot be included in pair. Also, pair must be from different indices). Example 1: Input : arr[] = {10, 3, 5, 3...
```python from math import * class Solution: def findGreatest(self, arr, n): m = dict() for i in arr: m[i] = m.get(i, 0) + 1 arr = sorted(arr) for i in range(n - 1, 0, -1): j = 0 if arr[i] == 1: if m[1] > 2: return 1 continue while j < i and arr[j] <= sqrt(arr[i]): if arr[j] == 1...
vfc_136128
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/pair-with-greatest-product-in-array3342/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "arr[] = {10, 3, 5, 30, 35}", "output": "30", "type": "stdin_stdout" }, { "fn_name": null, "input": "arr[] = {2, 5, 7, 8}", "output": "-1", "type": "stdin_stdout" }, { "fn_na...
taco
verifiable_code
https://www.codechef.com/problems/COUNTONES
Solve the following coding problem using the programming language python: Alice recently converted all the positive integers from 1 to 2^{N} - 1 (both inclusive) into binary strings and stored them in an array S. Note that the binary strings do not have leading zeroes. While she was out, Bob sorted all the elements...
```python z = [0 for _ in range(51)] z[1] = 1 for i in range(2, 51): z[i] = 2 * z[i - 1] + 2 ** (i - 2) b = [0 for i in range(51)] for i in range(1, 51): b[i] = b[i - 1] + z[i] def sol1(target, n): value = 1 sum1 = 1 num1 = 1 abnum = 2 ** (n - 1) - 1 while value != target: if value + abnum > target: value ...
vfc_136129
{ "difficulty": "very_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/COUNTONES", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3 2\n3 4\n3 7", "output": "2\n5\n12\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Rasta calls a number like a Tavas if and only if 1 ≤ a ≤ n and the sum of all primes (like p) that p | a is exactly equal to k. He asks you to find the number of Tavases. Input format The first and only line of input contains two integers, n a...
```python maxn = 1000010 p = [0] * maxn d = [0] * maxn for i in range(2, maxn): if p[i] == 0: for j in range(i, maxn, i): d[j] += i for j in range(2 * i, maxn, i): p[j] = 1 n, k = list(map(int, input().split())) res = 0 for i in range(1, n+1): if d[i] == k: res+=1 print(res) ...
vfc_136137
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1000000 166\n", "output": "381\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1000000 100\n", "output": "326\n", "type": "stdin_stdout" }, { "fn_name": null, ...
taco
verifiable_code
https://codeforces.com/problemset/problem/780/D
Solve the following coding problem using the programming language python: Innokenty is a president of a new football league in Byteland. The first task he should do is to assign short names to all clubs to be shown on TV next to the score. Of course, the short names should be distinct, and Innokenty wants that all sho...
```python n = int(input()) ans = 0 o = [] p = [] for i in range(n): (s, g) = [str(j) for j in input().split()] ss = s[0:3] gg = s[0:2] + g[0] flag = True if ss in o: flag = False o.append(ss) if gg in p and ss not in p and flag: p.append(ss) elif gg not in p: p.append(gg) else: ans = -1 if ans < 0: pr...
vfc_136145
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/780/D", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\nDINAMO BYTECITY\nFOOTBALL MOSCOW\n", "output": "YES\nDIN\nFOO\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/rotate-page0923/1
Solve the following coding problem using the programming language python: You are given three points a(a1, a2), b(b1, b2) and c(c1, c2) on a page. Find if it’s possible to rotate the page in any direction by any angle, such that the new position of a is same as the old position of b, and the new position of b is same ...
```python import math class Solution: def possibleOrNot(self, a1, a2, b1, b2, c1, c2): d1 = math.sqrt((b1 - a1) ** 2 + (b2 - a2) ** 2) d2 = math.sqrt((b1 - c1) ** 2 + (b2 - c2) ** 2) if d1 == d2: return 1 else: return 0 ```
vfc_136150
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/rotate-page0923/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "a1 = 1, a2 = 1\nb1 = 1, b2 = 1\nc1 = 1, c2 = 0", "output": "0", "type": "stdin_stdout" }, { "fn_name": null, "input": "a1 = 0, a2 = 1\nb1 = 1, b2 = 1\nc1 = 1, c2 = 0", "output": "1", "typ...
taco
verifiable_code
Solve the following coding problem using the programming language python: Short Phrase A Short Phrase (aka. Tanku) is a fixed verse, inspired by Japanese poetry Tanka and Haiku. It is a sequence of words, each consisting of lowercase letters 'a' to 'z', and must satisfy the following condition: > (The Condition for ...
```python tanku = [5, 7, 5, 7, 7] while True: n = int(input()) if n == 0: break w = [len(input()) for i in range(n)] ans = 0 for i in range(n): sum = 0 k = 0 for j in range(i, n): sum += w[j] if sum == tanku[k]: sum = 0 k += 1 if k == 5: ans = i + 1 break elif sum > tanku[k]:...
vfc_136151
{ "difficulty": "unknown_difficulty", "memory_limit": "268.435456 megabytes", "memory_limit_bytes": null, "problem_url": null, "time_limit": "8.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "9\ndo\nhte\nbest\nand\nenjoy\ntoday\nat\nacm\nicpc\n14\noh\nyes\nby\nfar\nit\nis\nwow\nso\nbad\nto\nme\nyou\nknow\nhey\n15\nabcde\nfghijkl\nmnopq\nrstuvwx\nyzz\nabcde\nfghijkl\nmnopq\nrstuvwx\nyz\nabcde\nfghijkl\nmnopq\nrstuvwx\nyz...
taco
verifiable_code
https://www.codechef.com/problems/FLOW001
Solve the following coding problem using the programming language python: Shivam is the youngest programmer in the world, he is just 12 years old. Shivam is learning programming and today he is writing his first program. Program is very simple, Given two integers A and B, write a program to add these two numbers. -...
```python T = int(input()) for tc in range(T): (a, b) = list(map(int, input().split(' '))) ans = a + b print(ans) ```
vfc_136156
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/FLOW001", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 2\n100 200\n10 40\n", "output": "3\n300\n50\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/column-name-from-a-given-column-number4244/1
Solve the following coding problem using the programming language python: Given a positive integer, return its corresponding column title as appear in an Excel sheet. Excel columns has a pattern like A, B, C, … ,Z, AA, AB, AC,…. ,AZ, BA, BB, … ZZ, AAA, AAB ….. etc. In other words, column 1 is named as “A”, column 2 as...
```python class Solution: def colName(self, n): str1 = '' while n != 0: if n % 26 == 0: str1 = 'Z' + str1 n = (n - 1) // 26 else: str1 = chr(n % 26 - 1 + 65) + str1 n = n // 26 return str1 ```
vfc_136160
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/column-name-from-a-given-column-number4244/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 28", "output": "AB", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 13", "output": "M", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.hackerrank.com/challenges/python-time-delta/problem
Solve the following coding problem using the programming language python: When users post an update on social media,such as a URL, image, status update etc., other users in their network are able to view this new post on their news feed. Users can also see exactly when the post was published, i.e, how many hours, minu...
```python from datetime import datetime, timedelta s = '%a %d %b %Y %H:%M:%S %z' t = int(input()) for _ in range(t): a = datetime.strptime(input(), s) b = datetime.strptime(input(), s) print(int(abs(timedelta.total_seconds(b - a)))) ```
vfc_136165
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.hackerrank.com/challenges/python-time-delta/problem", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\nSun 10 May 2015 13:54:36 -0700\nSun 10 May 2015 13:54:36 -0000\nSat 02 May 2015 19:54:36 +0530\nFri 01 May 2015 13:54:36 -0000\n", "output": "25200\n88200\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/reverse-alternate-levels-of-a-perfect-binary-tree/1
Solve the following coding problem using the programming language python: Given a complete binary tree, reverse the nodes present at alternate levels. Example 1: Input: 1 / \ 3 2 Output: 1 / \ 2 3 Explanation: Nodes at level 2 are reversed. Ex...
```python def reverseAlternate(root): q = [root] lev = 0 while q: l = len(q) tmp = [] for i in range(l): p = q[i] if lev % 2 == 0: if p.left: tmp.append(p.left.data) if p.right: tmp.append(p.right.data) tmp = tmp[::-1] a = 0 for i in range(l): p = q.pop(0) if lev % 2 == 0: ...
vfc_136169
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/reverse-alternate-levels-of-a-perfect-binary-tree/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\r\n / \\\r\n 3 2", "output": "1\r\n / \\\r\n 2 3", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\r\n / \\\r\n 2 ...
taco
verifiable_code
https://codeforces.com/problemset/problem/391/B
Solve the following coding problem using the programming language python: You will receive 5 points for solving this problem. Manao has invented a new operation on strings that is called folding. Each fold happens between a pair of consecutive letters and places the second part of the string above first part, running...
```python t = {} for (i, c) in enumerate(input()): if c not in t: t[c] = (i, 1) elif t[c][0] - i & 1: t[c] = (i, t[c][1] + 1) print(max((b for (a, b) in list(t.values())))) ```
vfc_136174
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/391/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "ABRACADABRA\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "ABBBCBDB\n", "output": "3\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/number-of-pairs-1587115620/1
Solve the following coding problem using the programming language python: Given two arrays X and Y of positive integers, find the number of pairs such that x^{y} > y^{x} (raised to power of) where x is an element from X and y is an element from Y. Example 1: Input: M = 3, X[] = [2 1 6] N = 2, Y[] = [1 5] Output: 3 E...
```python class Solution: def countPairs(self, a, b, M, N): from bisect import bisect as bi a.sort() b.sort() ans = 0 for X in a: if X == 1: continue elif X == 2: ans += bi(b, 1) + N - bi(b, 4) elif X == 3: ans += bi(b, 2) + N - bi(b, 3) else: ans += bi(b, 1) + N - bi(b, X) ret...
vfc_136182
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/number-of-pairs-1587115620/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "M = 3, X[] = [2 1 6] \r\nN = 2, Y[] = [1 5]", "output": "3", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/52/B
Solve the following coding problem using the programming language python: You are given a n × m field consisting only of periods ('.') and asterisks ('*'). Your task is to count all right triangles with two sides parallel to the square sides, whose vertices are in the centers of '*'-cells. A right triangle is a triang...
```python (n, m) = map(int, input().split()) grid = [input() for _ in range(n)] a = [[0 for _ in range(m)] for i in range(n)] b = [[0 for _ in range(m)] for i in range(n)] for i in range(n): for j in range(m): a[i][j] = a[i][j - 1] + (grid[i][j] == '*') if i: b[i][j] = b[i - 1][j] b[i][j] += grid[i][j] == '*'...
vfc_136183
{ "difficulty": "medium_hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/52/B", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 3\n*.*\n", "output": "0", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 2\n*.\n**\n.*\n..\n.*\n", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, ...
taco
verifiable_code
https://www.codechef.com/problems/BUDGET_
Solve the following coding problem using the programming language python: Akshat has X rupees to spend in the current month. His daily expenditure is Y rupees, i.e., he spends Y rupees each day. Given that the current month has 30 days, find out if Akshat has enough money to meet his daily expenditures for this mont...
```python for i in range(int(input())): (x, y) = map(int, input().split()) if x >= y * 30: print('YES') else: print('NO') ```
vfc_136187
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/BUDGET_", "time_limit": "0.5 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1000 10\n250 50\n1500 50\n", "output": "YES\nNO\nYES\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/stickler-theif-1587115621/1
Solve the following coding problem using the programming language python: Stickler the thief wants to loot money from a society having n houses in a single line. He is a weird person and follows a certain rule when looting the houses. According to the rule, he will never loot two consecutive houses. At the same time, ...
```python class Solution: def FindMaxSum(self, a, n): incl = 0 excl = 0 for i in a: new_excl = max(incl, excl) incl = excl + i excl = new_excl return max(incl, excl) ```
vfc_136199
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/stickler-theif-1587115621/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "n = 6\r\na[] = {5,5,10,100,10,5}", "output": "110", "type": "stdin_stdout" }, { "fn_name": null, "input": "n = 3\r\na[] = {1,2,3}", "output": "4", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/544/A
Solve the following coding problem using the programming language python: You are given a string q. A sequence of k strings s_1, s_2, ..., s_{k} is called beautiful, if the concatenation of these strings is string q (formally, s_1 + s_2 + ... + s_{k} = q) and the first characters of these strings are distinct. Find a...
```python n = int(input()) s = input() res = '' dic = set() num = 0 for (i, c) in enumerate(s): if c in dic: res += c else: res += '\n' dic.add(c) num += 1 if num == n: res += s[i:] break else: res += c if num != n: print('NO') else: print('YES' + res) ```
vfc_136200
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/544/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\nabca\n", "output": "YES\nabca\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\naaacas\n", "output": "YES\naaa\ncas\n", "type": "stdin_stdout" }, { "fn_name":...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/detect-cycle-in-an-undirected-graph/1
Solve the following coding problem using the programming language python: Given an undirected graph with V vertices and E edges, check whether it contains any cycle or not. Graph is in the form of adjacency list where adj[i] contains all the nodes ith node is having edge with. Example 1: Input: V = 5, E = 5 adj = {{...
```python from typing import List class Solution: def isCyclicHelper(self, si, adj, visited, parent): visited[si] = True for i in adj[si]: if visited[i] is False: if self.isCyclicHelper(i, adj, visited, si): return True elif visited[i] is True and i != parent: return True return False def ...
vfc_136205
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/detect-cycle-in-an-undirected-graph/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "V = 5, E = 5\nadj = {{1}, {0, 2, 4}, {1, 3}, {2, 4}, {1, 3}}", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "V = 4, E = 2\nadj = {{}, {2}, {1, 3}, {2}}", "output": "0", ...
taco
verifiable_code
https://codeforces.com/problemset/problem/1602/B
Solve the following coding problem using the programming language python: Black is gifted with a Divine array $a$ consisting of $n$ ($1 \le n \le 2000$) integers. Each position in $a$ has an initial value. After shouting a curse over the array, it becomes angry and starts an unstoppable transformation. The transforma...
```python import sys inp = sys.stdin.readline def solve(): n = int(inp()) a = [list(map(int, inp().split()))] while True: c = [0] * (n + 1) for i in a[-1]: c[i] += 1 b = [c[i] for i in a[-1]] if b == a[-1]: break a.append(b) ans = [] for i in range(int(inp())): (x, k) = map(int, inp().split()) ...
vfc_136206
{ "difficulty": "easy", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1602/B", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n7\n2 1 1 4 3 1 2\n4\n3 0\n1 1\n2 2\n6 1\n2\n1 1\n2\n1 0\n2 1000000000\n", "output": "1\n2\n3\n3\n1\n2\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/find-the-maximum-number-of-handshakes2349/1
Solve the following coding problem using the programming language python: There are N people in a room. If two persons shake hands exactly once, find the maximum number of handshakes possible. Example 1: Input: N = 2 Output: 1 Explaination: There are two people and they can shake hands maximum one time. Example ...
```python class Solution: def handShakes(self, N): return N * (N - 1) // 2 ```
vfc_136210
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/find-the-maximum-number-of-handshakes2349/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 2", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 3", "output": "3", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1295/D
Solve the following coding problem using the programming language python: You are given two integers $a$ and $m$. Calculate the number of integers $x$ such that $0 \le x < m$ and $\gcd(a, m) = \gcd(a + x, m)$. Note: $\gcd(a, b)$ is the greatest common divisor of $a$ and $b$. -----Input----- The first line contains...
```python import math t = int(input()) def phi(n): res = n i = 2 while i * i <= n: if n % i == 0: res /= i res *= i - 1 while n % i == 0: n /= i i += 1 if n > 1: res /= n res *= n - 1 return int(res) while t: (a, m) = list(map(int, input().split())) g = math.gcd(a, m) print(phi(m // g)) t...
vfc_136211
{ "difficulty": "medium_hard", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1295/D", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n4 9\n5 10\n42 9999999967\n", "output": "6\n1\n9999999966\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n1 2\n1 3\n1 4\n3 5\n3 6\n3 7\n1 8\n7 9\n8 10\n1 11\n", "output": "1\n2...
taco
verifiable_code
https://www.codechef.com/problems/REARRSTR
Solve the following coding problem using the programming language python: Read problems statements in Mandarin Chinese and Russian as well. Today is Devu's birthday. He has obtained few colored balloons from his friends. You are given this information by a string s consisting of lower case English Latin letters. Eac...
```python for _ in range(int(input())): s = list(input()) s.sort() n = len(s) s.append('0') l = [] (a, c) = (s[0], 1) for i in range(1, n + 1): if s[i] != s[i - 1]: l.append([a, c]) (a, c) = (s[i], 1) else: c += 1 s1 = '' a = max(l, key=lambda x: x[1]) a1 = l.index(a) while len(l) > 1: p = a[:...
vfc_136215
{ "difficulty": "medium_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/REARRSTR", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\naab\nab\naa", "output": "aba\nab\n-1", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/290/B
Solve the following coding problem using the programming language python: [Image] -----Input----- The input contains two integers a_1, a_2 (0 ≤ a_{i} ≤ 32), separated by a single space. -----Output----- Output a single integer. -----Examples----- Input 1 1 Output 0 Input 3 7 Output 0 Input 13 10 Output 1...
```python (a, b) = map(int, input().split()) b = str(b) c = '' for i in b: c = i + c print(a + int(c)) ```
vfc_136219
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/290/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 1\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 7\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "13 10\n...
taco
verifiable_code
https://codeforces.com/problemset/problem/1184/A1
Solve the following coding problem using the programming language python: Melody Pond was stolen from her parents as a newborn baby by Madame Kovarian, to become a weapon of the Silence in their crusade against the Doctor. Madame Kovarian changed Melody's name to River Song, giving her a new identity that allowed her ...
```python import math n = int(input()) flag = 0 for x in range(1, int(math.sqrt(n))): if (pow(x, 2) + x + 1 - n) / (-2 * x) == int((pow(x, 2) + x + 1 - n) / (-2 * x)): print(x, (pow(x, 2) + x + 1 - n) // -2 * x) flag = 1 break if flag == 0: print('NO') ```
vfc_136227
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1184/A1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "19\n", "output": "1 8\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "16\n", "output": "NO\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1287/E1
Solve the following coding problem using the programming language python: This problem is different with hard version only by constraints on total answers length It is an interactive problem Venya joined a tour to the madhouse, in which orderlies play with patients the following game. Orderlies pick a string s of le...
```python from bisect import bisect_left as bl from bisect import bisect_right as br import heapq import math from collections import * from functools import reduce, cmp_to_key import sys input = sys.stdin.readline def factors(n): return sorted(list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5...
vfc_136232
{ "difficulty": "very_hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1287/E1", "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "99\nyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy\n", "output": "? 1 99\n? 2 99\n! y\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/sum-of-fifth-powers-of-the-first-n-natural-numbers3415/1
Solve the following coding problem using the programming language python: Given a number N.Find the sum of fifth powers of natural numbers till N i.e. 1^{5}+2^{5}+3^{5}+..+N^{5}. Example 1: Input: N=2 Output: 33 Explanation: The sum is calculated as 1^{5}+2^{5}=1+32=33. Example 2: Input: N=3 Output: 276 Explanation: T...
```python class Solution: def sumOfFifthPowers(self, n): return n * n * (n + 1) * (n + 1) * (2 * n * n + 2 * n - 1) // 12 ```
vfc_136236
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/sum-of-fifth-powers-of-the-first-n-natural-numbers3415/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N=2", "output": "33", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/FRCPRT
Solve the following coding problem using the programming language python: Mandarin chinese , Russian and Vietnamese as well. You are given a grid with $n$ rows and $m$ columns. Each cell of this grid can either be empty or it contains one particle. It can never contain more than one particle. Let's denote the cell in ...
```python def main(): for _ in range(int(input())): (rows, column) = map(int, input().split()) arr = [] for i in range(rows): arr.append(list(input())) string = input() last = string[-1] operation = Find(string, last) for i in string[0] + operation: if i == 'L': arr = Left(arr) if i == 'R': ...
vfc_136237
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/FRCPRT", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n4 4\n1010\n0010\n1001\n0100\nLRDU\n4 3\n000\n010\n001\n101\nLRL\n3 2\n01\n10\n00\nD\n", "output": "0011\n0011\n0001\n0001\n000\n100\n100\n110\n00\n00\n11\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/S01E01
Solve the following coding problem using the programming language python: In a New York City coffee house called Central Perk, we're introduced to six friends: chef Monica Geller, data controller Chandler Bing who lives across the hall from Monica, Chandler's roommate/actor Joey Tribbiani, Monica's brother Ross Geller...
```python for _ in range(int(input())): n = int(input()) if n < 21: print('NO') else: print('YES') ```
vfc_136241
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/S01E01", "time_limit": "0.5 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n42\n5\n909", "output": "YES\nNO\nYES", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1078/E
Solve the following coding problem using the programming language python: Everyone knows that computers become faster and faster. Recently Berland scientists have built a machine that can move itself back in time! More specifically, it works as follows. It has an infinite grid and a robot which stands on one of the c...
```python def C(x, y): return x + '10' + y + 't' + y def CBF(x, y): return x + '01' + y + 't' + y Cr = C('r', 'l') Cl = C('l', 'r') Cu = C('u', 'd') Cd = C('d', 'u') CBFr = CBF('r', 'l') CBFl = CBF('l', 'r') CBFu = CBF('u', 'd') CBFd = CBF('d', 'u') def CE(x, y): return x + x + '0' + x + '1' + y + y + '10' + y + '...
vfc_136249
{ "difficulty": "very_hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1078/E", "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n236675740 987654321\n555555555 555555555\n", "output": "ds10utsusdtedslss10utsusdtedslss10utsusdtedslss10utsusdtedslss10utsusdtedslss10utsusdtedslss10utsusdtedslss10utsusdtedslss10utsusdtedslss10utsusdtedslss10utsusdtedsls...
taco
verifiable_code
https://codeforces.com/problemset/problem/1042/A
Solve the following coding problem using the programming language python: There are $n$ benches in the Berland Central park. It is known that $a_i$ people are currently sitting on the $i$-th bench. Another $m$ people are coming to the park and each of them is going to have a seat on some bench out of $n$ available. L...
```python n = int(input()) m = int(input()) a = [] for i in range(n): t = int(input()) a.append(t) maxi = max(a) Kmax = maxi + m d = 0 for k in range(n): d += maxi - a[k] if m <= d: Kmin = maxi elif (m - d) % n == 0: Kmin = (m - d) // n + maxi else: Kmin = (m - d) // n + maxi + 1 print(Kmin, Kmax) ```
vfc_136257
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1042/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n6\n1\n1\n1\n1\n", "output": "3 7\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/812/C
Solve the following coding problem using the programming language python: On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains n different items numbered from 1 to n. The i-th item has base cost a_{i} Egyptia...
```python def Solution(arr, N, S): l = 0 r = N ans = [0, 0] while l <= r: mid = (l + r) // 2 res = isValid(arr, S, mid) if res[0]: l = mid + 1 ans = (mid, res[1]) else: r = mid - 1 return ans def isValid(arr, S, k): tempArr = [] for j in range(len(arr)): tempArr.append(arr[j] + (j + 1) * k) ...
vfc_136261
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/812/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 11\n2 3 5\n", "output": "2 11\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 100\n1 2 5 6\n", "output": "4 54\n", "type": "stdin_stdout" }, { "fn_name": null...
taco
verifiable_code
https://codeforces.com/problemset/problem/554/E
Solve the following coding problem using the programming language python: There are many anime that are about "love triangles": Alice loves Bob, and Charlie loves Bob as well, but Alice hates Charlie. You are thinking about an anime which has n characters. The characters are labeled from 1 to n. Every pair of two char...
```python class DSU(object): def __init__(self, n): self.father = list(range(n)) self.size = n def union(self, x, s): x = self.find(x) s = self.find(s) if x == s: return self.father[s] = x self.size -= 1 def find(self, x): xf = self.father[x] if xf != x: self.father[x] = self.find(xf) re...
vfc_136266
{ "difficulty": "hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/554/E", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 4\n1 2 0\n2 3 0\n2 4 0\n3 4 0\n", "output": "0", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 6\n1 2 0\n2 3 1\n3 4 0\n4 5 1\n5 6 0\n6 1 1\n", "output": "0", "type": "stdin_s...
taco
verifiable_code
https://www.codechef.com/problems/SHUFFLE
Solve the following coding problem using the programming language python: Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef got another sequence as a birthday present. He does not like this sequence very much because it is not sorted. Since you are a good pro...
```python for _ in range(int(input())): (n, k) = map(int, input().split()) arr = list(map(int, input().split())) temp = sorted(arr) res = arr for i in range(k): res[i::k] = sorted(arr[i::k]) if res == temp: print('yes') else: print('no') ```
vfc_136270
{ "difficulty": "medium_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/SHUFFLE", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n4 1\n1 4 2 3\n4 2\n1 4 2 3", "output": "yes\nno", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1332/D
Solve the following coding problem using the programming language python: Bob is playing a game named "Walk on Matrix". In this game, player is given an n × m matrix A=(a_{i,j}), i.e. the element in the i-th row in the j-th column is a_{i,j}. Initially, player is located at position (1,1) with score a_{1,1}. To rea...
```python k = int(input()) arr = [[0, k, 0], [0, 0, k]] length = 0 t = k while t > 0: t >>= 1 length += 1 arr[1][1] = (1 << length) + k arr[1][0] = (1 << length) + ((1 << length) - 1 ^ k) arr[0][0] = (1 << length + 1) - 1 print(2, 3) for i in arr: print(*i) ```
vfc_136274
{ "difficulty": "medium_hard", "memory_limit": "512.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1332/D", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "79585\n", "output": "2 3\n210657 131072 0\n79585 210657 79585", "type": "stdin_stdout" }, { "fn_name": null, "input": "66536\n", "output": "2 3\n197608 131072 0\n66536 197608 66536", "typ...
taco
verifiable_code
https://codeforces.com/problemset/problem/111/B
Solve the following coding problem using the programming language python: Little Petya loves looking for numbers' divisors. One day Petya came across the following problem: You are given n queries in the form "xi yi". For each query Petya should count how many divisors of number xi divide none of the numbers xi - yi,...
```python maxn = 100000 div = [0] * (maxn + 1) last = [-maxn] * (maxn + 1) for i in range(maxn + 1): div[i] = list() for i in range(2, maxn + 1): for j in range(i, maxn + 1, i): div[j].append(i) t = int(input()) for k in range(0, t): (x_i, y_i) = input().split(' ') x_i = int(x_i) y_i = int(y_i) if y_i == 0: p...
vfc_136278
{ "difficulty": "hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/111/B", "time_limit": "5.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "15\n94836 0\n22780 1\n48294 0\n24834 3\n37083 2\n57862 0\n37231 1\n81795 7\n32835 2\n4696 8\n95612 0\n7536 6\n70084 5\n72956 10\n41647 7\n", "output": "24\n21\n12\n4\n6\n8\n3\n27\n12\n5\n24\n15\n8\n21\n1\n", "type": "st...
taco
verifiable_code
https://www.codechef.com/problems/MEXSUB
Solve the following coding problem using the programming language python: Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well. Ridbit is given an array $a_{1}, a_{2}, \ldots, a_{N}$. He needs to find the number of ways to divide the array into contiguous subarrays s...
```python mod = 10 ** 9 + 7 t = int(input()) for i in range(t): n = int(input()) arr = [int(x) for x in input().split()] l = sorted(arr) prev = -1 for i in range(n): if l[i] - prev > 1: break prev = l[i] m = prev + 1 d = {} for i in range(n): if arr[i] > m: continue d[arr[i]] = d.get(arr[i], 0) + ...
vfc_136282
{ "difficulty": "very_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/MEXSUB", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n6\n1 0 0 1 0 1\n3\n1 2 3", "output": "5\n4", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: The time was 3xxx, and the highly developed civilization was in a stagnation period. Historians decided to learn the wisdom of the past in an attempt to overcome this situation. What I paid attention to was the material left by the genius of the...
```python from itertools import product import time def ok(s): if '(+' in s or '(-' in s or '(*' in s or ('++' in s) or ('+-' in s) or ('-+' in s) or ('--' in s) or ('**' in s) or ('*+' in s) or ('*-' in s): return False if '(' in s or ')' in s: dic = {} count = -1 for c in s: if c == '(': count += 1 ...
vfc_136286
{ "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": "0.010621136904092388", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "0.1.", "output": "7\n", "type": "stdin_stdout" }, { "fn_name": null, "i...
taco
verifiable_code
https://www.codechef.com/problems/TANGDIV
Solve the following coding problem using the programming language python: Read problems statements in Mandarin Chinese and Russian. Once Chef decided to divide the tangerine into several parts. At first, he numbered tangerine's segments from 1 to n in the clockwise order starting from some segment. Then he intended...
```python def snek(c, k): if len(u) > len(c): return False c.sort() u.sort() (x, y) = (0, 0) while x < len(c) and y < len(u): if c[x][0] == k[y][0]: x += 1 y += 1 elif c[x][0] < k[y][0]: x += 1 else: return False return y == len(u) t = int(input()) for i in range(t): (n, k, p) = map(int, inpu...
vfc_136290
{ "difficulty": "medium_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/TANGDIV", "time_limit": "0.180108 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n10 3 2\n1 4\n5 5\n6 10\n1 5\n6 10\n10 3 1\n2 5\n10 1\n6 9\n1 10", "output": "Yes\nNo", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n10 3 2\n1 4\n5 5\n6 10\n1 5\n6 10\n10 3 1\n4 5\n10 ...
taco
verifiable_code
Solve the following coding problem using the programming language python: Example Input 4 1 1 2 Output 6 The input will be stdin and you should print your solution to stdout Now solve the problem and return the code.
```python import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools sys.setrecursionlimit(10 ** 7) inf = 10 ** 20 eps = 1.0 / 10 ** 13 mod = 10 ** 9 + 7 dd = [(-1, 0), (0, 1), (1, 0), (0, -1)] ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (...
vfc_136294
{ "difficulty": "unknown_difficulty", "memory_limit": "134.217728 megabytes", "memory_limit_bytes": null, "problem_url": null, "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 1 1", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1 2 2", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4...
taco
verifiable_code
https://codeforces.com/problemset/problem/1450/C2
Solve the following coding problem using the programming language python: The only difference between the easy and hard versions is that tokens of type O do not appear in the input of the easy version. Errichto gave Monogon the following challenge in order to intimidate him from taking his top contributor spot on Cod...
```python import sys input = lambda : sys.stdin.readline().rstrip() T = int(input()) for _ in range(T): N = int(input()) X = [[a for a in input()] for _ in range(N)] C = [0] * 3 D = [0] * 3 for i in range(N): Xi = X[i] for j in range(N): if Xi[j] == 'X': C[(i + j) % 3] += 1 elif Xi[j] == 'O': D[(...
vfc_136302
{ "difficulty": "hard", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1450/C2", "time_limit": "1 second" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3\n.O.\nOOO\n.O.\n6\nXXXOOO\nXXXOOO\nXX..OO\nOO..XX\nOOOXXX\nOOOXXX\n5\n.OOO.\nOXXXO\nOXXXO\nOXXXO\n.OOO.\n", "output": ".O.\nOXO\n.O.\nOXXOOX\nXXOOXO\nXO..OO\nOO..XX\nOXOXXO\nXOOXOX\n.XOO.\nXXOXO\nOOXXO\nOXXOX\n.OOX.\n", ...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/transform-the-array4344/1
Solve the following coding problem using the programming language python: Given an array arr[] of size N containing integers, zero is considered an invalid number, and rest all other numbers are valid. If two nearest valid numbers are equal then double the value of the first one and make the second number as 0. At las...
```python class Solution: def valid(self, arr, n): stck = list() count = 0 for i in arr: if i != 0 and (len(stck) == 0 or stck[-1] != i): stck.append(i) elif stck and stck[-1] == i: stck.pop() stck.append(2 * i) count += 1 else: count += 1 zero = [0 for i in range(count)] stck.e...
vfc_136311
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/transform-the-array4344/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 12\r\narr[] = {2, 4, 5, 0, 0, 5, 4, 8, 6, 0, \r\n 6, 8}", "output": "2 4 10 4 8 12 8 0 0 0 0 0", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 2, arr[...
taco
verifiable_code
https://codeforces.com/problemset/problem/1038/A
Solve the following coding problem using the programming language python: You are given a string $s$ of length $n$, which consists only of the first $k$ letters of the Latin alphabet. All letters in string $s$ are uppercase. A subsequence of string $s$ is a string that can be derived from $s$ by deleting some of its ...
```python def main_function(): (n, m) = [int(i) for i in input().split(' ')] s = list(input()) d = {} for i in s: if i in d: d[i] += 1 else: d[i] = 1 if len(d) < m: return 0 f = min(d, key=lambda i: d[i]) return d[f] * m print(main_function()) ```
vfc_136313
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1038/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "9 3\nACAABCCAB\n", "output": "6", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/0-1-knapsack-problem0945/1
Solve the following coding problem using the programming language python: You are given weights and values of N items, put these items in a knapsack of capacity W to get the maximum total value in the knapsack. Note that we have only one quantity of each item. In other words, given two integer arrays val[0..N-1] and w...
```python class Solution: def knapSack(self, W, wt, val, n): dp = [[-1 for m in range(W + 1)] for n in range(n + 1)] for i in range(n + 1): dp[i][0] = 0 for j in range(W + 1): dp[0][j] = 0 for i in range(1, n + 1): for j in range(1, W + 1): if wt[i - 1] <= j: dp[i][j] = max(val[i - 1] + dp[i...
vfc_136317
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/0-1-knapsack-problem0945/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 3\r\nW = 4\r\nvalues[] = {1,2,3}\r\nweight[] = {4,5,1}", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 3\r\nW = 3\r\nvalues[] = {1,2,3}\r\nweight[] = {4,5,6}", "...
taco
verifiable_code
https://www.codechef.com/problems/HELLO
Solve the following coding problem using the programming language python: Chef talks a lot on his mobile phone. As a result he exhausts his talk-value (in Rokdas) very quickly. One day at a mobile recharge shop, he noticed that his service provider gives add-on plans which can lower his calling rates (Rokdas/minute). ...
```python a = int(input()) for i in range(a): (D, U, P) = list(map(float, input().split())) ans = 0 cost = D * U temp = 1 for k in range(int(P)): (M, R, C) = list(map(float, input().split())) if cost >= C / M + R * U: cost = C / M + R * U ans = temp temp += 1 print(ans) ```
vfc_136318
{ "difficulty": "medium", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/HELLO", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1.00 200 1\n1 0.50 28\n1.00 200 2\n1 0.75 40\n3 0.60 100\n1.00 50 2\n1 0.75 40\n3 0.60 100\n1.00 100 2\n3 0.50 10\n2 0.10 20", "output": "1\n2\n0\n2", "type": "stdin_stdout" }, { "fn_name": null, ...
taco
verifiable_code
https://codeforces.com/problemset/problem/1129/C
Solve the following coding problem using the programming language python: In Morse code, an letter of English alphabet is represented as a string of some length from $1$ to $4$. Moreover, each Morse code representation of an English letter contains only dots and dashes. In this task, we will represent a dot with a "0"...
```python import os, sys nums = list(map(int, os.read(0, os.fstat(0).st_size).split())) MOD = 10 ** 9 + 7 BAD = ([0, 0, 1, 1], [0, 1, 0, 1], [1, 1, 1, 0], [1, 1, 1, 1]) def zfunc(s): z = [0] * len(s) l = r = 0 for i in range(1, len(s)): if i <= r: z[i] = min(r - i + 1, z[i - l]) while i + z[i] < len(s) and s...
vfc_136326
{ "difficulty": "very_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1129/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1\n1\n1\n", "output": "1\n3\n7\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1\n0\n1\n0\n1\n", "output": "1\n4\n10\n22\n43\n", "type": "stdin_stdout" }, { ...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/rank-the-permutations2229/1
Solve the following coding problem using the programming language python: Given a string, find the rank of the string amongst its permutations sorted lexicographically. Example 1: Input: S = "abc" Output: 1 Explanation: The order permutations with letters 'a', 'c', and 'b' : abc acb bac bca cab cba Example 2: Input...
```python class Solution: def findRank(self, S): n = len(S) inp = [] fact = 1 for i in range(n): inp.append(S[i]) fact *= i + 1 fact = fact // n i = 0 k = 1 inp = sorted(inp) for element in S: block = inp.index(element) k += block * fact inp.pop(block) if i != n - 1: fact = fac...
vfc_136330
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/rank-the-permutations2229/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "S = \"abc\"", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "S = \"acb\"", "output": "2", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/M1ENROL
Solve the following coding problem using the programming language python: For the upcoming semester, the admins of your university decided to keep a total of X seats for the MATH-1 course. A student interest survey was conducted by the admins and it was found that Y students were interested in taking up the MATH-1 cou...
```python t = int(input()) for i in range(t): (x, y) = map(int, input().split(' ')) if x < y: print(y - x) else: print(0) ```
vfc_136331
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/M1ENROL", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 1\n12 34\n50 49\n49 50\n", "output": "0\n22\n0\n1", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Create a program that reads the attendance numbers of students in a class and the data that stores the ABO blood group and outputs the number of people for each blood type. There are four types of ABO blood types: A, B, AB, and O. Input A co...
```python from collections import Counter import sys d = Counter([i.split(',')[1].strip() for i in sys.stdin]) [print(d[i]) for i in ['A', 'B', 'AB', 'O']] ```
vfc_136335
{ "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": "1,B\n2,A\n3,B\n4,AB\n5,B\n5,O\n7,A\n8,O\n9,AB\n10,A\n11,A\n12,B\n13,AB\n14,A", "output": "5\n4\n3\n2\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Hansa loves dancing and so do her friends. But she has some pretty weird friends. Like this one friend of hers, Jack, jumps forward while dancing. The dance floor is of finite length (L) and there are many people dancing on it. During each song,...
```python s=input().split() s1=int(s[0]) s2=int(s[1]) s3=int(s[2]) c=0 cpy=s2 if s1>=s2 and s1<=pow(10,9) and s2>s3 and s2<=s1 and s3>=1 and s3<s2: while(s1>(s2)): c+=1 s2-=s3 s2+=cpy if s2==s1: print(c) else: print((c+1)) ```
vfc_136340
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "83827465 1219917 36539", "output": "183", "type": "stdin_stdout" }, { "fn_name": null, "input": "871370 25452 8072", "output": "71", "type": "stdin_stdout" }, { "fn_name": n...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/absolute-list-sorting/1
Solve the following coding problem using the programming language python: Given a linked list of N nodes, sorted in ascending order based on the absolute values of its data,i.e. negative values are considered as positive ones. Sort the linked list in ascending order according to the actual values, and consider negativ...
```python class Node: def __init__(self, data): self.data = data self.next = None class Solution: def sortList(self, head): a = head while a.next: if a.next.data < 0: k = a.next if a.next.next: a.next = a.next.next else: a.next = None k.next = head head = k else: a =...
vfc_136344
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/absolute-list-sorting/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "List:1, -2, -3, 4, -5", "output": "List:-5, -3, -2, 1, 4", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Problem statement Meatishi can increase or decrease the number of fingers. There are n buns in front of Nikunishi-kun. Meatishi is trying to count the number of steamed buns by breaking his finger. There are only two shapes that Nishikun's fing...
```python n = int(input()) print(0 * (n == 0) + len(str(bin(n))[2:]) * (n != 0)) ```
vfc_136346
{ "difficulty": "unknown_difficulty", "memory_limit": "268.435456 megabytes", "memory_limit_bytes": null, "problem_url": null, "time_limit": "5.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1", "output": "1\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/697/E
Solve the following coding problem using the programming language python: As we all know Barney's job is "PLEASE" and he has not much to do at work. That's why he started playing "cups and key". In this game there are three identical cups arranged in a line from left to right. Initially key to Barney's heart is under ...
```python m = 1000000007 input() (n, d) = (2, 1) for q in map(int, input().split()): (d, n) = (q & d, pow(n, q, m)) n = n * pow(2, m - 2, m) % m k = (n + 1 - 2 * d) * pow(3, m - 2, m) % m print(str(k) + '/' + str(n)) ```
vfc_136350
{ "difficulty": "hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/697/E", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n2\n", "output": "1/2\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: There is an ice cream shop named Ten Ice Cream. At this store, we always have 10 types of ice cream on the shelves. The store manager creates a daily graph showing how well ice cream is selling for reference in product development. For such a s...
```python while True: c = [0] * 10 n = int(input()) if n == 0: break for i in range(n): a = int(input()) c[a] += 1 for i in c: if i == 0: print('-') else: print('*' * i) ```
vfc_136354
{ "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": "15\n2\n6\n7\n0\n1\n9\n8\n7\n3\n8\n9\n4\n8\n4\n2\n3\n9\n1\n5\n0", "output": "*\n*\n**\n*\n**\n-\n*\n**\n***\n**\n-\n*\n-\n-\n-\n*\n-\n-\n-\n*\n", "type": "stdin_stdout" }, { "fn_name": null, "input": ...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/minimum-swaps-required-to-bring-all-elements-less-than-or-equal-to-k-together4847/1
Solve the following coding problem using the programming language python: Given an array arr of n positive integers and a number k. One can apply a swap operation on the array any number of times, i.e choose any two index i and j (i < j) and swap arr[i] , arr[j] . Find the minimum number of swaps required to bring all...
```python import sys class Solution: def minSwap(self, arr, n, k): cnt = 0 for i in range(n): if arr[i] <= k: cnt += 1 if cnt == 0 or cnt == 1 or cnt == n: return 0 ans = sys.maxsize - 1 badEle = 0 for i in range(cnt): if arr[i] > k: badEle += 1 ans = min(ans, badEle) i = 0 j = cnt...
vfc_136358
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/minimum-swaps-required-to-bring-all-elements-less-than-or-equal-to-k-together4847/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "arr[ ] = {2, 1, 5, 6, 3} \r\nK = 3", "output": "1", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/check-if-it-is-possible-to-convert-one-string-into-another-with-given-constraints4116/1
Solve the following coding problem using the programming language python: Given two strings S and T, which contains three characters i.e 'A', 'B' and '#' only. Check whether it is possible to convert the first string into another string by performing following operations on string first. 1- A can move towards Left onl...
```python class Solution: def isItPossible(sef, S, T, M, N): if M != N: return 0 i = 0 j = 0 if S.count('#') != T.count('#'): return 0 while i < N and j < M: while i < N and S[i] == '#': i += 1 while j < M and T[j] == '#': j += 1 if i < N and j < M: if S[i] != T[j]: return 0 ...
vfc_136359
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/check-if-it-is-possible-to-convert-one-string-into-another-with-given-constraints4116/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "S=#A#B#B# \r\nT=A###B#B", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "S=#A#B# \r\nT=#B#A#", "output": "0", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1619/A
Solve the following coding problem using the programming language python: A string is called square if it is some string written twice in a row. For example, the strings "aa", "abcabc", "abab" and "baabaa" are square. But the strings "aaa", "abaaab" and "abcdabc" are not square. For a given string $s$ determine if it...
```python n = int(input()) for i in range(n): out = input() if len(out) % 2 == 0: mid = len(out) // 2 a = out[:mid] if a * 2 == out: print('YES') else: print('NO') else: print('NO') ```
vfc_136360
{ "difficulty": "easy", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1619/A", "time_limit": "1 second" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\na\naa\naaa\naaaa\nabab\nabcabc\nabacaba\nxxyy\nxyyx\nxyxy\n", "output": "NO\nYES\nNO\nYES\nYES\nYES\nNO\nNO\nNO\nYES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\nzz\n", "ou...
taco
verifiable_code
https://www.codechef.com/PTRN2020/problems/ITGUY40
Solve the following coding problem using the programming language python: The chef is trying to solve some pattern problems, Chef wants your help to code it. Chef has one number K to form a new pattern. Help the chef to code this pattern problem. -----Input:----- - First-line will contain $T$, the number of test case...
```python for _ in range(int(input())): n = int(input()) s = '' for i in range(1, n + 1): s += str(i) for i in range(n, 0, -1): if i % 2 == 0: for j in range(i, 0, -1): print(j, end='') else: for j in range(1, i + 1): print(j, end='') print() ```
vfc_136364
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/PTRN2020/problems/ITGUY40", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2\n3\n4\n", "output": "21\n1\n123\n21\n1\n4321\n123\n21\n1\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/875/B
Solve the following coding problem using the programming language python: Recently, Dima met with Sasha in a philatelic store, and since then they are collecting coins together. Their favorite occupation is to sort collections of coins. Sasha likes having things in order, that is why he wants his coins to be arranged ...
```python def f(n, a): a = list(map(lambda s: s - 1, a)) ar = [0] * (n + 1) l = 0 ans = [1] hi = n - 1 cnt = 0 for i in a: if i == hi: ar[i] = 1 hi -= 1 while ar[hi] == 1: hi -= 1 cnt -= 1 else: ar[i] = 1 cnt += 1 ans.append(cnt + 1) return ans a = int(input()) ls = list(map(int, in...
vfc_136369
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/875/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 3 4 2\n", "output": "1 2 3 2 1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "8\n6 8 3 4 7 2 1 5\n", "output": "1 2 2 3 4 3 4 5 1\n", "type": "stdin_stdout" }, { ...
taco
verifiable_code
https://codeforces.com/problemset/problem/794/A
Solve the following coding problem using the programming language python: A robber has attempted to rob a bank but failed to complete his task. However, he had managed to open all the safes. Oleg the bank client loves money (who doesn't), and decides to take advantage of this failed robbery and steal some money from ...
```python (a, b, c) = map(int, input().split()) n = int(input()) l = list(map(int, input().split())) count = 0 for i in l: if i > b and i < c: count = count + 1 print(count) ```
vfc_136373
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/794/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 3 7\n8\n4 7 5 5 3 6 2 8\n", "output": "4\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Sheldon Cooper, Leonard Hofstadter and Penny decide to go for drinks at Cheese cake factory. Sheldon proposes to make a game out of this. Sheldon proposes as follows, To decide the amount of beverage they plan to consume, say X. Then order for...
```python n=eval(input()) a=list(map(int,input().split())) m=eval(input()) b=[ a[x]+a[y]+a[z] for x in range(n-2) for y in range(x+1,n-1) for z in range(y+1,n)] print("True" if m in b else "False") ```
vfc_136377
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n45 55 5 7 23 4\n107", "output": "True", "type": "stdin_stdout" }, { "fn_name": null, "input": "8\n4 8 9 7 45 6 3 27\n56", "output": "True", "type": "stdin_stdout" }, { "f...
taco
verifiable_code
https://codeforces.com/problemset/problem/1613/C
Solve the following coding problem using the programming language python: Monocarp is playing yet another computer game. In this game, his character has to kill a dragon. The battle with the dragon lasts $100^{500}$ seconds, during which Monocarp attacks the dragon with a poisoned dagger. The $i$-th attack is performe...
```python from __future__ import division, print_function import math import sys import os from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = 'x' in file.mode or 'r' not in file.mode self...
vfc_136381
{ "difficulty": "easy", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1613/C", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n2 5\n1 5\n3 10\n2 4 10\n5 3\n1 2 4 5 7\n4 1000\n3 25 64 1337\n", "output": "3\n4\n1\n470\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n1 1000000000000000000\n1000000\n", "out...
taco
verifiable_code
Solve the following coding problem using the programming language python: Champernown constant is an irrational number represented in decimal by "0." followed by concatenation of all positive integers in the increasing order. The first few digits of this constant are: 0.123456789101112... Your task is to write a prog...
```python from collections import defaultdict from collections import deque from heapq import heappush, heappop import sys import math import bisect import random def LI(): return list(map(int, sys.stdin.readline().split())) def I(): return int(sys.stdin.readline()) def LS(): return list(map(list, sys.stdin.readl...
vfc_136385
{ "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": "3 5\n6 7\n0 0", "output": "34567\n6789101\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 5\n1 7\n0 0", "output": "45678\n1234567\n", "type": "stdin_stdout" }, { ...
taco
verifiable_code
https://codeforces.com/problemset/problem/733/D
Solve the following coding problem using the programming language python: Kostya is a genial sculptor, he has an idea: to carve a marble sculpture in the shape of a sphere. Kostya has a friend Zahar who works at a career. Zahar knows about Kostya's idea and wants to present him a rectangular parallelepiped of marble f...
```python from itertools import combinations def sides_pairs(box): return set((tuple(sorted(side)) for side in combinations(box.dimensions, 2))) def two_integer_tuple_hash(t, hash_mul): value = 3430008 for item in t: value = value * hash_mul ^ item return value class Box: def __init__(self, dimensions, ind):...
vfc_136389
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/733/D", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n5 5 5\n3 2 4\n1 4 1\n2 1 3\n3 2 4\n3 3 4\n", "output": "1\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\n10 7 8\n5 10 3\n4 2 6\n5 5 5\n10 2 8\n4 2 1\n7 7 7\n", "output": "2...
taco
verifiable_code
Solve the following coding problem using the programming language python: There is a sale in the market on clothes , so as usual N girls gathered there to grab great deals.But due to huge popularity of sale crowd has gone uncontrollable. You being head of management team of the mall has been assigned the task to make ...
```python test = int(input()) def solve(v,a,visit,parent): visit[v] = 1 # color[v] = val # print v,a[v] for i in a[v]: if visit[i] == 0: if solve(i,a,visit,v): # print v,i,parent return True else: if i != parent: # print v,i,parent return True return False while test > 0: flag = 0...
vfc_136393
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n384 71\n106 116\n210 128\n203 109\n298 206\n315 44\n243 380\n228 71\n253 67\n341 377\n156 105\n232 142\n375 219\n303 356\n308 32\n330 283\n103 307\n270 184\n50 89\n164 347\n166 94\n262 24\n345 362\n351 213\n300 307\n78 71\n284 ...
taco
verifiable_code
https://codeforces.com/problemset/problem/567/D
Solve the following coding problem using the programming language python: Alice and Bob love playing one-dimensional battle ships. They play on the field in the form of a line consisting of n square cells (that is, on a 1 × n table). At the beginning of the game Alice puts k ships on the field without telling their p...
```python (n, k, a) = list(map(int, input().split())) m = int(input()) + 1 x = list(map(int, input().split())) + [0] (l, r) = (0, m) while r - l > 1: d = (l + r) // 2 y = sorted(x[:d]) if sum(((q - p) // (a + 1) for (p, q) in zip([0] + y, y + [n + 1]))) >= k: l = d else: r = d print(r % m - (r == m)) ```
vfc_136398
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/567/D", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "11 3 3\n5\n4 8 6 1 11\n", "output": "3\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Look for the Winner! The citizens of TKB City are famous for their deep love in elections and vote counting. Today they hold an election for the next chairperson of the electoral commission. Now the voting has just been closed and the counting ...
```python from collections import Counter while True: n = int(input()) if n == 0: quit() elif n == 1: print(input(), 1) else: c = list(input().split()) h = [0 for i in range(26)] flag = 0 for i in range(n): h[ord(c[i]) - 65] += 1 if sorted(h)[-1] - sorted(h)[-2] >= n - i: print(chr(h.index(max...
vfc_136402
{ "difficulty": "unknown_difficulty", "memory_limit": "268.435456 megabytes", "memory_limit_bytes": null, "problem_url": null, "time_limit": "8.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\nA\n4\nA A B B\n5\nL M N L N\n6\nK K K K K K\n6\nX X X Y Z X\n10\nA A A B A C A C C B\n10\nV U U U U V V W W W\n0", "output": "A 1\nTIE\nTIE\nK 4\nX 5\nA 7\nU 10\n", "type": "stdin_stdout" }, { "fn_name"...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/range-of-composite-numbers/1
Solve the following coding problem using the programming language python: Given an integer n, we need to find a range of positive integers such that all the number in that range are composite and length of that range is n. You may return anyone range in the case of more than one answer. Input: First line consists of T...
```python def Range(n): return 1 ```
vfc_136406
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/range-of-composite-numbers/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": "Range", "input": "2\r\n\n3\r\n\n5", "output": "1\n1", "type": "function_call" } ] }
taco
verifiable_code
https://www.hackerrank.com/challenges/swap-nodes-algo/problem
Solve the following coding problem using the programming language python: A binary tree is a tree which is characterized by one of the following properties: It can be empty (null). It contains a root node only. It contains a root node with a left subtree, a right subtree, or both. These subtrees are also binary trees...
```python def inorder(T): stack = [1] result = [] while stack: i = stack.pop() if i > 0: if T[i][1] > 0: stack.append(T[i][1]) stack.append(-i) if T[i][0] > 0: stack.append(T[i][0]) else: result.append(-i) return result def swap(T, K): (toVisit, depth) = ([1], 1) while toVisit: if dep...
vfc_136407
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.hackerrank.com/challenges/swap-nodes-algo/problem", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2 3\n-1 -1\n-1 -1\n2\n1\n1\n", "output": "3 1 2\n2 1 3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n2 3\n-1 4\n-1 5\n-1 -1\n-1 -1\n1\n2\n", "output": "4 2 1 5 3\n", "t...
taco
verifiable_code
https://www.hackerrank.com/challenges/manasa-and-pizza/problem
Solve the following coding problem using the programming language python: With the college fest approaching soon, Manasa is following a strict dieting regime . Today, she just cannot resist her temptation for having a pizza. An inner conflict ensues, and she decides that she will have a pizza, only if she comes up wit...
```python from random import randint from collections import Counter from functools import reduce from itertools import accumulate, combinations, takewhile, product home = 0 lire = 1 trace = 0 mp = 10 ** 6 if home: from mesures import ch modo = 10 ** 9 + 7 pars = [] class Lucmat: def __init__(s, P, Q, Iv, modo): ...
vfc_136411
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.hackerrank.com/challenges/manasa-and-pizza/problem", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 2 3\n", "output": "40392\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1154/A
Solve the following coding problem using the programming language python: Polycarp has guessed three positive integers $a$, $b$ and $c$. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order — their pairwise sums (three numbers) and sum of all three numbers (one number). So, t...
```python my_list = list(map(int, input().split())) sum_of_3 = max(my_list) answer = [] for i in my_list: if i != sum_of_3: answer.append(sum_of_3 - i) print(*answer) ```
vfc_136415
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1154/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 6 5 4\n", "output": "1 2 3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "40 40 40 60\n", "output": "20 20 20\n", "type": "stdin_stdout" }, { "fn_name": null, ...
taco
verifiable_code
https://www.codechef.com/problems/DNASTRAND
Solve the following coding problem using the programming language python: You are given the sequence of Nucleotides of one strand of DNA through a string S of length N. S contains the character A, T, C, and G only. Chef knows that: A is complementary to T. T is complementary to A. C is complementary to G. G is comple...
```python T = int(input()) for i in range(0, T): n = int(input()) s = input() for i in range(0, n): if s[i] == 'A': print('T', end='') elif s[i] == 'T': print('A', end='') elif s[i] == 'G': print('C', end='') elif s[i] == 'C': print('G', end='') print() ```
vfc_136419
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/DNASTRAND", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n4\nATCG\n4\nGTCC\n5\nAAAAA\n3\nTAC\n", "output": "TAGC\nCAGG\nTTTTT\nATG\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/8/B
Solve the following coding problem using the programming language python: The whole world got obsessed with robots,and to keep pace with the progress, great Berland's programmer Draude decided to build his own robot. He was working hard at the robot. He taught it to walk the shortest path from one point to another, to...
```python __author__ = 'runekri3' def cells_touching(cell_1, cell_2): abs_x = abs(cell_1[0] - cell_2[0]) if abs_x > 1: return False abs_y = abs(cell_1[1] - cell_2[1]) if abs_y > 1: return False if not (abs_x == 1 and abs_y == 1): return True movements = input() total_movements = len(movements) cur_cell = [0...
vfc_136423
{ "difficulty": "medium", "memory_limit": "64.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/8/B", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "DDUL\n", "output": "BUG\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "LLLLLLLLRRRRDDDDDDDUUUUUU\n", "output": "BUG\n", "type": "stdin_stdout" }, { "fn_name": nu...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/rotate-a-linked-list/1
Solve the following coding problem using the programming language python: Given a singly linked list of size N. The task is to left-shift the linked list by k nodes, where k is a given positive integer smaller than or equal to length of the linked list. Example 1: Input: N = 5 value[] = {2, 4, 7, 8, 9} k = 3 Output: ...
```python class Solution: def rotate(self, head, k): if head == None or k == 0: return head prev = head while prev.next: prev = prev.next for i in range(k): prev.next = head head = head.next prev = prev.next prev.next = None return head ```
vfc_136427
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/rotate-a-linked-list/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 5\r\nvalue[] = {2, 4, 7, 8, 9}\r\nk = 3", "output": "8 9 2 4 7", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 8\r\nvalue[] = {1, 2, 3, 4, 5, 6, 7, 8}\r\nk = 4", "output": "5 6...
taco
verifiable_code
https://codeforces.com/problemset/problem/1433/B
Solve the following coding problem using the programming language python: There is a bookshelf which can fit $n$ books. The $i$-th position of bookshelf is $a_i = 1$ if there is a book on this position and $a_i = 0$ otherwise. It is guaranteed that there is at least one book on the bookshelf. In one move, you can cho...
```python for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) l = 0 an = 0 p = [] for i in range(n): if a[i] == 1: p.append(i) l += 1 if l == 1: an = 0 else: for i in range(l - 1): for j in range(p[i], p[i + 1]): if a[j] == 0: an += 1 print(an) ```
vfc_136428
{ "difficulty": "easy", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1433/B", "time_limit": "1 second" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n7\n0 0 1 0 1 0 1\n3\n1 0 0\n5\n1 1 0 0 1\n6\n1 0 0 0 0 1\n5\n1 1 0 1 1\n", "output": "2\n0\n2\n4\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n8\n0 0 0 1 1 1 1 1\n", "outp...
taco
verifiable_code
https://codeforces.com/problemset/problem/1070/K
Solve the following coding problem using the programming language python: Polycarp took $n$ videos, the duration of the $i$-th video is $a_i$ seconds. The videos are listed in the chronological order, i.e. the $1$-st video is the earliest, the $2$-nd video is the next, ..., the $n$-th video is the last. Now Polycarp ...
```python def main(): (n, k) = map(int, input().split()) v = list(map(int, input().split())) d = sum(v) / k j = 0 res = '' sumpart = 0 for i in range(len(v)): sumpart += v[i] if sumpart == d: res += str(i + 1 - j) + ' ' j = i + 1 sumpart = 0 if j >= len(v): break elif sumpart > d: print(...
vfc_136432
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1070/K", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 3\n3 3 1 4 1 6\n", "output": "Yes\n2 3 1 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 3\n1 1 1\n", "output": "Yes\n1 1 1 ", "type": "stdin_stdout" }, { "fn_...
taco
verifiable_code
https://codeforces.com/problemset/problem/90/D
Solve the following coding problem using the programming language python: Vasya writes his own library for building graphical user interface. Vasya called his creation VTK (VasyaToolKit). One of the interesting aspects of this library is that widgets are packed in each other. A widget is some element of graphical in...
```python import sys from array import array import re def input(): return sys.stdin.buffer.readline().decode('utf-8') class Widget(object): def __init__(self, x, y): self.x = x self.y = y class Box(object): def __init__(self): self.children = [] self.border = 0 self.spacing = 0 self._x = -1 self....
vfc_136436
{ "difficulty": "hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/90/D", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\nVBox abcdefghij\n", "output": "abcdefghij 0 0\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/COLOUR
Solve the following coding problem using the programming language python: For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixin...
```python test = int(input()) while test > 0: test = test - 1 (X, Y, Z) = map(int, input().split()) list1 = [X, Y, Z] ans = 0 if list1[0] > 0: ans += 1 list1[0] -= 1 if list1[1] > 0: ans += 1 list1[1] -= 1 if list1[2] > 0: ans += 1 list1[2] -= 1 list1.sort() list1.reverse() if list1[0] > 0 and lis...
vfc_136445
{ "difficulty": "medium", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/COLOUR", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 0 1\n3 3 0\n1 1 1\n0 0 0\n", "output": "2\n3\n3\n0", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/MAXCOUNT
Solve the following coding problem using the programming language python: Given an array A of length N, your task is to find the element which repeats in A maximum number of times as well as the corresponding count. In case of ties, choose the smaller element first. ------ Input ------ First line of input contains ...
```python for i in range(int(input())): n = int(input()) l = list(map(int, input().split())) k = [0] * 10001 for i in range(n): k[l[i]] += 1 c = max(k) index = k.index(c) print(index, c) ```
vfc_136449
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/MAXCOUNT", "time_limit": "0.207865 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5\n1 2 3 2 5\n6\n1 2 2 1 1 2", "output": "2 2\n1 3", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/CSTR2020/problems/MALLTILE
Solve the following coding problem using the programming language python: Theatre Square in the capital city of Berland has a rectangular shape with the size n × m meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the size a ...
```python try: (n, m, a) = map(int, input().split()) if n % a != 0: number1 = n // a + 1 else: number1 = n // a if m % a != 0: number2 = m // a + 1 else: number2 = m // a print(number1 * number2) except: pass ```
vfc_136458
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/CSTR2020/problems/MALLTILE", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "s\ninput\n6 6 4\noutput\n4\n", "output": "", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/circle-of-strings4530/1
Solve the following coding problem using the programming language python: Given an array of lowercase strings A[] of size N, determine if the strings can be chained together to form a circle. A string X can be chained together with another string Y if the last character of X is same as first character of Y. If every s...
```python def dfs(node, adj, vis): vis[node] = 1 for i in adj[node]: if not vis[i]: dfs(i, adj, vis) def detectCycle(src, adj, mark): vis = [0] * 26 dfs(src, adj, vis) for i in range(26): if not vis[i] and mark[i] == 1: return 0 return 1 class Solution: def isCircle(self, N, A): mark = [0] * 26 ...
vfc_136462
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/circle-of-strings4530/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 3\nA[] = { \"abc\", \"bcd\", \"cdf\" }", "output": "0", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 4\nA[] = { \"ab\" , \"bc\", \"cd\", \"da\" }", "output": "1", "type"...
taco
verifiable_code
https://codeforces.com/problemset/problem/774/J
Solve the following coding problem using the programming language python: Well, the series which Stepan watched for a very long time, ended. In total, the series had n episodes. For each of them, Stepan remembers either that he definitely has watched it, or that he definitely hasn't watched it, or he is unsure, has he...
```python import sys (n, k) = list(map(int, input().split(' '))) s = input() def max_streak(s): result = 0 for i in range(len(s)): j = i while j < len(s) and s[j] == 'N': j += 1 result = max(result, j - i) return result for i in range(n - k + 1): cur = list(s) for j in range(i, i + k): if cur[j] == '?'...
vfc_136463
{ "difficulty": "hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/774/J", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 2\nNYNNY\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 1\n????NN\n", "output": "NO\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1389/A
Solve the following coding problem using the programming language python: Let $LCM(x, y)$ be the minimum positive integer that is divisible by both $x$ and $y$. For example, $LCM(13, 37) = 481$, $LCM(9, 6) = 18$. You are given two integers $l$ and $r$. Find two integers $x$ and $y$ such that $l \le x < y \le r$ and $...
```python import os import sys from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = 'x' in file.mode or 'r' not in file.mode self.write = self.buffer.write if self.writable else None def ...
vfc_136467
{ "difficulty": "easy", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1389/A", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 1337\n13 69\n2 4\n88 89\n", "output": "1 2\n13 26\n2 4\n-1 -1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n55556 55557\n", "output": "-1 -1\n", "type": "stdin_stdout...
taco
verifiable_code
https://www.codechef.com/problems/ADVANCE
Solve the following coding problem using the programming language python: Chef's current rating is X, and he wants to improve it. It is generally recommended that a person with rating X should solve problems whose difficulty lies in the range [X, X+200], i.e, problems whose difficulty is at least X and at most X+200. ...
```python for i in range(int(input())): (a, b) = map(int, input().split()) if b >= a and b <= a + 200: print('YES') else: print('NO') ```
vfc_136471
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/ADVANCE", "time_limit": "0.5 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1300 1500\n1201 1402\n300 4000\n723 805\n1330 512\n", "output": "YES\nNO\nNO\nYES\nNO\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/doubling-the-value4859/1
Solve the following coding problem using the programming language python: Given an array and an integer B, traverse the array (from the beginning) and if the element in array is B, double B and continue traversal. Find the value of B after the complete traversal. Example 1: Input: N = 5, B = 2 arr[] = {1 2 3 4 8} Outp...
```python class Solution: def solve(self, n: int, a: list, b: int): for i in a: if i == b: b *= 2 return b ```
vfc_136475
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/doubling-the-value4859/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 5, B = 2\r\narr[] = {1 2 3 4 8}", "output": "16", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 5, B = 3\r\narr[] = {1 2 3 4 8}", "output": "6", "type": "stdin_stdout" ...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/transpose-of-matrix-1587115621/1
Solve the following coding problem using the programming language python: Write a program to find the transpose of a square matrix of size N*N. Transpose of a matrix is obtained by changing rows to columns and columns to rows. Example 1: Input: N = 4 mat[][] = {{1, 1, 1, 1}, {2, 2, 2, 2} {3, 3, 3...
```python class Solution: def transpose(self, mat, n): for i in range(n): for j in range(i + 1, n): (mat[i][j], mat[j][i]) = (mat[j][i], mat[i][j]) return mat ```
vfc_136476
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/transpose-of-matrix-1587115621/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 4\nmat[][] = {{1, 1, 1, 1},\n {2, 2, 2, 2}\n {3, 3, 3, 3}\n {4, 4, 4, 4}}", "output": "{{1, 2, 3, 4}, \n {1, 2, 3, 4} \n {1, 2, 3, 4}\n {1, 2, 3, 4}} \n", "type": "stdin_stdout" }...
taco
verifiable_code
https://www.hackerrank.com/challenges/np-min-and-max/problem
Solve the following coding problem using the programming language python: min The tool min returns the minimum value along a given axis. import numpy my_array = numpy.array([[2, 5], [3, 7], [1, 3], [4, 0]]) print numpy.min(my_array, axis = 0...
```python import numpy (n, m) = list(map(int, input().split())) arr = numpy.array([list(map(int, input().split())) for i in range(n)]) print(numpy.max(numpy.min(arr, axis=1), axis=0)) ```
vfc_136477
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.hackerrank.com/challenges/np-min-and-max/problem", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 2\n2 5\n3 7\n1 3\n4 0\n", "output": "3\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/ROTATION
Solve the following coding problem using the programming language python: Read problems statements in Mandarin Chinese and Russian. You are given an array A of N integers. You are to fulfill M queries. Each query has one of the following three types: C d : Rotate the array A clockwise by d units. A d : Rotate the ...
```python (N, M) = map(int, input().split(' ')) arr = list(map(int, input().split(' '))) query = [] for _ in range(M): query.append(list(input().split())) pointer = 0 for each in query: if each[0] == 'C': pointer += int(each[1]) elif each[0] == 'A': pointer -= int(each[1]) else: print(arr[(pointer + int(each[...
vfc_136481
{ "difficulty": "medium", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/ROTATION", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 5\n5 4 3 3 9\nR 1\nC 4\nR 5\nA 3\nR 2", "output": "5\n3\n3", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 5\n5 4 3 3 9\nR 1\nC 4\nR 5\nA 6\nR 2", "output": "5\n3\n9\n", "typ...
taco
verifiable_code
https://codeforces.com/problemset/problem/203/C
Solve the following coding problem using the programming language python: Valera's lifelong ambition was to be a photographer, so he bought a new camera. Every day he got more and more clients asking for photos, and one day Valera needed a program that would determine the maximum number of people he can serve. The ca...
```python (n, d) = map(int, input().split()) (d1, d2) = map(int, input().split()) arr = [0] * n for i in range(n): (a, b) = map(int, input().split()) arr[i] = [d1 * a + d2 * b, i + 1] arr.sort() (res, idx) = (0, '') for i in arr: if d - i[0] < 0: break d -= i[0] res += 1 idx += str(i[1]) + ' ' print(res) print(...
vfc_136486
{ "difficulty": "medium", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/203/C", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "50 50\n6 10\n10 0\n1 9\n8 2\n4 9\n0 7\n2 0\n7 5\n4 8\n10 7\n2 4\n5 6\n6 8\n3 2\n4 6\n7 8\n6 9\n7 7\n7 3\n9 5\n3 10\n7 2\n4 3\n2 0\n6 5\n5 3\n1 7\n1 7\n9 1\n10 4\n10 5\n4 2\n10 10\n0 7\n1 2\n10 1\n1 7\n3 7\n8 7\n5 2\n6 1\n3 1\n4 7\n...
taco
verifiable_code
https://codeforces.com/problemset/problem/1436/C
Solve the following coding problem using the programming language python: Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in ...
```python import bisect import math def binsearch(arr, x): left = 0 right = len(arr) big = 0 small = 0 while left < right: middle = int((left + right) / 2) if arr[middle] < x: left = middle + 1 small += 1 elif arr[middle] == x: left = middle + 1 else: right = middle big += 1 return (big, s...
vfc_136492
{ "difficulty": "medium", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1436/C", "time_limit": "1 second" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 1 2\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "123 42 24\n", "output": "824071958\n", "type": "stdin_stdout" }, { "fn_name": null, "...
taco
verifiable_code
https://codeforces.com/problemset/problem/161/B
Solve the following coding problem using the programming language python: One day Polycarpus stopped by a supermarket on his way home. It turns out that the supermarket is having a special offer for stools. The offer is as follows: if a customer's shopping cart contains at least one stool, the customer gets a 50% disc...
```python (n, k) = list(map(int, input().split())) p = [[], []] for i in range(1, n + 1): (c, t) = map(int, input().split()) p[t > 1].append((c, i)) if k > len(p[0]): l = k - len(p[0]) - 1 print(sum((c for (c, i) in p[0])) / 2 + sum((c for (c, i) in p[1]))) print('\n'.join(('1 ' + str(i) for (c, i) in p[0]))) pri...
vfc_136496
{ "difficulty": "medium_hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/161/B", "time_limit": "3.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "11 11\n6 2\n6 2\n1 2\n2 2\n3 1\n6 2\n1 1\n1 1\n3 1\n3 1\n6 2\n", "output": "32.5\n1 10\n1 9\n1 5\n1 8\n1 7\n1 11\n1 6\n1 2\n1 1\n1 4\n1 3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "21...
taco
verifiable_code
https://codeforces.com/problemset/problem/1248/B
Solve the following coding problem using the programming language python: Gardener Alexey teaches competitive programming to high school students. To congratulate Alexey on the Teacher's Day, the students have gifted him a collection of wooden sticks, where every stick has an integer length. Now Alexey wants to grow a...
```python def f(l): l.sort() h = len(l) // 2 y = sum(l[:h]) x = sum(l[h:]) return x * x + y * y _ = input() l = list(map(int, input().split())) print(f(l)) ```
vfc_136504
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1248/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 2 3\n", "output": "26", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1 1 2 2\n", "output": "20", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/find-pairs-with-given-relation1540/1
Solve the following coding problem using the programming language python: Given an array of distinct integers, write a program to find if there exist two pairs (a, b) and (c, d) such that ab = cd, where a, b, c and d are distinct elements. If such pairs exists then print 1 else -1. Example 1: Input: N=7 arr[] = {3, ...
```python class Solution: def findPairs(self, arr, n): H = dict() for i in range(n): for j in range(i + 1, n): prod = arr[i] * arr[j] if prod not in H.keys(): H[prod] = [i, j] else: return 1 return -1 ```
vfc_136508
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/find-pairs-with-given-relation1540/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N=7\narr[] = {3, 4, 7, 1, 2, 9, 8}", "output": "1", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1399/E1
Solve the following coding problem using the programming language python: Easy and hard versions are actually different problems, so we advise you to read both statements carefully. You are given a weighted rooted tree, vertex 1 is the root of this tree. A tree is a connected graph without cycles. A rooted tree has ...
```python import sys import math import bisect from sys import stdin, stdout from math import gcd, floor, sqrt, log2, ceil from collections import defaultdict from bisect import bisect_left as bl, bisect_right as br from collections import Counter from collections import deque from heapq import heappush, heappop, heapi...
vfc_136509
{ "difficulty": "hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1399/E1", "time_limit": "3.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n4 18\n2 1 9 2\n3 2 4 1\n4 1 1 2\n3 20\n2 1 8 1\n3 1 7 2\n5 50\n1 3 100 1\n1 5 10 2\n2 3 123 2\n5 4 55 1\n2 100\n1 2 409 2\n", "output": "0\n0\n11\n6\n", "type": "stdin_stdout" }, { "fn_name": null, ...