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/circle-and-lattice-points4257/1
Solve the following coding problem using the programming language python: Given an integer R which represents the radius of a circle that has (0,0) as its centre, find the total number of lattice points on the circumference. Lattice Points are points with coordinates as integers in 2-D space. Example 1: Input: R = 5 O...
```python import math class Solution: def latticePoints(self, r): if r == 0: return 0 count = 4 for i in range(1, r): t = math.sqrt(r * r - i * i) if t == int(t): count += 4 return count ```
vfc_88326
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/circle-and-lattice-points4257/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "R = 5", "output": "12", "type": "stdin_stdout" }, { "fn_name": null, "input": "R = 88", "output": "4", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Panda loves solving problems which are deemed impossible by his fellow classmates. The current problem which he is working on is to express a number N as sum of powers of number X (Not necessarily distinct) such that the number of powers of num...
```python test = int(input()) for t in range(test): n, m = list(map(int,input().split())) answer = 0 while n>0: answer += n%m n = n/m print(answer) ```
vfc_88327
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1000\n141 401\n789 953\n575 908\n278 464\n211 413\n221 458\n464 719\n983 997\n791 968\n273 401\n857 968\n341 726\n607 994\n785 957\n412 621\n822 764\n313 366\n321 951\n795 993\n566 602\n401 863\n602 793\n838 776\n818 977\n103 167\n...
taco
verifiable_code
https://www.hackerrank.com/challenges/count-palindromes/problem
Solve the following coding problem using the programming language python: A string is made of only lowercase latin letters (a,b,c,d,.....,z). Can you find the length of the lexicographically smallest string such that it has exactly ${K}$ sub-strings, each of which are palindromes? Input Format The first line of inp...
```python def compute_pallindrome_length(n): length = 0 debug_print = False current_n = 0 if n == 5: return 4 elif n == 8: return 5 i = int((1 + pow(1 + 8 * n, 0.5)) / 2) - 10 while i * (i + 1) // 2 <= n: current_n = i i += 1 length += current_n n -= current_n * (current_n + 1) // 2 if debug_print: ...
vfc_88342
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.hackerrank.com/challenges/count-palindromes/problem", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n10\n17\n", "output": "4\n7\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/CHEFLCM
Solve the following coding problem using the programming language python: Read problems statements in Mandarin Chinese and Russian. Chef wants to hire a new assistant. He published an advertisement regarding that in a newspaper. After seeing the advertisement, many candidates have applied for the job. Now chef want...
```python t = int(input()) for i in range(t): n = int(input()) c = 0 for i in range(1, int(n ** (1 / 2)) + 1): if n % i == 0: k = n // i if k == i: c = c + i else: c = c + i + k print(c) ```
vfc_88347
{ "difficulty": "medium", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CHEFLCM", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1\n2", "output": "1\n3", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n1\n3", "output": "1\n4\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: This problem is as simple as short. Just find how many numbers from A to B with sum of digits from X to Y are divisible by K. Input The first line contains 5 space-separated positive integers: A, B, X, Y, K Output Output one number - answer ...
```python A, B, X, Y, K=list(map(int,input().split())) def digsum(x): r=0 while x>0: r+=x%10 x/=10 return r #return sum(map(int,str(x))) def simpleCount(l,r): if r<=l: return 0 cnt=0 incr=0 if l%K: incr=K-l%K for x in range(l+incr,r,K): s=digsum(x) if X<=s<=Y:cnt+=1 return cnt if K>1.e5 or B-A<=2...
vfc_88351
{ "difficulty": "hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "31899089 149444449490 3 327 14704\n", "output": "112501\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2389783 900009000600 29 120 3713\n", "output": "10161354\n", "type": "st...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/minimum-element-in-a-sorted-and-rotated-array3611/1
Solve the following coding problem using the programming language python: A sorted(in ascending order) array A[ ] with distinct elements is rotated at some unknown point, the task is to find the minimum element in it. Example 1 Input: N = 5 arr[] = {4 ,5 ,1 ,2 ,3} Output: 1 Explanation: 1 is the minimum element inthe ...
```python class Solution: def findMin(self, arr, n): return min(arr) ```
vfc_88355
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/minimum-element-in-a-sorted-and-rotated-array3611/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 5\r\narr[] = {4 ,5 ,1 ,2 ,3}", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 7\r\narr[] = {10, 20, 30, 40, 50, 5, 7}", "output": "5", "type": "stdin_stdout...
taco
verifiable_code
https://codeforces.com/problemset/problem/900/B
Solve the following coding problem using the programming language python: You have a fraction $\frac{a}{b}$. You need to find the first occurrence of digit c into decimal notation of the fraction after decimal point. -----Input----- The first contains three single positive integers a, b, c (1 ≤ a < b ≤ 10^5, 0 ≤ c ...
```python (a, b, c) = input().split() (a, b, c) = (int(a), int(b), int(c)) rem1 = -1 flag = 0 count = 0 d = a % b while d != rem1 and count <= 1000000: rem1 = d % b count += 1 d = d * 10 q = d // b if q == c: print(count) flag = 1 break d = d % b if flag == 0: print(-1) ```
vfc_88356
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/900/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 2 0\n", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 3 7\n", "output": "-1", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 1000...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/87f12e5c728d69a5322634776b54c75897d14daa/1
Solve the following coding problem using the programming language python: Given a sorted linked list of distinct nodes (no two nodes have the same data) and an integer X. Count distinct triplets in the list that sum up to given integer X. Note: The Linked List can be sorted in any order. Example 1: Input: LinkedList: ...
```python def countTriplets(head, x): if head == None: return temp1 = head answer = [] while temp1: hashmap = {} temp2 = temp1.nxt while temp2: value = x - (temp1.val + temp2.val) if value in hashmap: answer.append([temp1.val, temp2.val, value]) else: hashmap[temp2.val] = 1 temp2 = temp2...
vfc_88360
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/87f12e5c728d69a5322634776b54c75897d14daa/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": "countTriplets", "input": "LinkedList:9->8->6->5->4->2->1, X = 17", "output": "2", "type": "function_call" }, { "fn_name": "countTriplets", "input": "LinkedList:9->8->6->5->4->2->1, X = 15", "output": "5", ...
taco
verifiable_code
https://codeforces.com/problemset/problem/554/B
Solve the following coding problem using the programming language python: Ohana Matsumae is trying to clean a room, which is divided up into an n by n grid of squares. Each square is initially either clean or dirty. Ohana can sweep her broom over columns of the grid. Her broom is very strange: if she sweeps over a cle...
```python n = int(input()) arr = [] maxt = 0 for i in range(0, n): arr.append(input()) for k in range(0, len(arr)): p = arr.count(arr[k]) if p > maxt: maxt = p print(maxt) ```
vfc_88361
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/554/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n0101\n1000\n1111\n0101\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n111\n111\n111\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_n...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/pythagorean-triplet3018/1
Solve the following coding problem using the programming language python: Given an array arr of N integers, write a function that returns true if there is a triplet (a, b, c) that satisfies a^{2} + b^{2} = c^{2}, otherwise false. Example 1: Input: N = 5 Arr[] = {3, 2, 4, 6, 5} Output: Yes Explanation: a=3, b=4, and c=...
```python class Solution: def checkTriplet(self, arr, n): arr.sort() A = [i ** 2 for i in arr] for i in A: for j in A: sm = i + j if sm < A[n - 1]: if sm in A: return True return False ```
vfc_88365
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/pythagorean-triplet3018/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 5\r\nArr[] = {3, 2, 4, 6, 5}", "output": "Yes", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 3\r\nArr[] = {3, 8, 5}", "output": "No", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/GDTURN
Solve the following coding problem using the programming language python: Chef and Chefina are playing with dice. In one turn, both of them roll their dice at once. They consider a turn to be *good* if the sum of the numbers on their dice is greater than 6. Given that in a particular turn Chef and Chefina got X and...
```python n = int(input()) for i in range(n): (x, y) = map(int, input().split()) if x + y > 6: print('YES') else: print('NO') ```
vfc_88370
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/GDTURN", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 4\n3 4\n4 2\n2 6\n", "output": "NO\nYES\nNO\nYES\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/SPOON
Solve the following coding problem using the programming language python: Chef recently saw the movie Matrix. He loved the movie overall but he didn't agree with some things in it. Particularly he didn't agree with the bald boy when he declared - There is no spoon. Being a chef, he understands the importance of the sp...
```python for i in range(int(input())): (n, m) = map(int, input().split()) l = [] for i in range(n): l.append(input().lower()) f = 0 for i in l: if 'spoon' in i: f = 1 break if f == 0: for j in range(m): for i in range(n - 4): if l[i][j] == 's' and l[i + 1][j] == 'p' and (l[i + 2][j] == 'o') an...
vfc_88374
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/SPOON", "time_limit": "0.372294 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3 6\nabDefb\nbSpoon\nNIKHil\n6 6\naaaaaa\nssssss\nxuisdP\noooooo\nioowoo\nbdylan\n6 5\nbdfhj\ncacac\nopqrs\nddddd\nindia\nyucky", "output": "There is a spoon!\nThere is a spoon!\nThere is indeed no spoon!", "type": "...
taco
verifiable_code
https://codeforces.com/problemset/problem/39/F
Solve the following coding problem using the programming language python: Thumbelina has had an accident. She has found herself on a little island in the middle of a swamp and wants to get to the shore very much. One can get to the shore only by hills that are situated along a straight line that connects the little i...
```python (n, m, k) = map(int, input().split()) (x, y) = (n, []) a = map(int, input().split()) b = list(map(int, input().split())) for (i, d) in enumerate(a): c = 0 for t in b: if 0 == t % d: c += 1 if c < x: x = c y = [i + 1] elif c == x: y += (i + 1,) print(len(y)) print(' '.join(map(str, y))) ```
vfc_88383
{ "difficulty": "easy", "memory_limit": "64.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/39/F", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10 3 6\n5 2 8\n5 6 7 8 9 10\n", "output": "1\n3 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "1000 19 27\n656 162 264 790 579 786 877 998 516 247 650 150 858 281 279 549 354 353 533\n349 ...
taco
verifiable_code
Solve the following coding problem using the programming language python: The time is 1st January 20000014 Gazu is depressed with his life as he thinks there is nothing unique about him. One day he meets a travelling coder, Gazu tells him why he is depressed, to which coder replies “Everyone is one in a zillion my br...
```python for _ in range(eval(input())): n=eval(input()) print(2**(n/30+1)) ```
vfc_88391
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "100\n3640\n715\n2917\n23574\n4631\n23050\n23994\n13247\n29539\n143\n306\n8581\n18888\n9588\n1153\n730\n8262\n2237\n1592\n666\n8846\n16789\n27976\n2679\n14767\n26032\n2753\n14076\n23537\n15442\n2272\n2006\n5121\n28552\n19273\n25014\...
taco
verifiable_code
https://www.codechef.com/problems/CHQUEENS
Solve the following coding problem using the programming language python: Chef got in the trouble! He is the king of Chefland and Chessland. There is one queen in Chefland and one queen in Chessland and they both want a relationship with him. Chef is standing before a difficult choice… Chessland may be considered a ch...
```python def C(n): return n * (n - 1) // 2 def sol(): (equal, mini) = (False, min(N, M)) total_ways = 2 * C(N * M) if N == M: equal = True ways = 0 if not equal: ways = N * C(M) + M * C(N) diag = 0 for i in range(2, mini + 1): diag += 2 * C(i) for i in range(mini + 1, max(N, M)): diag += C(mini)...
vfc_88400
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CHQUEENS", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3 3 2 2\n4 4 2 3\n", "output": "24\n94\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/make-the-hit-in-power-game3729/1
Solve the following coding problem using the programming language python: There are two integers (X and N). You have to make a number in such a way that it contains the first digit and last digit occurring in X^{1 }, X^{2 }, X^{3}, .... X^{N}. For Example: let's take X=12 and N=5. let l is last digit and f is first ...
```python class Solution: def powerGame(self, X, N): new_number = '' for i in range(1, N + 1): number = X ** i new_number = new_number + str(number)[0] + str(number)[-1] return new_number ```
vfc_88404
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/make-the-hit-in-power-game3729/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "X = 10, N = 2", "output": "1010", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Professor Sharma gives the following problem to his students: given two integers X( ≥ 2) and Y( ≥ 2) and tells them to find the smallest positive integral exponent E such that the decimal expansion of X^E begins with Y. For example, if X = 8 an...
```python for t in range(eval(input())): a,b=list(map(int,input().split())) i=1 b=str(b) l=len(b) mul=a while True: a=a*mul if str(a)[0:l]==b: i=i+1 break i=i+1 print("Case "+str(t+1)+":",i) ```
vfc_88405
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7\n21 85\n33 11\n41 79\n53 28\n81 53\n123 34\n245 88", "output": "Case 1: 4\nCase 2: 6\nCase 3: 9\nCase 4: 3\nCase 5: 7", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.hackerrank.com/challenges/counting-on-a-tree/problem
Solve the following coding problem using the programming language python: Taylor loves trees, and this new challenge has him stumped! Consider a tree, $\boldsymbol{\boldsymbol{t}}$, consisting of $n$ nodes. Each node is numbered from $1$ to $n$, and each node $\boldsymbol{i}$ has an integer, $c_i$, attached to it. ...
```python import sys from filecmp import cmp from os import linesep from time import time from collections import Counter memoized_BIT_prevs = [list() for _ in range(10 ** 5 + 1)] for i in range(1, 10 ** 5 + 1): next = i + (i & -i) if next >= len(memoized_BIT_prevs): continue memoized_BIT_prevs[next].append(i) cl...
vfc_88410
{ "difficulty": "hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.hackerrank.com/challenges/counting-on-a-tree/problem", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10 5\n10 2 3 5 10 5 3 6 2 1\n1 2\n1 3\n3 4\n3 5\n3 6\n4 7\n5 8\n7 9\n2 10\n8 5 2 10\n3 8 4 9\n1 9 5 9\n4 6 4 6\n5 8 5 8\n", "output": "0\n1\n3\n2\n0\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/77/A
Solve the following coding problem using the programming language python: The year of 2012 is coming... According to an ancient choradrican legend in this very year, in 2012, Diablo and his brothers Mephisto and Baal will escape from hell, and innumerable hordes of demons will enslave the human world. But seven brave...
```python from itertools import product, permutations, combinations n = int(input()) names = {} nex = 0 mama = 128 liking = [0] * mama likes = [[0] * 7 for _ in range(7)] def getName(name): global nex if name in names: return names[name] names[name] = nex nex += 1 return names[name] for _ in range(n): (a, b, c...
vfc_88418
{ "difficulty": "medium", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/77/A", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\nAnka likes Troll\nTroll likes Chapay\nTroll likes Hexadecimal\nHexadecimal likes Cleo\nSnowy likes Hexadecimal\nChapay likes Troll\n740076959 230477703 987799796\n", "output": "98788895 5\n", "type": "stdin_stdout" ...
taco
verifiable_code
https://codeforces.com/problemset/problem/555/A
Solve the following coding problem using the programming language python: Andrewid the Android is a galaxy-famous detective. He is now investigating the case of vandalism at the exhibition of contemporary art. The main exhibit is a construction of n matryoshka dolls that can be nested one into another. The matryoshka...
```python (n, k) = map(int, input().split()) p = [0 for i in range(n + 1)] d = p.copy() for i in range(k): a = list(map(int, input().split())) l = len(a) for j in range(1, l - 1): p[a[j]] = a[j + 1] d[a[j + 1]] = 1 c = 1 while p[c] == c + 1: c = p[c] ans = 0 for i in range(c + 1, n + 1): ans += 1 + d[i] print(...
vfc_88422
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/555/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2\n2 1 2\n1 3\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7 3\n3 1 3 7\n2 2 5\n2 4 6\n", "output": "10\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: In this problem you will be given a range 'n', and you are supposed to find all composite numbers within that range. Make your program efficient as time limit of the program is set to 1 second. Choose an efficient algorithm to find all the compo...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' #print 'Hello World!' import math def findprime(n): for i in range(2,int(math.sqrt(n)) + 1): if(n % i == 0): print(n, end=' ') break n = int(input()) if(n == 1 or n==...
vfc_88430
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "108", "output": "4 6 8 9 10 12 14 15 16 18 20 21 22 24 25 26 27 28 30 32 33 34 35 36 38 39 40 42 44 45 46 48 49 50 51 52 54 55 56 57 58 60 62 63 64 65 66 68 69 70 72 74 75 76 77 78 80 81 82 84 85 86 87 88 90 91 92 93 94 95 96...
taco
verifiable_code
Solve the following coding problem using the programming language python: Sunake is in the form of a polygonal line consisting of n vertices (without self-intersection). First, Sunake-kun's i-th vertex is at (xi, yi). You can move continuously by translating or rotating, but you cannot deform (change the length of the...
```python import sys readline = sys.stdin.readline write = sys.stdout.write def dot3(p0, p1, p2): (x0, y0) = p0 (x1, y1) = p1 (x2, y2) = p2 return (x1 - x0) * (x2 - x0) + (y1 - y0) * (y2 - y0) def cross3(p0, p1, p2): (x0, y0) = p0 (x1, y1) = p1 (x2, y2) = p2 return (x1 - x0) * (y2 - y0) - (y1 - y0) * (x2 - x0...
vfc_88435
{ "difficulty": "unknown_difficulty", "memory_limit": "268.435456 megabytes", "memory_limit_bytes": null, "problem_url": null, "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n0 1\n1 1\n1 2\n3 2", "output": "Possible\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "11\n63 106\n87 143\n102 132\n115 169\n74 145\n41 177\n56 130\n28 102\n19 124\n0 156\n22 183", ...
taco
verifiable_code
https://www.codechef.com/problems/JASSIGNMENTS
Solve the following coding problem using the programming language python: Janmansh has to submit 3 assignments for Chingari before 10 pm and he starts to do the assignments at X pm. Each assignment takes him 1 hour to complete. Can you tell whether he'll be able to complete all assignments on time or not? ------ Inpu...
```python t = int(input()) for i in range(t): x = int(input()) if x + 3 <= 10: print('Yes') else: print('No') ```
vfc_88439
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/JASSIGNMENTS", "time_limit": "0.5 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n7\n9\n", "output": "Yes\nNo\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: It's been a while since I played with A, B, and C. Mr. A and Mr. B became players, and Mr. C became a referee and played a badminton singles game. The rules decided by the three people are as follows. * 3 Play the game. * The person who gets 11...
```python import sys while True: a = [] for i in range(3): z = str(input()) if z == '0': sys.exit() a.append(z) (A, B, C) = (a[0], a[1], a[2]) A = A[1:] + B[0] B = B[1:] + C[0] C = C[1:] print(A.count('A'), A.count('B')) print(B.count('A'), B.count('B')) (d, e) = (C.count('A'), C.count('B')) if d > e...
vfc_88443
{ "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": "AABBAAABABAABBBAABA\nAABBBABBABBAAABABABAAB\nBABAABAABABABBAAAB\nAABABAAABBAABBBABAA\nAAAAAAAAAAA\nABBBBBBBBBB\n0", "output": "11 8\n10 12\n11 7\n11 8\n11 0\n0 11\n", "type": "stdin_stdout" }, { "fn_name":...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/make-coprime-array3058/1
Solve the following coding problem using the programming language python: Given an array of N elements, find the minimum number of insertions to convert the given array into a co-prime array adjacent pair-wise. Example 1: Input: A[] = {2, 7, 28} Output: 1 Explanation: Here, 1st pair = {2, 7} are co-primes( gcd(2, 7) ...
```python from fractions import gcd class Solution: def countCoPrime(self, arr, n): def gcd(m, n): while n: (m, n) = (n, m % n) return abs(m) c = 0 for i in range(0, n - 1, 1): if gcd(arr[i], arr[i + 1]) != 1: c += 1 return c ```
vfc_88447
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/make-coprime-array3058/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "A[] = {2, 7, 28}", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "A[] = {5, 10, 20}", "output": "2", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1220/C
Solve the following coding problem using the programming language python: Mike and Ann are sitting in the classroom. The lesson is boring, so they decided to play an interesting game. Fortunately, all they need to play this game is a string $s$ and a number $k$ ($0 \le k < |s|$). At the beginning of the game, players...
```python import atexit import io import sys _I_B = sys.stdin.read().splitlines() input = iter(_I_B).__next__ _O_B = io.StringIO() sys.stdout = _O_B @atexit.register def write(): sys.__stdout__.write(_O_B.getvalue()) def main(): s = input() mn = s[0] for i in range(len(s)): mn = min(mn, s[i]) if s[i] > mn: ...
vfc_88449
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1220/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "abba\n", "output": "Mike\nAnn\nAnn\nMike\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "cba\n", "output": "Mike\nMike\nMike\n", "type": "stdin_stdout" }, { "fn_n...
taco
verifiable_code
https://www.codechef.com/problems/BOOLGAME
Solve the following coding problem using the programming language python: Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. Consider $N$ binary variables $x_{1}, x_{2}, \ldots, x_{N}$. For each valid $i$, the $i$-th of these variables can be $x_{i} = 0$ or $x_{i} = 1$; the...
```python from sys import stdin input = stdin.readline def answer(): dp = [[] for i in range(n + 1)] dp[0].append(0) for i in range(1, n + 1): dp[i].extend(dp[i - 1]) for j in range(i, 0, -1): x = 0 for l in range(j, i + 1): for r in range(l, i + 1): x += value[l][r] if j == 1: dp[i].appen...
vfc_88453
{ "difficulty": "hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/BOOLGAME", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n4 2 3\n-4 -2 5 2\n1 3 0\n1 4 -3", "output": "7 5 5", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/898/C
Solve the following coding problem using the programming language python: Vasya has several phone books, in which he recorded the telephone numbers of his friends. Each of his friends can have one or several phone numbers. Vasya decided to organize information about the phone numbers of friends. You will be given n s...
```python def check_suffix(s1, s2): l1 = len(s1) l2 = len(s2) if l1 >= l2: return 0 if s2[-l1:] == s1: return 1 return 0 def no_suffix(ls): ls2 = [] for i in range(len(ls)): for j in range(len(ls)): if i == j: continue if check_suffix(ls[i], ls[j]) == 1: ls2.append(ls[i]) for i in ls2: if...
vfc_88457
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/898/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\nivan 1 00123\nmasha 1 00123\n", "output": "2\nmasha 1 00123 \nivan 1 00123 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\nkarl 2 612 12\npetr 1 12\nkatya 1 612\n", "output": ...
taco
verifiable_code
https://www.codechef.com/problems/CHEFLR
Solve the following coding problem using the programming language python: Chef has a nice complete binary tree in his garden. Complete means that each node has exactly two sons, so the tree is infinite. Yesterday he had enumerated the nodes of the tree in such a way: - Let's call the nodes' level a number of nodes th...
```python for t in range(int(input())): s = input() n = 1 for i in range(len(s)): if i % 2 == 0: if s[i] == 'l': n = n * 2 if s[i] == 'r': n = n * 2 + 2 else: if s[i] == 'l': n = n * 2 - 1 if s[i] == 'r': n = n * 2 + 1 print(n % (10 ** 9 + 7)) ```
vfc_88461
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CHEFLR", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\nlrl\nrll\nr\nlllr\n\n", "output": "10\n14\n4\n13\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/candy-packetssample-test-case-file-to-be-added1632/1
Solve the following coding problem using the programming language python: Given a number N denoting candies. Find how many packets are needed to contain the number if 1st packet can contain 1 candy, 2nd packet can contain 2 candies, 3rd packet can contain 4 candies and so on. Example 1: Input: N = 2 Output: 2 Explanat...
```python class Solution: def countPackets(self, N): c = 0 while N: N //= 2 c += 1 return c ```
vfc_88473
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/candy-packetssample-test-case-file-to-be-added1632/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 2", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 8", "output": "4", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1032/B
Solve the following coding problem using the programming language python: At many competitions that have a word «cup» in its official name the winner is presented with an actual cup. This time the organizers of one unusual programming competition have decided to please the winner even more and to add a nameplate to th...
```python def print2d(a): for i in range(len(a)): print(''.join(list(map(str, a[i])))) st = input() for i in range(1, 5 + 1): vst = len(st) // i ost = len(st) % i if vst + min(ost, 1) > 20: continue a = [0] * i ind = 0 f = 0 for j in range(len(a)): a[j] = [] for j in range(len(a)): for k in range(vst):...
vfc_88474
{ "difficulty": "easy", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1032/B", "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "uvkxATqVwsCaAJeBaBGXZKiktZFHbzywaqNdrGSNfgTIwOBFzKDv\n", "output": "3 18\nuvkxATqVwsCaAJeBa*\nBGXZKiktZFHbzywaq*\nNdrGSNfgTIwOBFzKDv\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "aoNtJAe...
taco
verifiable_code
https://www.codechef.com/problems/VILLINE
Solve the following coding problem using the programming language python: WW3 is near and Gru wants to recruit minions for his team. Gru went to the planet of minions to recruit minions, he saw that there are two villages separated by a river. He cannot recruit minions from both villages because then his team will hav...
```python n = int(input()) (m, c) = map(int, input().split()) (a, b) = (0, 0) for i in range(n): (x, y, p) = map(int, input().split()) if m * x + c < y: a = a + p else: b = b + p print(max(a, b)) ```
vfc_88482
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/VILLINE", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 0\n0 5 5\n0 6 5\n0 -8 20", "output": "20", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Our monk, while taking a stroll in the park, stumped upon a polynomial ( A X^2 + B X +C ) lying on the ground. The polynomial was dying! Being considerate, our monk tried to talk and revive the polynomial. The polynomial said: I have served m...
```python t=eval(input()) while t>0: a,b,c,k=list(map(int,input().split())) i=50 while True: if (a*i*i)+(b*i)+(c)>=k: j=i-50 while j<=i: if (a*j*j)+(b*j)+(c)>=k: print(j) break j+=1 break i+=50 t-=1 ```
vfc_88486
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n3 4 5 1\n3 4 5 2\n3 4 5 3\n3 4 5 4\n3 4 5 5\n3 4 5 6\n", "output": "5\n6\n6\n6\n6\n6\n6\n6\n6\n7\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1000\n4 3 2 3258\n5 1 3 15082\n5 2 5 138...
taco
verifiable_code
Solve the following coding problem using the programming language python: problem JOI decided to make a signboard for the store. There are N old signboards with letters written at equal intervals. JOI makes a sign by erasing some letters from the old sign. I want the remaining characters to be the name of the store,...
```python n = int(input()) name = input() length = len(name) def check(ss): ind = 0 end = len(ss) while ind < end: while ind < end and ss[ind] != name[0]: ind += 1 for i in range(100): j1 = ind j2 = 0 while j1 < end and j2 < length and (ss[j1] == name[j2]): j1 += i j2 += 1 if j2 == length...
vfc_88495
{ "difficulty": "unknown_difficulty", "memory_limit": "134.217728 megabytes", "memory_limit_bytes": null, "problem_url": null, "time_limit": "8.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\nbar\nabracadabra\nbear\nbar\nbbraxbara", "output": "3\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: A wise king declared a new calendar. "Tomorrow shall be the first day of the calendar, that is, the day 1 of the month 1 of the year 1. Each year consists of 10 months, from month 1 through month 10, and starts from a big month. A common year sh...
```python for cno in range(int(input())): (y, m, d) = map(int, input().split()) ans = 195 * y if y > 1: ans += 5 * ((y - 1) // 3) if y % 3: ans += 19 * (m - 1) + m // 2 else: ans += (m - 1) * 20 print(196666 - ans - d) ```
vfc_88500
{ "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": "8\n1 1 1\n344 3 1\n696 5 1\n182 9 5\n998 5 7\n344 2 19\n696 4 19\n999 10 20", "output": "196470\n128976\n59710\n160715\n311\n128977\n59712\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input":...
taco
verifiable_code
Solve the following coding problem using the programming language python: problem A city in Canada where JOI lives is divided into a grid pattern by w roads that extend straight in the north-south direction and h roads that extend straight in the east-west direction. The w roads in the north-south direction are numb...
```python for e in iter(input, '0 0'): (w, h) = map(int, e.split()) M = [[[1, 0] * 2 for _ in [0] * h] for _ in [0] * w] for i in range(1, w): for j in range(1, h): (a, b, c, d) = [*M[i - 1][j][:2], *M[i][j - 1][2:]] M[i][j] = [d, a + b, b, c + d] print((sum(M[w - 2][h - 1][:2]) + sum(M[w - 1][h - 2][2:])) ...
vfc_88504
{ "difficulty": "unknown_difficulty", "memory_limit": "134.217728 megabytes", "memory_limit_bytes": null, "problem_url": null, "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 4\n15 20\n0 0", "output": "5\n58046\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 4\n15 24\n0 0", "output": "5\n8663\n", "type": "stdin_stdout" }, { "fn_nam...
taco
verifiable_code
Solve the following coding problem using the programming language python: Xenny was a teacher and he had N students. The N children were sitting in a room. Each child was wearing a white T-shirt, with a unique number from the range 1 to N written on it. T-Shirts of pink and blue color were to be distributed among the ...
```python def val(x): if x=='B': return 1 return 0 n,m=(int(e) for e in input().split()) arr=[val(e) for e in input().split()] graph={} for afsafsa in range(m): u,v=(int(e)-1 for e in input().split()) if u in graph: graph[u].append(v) else: graph[u]=[v] if v in graph: graph[v].append(u) else: graph[v...
vfc_88508
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "91 1026\nB B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B \n41 13\n65 24\n46 42\n61 82\n77 24\n91 ...
taco
verifiable_code
https://www.codechef.com/COLE2020/problems/CLLCM
Solve the following coding problem using the programming language python: Chef got into a fight with the evil Dr Doof. Dr Doof has decided to destroy all even numbers from the universe using his Evil-Destroy-inator. Chef has $N$ integers with him. To stop Doof, Chef has to find an odd number which is an integer multip...
```python def gcd(a, b): if b == 0: return a return gcd(b, a % b) for _ in range(int(input())): n = int(input()) arr = list(map(int, input().split())) value = arr[0] if n != 1: for i in arr[1:]: value = value * i // gcd(value, i) if value % 2 == 0: print('NO') else: print('YES') ```
vfc_88512
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/COLE2020/problems/CLLCM", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5\n1 2 5 4 3\n1\n7\n", "output": "NO\nYES\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/odd-even-level-difference/1
Solve the following coding problem using the programming language python: Given a Binary Tree. Find the difference between the sum of node values at even levels and the sum of node values at the odd levels. Example 1: Input: 1 / \ 2 3 Output: -4 Explanation: sum at odd levels - sum...
```python class Solution: def getLevelDiff(self, root): if root == None: return 0 q = [] q.append(root) reverse = True s = 0 while q != []: c = len(q) for i in range(c): val = q.pop(0) if reverse == True: s += val.data else: s -= val.data if val.left != None: q.appe...
vfc_88516
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/odd-even-level-difference/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n / \\\n 2 3", "output": "-4", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n / \\\n 20 30\n / \\ \n 40 60", ...
taco
verifiable_code
Solve the following coding problem using the programming language python: The Monk is trying to explain to its users that even a single unit of time can be extremely important and to demonstrate this particular fact he gives them a challenging task. There are N processes to be completed by you, the chosen one, sinc...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' t=int(input()) c=input().split() i=input().split() x=0 z=0 while x<t: if c[x]==i[x]: x+=1 else: temp=c[x] for j in range(x+1,t): c[j-1]=c[j] c[t-1]=temp z+=1 pri...
vfc_88517
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n5 4 2 3 1\n5 2 1 4 3", "output": "1733\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n5 4 8 9 1 6 3 2 7 10\n1 6 8 9 5 4 10 3 2 7", "output": "1515\n", "type": "stdin_st...
taco
verifiable_code
https://codeforces.com/problemset/problem/397/B
Solve the following coding problem using the programming language python: Alexey, a merry Berland entrant, got sick of the gray reality and he zealously wants to go to university. There are a lot of universities nowadays, so Alexey is getting lost in the diversity — he has not yet decided what profession he wants to g...
```python t = int(input()) for _ in range(t): (n, l, r) = map(int, input().split()) print('No' if n // l * r < n else 'Yes') ```
vfc_88521
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/397/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5 2 3\n6 4 5\n", "output": "Yes\nNo\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "50\n69 6 6\n22 1 1\n23 3 3\n60 13 13\n13 3 3\n7 4 7\n6 1 1\n49 7 9\n68 8 8\n20 2 2\n34 1 1\n79 5 5\n2...
taco
verifiable_code
Solve the following coding problem using the programming language python: problem AOR Ika is studying to pass the test. AOR Ika-chan solved the $ N $ question. After that, round the solved problem according to the following procedure. 1. Check the correctness of the answer. 2. If the answer is correct, write a circ...
```python def main(): N = int(input()) S = input() try: ans = S.index('xx') + 1 print(ans) except: print(N) main() ```
vfc_88525
{ "difficulty": "unknown_difficulty", "memory_limit": "268.435456 megabytes", "memory_limit_bytes": null, "problem_url": null, "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\nnxx", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\nnwx", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\nxx...
taco
verifiable_code
https://codeforces.com/problemset/problem/26/B
Solve the following coding problem using the programming language python: A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))...
```python import os import sys from io import BytesIO, IOBase def main(): l = list(input()) ans = 0 stack = 0 for item in l: if item == '(': stack += 1 elif stack: ans += 2 stack -= 1 print(ans) BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno()...
vfc_88529
{ "difficulty": "medium", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/26/B", "time_limit": "5.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "))()()((()()))())()(((((((())((((((((())()()((())(\n", "output": "32\n", "type": "stdin_stdout" }, { "fn_name": null, "input": ")))((((())(()((()((((()()())((\n", "output": "16\n", "type"...
taco
verifiable_code
https://www.codechef.com/problems/CIELRCPT
Solve the following coding problem using the programming language python: Tomya is a girl. She loves Chef Ciel very much. Tomya like a positive integer p, and now she wants to get a receipt of Ciel's restaurant whose total price is exactly p. The current menus of Ciel's restaurant are shown the following table. Name ...
```python for i in range(int(input())): a = int(input()) j = 11 c = 0 while a > 0: b = a // 2 ** j c += b a = a % 2 ** j j -= 1 print(c) ```
vfc_88533
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CIELRCPT", "time_limit": "1.32 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n10\n256\n255\n4096\n", "output": "2\n1\n8\n2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n10\n376\n255\n4096", "output": "2\n5\n8\n2\n", "type": "stdin_stdout" }, ...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/array-of-alternate-ve-and-ve-nos1401/1
Solve the following coding problem using the programming language python: Given an unsorted array Arr of N positive and negative numbers. Your task is to create an array of alternate positive and negative numbers without changing the relative order of positive and negative numbers. Note: Array should start with a posi...
```python class Solution: def rearrange(self, arr, n): pn = [] nn = [] for i in arr: if i < 0: nn.append(i) else: pn.append(i) i = 0 pn.reverse() nn.reverse() while len(pn) != 0 and len(nn) != 0: p = pn.pop() arr[i] = p n = nn.pop() i += 1 arr[i] = n i += 1 if len(pn) !...
vfc_88537
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/array-of-alternate-ve-and-ve-nos1401/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 9\nArr[] = {9, 4, -2, -1, 5, 0, -5, -3, 2}", "output": "9 -2 4 -1 5 -5 0 -3 2", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 10\nArr[] = {-5, -2, 5, 2, 4, 7, 1, 8, 0, -8}", "o...
taco
verifiable_code
https://codeforces.com/problemset/problem/606/D
Solve the following coding problem using the programming language python: Student Vladislav came to his programming exam completely unprepared as usual. He got a question about some strange algorithm on a graph — something that will definitely never be useful in real life. He asked a girl sitting next to him to lend h...
```python import os import sys from io import BytesIO, IOBase from heapq import * def main(): (n, m) = map(int, input().split()) a = [list(map(int, input().split())) for _ in range(m)] (edges, j, b) = ([[]] * m, 1, sorted(range(m), key=lambda x: a[x][0] * 10000000000 - a[x][1])) c = [] for i in range(1, n - 1): ...
vfc_88538
{ "difficulty": "medium_hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/606/D", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 9\n1 1\n2 1\n3 0\n4 1\n5 0\n6 0\n7 0\n8 1\n9 0\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 6\n1 1\n3 1\n2 0\n2 1\n3 0\n3 0\n", "output": "1 2\n1 4\n2 3\n1 3...
taco
verifiable_code
https://codeforces.com/problemset/problem/321/B
Solve the following coding problem using the programming language python: Fox Ciel is playing a card game with her friend Jiro. Jiro has n cards, each one has two attributes: position (Attack or Defense) and strength. Fox Ciel has m cards, each one has these two attributes too. It's known that position of all Ciel's ...
```python (n, m) = map(int, input().split()) (a, d) = ([], []) for i in range(n): (t, val) = input().split() (a if t == 'ATK' else d).append(int(val)) my = sorted([int(input()) for i in range(m)]) a.sort() d.sort() def solve1(): ret = 0 used = [False] * m for val in d: for i in range(m): if not used[i] and m...
vfc_88542
{ "difficulty": "hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/321/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 3\nATK 2000\nDEF 1700\n2500\n2500\n2500\n", "output": "3000\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/k-largest-elements3736/1
Solve the following coding problem using the programming language python: Given an array of N positive integers, print k largest elements from the array. Example 1: Input: N = 5, k = 2 arr[] = {12,5,787,1,23} Output: 787 23 Explanation: First largest element in the array is 787 and the second largest is 23. Example 2...
```python import heapq class Solution: def kLargest(self, li, n, k): pq = [] ans = [] n = len(li) for i in range(n): heapq.heappush(pq, -li[i]) f = k while f > 0: a = heapq.heappop(pq) ans.append(-a) f -= 1 return ans ```
vfc_88546
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/k-largest-elements3736/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 5, k = 2\r\narr[] = {12,5,787,1,23}", "output": "787 23", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 7, k = 3\r\narr[] = {1,23,12,9,30,2,50}", "output": "50 30 23", "t...
taco
verifiable_code
https://codeforces.com/problemset/problem/344/C
Solve the following coding problem using the programming language python: Mad scientist Mike is building a time machine in his spare time. To finish the work, he needs a resistor with a certain resistance value. However, all Mike has is lots of identical resistors with unit resistance R0 = 1. Elements with other resi...
```python import sys import string import math import heapq from collections import defaultdict from collections import deque from collections import Counter from functools import lru_cache from fractions import Fraction def mi(s): return map(int, s.strip().split()) def lmi(s): return list(mi(s)) def tmi(s): retu...
vfc_88547
{ "difficulty": "medium_hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/344/C", "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "36 316049483082136289\n", "output": "8779152307837131\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 923438\n", "output": "923438\n", "type": "stdin_stdout" }, { ...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/prefix-to-infix-conversion/1
Solve the following coding problem using the programming language python: You are given a string S of size N that represents the prefix form of a valid mathematical expression. Convert it to its infix form. Example 1: Input: *-A/BC-/AKL Output: ((A-(B/C))*((A/K)-L)) Explanation: The above output is its valid infix ...
```python class Solution: def preToInfix(self, pre_exp): stk = [] i = len(pre_exp) - 1 while i != -1: if pre_exp[i] in ['+', '/', '*', '-', '^', '(', ')']: op1 = stk.pop() op2 = stk.pop() stk.append('(' + op1 + prefix[i] + op2 + ')') else: stk.append(pre_exp[i]) i -= 1 return stk.pop(...
vfc_88552
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/prefix-to-infix-conversion/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "*-A/BC-/AKL", "output": "((A-(B/C))*((A/K)-L))", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Bosky needs your help in completing his maths homework today. He has to solve some questions as homework from a book named Jungly Mathematics. He knows that Jungly Mathematics contains certain quadratic equations which have imaginary roots. He i...
```python n = int(input()) count = 0 for i in range(n): s = input().split() a,b,c = int(s[0]),int(s[1]),int(s[2]) if b*b-(4*a*c)>=0: count+=1 print(count) ```
vfc_88556
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1 1 1\n1 0 -1", "output": "5", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\n1 7 5\n2 -1 1\n5 1 -4\n1 0 -4\n1 0 4\n1 0 -9\n1 0 0", "output": "1", "type": "stdin_stdout" ...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/euler-totient-sum-and-divisors5501/1
Solve the following coding problem using the programming language python: Given a number N find the sum of the Euler Totient values of all the divisors of N. Example 1: Input: N = 5 Output: 5 Explanation: 1 and 5 are the factor of 5 and Φ(1) = 1 and Φ(5) = 4 and their sum is 4 + 1 = 5 Example 2: Input: N = 1 Output...
```python class Solution: def phiSum(self, N): return N ```
vfc_88560
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/euler-totient-sum-and-divisors5501/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 5", "output": "5", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 1", "output": "1", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/EITA
Solve the following coding problem using the programming language python: Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chefland has $7$ days in a week. Chef is very conscious about his work done during the week. There are two ways he can spend his energy during the w...
```python def main(): t = input() for i in range(int(t)): (d, x, y, z) = map(int, input().split()) first = x * 7 second = y * d + (7 - d) * z if first >= second: print(first) elif second > first: print(second) main() ```
vfc_88561
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/EITA", "time_limit": "0.5 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 2 3 1\n6 2 3 1\n1 2 8 1", "output": "14\n19\n14", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/recamans-sequence4856/1
Solve the following coding problem using the programming language python: Given an integer n. Print first n elements of Recaman’s sequence. It is basically a function with domain and co-domain as natural numbers and 0. It is recursively defined as below: Specifically, let a(n) denote the (n+1)-th term. (0 being alread...
```python class Solution: def __init__(self): self.res = [] def recamanSequence(self, n): self.recaman(n) return self.res def recaman(self, n): if n == 1: self.res.append(0) return 0 self.recaman(n - 1) minus_val = self.res[-1] - (n - 1) if minus_val > 0 and minus_val not in self.res: self....
vfc_88566
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/recamans-sequence4856/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "n = 6", "output": "0 1 3 6 2 7", "type": "stdin_stdout" }, { "fn_name": null, "input": "n = 3", "output": "0 1 3", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1324/C
Solve the following coding problem using the programming language python: There is a frog staying to the left of the string $s = s_1 s_2 \ldots s_n$ consisting of $n$ characters (to be more precise, the frog initially stays at the cell $0$). Each character of $s$ is either 'L' or 'R'. It means that if the frog is stay...
```python testcases = int(input()) for i in range(testcases): moves = input() + 'R' index = -1 ans = 0 for i in range(len(moves)): if moves[i] == 'R': ans = max(ans, i - index) index = i print(ans) ```
vfc_88567
{ "difficulty": "easy", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1324/C", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\nLRLRRLL\nL\nLLR\nRRRR\nLLLLLL\nR\n", "output": "3\n2\n3\n1\n7\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\nRRLRLLL\nL\nLLR\nRRRR\nLLLLLL\nR\n", "output": "4\n2\n3\n1\n7\n...
taco
verifiable_code
https://www.codechef.com/problems/GRIDCONN
Solve the following coding problem using the programming language python: Read problems statements in Mandarin Chinese and Russian. The problem is completely unrelated to its problem code :). Let us build an infinite string D that is simply a concatenation of the decimal representations of all positive integers wi...
```python T = int(input()) def calc(w): w -= 1 ans = 1 t = 10 d = 1 while t - 1 <= w: ans += t // 10 * 9 * d d += 1 t *= 10 return ans + d * (w - t // 10 + 1) def solve(S): ans = [] for K in range(1, len(S) + 1): if ans != []: break for N in range(K): sub = S[N:N + K] if sub[0] == '0': ...
vfc_88571
{ "difficulty": "very_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/GRIDCONN", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n78910\n9930", "output": "7\n2679", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/CHEFBOTTLE
Solve the following coding problem using the programming language python: Chef has N empty bottles where each bottle has a capacity of X litres. There is a water tank in Chefland having K litres of water. Chef wants to fill the empty bottles using the water in the tank. Assuming that Chef does not spill any water...
```python t = int(input()) for i in range(t): (n, x, k) = map(int, input().split()) bottle = 0 if n * x <= k: print(n) else: for i in range(1, n + 1): if x * i <= k: bottle = bottle + 1 print(bottle) ```
vfc_88579
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CHEFBOTTLE", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n5 2 8\n10 5 4\n3 1 4", "output": "4\n0\n3", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1214/E
Solve the following coding problem using the programming language python: It's Petya's birthday party and his friends have presented him a brand new "Electrician-n" construction set, which they are sure he will enjoy as he always does with weird puzzles they give him. Construction set "Electrician-n" consists of 2n -...
```python n = int(input()) d = map(int, input().split()) d = [[2 * i + 1, di] for (i, di) in enumerate(d)] d = sorted(d, key=lambda x: x[1], reverse=True) edge = [] arr = [x[0] for x in d] for (i, [x, d_]) in enumerate(d): if i + d_ - 1 == len(arr) - 1: arr.append(x + 1) edge.append([arr[i + d_ - 1], x + 1]) for (u...
vfc_88583
{ "difficulty": "hard", "memory_limit": "512.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1214/E", "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n2 2 2 2\n", "output": "7 5\n5 3\n3 1\n5 8\n3 6\n1 4\n4 2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "99\n2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/mobile-numeric-keypad5456/1
Solve the following coding problem using the programming language python: Given the mobile numeric keypad. You can only press buttons that are up, left, right, or down to the current button or the current button itself (like 00,11, etc.). You are not allowed to press the bottom row corner buttons (i.e. * and # ). Give...
```python class Solution: def getCount(self, N): neigh = [[0, 8], [1, 2, 4], [1, 2, 3, 5], [2, 3, 6], [1, 4, 5, 7], [2, 4, 5, 6, 8], [3, 5, 6, 9], [4, 7, 8], [5, 7, 8, 9, 0], [6, 8, 9]] dp = [-1 for j in range(10)] ans = [-1 for j in range(10)] for i in range(10): ans[i] = 1 for n in range(2, N + 1): ...
vfc_88587
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/mobile-numeric-keypad5456/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1", "output": "10", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 2", "output": "36", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.hackerrank.com/challenges/the-power-sum/problem
Solve the following coding problem using the programming language python: Find the number of ways that a given integer, $\mbox{X}$, can be expressed as the sum of the $N^{\mbox{th}}$ powers of unique, natural numbers. For example, if $X=13$ and $N=2$, we have to find all combinations of unique squares adding up to $...
```python (num1, num2) = (int(input()), int(input())) def power_sum(num, count, total, pair_count): powered_num = num ** num2 if powered_num == total: return pair_count + 1 if powered_num < total: return power_sum(num + 1, count - 1, total - powered_num, pair_count) + power_sum(num + 1, count, total, pair_count...
vfc_88588
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.hackerrank.com/challenges/the-power-sum/problem", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n2\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "100\n2\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10...
taco
verifiable_code
https://codeforces.com/problemset/problem/1151/A
Solve the following coding problem using the programming language python: Today in the scientific lyceum of the Kingdom of Kremland, there was a biology lesson. The topic of the lesson was the genomes. Let's call the genome the string "ACTG". Maxim was very boring to sit in class, so the teacher came up with a task f...
```python import sys as snus n = int(snus.stdin.readline()) s = snus.stdin.readline() ans = 10 ** 4 gen = 'ACTG' for i in range(n - 3): s1 = s[i:i + 4] a = 0 for j in range(4): b = abs(ord(s1[j]) - ord(gen[j])) b = min(b, 26 - b) a += b ans = min(ans, a) print(ans) ```
vfc_88592
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1151/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\nZCTH\n", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\nZDATG\n", "output": "5", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\...
taco
verifiable_code
https://codeforces.com/problemset/problem/1327/E
Solve the following coding problem using the programming language python: You wrote down all integers from $0$ to $10^n - 1$, padding them with leading zeroes so their lengths are exactly $n$. For example, if $n = 3$ then you wrote out 000, 001, ..., 998, 999. A block in an integer $x$ is a consecutive segment of equ...
```python def main(): import sys input = sys.stdin.readline n = int(input()) mod = 998244353 l = [1] ans = [] for i in range(2 * 10 ** 5): l.append(l[-1] * 10 % mod) for i in range(1, n): ans.append((10 * 9 * l[n - i - 1] * 2 + 10 * 81 * l[n - i - 2] * (n - i - 1)) % mod) ans.append(10) print(*ans) main()...
vfc_88597
{ "difficulty": "medium_hard", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1327/E", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n", "output": "10\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n", "output": "180 10\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n",...
taco
verifiable_code
https://codeforces.com/problemset/problem/296/B
Solve the following coding problem using the programming language python: Yaroslav thinks that two strings s and w, consisting of digits and having length n are non-comparable if there are two numbers, i and j (1 ≤ i, j ≤ n), such that s_{i} > w_{i} and s_{j} < w_{j}. Here sign s_{i} represents the i-th digit of strin...
```python from functools import reduce n = int(input()) (s1, s2) = (str(input()), str(input())) print((10 ** sum([(s1[i] == '?') + (s2[i] == '?') for i in range(n)]) - (not reduce(lambda x, y: x or y, [s1[i] != '?' and s2[i] != '?' and (ord(s1[i]) > ord(s2[i])) for i in range(n)], False)) * reduce(lambda x, y: x * y % ...
vfc_88601
{ "difficulty": "hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/296/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n90\n09\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n11\n55\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "inpu...
taco
verifiable_code
https://www.codechef.com/problems/BINHAPP
Solve the following coding problem using the programming language python: For a binary string S, define its beauty to be the maximum number of [substrings] S can be partitioned into, such that each substring has strictly more ones than zeroes. For example, the beauty of 11011 is 3, as it can be partitioned as [110][1]...
```python from sys import stdin input = stdin.readline inp = lambda : list(map(int, input().split())) def b_s(take, left, right): (l, h) = (0, len(take) - 1) while l <= h: mid = (l + h) // 2 if take[mid] < left: l = mid + 1 continue if take[mid] > right: h = mid - 1 continue return take[mid] def...
vfc_88605
{ "difficulty": "very_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/BINHAPP", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 1\n1\n0\n2\n11\n3\n010\n4\n0110\n2 4", "output": "3", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/CHHAPPY
Solve the following coding problem using the programming language python: "What do you know about happiness?" — Yoda Chef is happy only if three conditions hold: - Chef finished cooking a delicious meal - Chef got AC for a programming problem with an almost correct code - Chef got a new problem with a sequence of int...
```python t = int(input()) for _ in range(t): N = int(input()) dict1 = {} flag = False S = [int(x) for x in input().split()] for i in range(N): if S[i] in dict1.keys(): dict1[S[i]].append(i + 1) else: dict1[S[i]] = [i + 1] for (key, val) in dict1.items(): if len(val) == 1: continue count = 0 fo...
vfc_88609
{ "difficulty": "medium", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CHHAPPY", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n4\n1 1 2 3\n4\n2 1 3 3\n5\n5 4 4 3 1\n5\n3 2 1 1 4\n", "output": "Truly Happy\nPoor Chef\nPoor Chef\nTruly Happy\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Honestly, a rabbit does not matter. There is a rabbit playing a stage system action game. In this game, every stage has a difficulty level. The rabbit, which always needs challenges, basically wants to play more difficult stages than he has eve...
```python import sys import bisect def main(): (n, t) = map(int, sys.stdin.readline().split()) levels = [] for i in range(n): d = int(sys.stdin.readline()) levels.append(d) levels.sort() ans = 1 for i in range(n): cnt = i - bisect.bisect_left(levels, levels[i] - t) + 1 ans *= cnt ans %= 1000000007 pri...
vfc_88613
{ "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 0\n1\n2\n3", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 3\n9\n1\n6\n8\n8", "output": "24\n", "type": "stdin_stdout" }, { "fn_name": null, ...
taco
verifiable_code
Solve the following coding problem using the programming language python: Heisenberg is very fond of mixing various strings together. But he has storage problem. He wants that his strings use as less space as possible. He has N strings right now. He wants to store them together. To reduce space he can use this pro...
```python from itertools import permutations l=[] o=[] n=eval(input()) for i in range(n): a=input() l.append(a) p=permutations(l) for st in p: opt = st[0] for j in range(1,n): indices = [i for i, x in enumerate(opt) if x == st[j][0]] flag = 1 for ind in indices: if opt[ind:] == st[j][0:len(opt[ind:])]: ...
vfc_88618
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8\na\na\na\na\na\na\na\na\n", "output": "46\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/combine-the-strings3459/1
Solve the following coding problem using the programming language python: Given an array s containing n strings, find the length of the string obtained by combining the strings. Two strings can be only combined if the last character of the first string and the first character of the second string are the same. Example...
```python class Solution: def combine(self, n, s): BB = RR = BR = RB = 0 for i in s: if i[0] + i[-1] == 'BB': BB = BB + 1 elif i[0] + i[-1] == 'RR': RR = RR + 1 elif i[0] + i[-1] == 'RB': RB = RB + 1 elif i[0] + i[-1] == 'BR': BR = BR + 1 mn = min(BR, RB) ans = 0 if not BR and (n...
vfc_88626
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/combine-the-strings3459/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "n = 3\r\ns[] = {\"RBR\", \"BBR\", \"RRR\"}", "output": "9", "type": "stdin_stdout" }, { "fn_name": null, "input": "n = 2\r\ns[] = {\"RRR\", \"BBB\"}", "output": "0", "type": "stdin_stdout...
taco
verifiable_code
https://codeforces.com/problemset/problem/421/C
Solve the following coding problem using the programming language python: Nearly each project of the F company has a whole team of developers working on it. They often are in different rooms of the office in different cities and even countries. To keep in touch and track the results of the project, the F company condu...
```python (n, m) = [int(x) for x in input().strip().split(' ')] posibles_jefes = set(range(1, n + 1)) anteriores = set() posteriores = set() continuos = [True] * (n + 1) mencionados = set() posibles_jefes_mencionados = set() ultimo_en_salir = [True] * (n + 1) ultima_salida_inesperada = None ops = [] if m > 1: for _ in...
vfc_88627
{ "difficulty": "medium_hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/421/C", "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "20 50\n+ 5\n+ 11\n- 5\n+ 6\n- 16\n- 13\n+ 5\n+ 7\n- 8\n- 7\n- 10\n+ 10\n- 20\n- 19\n+ 17\n- 2\n+ 2\n+ 19\n+ 18\n- 2\n- 6\n- 5\n+ 6\n+ 4\n- 14\n+ 14\n- 9\n+ 15\n- 17\n- 15\n+ 2\n+ 5\n- 2\n+ 9\n- 11\n+ 2\n- 19\n+ 7\n+ 12\n+ 16\n+ 19\...
taco
verifiable_code
https://codeforces.com/problemset/problem/1616/A
Solve the following coding problem using the programming language python: You are given $n$ integers $a_1, a_2, \ldots, a_n$. You choose any subset of the given numbers (possibly, none or all numbers) and negate these numbers (i. e. change $x \to (-x)$). What is the maximum number of different values in the array you ...
```python def task(): n = int(input()) a = set() w = [int(i) for i in input().split()] for i in w: if i in a: a.add(-i) else: a.add(i) print(len(a)) def main(): n = int(input()) for _ in range(n): task() main() ```
vfc_88632
{ "difficulty": "easy", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1616/A", "time_limit": "1 second" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n4\n1 1 2 2\n3\n1 2 3\n2\n0 0\n", "output": "4\n3\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n2\n-100 100\n", "output": "2\n", "type": "stdin_stdout" }, { ...
taco
verifiable_code
Solve the following coding problem using the programming language python: There is a 120 minute videotape with standard recording. When I set the VCR counter to 00:00:00 with the tape completely rewound and recorded in standard recording mode, I got a certain counter value. Enter this counter value (hours, minutes, se...
```python def time(sec): h = sec // 3600 ti = sec % 3600 m = ti // 60 s = ti % 60 return [h, m, s] while True: (t, h, s) = map(int, input().split()) if t == h == s == -1: break sec = t * 3600 + h * 60 + s sec = 7200 - sec ans = time(sec) t_ans = time(3 * sec) if ans[2] < 10: ans[2] = '0' + str(ans[2]) ...
vfc_88636
{ "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 36 0\n-1 -1 -1", "output": "00:24:00\n01:12:00\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "0 30 0\n-1 -1 -1", "output": "01:30:00\n04:30:00\n", "type": "stdin_stdout" ...
taco
verifiable_code
https://codeforces.com/problemset/problem/690/B1
Solve the following coding problem using the programming language python: The zombies are gathering in their secret lair! Heidi will strike hard to destroy them once and for all. But there is a little problem... Before she can strike, she needs to know where the lair is. And the intel she has is not very good. Heidi ...
```python n = int(input()) A = [input() for i in range(n)] def early_exit(): print('No') exit() if n < 3: early_exit() corner_row = [] for i in range(n): if '1' in A[i]: corner_row.append(i) if len(corner_row) != 2: early_exit() def check_zero(x): for i in x: if i != '0': return False return True for i ...
vfc_88640
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/690/B1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n000000\n000000\n012100\n024200\n012100\n000000\n", "output": "Yes\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n000000\n012210\n024420\n012210\n000000\n000000\n", "output": "...
taco
verifiable_code
https://codeforces.com/problemset/problem/466/B
Solve the following coding problem using the programming language python: The start of the new academic year brought about the problem of accommodation students into dormitories. One of such dormitories has a a × b square meter wonder room. The caretaker wants to accommodate exactly n students there. But the law says ...
```python from math import ceil (n, a, b) = list(map(int, input().split())) s = 6 * n if a * b >= s: (x, y) = (a, b) else: (a1, b1) = (min(a, b), max(a, b)) q = [(x, ceil(s / x)) for x in range(a1, ceil(s ** 0.5)) if ceil(s / x) > b1] (x, y) = min(q, key=lambda c: c[0] * c[1]) if x < a: (x, y) = (y, x) print(x *...
vfc_88644
{ "difficulty": "hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/466/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3 5\n", "output": "18\n3 6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 4 4\n", "output": "16\n4 4\n", "type": "stdin_stdout" }, { "fn_name": null, "...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/7995e41d167d81f14f1d4194b29ef839f52d18ba/1
Solve the following coding problem using the programming language python: You are going to book a taxi. There are infinite number of points 1, 2, 3... on the X axis and your current position is cur. There are N Taxis near you, and the position of those taxis is given as an array pos. Where pos[i] denotes the position ...
```python from typing import List class Solution: def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int: q = [] for i in range(len(pos)): q.append(abs(pos[i] - cur) * time[i]) return min(q) ```
vfc_88648
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/7995e41d167d81f14f1d4194b29ef839f52d18ba/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 3, cur = 4\r\npos = [1, 5, 6]\r\ntime = [2, 3, 1]", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 2, cur = 1\r\npos = [1, 6]\r\ntime = [10, 3]", "output": "0", ...
taco
verifiable_code
https://codeforces.com/problemset/problem/1191/F
Solve the following coding problem using the programming language python: There are n points on the plane, the i-th of which is at (x_i, y_i). Tokitsukaze wants to draw a strange rectangular area and pick all the points in the area. The strange area is enclosed by three lines, x = l, y = a and x = r, as its left side...
```python from sys import stdin, stdout from collections import defaultdict n = int(input()) pts = [] for i in range(n): (x, y) = map(int, stdin.readline().split()) pts.append((x, y)) pts.sort() cts = [0] * (n + 1) x_map = {} ctr = 0 for p in pts: if p[0] not in x_map: ctr += 1 x_map[p[0]] = ctr cts[ctr] += 1 p...
vfc_88653
{ "difficulty": "hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1191/F", "time_limit": "3.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "30\n9 1\n1 6\n2 10\n6 8\n5 5\n5 10\n8 6\n10 8\n7 7\n8 5\n6 4\n1 5\n8 4\n4 6\n7 3\n5 1\n9 2\n5 6\n5 9\n10 9\n7 8\n5 2\n6 3\n10 5\n9 8\n10 2\n3 5\n7 10\n10 6\n2 6\n", "output": "281", "type": "stdin_stdout" }, { ...
taco
verifiable_code
Solve the following coding problem using the programming language python: In the International City of Pipe Construction, it is planned to repair the water pipe at a certain point in the water pipe network. The network consists of water pipe segments, stop valves and source point. A water pipe is represented by a segm...
```python from collections import deque import sys readline = sys.stdin.readline write = sys.stdout.write def dot3(O, A, B): (ox, oy) = O (ax, ay) = A (bx, by) = B return (ax - ox) * (bx - ox) + (ay - oy) * (by - oy) def cross3(O, A, B): (ox, oy) = O (ax, ay) = A (bx, by) = B return (ax - ox) * (by - oy) - (b...
vfc_88662
{ "difficulty": "unknown_difficulty", "memory_limit": "134.217728 megabytes", "memory_limit_bytes": null, "problem_url": null, "time_limit": "5.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 1\n0 0 0 4\n0 2 2 2\n1 2\n-1 1\n0 3", "output": "6.0000000000\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 3\n0 4 2 4\n0 2 2 2\n0 0 2 0\n0 0 0 4\n2 0 2 4\n0 2\n1 0\n2 2\n2 4\n2 1", ...
taco
verifiable_code
Solve the following coding problem using the programming language python: Micro's midsem exams are finally over. When they were going on, instead of studying he would spend time making list of things that he wanted to do after the exams. But, now when they are over, he has lost the list. He was feeling very low, so hi...
```python Size=int(input()) N=list(map(str,input().split())) #print N def comp(x,y): return int(x+y) - int(y+x) L=sorted(N,reverse=True,cmp=comp) ans='' for i in L: ans+=i print(ans) ```
vfc_88666
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "100000\n373586872 620978519 183898757 930806600 328030063 540208517 693870132 609974813 846758558 854975864 802860422 491579023 481107514 207331561 274309494 948892321 872578714 766783921 390274249 356163426 393606342 42025358 5655...
taco
verifiable_code
https://www.hackerrank.com/challenges/bincoefrevenge/problem
Solve the following coding problem using the programming language python: The binomial coefficient C(N, K) is defined as N! / K! / (N − K)! for 0 ≤ K ≤ N. Here N! = 1 * 2 * ... * N for N ≥ 1, and 0! = 1. You are given a prime number P and a positive integer N. A_{L} is defined as the number of elements in the seq...
```python from collections import Counter def main(): ncases = int(input()) for _ in range(ncases): (n, p) = [int(fld) for fld in input().split()] m = count(n, p) print(' '.join(map(str, m))) def count(n, p): d = [] nn = n while nn != 0: d.append(nn % p) nn //= p pprev = Counter() nprev = Counter([0]...
vfc_88670
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.hackerrank.com/challenges/bincoefrevenge/problem", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n4 5\n6 3\n10 2\n", "output": "5\n3 4\n4 4 1 2\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Write a program which reads two integers a and b, and calculates the following values: * a ÷ b: d (in integer) * remainder of a ÷ b: r (in integer) * a ÷ b: f (in real number) Constraints * 1 ≤ a, b ≤ 109 Input Two integers a and b are give...
```python (a, b) = map(int, input().split()) print('%d %d %.5f' % (a / b, a % b, a / b)) ```
vfc_88674
{ "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": "0 2", "output": "0 0 0.000000\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/WRKWAYS
Solve the following coding problem using the programming language python: Read problems statements in Mandarin chinese, Russian and Vietnamese as well. Chef is working at his dream workplace with $N-1$ of his friends! Like any dream workplace, this one also has dream work conditions. To ensure absolute happiness of ...
```python from sys import stdin, stdout def calc(c, y): if 1 < c <= y: return [c] B = [] z = 2 while z * z <= c: if c % z == 0 and 1 < c // z <= y: B.append(c // z) B.append(z) c = 1 break z += 1 while z >= 2 and c > 1: if c % z == 0 and 1 < z <= y: while c % z == 0 and c > y: B.append(...
vfc_88679
{ "difficulty": "very_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/WRKWAYS", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n2 12", "output": "4 4", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/52/A
Solve the following coding problem using the programming language python: There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line...
```python from collections import deque from math import ceil, floor, sqrt, gcd def ii(): return int(input()) def mi(): return map(int, input().split()) def li(): return list(mi()) def si(): return input() n = ii() a = li() m = {} for i in a: if i not in m: m[i] = 1 else: m[i] += 1 b = [] for i in m.keys(...
vfc_88683
{ "difficulty": "easy", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/52/A", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n1\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n3 2\n", "output": "1\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/CANDY123
Solve the following coding problem using the programming language python: Bears love candies and games involving eating them. Limak and Bob play the following game. Limak eats 1 candy, then Bob eats 2 candies, then Limak eats 3 candies, then Bob eats 4 candies, and so on. Once someone can't eat what he is supposed to ...
```python from math import sqrt t = int(input()) for i in range(t): (a, b) = map(int, input().split()) if int(sqrt(a)) > int((-1 + sqrt(1 - 4 * -b)) / 2): print('Limak') else: print('Bob') ```
vfc_88687
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CANDY123", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n3 2\n4 2\n1 1\n1 2\n1 3\n9 3\n9 11\n9 12\n9 1000\n8 11\n", "output": "Bob\nLimak\nLimak\nBob\nBob\nLimak\nLimak\nBob\nBob\nBob\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/sum-of-primes0042/1
Solve the following coding problem using the programming language python: Your task is to calculate sum of primes present as digits of given number N. Example 1: Input: 333 Output: 9 Explaination: 3 is a prime number. It is present 3 times. So 3+3+3 = 9. Example 2: Input: 686 Output: 0 Explaination: Neither 6 nor 8 ...
```python import math class Solution: def primeSum(self, N): def prime(n): if n <= 1: return False for i in range(2, int(math.sqrt(n) + 1)): if n % i == 0: return False return True c = 0 m = [] while N > 0: d = N % 10 m.append(d) N = N // 10 for i in m: if prime(i): c...
vfc_88691
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/sum-of-primes0042/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "333", "output": "9", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/find-first-set-bit-1587115620/1
Solve the following coding problem using the programming language python: Given an integer N. The task is to return the position of first set bit found from the right side in the binary representation of the number. Note: If there is no set bit in the integer N, then return 0 from the function. Example 1: Input: N =...
```python class Solution: def getFirstSetBit(self, n): ans = 0 while n: mod = n % 2 ans += 1 if mod == 1: return ans n = n // 2 return 0 ```
vfc_88692
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/find-first-set-bit-1587115620/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 18", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 12", "output": "3", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/46/D
Solve the following coding problem using the programming language python: Nowadays it is becoming increasingly difficult to park a car in cities successfully. Let's imagine a segment of a street as long as L meters along which a parking lot is located. Drivers should park their cars strictly parallel to the pavement o...
```python (l, b, f) = map(int, input().split()) p = [[-b, -b, -192], [l + f, l + f, -38]] n = int(input()) for i in range(1, n + 1): (a, h) = map(int, input().split()) if a == 1: k = False for w in range(len(p) - 1): if p[w + 1][0] - p[w][1] >= b + f + h: p.insert(w + 1, [p[w][1] + b, p[w][1] + b + h, i]) ...
vfc_88694
{ "difficulty": "medium_hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/46/D", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10 1 1\n2\n1 3\n1 7\n", "output": "0\n-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "30 2 1\n10\n1 4\n2 1\n1 1\n1 3\n1 1\n1 1\n1 2\n1 5\n2 4\n2 7\n", "output": "0\n0\n3\n8\n11\n1...
taco
verifiable_code
Solve the following coding problem using the programming language python: Little Ashish got a lot of strings as his birthday gift. He does not mind getting so many strings for free; in fact, he loves them. But, on noticing all the strings he received as a gift, Little Ashish, who's also a snob and a bit OCD kind of a ...
```python n=eval(input()) d=dict() def fun(v): s = "" for i in range(len(v)): for j in range(v[i][0]): s = s + str(v[i][1]) print(s) for j in range(n): m=input().strip() for i in m: d[i]=d.get(i,0)+1 v=sorted([(value,key) for (key,value) in list(d.items())]) fun(v) d = dict() ```
vfc_88698
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8\nbrowserstack\nsyscloud\nmetricstream\nporter\nwalmartlab\nemc\nthoughtworks\nbrowserstacksyscloudmetricstreamporterwalmartlabthoughtworks\n\n", "output": "aabbccdd\nbaacc\ncktaaeehhrr\n", "type": "stdin_stdout" }...
taco
verifiable_code
https://codeforces.com/problemset/problem/1267/K
Solve the following coding problem using the programming language python: Karl is developing a key storage service. Each user has a positive integer key. Karl knows that storing keys in plain text is bad practice. So, instead of storing a key, he decided to store a fingerprint of a key. However, using some existing f...
```python import math as m import collections IP = lambda : list(map(int, input().split())) INF = 1000000000.0 f = [1] for i in range(1, 22): f.append(f[-1] * i) def solve(arr, n): d = collections.Counter(arr) tu = 1 mau = 1 a = [0] * 22 for i in arr: a[i] += 1 for i in range(1, len(a)): a[i] += a[i - 1] f...
vfc_88706
{ "difficulty": "hard", "memory_limit": "512.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1267/K", "time_limit": "3.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "100\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n49\n50\n51\n52\n53\n54\n55\n56\n57\n58\n59\...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/squares-in-reactangle3340/1
Solve the following coding problem using the programming language python: Given a rectangle of size L x B. Find the minimum number of squares required to fill the rectangle such that no two square overlaps. Example 1: Input: L = 4, B = 5 Output: 5 Explaination: One 4*4 square and four 1*1 squares are required. Exampl...
```python class Solution: def minSquares(self, L, B): p = 1000000007 if L == 1: return B % p if B == 1: return L % p ans = 0 while L > 0 and B > 0: if L > B: ans = (ans + L // B) % p L = L % B else: ans = (ans + B // L) % p B = B % L return ans % p ```
vfc_88710
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/squares-in-reactangle3340/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "L = 4, B = 5", "output": "5", "type": "stdin_stdout" }, { "fn_name": null, "input": "L = 2, B = 4", "output": "2", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/factorial-pairs5916/1
Solve the following coding problem using the programming language python: Given Two integers L and R find the total number of distinct pairs (p,q) between L and R ( both inclusive ) satisfying the given relationship. p! * q!=k^2 (a perfect square) where p,q,k is any integer and '!' denotes factorial. Example 1: Input...
```python import math class Solution: def isPerfectSquare(self, x): if x >= 0: sr = math.floor(math.sqrt(x)) return sr * sr == x return False def countPerfectSquares(self, L, R): if self.isPerfectSquare(L): return math.floor(math.sqrt(R)) - math.floor(math.sqrt(L)) + 1 else: return math.floor(m...
vfc_88711
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/factorial-pairs5916/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "L = 0, R = 1", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "L = 9, R = 25", "output": "3", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/442/B
Solve the following coding problem using the programming language python: Andrey needs one more problem to conduct a programming contest. He has n friends who are always willing to help. He can ask some of them to come up with a contest problem. Andrey knows one value for each of his fiends — the probability that this...
```python import sys input() ps = sorted((float(p) for p in input().split()), reverse=True) if 1.0 in ps: print(1) sys.exit() (a, b) = (0, 1) for p in ps: (c, d) = (a + p / (1 - p), b * (1 - p)) if c * d > a * b: (a, b) = (c, d) else: break print('{:.9}'.format(a * b)) ```
vfc_88712
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/442/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n0.1 0.2 0.3 0.8\n", "output": "0.800000000000\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n0.1 0.2\n", "output": "0.260000000000\n", "type": "stdin_stdout" }, ...
taco
verifiable_code
https://www.hackerrank.com/challenges/python-quest-1/problem
Solve the following coding problem using the programming language python: You are given a positive integer $N$. Print a numerical triangle of height $N-1$ like the one below: 1 22 333 4444 55555 ...... Can you do it using only arithmetic operations, a single for loop and print statement? Use no more than two li...
```python for i in range(1, int(input())): print(1 if i == 1 else 22 if i == 2 else 333 if i == 3 else 4444 if i == 4 else 55555 if i == 5 else 666666 if i == 6 else 7777777 if i == 7 else 88888888 if i == 8 else 999999999) ```
vfc_88716
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.hackerrank.com/challenges/python-quest-1/problem", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n", "output": "1\n22\n333\n4444\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/709/A
Solve the following coding problem using the programming language python: Kolya is going to make fresh orange juice. He has n oranges of sizes a_1, a_2, ..., a_{n}. Kolya will put them in the juicer in the fixed order, starting with orange of size a_1, then orange of size a_2 and so on. To be put in the juicer the ora...
```python (n, b, d) = list(map(int, input().split())) l = list(map(int, input().split())) c = 0 tw = 0 for i in l: if i > b: continue tw += i if tw > d: c += 1 tw = 0 print(c) ```
vfc_88720
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/709/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 7 10\n5 6\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 5 10\n7\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "in...
taco
verifiable_code
https://codeforces.com/problemset/problem/452/B
Solve the following coding problem using the programming language python: You are given a rectangular grid of lattice points from (0, 0) to (n, m) inclusive. You have to choose exactly 4 different points to build a polyline possibly with self-intersections and self-touching. This polyline should be as long as possible...
```python def main(): a = input().split() for i in range(len(a)): a[i] = int(a[i]) m = a[1] n = a[0] if n == 0: c1 = {(0, 0), (0, 1), (0, m - 1), (0, m)} elif m == 0: c1 = {(0, 0), (1, 0), (n - 1, 0), (n, 0)} else: c1 = {(0, 0), (0, 1), (1, 0), (1, 1), (0, m - 1), (0, m), (1, m - 1), (1, m), (n - 1, m - ...
vfc_88724
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/452/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 1\n", "output": "1 1\n0 0\n1 0\n0 1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "0 10\n", "output": "0 1\n0 10\n0 0\n0 9\n", "type": "stdin_stdout" }, { "fn_...
taco
verifiable_code
https://www.codechef.com/problems/XORORED
Solve the following coding problem using the programming language python: Read problems statements in [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well. Given an array A of N non-negative integers, you can choose any non-negative integer X and replace every element A_{i} with (A_{i}\oplus X) Here, \o...
```python def brute(x, arr): res = arr[0] ^ x for i in range(1, len(arr)): res |= arr[i] ^ x return res def soln(n, arr): maxm = max(arr) return (maxm, brute(maxm, arr)) for _ in range(int(input())): n = int(input()) arr = list(map(int, input().split())) print(*soln(n, arr)) ```
vfc_88728
{ "difficulty": "medium_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/XORORED", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n2\n4 6", "output": "6 2", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1455/B
Solve the following coding problem using the programming language python: You are standing on the $\mathit{OX}$-axis at point $0$ and you want to move to an integer point $x > 0$. You can make several jumps. Suppose you're currently at point $y$ ($y$ may be negative) and jump for the $k$-th time. You can: either jum...
```python from math import sqrt def findclosest(a): a1 = 1 b1 = 1 c1 = -1 * 2 * a d = b1 ** 2 - 4 * a1 * c1 x = (-1 * b1 + sqrt(d)) / 2 if x - int(x) == 0: return [x] return [int(x), int(x + 1)] def findclosest2(a): a1 = 1 b1 = 1 c1 = -1 * 2 * (a + 2) d = b1 ** 2 - 4 * a1 * c1 x = (-1 * b1 + sqrt(d)) / ...
vfc_88737
{ "difficulty": "easy", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1455/B", "time_limit": "1 second" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1\n2\n3\n4\n5\n", "output": "1\n3\n2\n3\n4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n10\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": nu...
taco
verifiable_code
https://codeforces.com/problemset/problem/1760/D
Solve the following coding problem using the programming language python: You are given an array $a[0 \dots n-1]$ of $n$ integers. This array is called a "valley" if there exists exactly one subarray $a[l \dots r]$ such that: $0 \le l \le r \le n-1$, $a_l = a_{l+1} = a_{l+2} = \dots = a_r$, $l = 0$ or $a_{l-1} > a_...
```python from itertools import * for s in [*open(0)][2::2]: a = [k for (k, g) in groupby(map(int, s.split()))] print('YNEOS'[sum((x > y < z for (x, y, z) in zip([2000000000.0] + a, a, a[1:] + [2000000000.0]))) > 1::2]) ```
vfc_88742
{ "difficulty": "easy", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1760/D", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n7\n3 2 2 1 2 2 3\n11\n1 1 1 2 3 3 4 5 6 6 6\n7\n1 2 3 4 3 2 1\n7\n9 7 4 6 9 9 10\n1\n1000000000\n8\n9 4 4 5 9 4 9 10\n", "output": "YES\nYES\nNO\nYES\nYES\nNO\n", "type": "stdin_stdout" }, { "fn_name": ...
taco
verifiable_code
https://codeforces.com/problemset/problem/981/B
Solve the following coding problem using the programming language python: Two famous competing companies ChemForces and TopChemist decided to show their sets of recently discovered chemical elements on an exhibition. However they know that no element should be present in the sets of both companies. In order to avoid ...
```python def STR(): return list(input()) def INT(): return int(input()) def MAP(): return map(int, input().split()) def MAP2(): return map(float, input().split()) def LIST(): return list(map(int, input().split())) def STRING(): return input() import string import sys from heapq import heappop, heappush from...
vfc_88746
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/981/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 2\n7 2\n3 10\n4\n1 4\n2 4\n3 4\n4 4\n", "output": "24\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n1000000000 239\n3\n14 15\n92 65\n35 89\n", "output": "408\n", "typ...
taco
verifiable_code
https://www.codechef.com/problems/MEANIDIAN
Solve the following coding problem using the programming language python: Chef gets confused between mean and median very often, and as a result, he has developed a dislike of arrays whose mean and median are not equal. Chef has an array A of N elements. He can perform the following operation on it: Pick an index 1 ≤...
```python def check(arr, mean, n): sum = 0 for i in range(len(arr)): sum += arr[i] allowed_operations = n * mean - sum if allowed_operations < 0: return -1 required_operations = 0 for i in range((n - 1) // 2, n): required_operations += max(0, mean - arr[i]) if required_operations > allowed_operations: re...
vfc_88750
{ "difficulty": "very_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/MEANIDIAN", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3\n1 2 3\n4\n1 1 3 3\n5\n1 1000000000 1 1000000000 1\n", "output": "0\n4\n500000002\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/888/B
Solve the following coding problem using the programming language python: Ivan has a robot which is situated on an infinite grid. Initially the robot is standing in the starting cell (0, 0). The robot can process commands. There are four types of commands it can perform: U — move from the cell (x, y) to (x, y + 1); ...
```python n = int(input()) commands = input() (dx, dy) = (0, 0) for command in commands: if command == 'U': dy += 1 elif command == 'D': dy -= 1 elif command == 'L': dx -= 1 elif command == 'R': dx += 1 (dx, dy) = (abs(dx), abs(dy)) print(n - dx - dy) ```
vfc_88758
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/888/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\nLDUR\n", "output": "4\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1231/C
Solve the following coding problem using the programming language python: In this problem, a $n \times m$ rectangular matrix $a$ is called increasing if, for each row of $i$, when go from left to right, the values strictly increase (that is, $a_{i,1}<a_{i,2}<\dots<a_{i,m}$) and for each column $j$, when go from top to...
```python (n, m) = map(int, input().split()) a = [[0 for i in range(m)] for j in range(n)] sum1 = 0 fg = 0 for i in range(n): a[i] = list(map(int, input().split())) for i in range(n - 1, 0, -1): for j in range(m - 1, 0, -1): if a[i][j] == 0: a[i][j] = min(a[i + 1][j], a[i][j + 1]) - 1 if a[i][j] <= a[i - 1][j]...
vfc_88762
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1231/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12\n", "output": "144\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 3\n1 2 3\n2 0 4\n4 5 6\n", "output": "30\n", "type": "s...