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/remove-duplicates-from-an-unsorted-linked-list/1
Solve the following coding problem using the programming language python: Given an unsorted linked list of N nodes. The task is to remove duplicate elements from this unsorted Linked List. When a value appears in multiple nodes, the node which appeared first should be kept, all others duplicates are to be removed. Exa...
```python class Solution: def removeDuplicates(self, head): if head is None: return None a = set() i = head a.add(i.data) while i.next: if i.next.data not in a: a.add(i.next.data) i = i.next else: i.next = i.next.next return head ```
vfc_133780
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/remove-duplicates-from-an-unsorted-linked-list/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 4\nvalue[] = {5,2,2,4}", "output": "5 2 4", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 5\nvalue[] = {2,2,2,2,2}", "output": "2", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1687/A
Solve the following coding problem using the programming language python: The enchanted forest got its name from the magical mushrooms growing here. They may cause illusions and generally should not be approached. —Perfect Memento in Strict Sense Marisa comes to pick mushrooms in the Enchanted Forest. The Enchanted...
```python import sys input = sys.stdin.readline def solve(): (n, k) = map(int, input().split()) arr = list(map(int, input().split())) if k <= n: lps = ans = 0 for i in range(n): lps += arr[i] if i >= k: lps -= arr[i - k] ans = max(ans, lps) return ans + k * (k - 1) // 2 else: ans = sum(arr) + ...
vfc_133785
{ "difficulty": "medium_hard", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1687/A", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n5 2\n5 6 1 2 3\n5 7\n5 6 1 2 3\n1 2\n999999\n5 70000\n1000000000 1000000000 1000000000 1000000000 1000000000\n", "output": "12\n37\n1000000\n5000349985\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Hackland is being attacked by Greyland, and you have been assigned the job to save it. Your enemies, known as Grey hats, are numbered starting from L to R, both inclusive. But, here is the fun part: Grey hats are known to switch sides, and you ...
```python t=int(input()); while t > 0 : s,e,k = list(map(int,input().split(" "))); m = 1; for i in range(s,e+1) : if i > s*k : s=i; m+=1; t-=1; print(m); ```
vfc_133789
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "200\n1 1001 1000\n5 511 10\t\n5 4747 10\n1 1000000 10\t\n10 10110 10\n1 1 10\t\n1000000 1000000 10\t\n491273 842398 10\t\n849859 958925 10\t\n67803 771363 10\t\n184892 391907 10\t\n75799 256150 10\n268944 342402 10\t\n228640 894352...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/repated-sum-and-then-multiply1046/1
Solve the following coding problem using the programming language python: You are given a natural number. Repeatedly sum its digits until the smallest possible two-digit number remains. Then multiply the digits of the remaining two-digit number and return it. Example 1: Input: n = 19 Output: 0 Explanation: 1+9 = 1+0 ...
```python class Solution: def repeatedSumMul(self, n): l = [] l.append(n) while len(str(n)) > 1: summ = 0 for i in str(n): summ += int(i) l.append(summ) n = summ val = 1 for i in str(l[-2]): val *= int(i) return val ```
vfc_133793
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/repated-sum-and-then-multiply1046/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "n = 19", "output": "0", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/count-zero3710/1
Solve the following coding problem using the programming language python: Given a number d, representing the number of digits of a number. Find the total count of positive integers which have at-least one zero in them and consist d or less digits. Example 1: Input: d = 2 Output: 9 Explanation: There are total 9 posi...
```python class Solution: def findCountUpto(ob, n): return 9 * (10 ** n - 1) // 9 - 9 * (9 ** n - 1) // 8 ```
vfc_133794
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/count-zero3710/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "d = 2", "output": "9", "type": "stdin_stdout" }, { "fn_name": null, "input": "d = 3", "output": "180", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/number-of-unique-paths5339/1
Solve the following coding problem using the programming language python: Given a A X B matrix with your initial position at the top-left cell, find the number of possible unique paths to reach the bottom-right cell of the matrix from the initial position. Note: Possible moves can be either down or right at any point ...
```python class Solution: def NumberOfPaths(self, a, b): if a > b: return self.NumberOfPaths(b, a) x = a + b - 2 ans = 1 for i in range(1, a): ans = ans * x ans = ans / i x = x - 1 return int(ans) ```
vfc_133807
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/number-of-unique-paths5339/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "A = 2, B = 2", "output": "2", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/sum-of-subset-differences/1
Solve the following coding problem using the programming language python: Given an array S consisting of N numbers, find the sum of difference between last and first element of each subset. Example 1: Input: S = [5,8] Output: 3 Explanation: There are 3 subsets possible for the given array S. 1 -> [5] having first and...
```python from math import factorial def sumDiff(S, n): output = 0 for (i, item) in enumerate(S): output += item * 2 ** i output -= item * 2 ** (n - i - 1) return output ```
vfc_133808
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/sum-of-subset-differences/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": "sumDiff", "input": "S = [5,8]", "output": "3", "type": "function_call" } ] }
taco
verifiable_code
https://www.codechef.com/problems/SUMPERM
Solve the following coding problem using the programming language python: You are given an integer N. Your task is to generate a permutation P of size N, such that: For all (1< i≤ N), \sum_{j = 1}^{i} P_{j} is not divisible by i. In other words, the sum of prefix of length i (i> 1) should not be divisible by i. In...
```python for kjds in range(int(input())): n = int(input()) l = [] if n % 2 == 1: print(-1) continue for g in range(1, n + 1): l.append(g) a = 0 for f in range(n // 2): temp = l[a] l[a] = l[a + 1] l[a + 1] = temp a += 2 print(*l) ```
vfc_133810
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/SUMPERM", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n4\n6\n7\n", "output": "3 4 1 2\n1 2 4 6 3 5\n-1\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Things are heated up between the Finance team and the Marketing team, and they decide to have one-on-one fifa matches to settle it once and for all. Jha, being an intern, won’t play (it’s a battle of legends, after all) and has been given one j...
```python def just_smaller(x, arr): ret = -1 for i in range(len(arr)): if arr[i] < x: ret = i return ret n = int(input()) t1 = list(map(int, input().split())) t2 = list(map(int, input().split())) t1.sort() t2.sort() ans = 0 for i in range(n): r = just_smaller(t1[i], t2) if r != -1: t2 = t2[:r]+t2[r+1:] ...
vfc_133814
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 10 7 4\n15 3 8 7", "output": "250", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1759/G
Solve the following coding problem using the programming language python: A sequence of $n$ numbers is called permutation if it contains all numbers from $1$ to $n$ exactly once. For example, the sequences [$3, 1, 4, 2$], [$1$] and [$2,1$] are permutations, but [$1,2,1$], [$0,1$] and [$1,3,4$] — are not. For a permut...
```python import sys from bisect import bisect_right as bs input = sys.stdin.readline for _ in range(int(input())): n = int(input()) b = list(map(int, input().split())) st = set(b) if len(st) != n // 2: print(-1) continue res = [i for i in range(1, n + 1) if i not in st] ans = [] for i in range(n // 2 - 1, -...
vfc_133818
{ "difficulty": "hard", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1759/G", "time_limit": "1 second" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n6\n4 3 6\n4\n2 4\n8\n8 7 2 3\n6\n6 4 2\n4\n4 4\n8\n8 7 4 5\n", "output": "1 4 2 3 5 6 \n1 2 3 4 \n-1\n5 6 3 4 1 2 \n-1\n1 8 6 7 2 4 3 5 \n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1307/B
Solve the following coding problem using the programming language python: Bessie has way too many friends because she is everyone's favorite cow! Her new friend Rabbit is trying to hop over so they can play! More specifically, he wants to get from $(0,0)$ to $(x,0)$ by making multiple hops. He is only willing to hop...
```python for i in range(int(input())): (a, b) = list(map(int, input().split())) to = 0 l = [] t = 0 l = list(map(int, input().split())) d = max(l) if b == d: to = 1 elif d > b: to = 2 for vaibhav in l: if vaibhav == b: to = 1 break elif b % d == 0: to = b // d else: to = b // d + 1 prin...
vfc_133822
{ "difficulty": "easy", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1307/B", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n2 4\n1 3\n3 12\n3 4 5\n1 5\n5\n2 10\n15 4\n", "output": "2\n3\n1\n2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n10 999999733\n25 68 91 55 36 29 96 4 63 3\n", "output": "104...
taco
verifiable_code
https://www.codechef.com/PBK32020/problems/ITGUY29
Solve the following coding problem using the programming language python: The chef was searching for his pen in the garage but he found his old machine with a display and some numbers on it. If some numbers entered then some different output occurs on the display. Chef wants to crack the algorithm that the machine is ...
```python T = int(input()) for t in range(T): N = int(input()) print(int((N - 1) * N / 2)) ```
vfc_133826
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/PBK32020/problems/ITGUY29", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n7\n", "output": "21\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/AGTK2012/problems/ALGPAN
Solve the following coding problem using the programming language python: So the Chef has become health conscious and is now lifting weights at the gym. But its his first time so the trainer gives him a simple job to do. He has been given a weight lifting rod and N heavy weights, each weighing 20, 21, .... , 2n-1. H...
```python t = int(input()) while t > 0: n = int(input()) if n <= 0: print(0) fact = 1 start = 1 for i in range(1, n + 1): fact *= start start += 2 print(fact) t = t - 1 ```
vfc_133830
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/AGTK2012/problems/ALGPAN", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2\n5\n18\n", "output": "3\n945\n221643095476699771875\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Pandaland is a place full of strings. One day Panda visited Pandaland and get confused wether Pandaland is a lucky place or not. According to Panda a place is lucky if all the strings in that place follows the following property 'P' : - P:A pla...
```python import sys flag = True class Node: def __init__(self,c): self.c = c self.next = {} self.cnt = 0 self.ends = 0 def insert(node, word): for w in word: if w not in node.__next__: node.next[w] = Node(w) node = node.next[w] node.cnt += 1 node.ends += 1 def traverse(node, path): global fla...
vfc_133834
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n83\nlrbbmqbhcdarzowkkyhiddqscdxrjmowfrxsjybldbefsarcbynecdyggxxpklorellnmpapqfwkhopkmcoqhn\nnkuewhsqmgbbuqcljjivswmdkqtbxixmvtrrbljptnsnfwzqfjmafa\nrrwsofsbcnuvqhffbsaqxwpqcaceh\nhzvfrkmlnozjkpqpxrjxkitzyxacbhhkicqcoendtomfgdwd...
taco
verifiable_code
https://www.codechef.com/problems/INCREAST
Solve the following coding problem using the programming language python: You are given a string S, consisting of lowercase English letters. You can do the following operation at most once : Choose a subsequence of the string S, then remove it from S and concatenate the subsequence at the end of the remaining string....
```python def solve(s): len_s = len(s) cur = [False] * len_s let = 'z' if len_s - 1 > 0: for i in range(len_s - 1, 0, -1): if s[i] <= let: cur[i] = True let = s[i] if s[0] <= let: cur[0] = True let = s[0] before = '' after = '' got = [] for i in range(0, len_s): if cur[i]: before += s[...
vfc_133838
{ "difficulty": "very_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/INCREAST", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\naba\nabcd\ncbcdbef\nfabcdac", "output": "aab\nabcd\nbbccdef\naacfbcd\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: "What are your shoe sizes?" Suddenly, the doctor asked me when I met him for the first time. "It's 23.5" "Oh, that's a really nice number. It's 2 to the 4th power plus 2 to the 2nd power, 2 to the 1st power, 2 to the 0th power, and 2 to the 1s...
```python def ans(N): n = int(N) d = N - n ans_l = bin(n)[2:] ans_r = '' for _ in range(4): ans_r += str(int(d * 2)) d = d * 2 - int(d * 2) if n >= 256 or d != 0: return 'NA' else: return '0' * (8 - len(ans_l)) + ans_l + '.' + ans_r while True: INP = float(input()) if INP < 0: break print(ans(INP)) ...
vfc_133842
{ "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": "23.72975180461117\n158.1\n-1.0", "output": "NA\nNA\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "23.5\n158.1\n-0.5246083014985048", "output": "00010111.1000\nNA\n", "type": "...
taco
verifiable_code
https://www.codechef.com/problems/GENE01
Solve the following coding problem using the programming language python: People in Chefland have three different eye colors, namely brown, blue, and green. green is the rarest of the eye colors whereas brown is most common. The eye color of the child of two people is most likely to be the most common eye color betwe...
```python (a, b) = map(str, input().split()) if a == 'R' or b == 'R': print('R') elif a == 'B' or b == 'B': print('B') else: print('G') ```
vfc_133847
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/GENE01", "time_limit": "0.5 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "R B\n", "output": "R", "type": "stdin_stdout" }, { "fn_name": null, "input": "B B\n", "output": "B", "type": "stdin_stdout" }, { "fn_name": null, "input": "G B\n", ...
taco
verifiable_code
https://codeforces.com/problemset/problem/1349/D
Solve the following coding problem using the programming language python: Slime and his $n$ friends are at a party. Slime has designed a game for his friends to play. At the beginning of the game, the $i$-th player has $a_i$ biscuits. At each second, Slime will choose a biscuit randomly uniformly among all $a_1 + a_2...
```python import os import sys input = sys.stdin.buffer.readline from collections import deque import math class CF(object): def __init__(self): self.mod = 998244353 self.n = int(input()) self.a = list(map(int, input().split())) self.tot = sum(self.a) self.dp = [[0, 0] for _ in range(self.tot + 1)] def i...
vfc_133851
{ "difficulty": "hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1349/D", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1 1\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n1 2\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5...
taco
verifiable_code
Solve the following coding problem using the programming language python: Robert Frost is standing on a cross-way with six roads diverging out. He decides to choose the road not taken. After travelling the pathway he reaches a similar but yet another cross-way with six another roads diverging out. He keeps on travelli...
```python a = [1, 0, 6, 12, 90, 360, 2040, 10080, 54810, 290640, 1588356, 8676360, 47977776, 266378112, 1488801600, 8355739392, 47104393050, 266482019232, 1512589408044, 8610448069080, 49144928795820, 281164160225520] t = eval(input()) while t: n = eval(input()) print(a[n]) t -= 1 ```
vfc_133864
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "14\n1\n7\n2\n12\n6\n10\n3\n8\n11\n13\n4\n5\n9\n14", "output": "0\n10080\n6\n47977776\n2040\n1588356\n12\n54810\n8676360\n266378112\n90\n360\n290640\n1488801600", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: View Russian Translation Tom works in a public library in his town. Today, a completely new set of N books is arriving to the library and they have to be placed on shelves, which are initially empty. A single shelf can contain at most 10 books...
```python lis=dict() #gives the index in list to givver letter for i in range(eval(input())): name=input() first_letter=name[0] #checking if letter in list if first_letter in lis: lis[first_letter]+=1 else: lis[first_letter]=1 count=len(lis) for j in lis: cout=lis[j] if cout%10==0: count+=(lis[j]/10)-1 ...
vfc_133868
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1000\ndxbcxrqtvoewliohlkkp\nbjskdhryrqcsqseqitfo\nktfveuvbirctthgpwujl\ntgwnczaimkwgrofbjhen\nmvyavrcqhtezscldzlnp\nkgwzgpjhnbgtyslurjba\nldyuslsaxntsfxsnguxy\ntbquxlfifayxjfrkfzex\nektwdrrogqyemyybzyhh\nlqvjsrnypggxcsiwfhbb\nkrsna...
taco
verifiable_code
https://codeforces.com/problemset/problem/649/A
Solve the following coding problem using the programming language python: Поликарп мечтает стать программистом и фанатеет от степеней двойки. Среди двух чисел ему больше нравится то, которое делится на большую степень числа 2. По заданной последовательности целых положительных чисел a_1, a_2, ..., a_{n} требуется на...
```python n = int(input()) l = list(map(int, input().split())) max1 = 1 for i in l: k = 1 x = i while x % 2 == 0: k *= 2 x //= 2 max1 = max(max1, k) c = 0 for i in l: if i % max1 == 0: c += 1 print(max1, c) ```
vfc_133872
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/649/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n80 7 16 4 48\n", "output": "16 3\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/maximum-xor-with-an-element-from-array/1
Solve the following coding problem using the programming language python: Given an array arr of size N consisting of non-negative integers. You are also given Q queries represented by 2D integer array queries, where queries[ i ] = [xi, mi]. The answer to the i^{th} query is the maximum bitwise XOR value of x_{i} and a...
```python from bisect import bisect_left, bisect_right class Solution: def maximumXor(self, N, Q, nums, queries): nums.sort() answer = [] for (x, m) in queries: (start, stop) = (0, bisect_right(nums, m)) num = 0 for i in range(30)[::-1]: cut = bisect_left(nums, num + (1 << i), start, stop) if ...
vfc_133876
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/maximum-xor-with-an-element-from-array/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 5\r\nQ = 3\r\narr [ ] = {0, 1, 2, 3, 4}\r\nqueries [ ][ ] = {{3, 1}, {1, 3}, {5, 6}}", "output": "{3, 3, 7}", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 6\r\nQ = 3\r\narr [ ] = {5...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/ishaans-curiosity0853/1
Solve the following coding problem using the programming language python: Given 2 integers L, R as input, and find the bitwise OR of all the integers in the range [L, R] (both inclusive). Example 1: Input: L = 3, R = 8 Output: 15 Explanation: 3|4|5|6|7|8 = 15 ​Example 2: Input: L = 12, R = 18 Output: 31 Explan...
```python class Solution: def findBitwiseOR(self, L, R): while L < R: L |= L + 1 return R | L ```
vfc_133878
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/ishaans-curiosity0853/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "L = 3, R = 8", "output": "15", "type": "stdin_stdout" }, { "fn_name": null, "input": "L = 12, R = 18", "output": "31", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/716/C
Solve the following coding problem using the programming language python: ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '<image>' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels in the game and ZS the Code...
```python n = int(input()) print(2) for lvl in range(2, n + 1): print(lvl * (lvl + 1) * (lvl + 1) - (lvl - 1)) ```
vfc_133879
{ "difficulty": "medium_hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/716/C", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2016\n", "output": "2\n17\n46\n97\n176\n289\n442\n641\n892\n1201\n1574\n2017\n2536\n3137\n3826\n4609\n5492\n6481\n7582\n8801\n10144\n11617\n13226\n14977\n16876\n18929\n21142\n23521\n26072\n28801\n31714\n34817\n38116\n41617\n4...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/permutation-divisibility0447/1
Solve the following coding problem using the programming language python: You are given a number. Your task is to check if there exists a permutation of the digits of this number which is divisible by 4. ^{ } Example 1: Input: 003 Output: 1 Explanation: For 003, we have a permutation 300 which is divisible by 4. ...
```python class Solution: def divisible_by_four(self, s): if s == '4' or s == '8': return 1 odd = 0 even = 0 four = 0 for item in s: item = int(item) odd += item % 2 even += item % 2 == 0 four += item % 4 == 0 return int(even > four and odd > 0 or (four and even > 1)) ```
vfc_133883
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/permutation-divisibility0447/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "003", "output": "1", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: <image> For given three points p0, p1, p2, print COUNTER_CLOCKWISE if p0, p1, p2 make a counterclockwise turn (1), CLOCKWISE if p0, p1, p2 make a clockwise turn (2), ONLINE_BACK if p2 is on a line p2, p0, p1 in this order (3), ONL...
```python (x0, y0, x1, y1) = map(int, input().split()) p0 = complex(x0, y0) p1 = complex(x1, y1) q = int(input()) CCW = {1: 'COUNTER_CLOCKWISE', -1: 'CLOCKWISE', 2: 'ONLINE_BACK', -2: 'ONLINE_FRONT', 0: 'ON_SEGMENT'} def dot(a, b): return a.real * b.real + a.imag * b.imag def cross(a, b): return a.real * b.imag - a...
vfc_133884
{ "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 0 2 -1\n3\n-1 0\n0 0\n3 0", "output": "CLOCKWISE\nON_SEGMENT\nCOUNTER_CLOCKWISE\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/rearrange-linked-list-in-place/1
Solve the following coding problem using the programming language python: Given a singly linked list L_{0} -> L_{1} -> … -> L_{n-1} -> L_{n}. Rearrange the nodes in the list so that the new formed list is: L_{0} -> L_{n} -> L_{1} -> L_{n-1} -> L_{2} -> L_{n-2}. Input: You have to complete the method which takes 1 argu...
```python def inPlace(root): t = root k = [] while t != None: k.append(t.data) t = t.next i = 0 j = len(k) - 1 l = 0 t = root while l < len(k): if l % 2 == 0: t.data = k[i] i += 1 l = l + 1 t = t.next else: t.data = k[j] j = j - 1 l = l + 1 t = t.next return root ```
vfc_133889
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/rearrange-linked-list-in-place/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": "inPlace", "input": "2\r\n\n4\r\n\n1 2 3 4\r\n\n5\r\n\n1 2 3 4 5", "output": "1 4 2 3\r\n\n1 5 2 4 3", "type": "function_call" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Today, Vasya has decided to study about Numbers and Number Theory. One of her good friends Kolya is very good at the subject. To help her, he kept the following task in front of Vasya: Given an array A of size N, Vasya needs to find the size o...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' # 'Hello World!' n = int(input()) numbers = list(map(int,input().split())) value = [0]*n numbers.sort() divisors = {} for i in range(n): li = [] for j in range(i+1,n): if...
vfc_133890
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1000\n666 465 843 261 16 239 403 485 787 127 209 15 694 890 674 953 49 319 67 661 96 173 932 653 362 417 521 644 62 230 781 390 610 155 119 452 25 983 945 606 374 18 160 354 830 573 231 217 678 670 721 104 373 887 554 818 709 427 3...
taco
verifiable_code
https://codeforces.com/problemset/problem/110/C
Solve the following coding problem using the programming language python: Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya wonders eagerly wha...
```python n = int(input()) from collections import Counter c = Counter([]) c[1] = [-1, 2] c[2] = [-2, 4] c[3] = [-3, 6] c[4] = [0, 1] c[5] = [-1, 3] c[6] = [-2, 5] a = n % 7 s = n // 7 f = 0 if a == 0: print('7' * s) else: s += c[a][0] f += c[a][1] if s < 0: if n % 4 == 0: print('4' * (n // 4)) else: prin...
vfc_133894
{ "difficulty": "easy", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/110/C", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "999980\n", "output": "44447777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777...
taco
verifiable_code
https://www.codechef.com/problems/GUZAC
Solve the following coding problem using the programming language python: ------Read problems statements in Mandarin chinese , Russian and Vietnamese as well. ------ Professor GukiZ decided to distribute all of his candies to his $N$ students (numbered $1$ through $N$). Let's denote the number of candies GukiZ gave ...
```python for _ in range(int(input())): (n, k, x) = map(int, input().split()) candies = sorted(map(int, input().split()), reverse=True) M = candies[-1] + x ans = sum(candies) i = 0 req = n - k while req: if M > candies[i]: c = candies[i] if M - req >= c: y = M - req ans += M * (M + 1) // 2 - y * ...
vfc_133902
{ "difficulty": "hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/GUZAC", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n4 3 4 \n2 1 5\n2 2 9\n3 6", "output": "12\n9", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/POLIN
Solve the following coding problem using the programming language python: Given N points of the form (x_{i}, y_{i}) on a 2-D plane. From each point, you draw 2 lines one horizontal and one vertical. Now some of the lines may overlap each other, therefore you are required to print the number of distinct lines you can ...
```python n = int(input()) for i in range(n): k = int(input()) l1 = [] l2 = [] for i in range(k): (a, b) = map(int, input().split()) l1.append(a) l2.append(b) print(len(set(l1)) + len(set(l2))) ```
vfc_133906
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/POLIN", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n4\n1 1\n1 0\n0 1\n0 0\n5\n0 0\n0 1\n0 2\n0 3\n0 4\n1\n10 10", "output": "4\n6\n2", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Dr. A of the Aizu Institute of Biological Research discovered a mysterious insect on a certain southern island. The shape is elongated like a hornworm, but since one segment is shaped like a ball, it looks like a beaded ball connected by a threa...
```python from collections import deque def new_color(s, i, rgb): for color in rgb: if color != s[i] and color != s[i + 1]: break return s[:i] + color * 2 + s[i + 2:] def solve(s): length = len(s) monos = ['r' * length, 'g' * length, 'b' * length] if s in monos: print(0) return dic = {s: 0} rgb = 'rgb...
vfc_133910
{ "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": "rbgrg\nrbbgbbr\nbgr\nrgbbrgbr\nbggrgbgrr\ngbrggrbggr\nrrrrr\nbgbr\n0", "output": "5\n7\n1\n6\nNA\n8\n0\n4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "rbgrg\ngbbrbbr\ngbr\nrgbbrgbr\nrrg...
taco
verifiable_code
https://www.codechef.com/problems/RRFRNDS
Solve the following coding problem using the programming language python: Read problems statements in Mandarin Chinese and Russian as well. After IOI Ilya decided to make a business. He found a social network called "TheScorpyBook.com". It currently has N registered users. As in any social network two users can be ...
```python n = int(input()) vertex = [input() for x in range(n)] friendship = [int(x, 2) for x in vertex] limit = 0 count = 0 for i in range(n): for j in range(limit): if vertex[i][j] == '0' and i != j and friendship[i] & friendship[j]: count += 2 limit += 1 print(count) ```
vfc_133918
{ "difficulty": "very_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/RRFRNDS", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n0111\n1000\n1000\n1000", "output": "6", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1111\n1000\n1000\n1000", "output": "6\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/124/A
Solve the following coding problem using the programming language python: Petr stands in line of n people, but he doesn't know exactly which position he occupies. He can say that there are no less than a people standing in front of him and no more than b people standing behind him. Find the number of different positio...
```python (x, y, z) = map(int, input().split()) if y + z >= x: print(x - y) else: print(z + 1) ```
vfc_133926
{ "difficulty": "easy", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/124/A", "time_limit": "0.5 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "23 8 14\n", "output": "15", "type": "stdin_stdout" }, { "fn_name": null, "input": "59 12 39\n", "output": "40", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1312/A
Solve the following coding problem using the programming language python: You are given two integers $n$ and $m$ ($m < n$). Consider a convex regular polygon of $n$ vertices. Recall that a regular polygon is a polygon that is equiangular (all angles are equal in measure) and equilateral (all sides have the same length...
```python t = int(input()) for i in range(t): (a, b) = list(map(int, input().rstrip().split())) if a % b == 0: print('YES') else: print('NO') ```
vfc_133940
{ "difficulty": "easy", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1312/A", "time_limit": "1 second" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n6 3\n7 3\n", "output": "YES\nNO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n69 68\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, ...
taco
verifiable_code
https://codeforces.com/problemset/problem/926/H
Solve the following coding problem using the programming language python: Arkady decided to buy roses for his girlfriend. A flower shop has white, orange and red roses, and the total amount of them is n. Arkady thinks that red roses are not good together with white roses, so he won't buy a bouquet containing both red...
```python (n, k) = list(map(int, input().split())) b = list(map(int, input().split())) s = input() a = [] if k == 1: print(-1) return for i in range(n): a.append((b[i], s[i])) a.sort(reverse=True) i = 0 j = 0 m1 = 0 q1 = False q2 = False while i != k: if a[j][1] != 'R': m1 += a[j][0] g = j + 0 if a[j][1] == '...
vfc_133944
{ "difficulty": "hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/926/H", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 3\n4 3 4 1 6\nRROWW\n", "output": "11\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Example Input R?????,2?) Output 29 The input will be stdin and you should print your solution to stdout Now solve the problem and return the code.
```python import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools sys.setrecursionlimit(10 ** 7) inf = 10 ** 20 eps = 1.0 / 10 ** 13 mod = 10 ** 9 + 7 dd = [(-1, 0), (0, 1), (1, 0), (0, -1)] ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (...
vfc_133948
{ "difficulty": "unknown_difficulty", "memory_limit": "134.217728 megabytes", "memory_limit_bytes": null, "problem_url": null, "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": ")?2,?????R", "output": "invalid\n", "type": "stdin_stdout" }, { "fn_name": null, "input": ")?2,???@?R", "output": "invalid\n", "type": "stdin_stdout" }, { "fn_name": null, ...
taco
verifiable_code
https://codeforces.com/problemset/problem/963/A
Solve the following coding problem using the programming language python: You are given two integers $a$ and $b$. Moreover, you are given a sequence $s_0, s_1, \dots, s_{n}$. All values in $s$ are integers $1$ or $-1$. It's known that sequence is $k$-periodic and $k$ divides $n+1$. In other words, for each $k \leq i \...
```python def pow_mod(x, y, p): number = 1 while y: if y & 1: number = number * x % p y >>= 1 x = x * x % p return number % p def inv(x, p): if 1 < x: return p - inv(p % x, x) * p // x return 1 def v(p, a, b, k): i = 1 while pow_mod(a, k, (10 ** 9 + 9) ** i) - pow_mod(b, k, (10 ** 9 + 9) ** i) == 0:...
vfc_133953
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/963/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 2 3 3\n+-+\n", "output": "7\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 1 5 1\n-\n", "output": "999999228\n", "type": "stdin_stdout" }, { "fn_name": null,...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/printing-maximum-sum-increasing-subsequence4903/1
Solve the following coding problem using the programming language python: You are given an array A of length N .You have to find the maximum sum subsequence of a given sequence such that all elements of the subsequence are sorted in strictly increasing order. If there are more than one such subsequences,then print the...
```python class Solution: def maxSumSequence(self, N, A): lis = [[i] for i in A] for i in range(1, len(A)): for j in range(0, i): if A[i] > A[j] and sum(lis[i]) < sum(lis[j]) + A[i]: lis[i] = lis[j].copy() lis[i].append(A[i]) ans = [0] for i in lis: if sum(i) > sum(ans): ans = i.copy()...
vfc_133958
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/printing-maximum-sum-increasing-subsequence4903/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 7\nA = {1, 101, 2, 3, 100, 4, 5}", "output": "{1, 2, 3, 100}", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 5\nA = {4, 2, 5, 3, 4}", "output": "{4, 5}", "type": "stdin_s...
taco
verifiable_code
https://www.hackerrank.com/challenges/divisible-sum-pairs/problem
Solve the following coding problem using the programming language python: Given an array of integers and a positive integer $\boldsymbol{\mbox{k}}$, determine the number of $(i,j)$ pairs where $i<j$ and $ar[i]$ + $ar[j]$ is divisible by $\boldsymbol{\mbox{k}}$. Example $ar=[1,2,3,4,5,6]$ $k=5$ Three pairs ...
```python import sys (n, k) = input().strip().split(' ') (n, k) = [int(n), int(k)] a = [int(a_temp) for a_temp in input().strip().split(' ')] result = 0 for i in range(n - 1): for j in range(i + 1, n): if not (a[i] + a[j]) % k: result += 1 print(result) ```
vfc_133960
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.hackerrank.com/challenges/divisible-sum-pairs/problem", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 3\n1 3 2 6 1 2\n", "output": " 5\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/COOK86/problems/LIKECS02
Solve the following coding problem using the programming language python: Chef Tobby asked Bhuvan to brush up his knowledge of statistics for a test. While studying some distributions, Bhuvan learns the fact that for symmetric distributions, the mean and the median are always the same. Chef Tobby asks Bhuvan out for a...
```python x = int(input()) for a in range(x): n = int(input()) L = [str(n)] c = 1 while len(L) != n: L.append(str(n + c)) if len(L) == n: break L.append(str(n - c)) c += 1 a = ' '.join(L) print(a) ```
vfc_133968
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/COOK86/problems/LIKECS02", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1\n2\n3\n", "output": "1\n1 2\n1 2 3\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/884/B
Solve the following coding problem using the programming language python: A one-dimensional Japanese crossword can be represented as a binary string of length x. An encoding of this crossword is an array a of size n, where n is the number of segments formed completely of 1's, and a_{i} is the length of i-th segment. N...
```python (n, x) = map(int, input().split()) encoding = list(map(int, input().split())) zeros = n - 1 ones = sum(encoding) if zeros + ones == x: print('YES') else: print('NO') ```
vfc_133973
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/884/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 4\n1 3\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 10\n3 3 2\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "...
taco
verifiable_code
Solve the following coding problem using the programming language python: Example Input mmemewwemeww Output Cat The input will be stdin and you should print your solution to stdout Now solve the problem and return the code.
```python import re b = s = input() while 1: s = re.sub('(m|e)mew(e|w)', '\\1\\2', s) if b == s: break b = s print(['Rabbit', 'Cat'][s == 'mew']) ```
vfc_133982
{ "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": "mmemwweemeww", "output": "Rabbit\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "wwemeewwmemm", "output": "Rabbit\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/357/B
Solve the following coding problem using the programming language python: In Berland, there is the national holiday coming — the Flag Day. In the honor of this event the president of the country decided to make a big dance party and asked your agency to organize it. He has several conditions: overall, there must be m...
```python (n, m) = (int(x) for x in input().split()) available = [1, 2, 3] colors = [0] * (n + 1) for i in range(m): (a, b, c) = [int(x) for x in input().split()] if colors[a] != 0: available.remove(colors[a]) if colors[b] != 0: available.remove(colors[b]) if colors[c] != 0: available.remove(colors[c]) if le...
vfc_133993
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/357/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7 3\n1 2 3\n1 4 5\n4 6 7\n", "output": "1 2 3 3 2 2 1 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "9 3\n3 6 9\n2 5 8\n1 4 7\n", "output": "1 1 1 2 2 2 3 3 3 \n", "type": "s...
taco
verifiable_code
https://codeforces.com/problemset/problem/1208/C
Solve the following coding problem using the programming language python: Let us define a magic grid to be a square matrix of integers of size n × n, satisfying the following conditions. * All integers from 0 to (n^2 - 1) inclusive appear in the matrix exactly once. * [Bitwise XOR](https://en.wikipedia.org/wiki...
```python n = int(input()) for i in range(n): printlist = [] m = i // 4 k = i % 4 for j in range(n): printlist.append(str(4 * n * m + 4 * j + k)) print(' '.join(printlist)) ```
vfc_134005
{ "difficulty": "medium_hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1208/C", "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "44\n", "output": "0 1 2 3 16 17 18 19 32 33 34 35 48 49 50 51 64 65 66 67 80 81 82 83 96 97 98 99 112 113 114 115 128 129 130 131 144 145 146 147 160 161 162 163 \n4 5 6 7 20 21 22 23 36 37 38 39 52 53 54 55 68 69 70 71 84 85...
taco
verifiable_code
https://www.codechef.com/problems/DEVARRAY
Solve the following coding problem using the programming language python: Devu has an array A consisting of N positive integers. He would like to perform following operation on array. - Pick some two elements a, b in the array (a could be same as b, but their corresponding indices in the array should not be same). Re...
```python (N, Q) = map(int, input().split()) A = list(map(int, input().split())) mn = min(A) mx = max(A) for i in range(Q): print('Yes' if mn <= int(input()) <= mx else 'No') ```
vfc_134010
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/DEVARRAY", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 2\n1\n1\n2\n", "output": "Yes\nNo\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 4\n1 3\n1\n2\n3\n4\n", "output": "Yes\nYes\nYes\nNo\n", "type": "stdin_stdout" }, ...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/multiply-two-strings/1
Solve the following coding problem using the programming language python: Given two numbers as strings s1 and s2. Calculate their Product. Note: The numbers can be negative and You are not allowed to use any built-in function or convert the strings to integers. Example 1: Input: s1 = "33" s2 = "2" Output: 66 Example 2...
```python class Solution: def multiplyStrings(self, s1, s2): a = int(s1) b = int(s2) return a * b ```
vfc_134018
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/multiply-two-strings/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "s1 = \"33\"\r\ns2 = \"2\"", "output": "66", "type": "stdin_stdout" }, { "fn_name": null, "input": "s1 = \"11\"\r\ns2 = \"23\"", "output": "253", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Given a string S which contains only lowercase characters ['a'-'z'] and an integer K you have to find number of substrings having weight equal to K. Weight of characters is defined as : Weight['a']=1 Weight['b']=2 Weight['c']=3 Weight['d'...
```python alpha = "abcdefghijklmnopqrstuvwxyz" x = 0 weight = {} for i in alpha: x=x+1 weight[i] = x def countSubStr(s, k): subStr =0 w = 0 i = 0 while i< len(s): j = i while j< len(s): w = w+weight[s[j]] if w<k: j= j+1 continue else: break if w==k: subStr = subStr + 1 w=0 i=i+1...
vfc_134019
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1\nd\n1\na\n5\nabcdef\n8\ndddddd\n6\nccabcd\n\n", "output": "4459\n6912\n2487\n2314\n2365\n791\n2370\n1792\n2440\n2697\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "20\n2\nabc\n10\npq...
taco
verifiable_code
Solve the following coding problem using the programming language python: problem JOI, who has been suffering from his winter vacation homework every time, decided to do his homework systematically this time. Homework is a national language and math drill, with a national language drill on page A and a math drill on ...
```python a = int(input()) b = int(input()) c = int(input()) d = int(input()) e = int(input()) if b % d == 0: x = b // d else: x = b // d + 1 if c % e == 0: y = c // e else: y = c // e + 1 if x >= y: print(a - x) else: print(a - y) ```
vfc_134023
{ "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": "20\n4\n30\n6\n8", "output": "16\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "20\n4\n30\n7\n1", "output": "-10\n", "type": "stdin_stdout" }, { "fn_name": null, ...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/search-an-element-in-an-array-1587115621/1
Solve the following coding problem using the programming language python: Given an integer array and another integer element. The task is to find if the given element is present in array or not. Example 1: Input: n = 4 arr[] = {1,2,3,4} x = 3 Output: 2 Explanation: There is one test case with array as {1, 2, 3 4} and...
```python class Solution: def search(self, arr, N, X): for i in range(len(arr)): if arr[i] == X: return i else: return -1 ```
vfc_134032
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/search-an-element-in-an-array-1587115621/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "n = 4\r\narr[] = {1,2,3,4}\r\nx = 3", "output": "2", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/394/D
Solve the following coding problem using the programming language python: The Physical education teacher at SESC is a sort of mathematician too. His most favorite topic in mathematics is progressions. That is why the teacher wants the students lined up in non-decreasing height form an arithmetic progression. To achie...
```python q = 10001 (n, a) = (int(input()), list(map(int, input().split()))) a.sort() for i in range(40000 // (n - 1) + 1): b = [a[j] - j * i for j in range(n)] (u, v) = (max(b), min(b)) p = (u - v + 1) // 2 if p < q: (q, s, d) = (p, v + p, i) print(q) print(s, d) ```
vfc_134033
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/394/D", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n-3 -4 -2 -3 3\n", "output": "2\n-3 1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n2 -3 -1 -4 3\n", "output": "1\n-4 2\n", "type": "stdin_stdout" }, { "fn...
taco
verifiable_code
Solve the following coding problem using the programming language python: You received a card with an integer $S$ and a multiplication table of infinite size. All the elements in the table are integers, and an integer at the $i$-th row from the top and the $j$-th column from the left is $A_{i,j} = i \times j$ ($i,j \g...
```python from collections import defaultdict, deque from heapq import heappush, heappop import sys import math import bisect import random def LI(): return [int(x) for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) def LS(): return [list(x) for x in sys.stdin.readline().split()] de...
vfc_134037
{ "difficulty": "unknown_difficulty", "memory_limit": "536.870912 megabytes", "memory_limit_bytes": null, "problem_url": null, "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "18", "output": "20\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "9", "output": "10\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1277/C
Solve the following coding problem using the programming language python: You are given a non-empty string s=s_1s_2... s_n, which consists only of lowercase Latin letters. Polycarp does not like a string if it contains at least one string "one" or at least one string "two" (or both at the same time) as a substring. In...
```python t = int(input()) for _ in range(t): s = input() i = 0 R = [] while i < len(s): if i + 4 < len(s) and s[i:i + 5] == 'twone': R.append(i + 2 + 1) i += 5 elif i + 2 < len(s) and (s[i:i + 3] == 'one' or s[i:i + 3] == 'two'): R.append(i + 1 + 1) i += 3 else: i += 1 print(len(R)) for i in...
vfc_134046
{ "difficulty": "medium", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1277/C", "time_limit": "3.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\nzzzone\n", "output": "1\n5 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\nonetwonetwooneooonetwooo\ntwo\none\ntwooooo\nttttwo\nttwwoo\nooone\nonnne\noneeeee\noneeeeeeetwooooo\n", ...
taco
verifiable_code
https://www.hackerrank.com/challenges/simple-array-sum/problem
Solve the following coding problem using the programming language python: Given an array of integers, find the sum of its elements. For example, if the array $ar=[1,2,3]$, $1+2+3=6$, so return $6$. Function Description Complete the simpleArraySum function in the editor below. It must return the sum of the array ...
```python n = int(input()) nums = list(map(int, input().split())) sum = 0 for num in nums: sum += num print(sum) ```
vfc_134054
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.hackerrank.com/challenges/simple-array-sum/problem", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n1 2 3 4 10 11\n", "output": "31\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/MEXOR
Solve the following coding problem using the programming language python: Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. The *MEX* (minimum excluded) of an array is the smallest non-negative integer that does not belong to the array. For instance: The MEX of [2, 2, 1] ...
```python from math import log2 def calc(num): cur = log2(num + 1) return cur == int(cur) def soln(n: int) -> int: if calc(n): return n + 1 return 1 << int(log2(n)) for _ in range(int(input())): n = int(input()) print(soln(n)) ```
vfc_134062
{ "difficulty": "medium_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/MEXOR", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n0\n1\n2\n5\n", "output": "1\n2\n2\n4\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/37/A
Solve the following coding problem using the programming language python: Little Vasya has received a young builder’s kit. The kit consists of several wooden bars, the lengths of all of them are known. The bars can be put one on the top of the other if their lengths are the same. Vasya wants to construct the minimal ...
```python x = int(input()) l = list(map(int, input().split())) a = list(set(l)) l.sort() maxx = l.count(0) for i in range(len(l)): if l.count(l[i]) > maxx: maxx = l.count(l[i]) print(maxx, len(a)) ```
vfc_134066
{ "difficulty": "easy", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/37/A", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "83\n246 535 994 33 390 927 321 97 223 922 812 705 79 80 977 457 476 636 511 137 6 360 815 319 717 674 368 551 714 628 278 713 761 553 184 414 623 753 428 214 581 115 439 61 677 216 772 592 187 603 658 310 439 559 870 376 109 321 18...
taco
verifiable_code
https://codeforces.com/problemset/problem/700/B
Solve the following coding problem using the programming language python: Treeland is a country in which there are n towns connected by n - 1 two-way road such that it's possible to get from any town to any other town. In Treeland there are 2k universities which are located in different towns. Recently, the presid...
```python def main(): (n, k) = list(map(int, input().split())) s = [0] * n for i in map(int, input().split()): s[i - 1] = 1 e = [[] for _ in range(n)] for _ in range(n - 1): (x, y) = (int(s) - 1 for s in input().split()) e[x].append(y) e[y].append(x) (q, fa) = ([0], [-1] * n) fa[0] = 0 for i in range(n)...
vfc_134070
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/700/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7 2\n1 5 6 2\n1 3\n3 2\n4 5\n3 7\n4 3\n4 6\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "9 3\n3 2 1 6 5 9\n8 9\n3 2\n2 7\n3 4\n7 6\n4 5\n2 1\n2 8\n", "output": "9\...
taco
verifiable_code
https://codeforces.com/problemset/problem/922/D
Solve the following coding problem using the programming language python: Pushok the dog has been chasing Imp for a few hours already. $48$ Fortunately, Imp knows that Pushok is afraid of a robot vacuum cleaner. While moving, the robot generates a string t consisting of letters 's' and 'h', that produces a lot of ...
```python n = int(input()) a = [] for i in range(n): b = input() a.append([b.count('h') / len(b), b]) a.sort() b = '' for i in range(n): b = b + a[i][1] c = 0 s = 0 for i in range(len(b)): if b[i] == 's': c = c + 1 if b[i] == 'h': s = s + c print(s) ```
vfc_134074
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/922/D", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\nssh\nhs\ns\nhhhs\n", "output": "18\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\nh\ns\n", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, ...
taco
verifiable_code
https://codeforces.com/problemset/problem/1792/A
Solve the following coding problem using the programming language python: Monocarp is playing a computer game. He's going to kill $n$ monsters, the $i$-th of them has $h_i$ health. Monocarp's character has two spells, either of which he can cast an arbitrary number of times (possibly, zero) and in an arbitrary order:...
```python for s in [*open(0)][2::2]: print(len((a := s.split())) - a.count('1') // 2) ```
vfc_134078
{ "difficulty": "easy", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1792/A", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n4\n1 2 1 2\n3\n2 4 2\n5\n1 2 3 4 5\n", "output": "3\n3\n5\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/SAVJEW
Solve the following coding problem using the programming language python: Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well. It is well-known that if you become rich, you will have a lot of trouble. Coach Khaled is one of the richest men in the world. He has $N$ j...
```python from collections import defaultdict class SegmentTree: def __init__(self, values): self.data = [0 for _ in values] + values self.n = len(values) for idx in reversed(range(1, self.n)): self.data[idx] = max(self.data[2 * idx], self.data[2 * idx + 1]) def update(self, idx, value): idx += self.n ...
vfc_134082
{ "difficulty": "very_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/SAVJEW", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n4 4\n1 2 4 3\n1 3\n3 4\n1 2\n2 3", "output": "4", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/516/E
Solve the following coding problem using the programming language python: Drazil has many friends. Some of them are happy and some of them are unhappy. Drazil wants to make all his friends become happy. So he invented the following plan. There are n boys and m girls among his friends. Let's number them from 0 to n - ...
```python (n, m) = (int(x) for x in input().split()) happy_boys = [0 for _ in range(n)] happy_girls = [0 for _ in range(m)] boys = [int(x) for x in input().split()] girls = [int(x) for x in input().split()] if boys[0]: for i in range(1, len(boys)): happy_boys[boys[i]] = 1 if girls[0]: for i in range(1, len(girls)):...
vfc_134086
{ "difficulty": "very_hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/516/E", "time_limit": "4.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 5\n0\n5 4 3 2 1 0\n", "output": "Yes\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 12\n0\n3 0 8 4\n", "output": "Yes\n", "type": "stdin_stdout" }, { "fn_nam...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/sum-of-lengths-of-non-overlapping-subarrays2237/1
Solve the following coding problem using the programming language python: Given an array arr[] of N elements, the task is to find the maximum sum of lengths of all non-overlapping subarrays with K as the maximum element in the subarray. Example 1: Input: N = 9, K = 4 arr[] = {2, 1, 4, 9, 2, 3, 8, 3, 4} Output: 5 Expl...
```python class Solution: def calculateMaxSumLength(self, arr, n, k): i = 0 ans = 0 while i < n: flag = False count = 0 while i < n and arr[i] <= k: count += 1 if arr[i] == k: flag = True i += 1 if flag: ans += count while i < n and arr[i] > k: i += 1 return ans ```
vfc_134091
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/sum-of-lengths-of-non-overlapping-subarrays2237/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 9, K = 4\narr[] = {2, 1, 4, 9, 2, 3, 8, 3, 4}", "output": "5", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 7, K = 4\narr[] = {1, 2, 3, 2, 3, 4, 1}", "output": "7", "typ...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/mind-game3637/1
Solve the following coding problem using the programming language python: Someone is asked to perform the following operations on a randomly chosen number between 1 and 10. Step 1: Double the chosen number. Step 2: Add a number K(even number given as input) to the number obtained after Step1 Step 3: Divide the obt...
```python class Solution: def mindGame(self, K): return K // 2 ```
vfc_134094
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/mind-game3637/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "K = 10", "output": "5", "type": "stdin_stdout" }, { "fn_name": null, "input": "K = 2", "output": "1", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/344/D
Solve the following coding problem using the programming language python: Mad scientist Mike has just finished constructing a new device to search for extraterrestrial intelligence! He was in such a hurry to launch it for the first time that he plugged in the power wires without giving it a proper glance and started e...
```python class Stack: def __init__(self): self.items = [] def isEmpty(self): return self.items == [] def push(self, item): self.items.append(item) def pop(self): return self.items.pop() def peek(self): return self.items[len(self.items) - 1] def size(self): return len(self.items) def untangle(s...
vfc_134095
{ "difficulty": "medium_hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/344/D", "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "-+-\n", "output": "No\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "+---++--++\n", "output": "No\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/move-all-negative-elements-to-end1813/1
Solve the following coding problem using the programming language python: Given an unsorted array arr[] of size N having both negative and positive integers. The task is place all negative element at the end of array without changing the order of positive element and negative element. Example 1: Input : N = 8 arr[]...
```python class Solution: def segregateElements(self, arr, n): d = [] c = [] for i in range(n): if arr[i] < 0: d.append(arr[i]) else: c.append(arr[i]) arr.clear f = c + d for i in range(len(f)): arr[i] = f[i] return arr ```
vfc_134099
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/move-all-negative-elements-to-end1813/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 8\narr[] = {1, -1, 3, 2, -7, -5, 11, 6 }", "output": "1 3 2 11 6 -1 -7 -5", "type": "stdin_stdout" }, { "fn_name": null, "input": "N=8\narr[] = {-5, 7, -3, -4, 9, 10, -1, 11}", "outp...
taco
verifiable_code
https://codeforces.com/problemset/problem/730/J
Solve the following coding problem using the programming language python: Nick has n bottles of soda left after his birthday. Each bottle is described by two values: remaining amount of soda a_{i} and bottle volume b_{i} (a_{i} ≤ b_{i}). Nick has decided to pour all remaining soda into minimal number of bottles, more...
```python f = lambda : list(map(int, input().split())) n = int(input()) (a, b) = (f(), f()) d = [[None] * 10001 for i in range(n)] def g(i, s): if s <= 0: return (0, s) if i == n: return (10000000.0, 0) if not d[i][s]: (x, y) = g(i + 1, s - b[i]) d[i][s] = min(g(i + 1, s), (x + 1, y + b[i] - a[i])) return ...
vfc_134100
{ "difficulty": "hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/730/J", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n3 3 4 3\n4 7 6 5\n", "output": "2 6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n1 1\n100 100\n", "output": "1 1\n", "type": "stdin_stdout" }, { "fn_name...
taco
verifiable_code
https://www.codechef.com/problems/DETSCORE
Solve the following coding problem using the programming language python: Chef appeared for a placement test. There is a problem worth X points. Chef finds out that the problem has exactly 10 test cases. It is known that each test case is worth the same number of points. Chef passes N test cases among them. Determ...
```python for i in range(int(input())): (p, c) = list(map(int, input().split())) k = p // 10 print(c * k) ```
vfc_134104
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/DETSCORE", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n10 3\n100 10\n130 4\n70 0\n", "output": "3\n100\n52\n0\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/547/B
Solve the following coding problem using the programming language python: Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly a_{i} feet high. [Image...
```python n = int(input()) arr = list(map(int, input().split())) (pse, nse) = ([-1] * n, [n] * n) (stack, stack2) = ([0], [n - 1]) for i in range(1, n): while len(stack) and arr[i] < arr[stack[-1]]: nse[stack.pop()] = i stack.append(i) while len(stack2) and arr[n - i - 1] < arr[stack2[-1]]: pse[stack2.pop()] = n...
vfc_134108
{ "difficulty": "hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/547/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n1 2 3 4 5 4 3 2 1 6\n", "output": "6 4 4 3 3 2 2 1 1 1 \n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/5/D
Solve the following coding problem using the programming language python: Everybody knows that the capital of Berland is connected to Bercouver (the Olympic capital) by a direct road. To improve the road's traffic capacity, there was placed just one traffic sign, limiting the maximum speed. Traffic signs in Berland ar...
```python import sys def time_distance(v0, a, d): return (-v0 + (v0 ** 2 + 2 * a * d) ** 0.5) / a def time_accelerating(v0, v1, a): return (v1 - v0) / a def time_speed(v, d): return d / v def distance_travelled(v0, t, a): return v0 * t + a / 2 * t ** 2 def main(): (a, v) = map(int, sys.stdin.readline().strip(...
vfc_134112
{ "difficulty": "hard", "memory_limit": "64.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/5/D", "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "20 40\n9958 9799 30\n", "output": "250.075000000000\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "23 4\n5 2 13\n", "output": "1.336956521739\n", "type": "stdin_stdout" },...
taco
verifiable_code
https://codeforces.com/problemset/problem/990/E
Solve the following coding problem using the programming language python: Adilbek's house is located on a street which can be represented as the OX axis. This street is really dark, so Adilbek wants to install some post lamps to illuminate it. Street has $n$ positions to install lamps, they correspond to the integer n...
```python import sys (n, m, k) = list(map(int, input().split())) s = list(map(int, sys.stdin.readline().split())) a = list(map(int, sys.stdin.readline().split())) if m > 0 and s[0] == 0: print('-1') else: block = [-1] * n for i in range(m): if block[s[i] - 1] == -1: block[s[i]] = s[i] - 1 else: block[s[i]]...
vfc_134120
{ "difficulty": "hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/990/E", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 2 3\n1 3\n1 2 3\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 3 4\n1 2 3\n1 10 100 1000\n", "output": "1000\n", "type": "stdin_stdout" }, { ...
taco
verifiable_code
https://www.codechef.com/problems/BRACKETS
Solve the following coding problem using the programming language python: A valid parentheses sequence is a non-empty string where each character is either '(' or ')', which satisfies the following constraint: You can find a way to repeat erasing adjacent pairs of parentheses '()' until it becomes empty. For exampl...
```python for i in range(int(input())): s = input() m = 0 c = 0 for j in range(len(s)): if s[j] == '(': c += 1 elif s[j] == ')': c -= 1 m = max(m, c) print(m * '(' + m * ')') ```
vfc_134124
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/BRACKETS", "time_limit": "0.5 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n()((()()))\n\n\n", "output": "((()))\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n()(())()()", "output": "(())\n", "type": "stdin_stdout" }, { "fn_name":...
taco
verifiable_code
Solve the following coding problem using the programming language python: Saving electricity is very important! You are in the office represented as R \times C grid that consists of walls and rooms. It is guaranteed that, for any pair of rooms in the office, there exists exactly one route between the two rooms. It ta...
```python import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools sys.setrecursionlimit(10 ** 7) inf = 10 ** 20 eps = 1.0 / 10 ** 13 mod = 10 ** 9 + 7 dd = [(-1, 0), (0, 1), (1, 0), (0, -1)] ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (...
vfc_134132
{ "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": "3 3 5\n...\n.##\n..#\n1 1 1\n1 0 0\n1 1 0\n3 3 3\n3 0 0\n5 3 0\n5 4 5\n4 0 0\n5 4 0\n1 0\n2 1\n0 2\n2 0\n0 0", "output": "79\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 3 2\n...\n1 1...
taco
verifiable_code
https://codeforces.com/problemset/problem/1341/E
Solve the following coding problem using the programming language python: If the girl doesn't go to Denis, then Denis will go to the girl. Using this rule, the young man left home, bought flowers and went to Nastya. On the way from Denis's house to the girl's house is a road of $n$ lines. This road can't be always c...
```python import sys from array import array import typing as Tp def input(): return sys.stdin.buffer.readline().decode('utf-8') def output(*args): sys.stdout.buffer.write(('\n'.join(map(str, args)) + '\n').encode('utf-8')) def main(): from collections import deque (n, m) = map(int, input().split()) pos = [-10 ...
vfc_134137
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1341/E", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "15 5\n0 3 7 14 15\n11 11\n", "output": "45", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/largest-independent-set-problem/1
Solve the following coding problem using the programming language python: Given a Binary Tree of size N, find the size of the Largest Independent Set(LIS) in it. A subset of all tree nodes is an independent set if there is no edge between any two nodes of the subset. Your task is to complete the function LISS(), which...
```python def LISS(root): def apply(root, choice): if not root: return 0 if choice == 0: ans = max(1 + apply(root.left, 1) + apply(root.right, 1), apply(root.left, 0) + apply(root.right, 0)) else: ans = apply(root.left, 0) + apply(root.right, 0) return ans return apply(root, 0) ```
vfc_134141
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/largest-independent-set-problem/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": "LISS", "input": "10 20 30 40 50 N 60 N N 70 80", "output": "5", "type": "function_call" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1759/B
Solve the following coding problem using the programming language python: A sequence of $n$ numbers is called a permutation if it contains all integers from $1$ to $n$ exactly once. For example, the sequences [$3, 1, 4, 2$], [$1$] and [$2,1$] are permutations, but [$1,2,1$], [$0,1$] and [$1,3,4$] — are not. Polycarp ...
```python import sys input = sys.stdin.readline def inp(): return int(input()) def inlt(): return list(map(int, input().split())) def insr(): s = input() return list(s[:len(s) - 1]) def invr(): return map(int, input().split()) test_cases = inp() inp_arr = [] for i in range(test_cases): l1 = inlt() l2 = inlt(...
vfc_134146
{ "difficulty": "easy", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1759/B", "time_limit": "1 second" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n3 13\n3 1 4\n1 1\n1\n3 3\n1 4 2\n2 1\n4 3\n5 6\n1 2 3 4 5\n", "output": "YES\nNO\nYES\nNO\nYES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n3 13\n4 1 3\n", "output": "YES\n"...
taco
verifiable_code
Solve the following coding problem using the programming language python: There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. Write a program which prints "YES" if a point $P$ $(x_p, y_p)$ is in the triangle and "NO" if not. Constraints You can assume that: * $ -100 \leq...
```python import math def simul_eq(a, b, c, d, e, f): C = [c, f] detA = a * e - b * d At = [[e, -b], [-d, a]] x = sum(map(lambda x, y: x * y, At[0], C)) / detA y = sum(map(lambda x, y: x * y, At[1], C)) / detA return (x, y) ss = input().split() while 1: (x1, y1, x2, y2, x3, y3, xp, yp) = map(float, ss) (s, t) ...
vfc_134150
{ "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.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5\n0.0 0.8224818410475855 1.0 4.0 5.0 3.0 -1.0 3.0", "output": "YES\nNO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "0.4580529168787624 0.0 2.0 0.842157591...
taco
verifiable_code
Solve the following coding problem using the programming language python: PIET's CS department has been continuously organizing mock placement drives for students. If a student under-performs negative point is rewarded otherwise positive points is rewarded. The HOD wants to find consistency of a student. So, he wants ...
```python N=eval(input()) a=list(map(int,input().split())) sum=0 r=0 for i in range(N): sum=sum+a[i] if sum<0: sum=0 if sum>r: r=sum print(r) ```
vfc_134155
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8\n-1 -2 5 -1 -2 3 2 -1", "output": "4453", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/series-gp4646/1
Solve the following coding problem using the programming language python: Given the A and R i,e first term and common ratio of a GP series. Find the Nth term of the series. Note: As the answer can be rather large print its modulo 1000000007 (10^{9} + 7). Example 1: Input: A = 2, R = 2, N = 4 Output: 16 Explanation: Th...
```python class Solution: def Nth_term(self, a, r, n): mod = pow(10, 9) + 7 n = a * pow(r, n - 1, mod) % mod return n ```
vfc_134169
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/series-gp4646/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "A = 2, R = 2, N = 4", "output": "16", "type": "stdin_stdout" }, { "fn_name": null, "input": "A = 4, R = 3, N = 3", "output": "36", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.hackerrank.com/challenges/journey-scheduling/problem
Solve the following coding problem using the programming language python: Fedya is a seasoned traveller and is planning his trip to Treeland. Treeland is a country with an ancient road system which is in the form of a tree structure. $N$ cities of Treeland are numbered by $N$ positive integers: $1,2,3,\ldots,N$. Fedy...
```python DEBUG = 0 class CacheEntry(object): def __init__(self, f, d, n, a_f, a_d, a_n, excluded=None): self.f = f self.d = d self.n = n self.a_f = a_f self.a_d = a_d self.a_n = a_n self.excluded = excluded def complete(self, prev): return self.excluded is None or self.excluded == prev def furth...
vfc_134171
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.hackerrank.com/challenges/journey-scheduling/problem", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8 7\n2 1\n3 2\n4 2\n5 1\n6 1\n7 1\n8 7\n4 6\n3 4\n6 3\n7 6\n4 6\n7 1\n2 6\n", "output": "24\n16\n11\n23\n24\n3\n23\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/776/B
Solve the following coding problem using the programming language python: Sherlock has a new girlfriend (so unlike him!). Valentine's day is coming and he wants to gift her some jewelry. He bought n pieces of jewelry. The i-th piece has price equal to i + 1, that is, the prices of the jewelry are 2, 3, 4, ... n + 1. ...
```python n = int(input()) primes = [2] primes_bool = [2 for _ in range(10 ** 5 + 4)] primes_bool[2] = 1 for i in range(3, 10 ** 5 + 4, 2): isPrime = True for j in range(len(primes)): if primes[j] ** 2 > i: break if i % primes[j] == 0: isPrime = False break if isPrime: primes.append(i) primes_bool[i...
vfc_134175
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/776/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n", "output": "2\n1 1 2 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n", "output": "2\n1 1 2 1 \n", "type": "stdin_stdout" }, { "fn_name": null, "in...
taco
verifiable_code
Solve the following coding problem using the programming language python: In India IPL is on full swing now. Fans of cricket love watching the game and seeing ball by ball with having Snacks. Yummy, crispy snacks. Ankit and his friends are one of them. One night, while watching his Favourite team's Match he is eating...
```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!' t=int(input()) while t: t=t-1 n=int(input()) d=list(map(float,input().split())) f=list(map(float,input().split())) sum=0 for i in range(0,n): sum...
vfc_134179
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n5\n0.2 0.56 0.12 0.89 0.34\n0.1 0.2 0.34 0.0 0.8\n3\n0.99 0.12 0.45\n0.3 0.67 0.23\n9\n0.21 0.43 0.23 0.67 0.39 0.8 0.1 0.4 0.3\n0.9 0.3 0.1 0.5 0.8 0.2 0.7 0.6 0.4\n4\n0.111 0.222 0.333 0.444\n0.1 0.2 0.3 0.4\n7\n0.275 0.74 0.3...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/plus-one/1
Solve the following coding problem using the programming language python: Given a non-negative number represented as a list of digits, add 1 to the number (increment the number represented by the digits). The digits are stored such that the most significant digit is first element of array. Example 1: Input: N = 3 ...
```python class Solution: def increment(self, arr, N): if arr[-1] == 9: s = 0 for i in arr: s = s * 10 + i return list(str(s + 1)) else: arr[-1] += 1 return arr ```
vfc_134184
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/plus-one/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 3\narr[] = {1, 2, 4}", "output": "1 2 5", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 3\narr[] = {9,9,9}", "output": "1 0 0 0", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/22/B
Solve the following coding problem using the programming language python: Bob wants to put a new bargaining table in his office. To do so he measured the office room thoroughly and drew its plan: Bob's office room is a rectangular room n × m meters. Each square meter of the room is either occupied by some furniture, o...
```python (n, m) = map(int, input().split()) a = [] for i in range(n): a.append([]) for x in input(): if x == '0': a[i].append(0) else: a[i].append(1) ans = 0 for x1 in range(0, m): for x2 in range(x1, m): for y1 in range(0, n): for y2 in range(y1, n): z = 0 for k in range(y1, y2 + 1): z ...
vfc_134185
{ "difficulty": "medium", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/22/B", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 25\n1111111111111111011010110\n", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 5\n00001\n00000\n10100\n", "output": "12", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1259/D
Solve the following coding problem using the programming language python: Polycarp has $n$ different binary words. A word called binary if it contains only characters '0' and '1'. For example, these words are binary: "0001", "11", "0" and "0011100". Polycarp wants to offer his set of $n$ binary words to play a game "...
```python for _ in range(int(input())): n = int(input()) mass = [] zo = 0 oz = 0 zz = 0 oo = 0 ozs = [] zos = [] ozss = set() zoss = set() for j in range(n): k = input() mass.append(k) if k[0] == '0' and k[-1] == '1': zoss.add(k) zos.append(j + 1) zo += 1 elif k[0] == '1' and k[-1] == '0': ...
vfc_134192
{ "difficulty": "hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1259/D", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n4\n0001\n1000\n0011\n0111\n3\n010\n101\n0\n2\n00000\n00001\n4\n01\n001\n0001\n00001\n", "output": "1\n3 \n-1\n0\n\n2\n1 2 \n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/longest-consecutive-subsequence2449/1
Solve the following coding problem using the programming language python: Given an array of positive integers. Find the length of the longest sub-sequence such that elements in the subsequence are consecutive integers, the consecutive numbers can be in any order. Example 1: Input: N = 7 a[] = {2,6,1,9,4,5,3} Output:...
```python class Solution: def findLongestConseqSubseq(self, arr, N): num_set = set(arr) max_len = 0 for num in num_set: if num - 1 not in num_set: curr_num = num curr_len = 1 while curr_num + 1 in num_set: curr_num += 1 curr_len += 1 max_len = max(max_len, curr_len) return max_len...
vfc_134196
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/longest-consecutive-subsequence2449/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 7\na[] = {2,6,1,9,4,5,3}", "output": "6", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 7\na[] = {1,9,3,10,4,20,2}", "output": "4", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1046/G
Solve the following coding problem using the programming language python: Everybody seems to think that the Martians are green, but it turns out they are metallic pink and fat. Ajs has two bags of distinct nonnegative integers. The bags are disjoint, and the union of the sets of numbers in the bags is \{0,1,…,M-1\}, f...
```python import sys input = sys.stdin.readline def main(): (n, m) = map(int, input().split()) a = list(map(int, input().split())) + [0] * 500000 ans_S = 0 a[n] = a[0] + m s = [0] * 600600 for i in range(n): s[i] = a[i + 1] - a[i] s[n] = -1 for i in range(n): s[2 * n - i] = s[i] for i in range(2 * n + 1, ...
vfc_134209
{ "difficulty": "very_hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1046/G", "time_limit": "1.5 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "14 34\n1 2 4 7 10 12 13 18 19 21 24 27 29 30\n", "output": "2\n14 31\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "36 81\n4 5 7 8 13 14 16 17 22 23 25 26 31 32 34 35 40 41 43 44 49 50 52...
taco
verifiable_code
https://codeforces.com/problemset/problem/841/D
Solve the following coding problem using the programming language python: Leha plays a computer game, where is on each level is given a connected graph with n vertices and m edges. Graph can contain multiple edges, but can not contain self loops. Each vertex has an integer di, which can be equal to 0, 1 or - 1. To pa...
```python import os, io input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline import sys import heapq INF = 10 ** 9 def Dijkstra(graph, start, m): dist = [INF] * len(graph) parent = [INF] * len(graph) queue = [(0, start)] while queue: (path_len, v) = heapq.heappop(queue) if dist[v] == INF: dist[v] = ...
vfc_134213
{ "difficulty": "hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/841/D", "time_limit": "3.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10 10\n-1 -1 -1 -1 -1 -1 -1 -1 -1 -1\n6 7\n8 3\n6 4\n4 2\n9 2\n5 10\n9 8\n10 7\n5 1\n6 2\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 2\n1 0 1\n1 2\n2 3\n", "ou...
taco
verifiable_code
https://codeforces.com/problemset/problem/1174/C
Solve the following coding problem using the programming language python: You're given an integer $n$. For every integer $i$ from $2$ to $n$, assign a positive integer $a_i$ such that the following conditions hold: For any pair of integers $(i,j)$, if $i$ and $j$ are coprime, $a_i \neq a_j$. The maximal value of all...
```python import math n = int(input()) arr = [1, 2] + [0] * (n - 2) def isprime(x): y = int(math.sqrt(x)) + 1 for i in range(2, y): if x % i == 0: return i return x p = 3 for i in range(4, n + 1): x = isprime(i) if x == i: arr[i - 2] = p p += 1 else: arr[i - 2] = arr[x - 2] print(*arr[:n - 1]) ```
vfc_134217
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1174/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n", "output": "1 2 1 ", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1240/F
Solve the following coding problem using the programming language python: There are $n$ football teams in the world. The Main Football Organization (MFO) wants to host at most $m$ games. MFO wants the $i$-th game to be played between the teams $a_i$ and $b_i$ in one of the $k$ stadiums. Let $s_{ij}$ be the numbers...
```python import random import math def set_color(game, color): color_count[game[0]][game[2]] -= 1 color_count[game[1]][game[2]] -= 1 game[2] = color color_count[game[0]][game[2]] += 1 color_count[game[1]][game[2]] += 1 def fix(node): minimum = math.inf maximum = 0 for i in range(k): minimum = min(minimum, ...
vfc_134221
{ "difficulty": "very_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1240/F", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7 11 3\n4 7 8 10 10 9 3\n6 2\n6 1\n7 6\n4 3\n4 6\n3 1\n5 3\n7 5\n7 3\n4 2\n1 4\n", "output": "3\n1\n3\n2\n2\n2\n1\n2\n3\n1\n1\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Professor Pathfinder is a distinguished authority on the structure of hyperlinks in the World Wide Web. For establishing his hypotheses, he has been developing software agents, which automatically traverse hyperlinks and analyze the structure of...
```python def testcase_ends(): (n, m) = map(int, input().split()) if (n, m) == (0, 0): return 1 htmls = set((input() for i in range(n))) files = set('/') for html in htmls: sp = html.split('/') for i in range(2, len(sp)): files.add('/'.join(sp[:i]) + '/') files.add(html) def find(url): has_ts = url....
vfc_134226
{ "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": "5 6\n/home/ACM/index.html\n/ICPC/index.html\n/ICPC/general.html\n/ICPC/japanese/index.html\n/ICPC/secret/confidential/2005/index.html\n/home/ACM/\n/home/ICPC/../ACM/\n/ICPC/secret/\n/ICPC/secret/index.html\n/ICPC\n/ICPC/../ICPC/ind...
taco
verifiable_code
https://codeforces.com/problemset/problem/1451/D
Solve the following coding problem using the programming language python: Utkarsh is forced to play yet another one of Ashish's games. The game progresses turn by turn and as usual, Ashish moves first. Consider the 2D plane. There is a token which is initially at $(0,0)$. In one move a player must increase either the...
```python from math import floor, sqrt def readints(): return list(map(int, input().split(' '))) t = readints()[0] for _ in range(t): (d, k) = readints() z = floor(sqrt(d ** 2 / 2 / k ** 2)) if (k * z) ** 2 + k ** 2 * (z + 1) ** 2 <= d ** 2: print('Ashish') else: print('Utkarsh') ```
vfc_134231
{ "difficulty": "medium_hard", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1451/D", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n2 1\n5 2\n10 3\n25 4\n15441 33\n", "output": "Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n2 1\n5 2\n10 3\n25 4\n25479 33\n", "outp...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/count-the-triplets4615/1
Solve the following coding problem using the programming language python: Given an array of distinct integers. The task is to count all the triplets such that sum of two elements equals the third element. Example 1: Input: N = 4 arr[] = {1, 5, 3, 2} Output: 2 Explanation: There are 2 triplets: 1 + 2 = 3 and 3 +...
```python class Solution: def countTriplet(self, array, n): array.sort() n = len(array) count = 0 for i in range(n - 1, 1, -1): j = 0 k = i - 1 while j < k: if array[j] + array[k] == array[i]: count += 1 j += 1 k -= 1 elif array[j] + array[k] < array[i]: j += 1 else: ...
vfc_134235
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/count-the-triplets4615/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 4 \r\narr[] = {1, 5, 3, 2}", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 3\r\narr[] = {2, 3, 4}", "output": "0", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/CLSPWR
Solve the following coding problem using the programming language python: Read problem statements in [Russian], [Mandarin Chinese], [Bengali], and [Vietnamese] as well. An integer x is said to be a Perfect Power if there exists positive integers a and b (i.e a, and b should be ≥ 1) such that x = a^{b+1}. Given an in...
```python from math import floor, log, exp, log1p, expm1 primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59] for __ in range(int(input())): (n, arr) = (int(input()), []) for bp1 in primes: a = floor(expm1(log1p(n - 1) / bp1)) + 1 arr.append(pow(a, bp1)) arr.append(pow(a + 1, bp1)) arr.sor...
vfc_134236
{ "difficulty": "very_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CLSPWR", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7\n7\n10\n26\n242\n129\n394857629456789876\n353872815358409997", "output": "8\n9\n25\n243\n128\n394857628993920400\n353872815358410000", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/beautiful-sequence4203/1
Solve the following coding problem using the programming language python: A beautiful sequence is a strictly increasing sequence, in which the term A_{i} divides all A_{j}, where j>i. Given N find a beautiful sequence whose last term is N and the length of the sequence is the maximum possible. If there are multiple so...
```python import math class Solution: def FindSequenece(self, N): m = int(math.sqrt(N)) v = [] for i in range(2, m + 1): while N % i == 0: v.append(N) N //= i if N > 1: v.append(N) v.append(1) v = v[::-1] return v ```
vfc_134240
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/beautiful-sequence4203/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 10", "output": "1 5 10", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 3", "output": "1 3", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1114/B
Solve the following coding problem using the programming language python: An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more el...
```python (n, m, k) = list(map(int, input().split())) a = list(map(int, input().split())) indexed_a = zip(a, list(range(n))) sorted_indexed_a = list(reversed(sorted(indexed_a))) sorted_a = list(reversed(sorted(a))) partition = list(sorted([y for (x, y) in sorted_indexed_a[:m * k]])) print(sum(sorted_a[:m * k])) result ...
vfc_134241
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1114/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "9 2 3\n5 2 5 2 4 1 1 3 2\n", "output": "21\n3 5 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 1 4\n4 1 3 2 2 3\n", "output": "12\n1 3 5 ", "type": "stdin_stdout" }, ...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/sandwiched-vowels5158/1
Solve the following coding problem using the programming language python: For a given string S, comprising of only lowercase English alphabets, eliminate the vowels from the string that occur between two consonants(sandwiched between two immediately adjacent consonants). Print the updated string on a new line. Example...
```python def Sandwiched_Vowel(S): vowels = 'aeiou' updated_string = '' n = len(S) for i in range(n): if S[i] in vowels: if i > 0 and i < n - 1 and (S[i - 1] not in vowels) and (S[i + 1] not in vowels): continue updated_string += S[i] return updated_string ```
vfc_134258
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/sandwiched-vowels5158/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": "Sandwiched_Vowel", "input": "S = \"bab\"", "output": "bb", "type": "function_call" }, { "fn_name": "Sandwiched_Vowel", "input": "S = \"ceghij\"", "output": "cghj", "type": "function_call" } ] }
taco
verifiable_code
https://www.codechef.com/problems/FIXFIX
Solve the following coding problem using the programming language python: Given a positive integer n and an integer k such that 0 ≤ k ≤ n, find any permutation A of 1, 2 \dots n such that the number of indices for which A_{i}=i is exactly k. If there exists no such permutation, print -1. If there exist multiple such p...
```python for _ in range(int(input())): (n, k) = map(int, input().split()) if n - k == 1: print(-1) continue for i in range(1, k + 1): print(i, end=' ') if (n - k) % 2 == 1: for i in range(k + 2, n + 1): print(i, end=' ') print(k + 1) else: for i in range(n, k, -1): print(i, end=' ') print() `...
vfc_134259
{ "difficulty": "medium", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/FIXFIX", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2 1\n3 1\n4 2\n", "output": "-1\n1 3 2\n3 2 1 4\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/CHPTRS01/problems/WASHHAND
Solve the following coding problem using the programming language python: People in Karunanagar are infected with Coronavirus. To understand the spread of disease and help contain it as early as possible, Chef wants to analyze the situation in the town. Therefore, he does the following: - Chef represents the populatio...
```python T = int(input()) for i in range(T): (N, data, D, People) = (int(input()), list(map(int, list(input()))), int(input()), list(map(int, input().split()))) (data.insert(0, '|'), data.append('|')) infected = [] for i in range(1, N + 1): if data[i] == 1: infected.append(i) i = 0 while i < D: boundary =...
vfc_134263
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/CHPTRS01/problems/WASHHAND", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n9\n000010000\n3\n2 5 8\n5\n00001\n1\n5\n", "output": "6\n1\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/d54c71dc974b7db3a200eb63f34e3d1cba955d86/1
Solve the following coding problem using the programming language python: Given an array arr of size n, the task is to find the maximum triplet product in the array. Example 1: Input: n = 4 arr[] = {1, 2, 3, 5} Output: 30 Explanation: 5*3*2 gives 30. This is the maximum possible triplet product in the array. Example 2...
```python class Solution: def maxTripletProduct(self, arr, n): arr.sort() n = len(arr) product1 = arr[n - 1] * arr[n - 2] * arr[n - 3] product2 = arr[0] * arr[1] * arr[n - 1] return max(product1, product2) ```
vfc_134267
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/d54c71dc974b7db3a200eb63f34e3d1cba955d86/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "n = 4\r\narr[] = {1, 2, 3, 5}", "output": "30", "type": "stdin_stdout" }, { "fn_name": null, "input": "n = 7\r\narr[] = {-3, -5, 1, 0, 8, 3, -2}", "output": "120", "type": "stdin_stdout" ...
taco
verifiable_code
https://codeforces.com/problemset/problem/1231/B
Solve the following coding problem using the programming language python: Ania has a large integer S. Its decimal representation has length n and doesn't contain any leading zeroes. Ania is allowed to change at most k digits of S. She wants to do it in such a way that S still won't contain any leading zeroes and it'll...
```python (n, k) = map(int, input().split()) l = list(input()) if k == 0: print(*l, sep='') elif n == 1: print(0) else: if l[0] != '1': l[0] = '1' k -= 1 for i in range(1, n): if k > 0 and int(l[i]) > 0: if l[i] != '0': l[i] = '0' k -= 1 print(*l, sep='') ```
vfc_134272
{ "difficulty": "easy", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1231/B", "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3\n888\n", "output": "100\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 3\n185\n", "output": "100\n", "type": "stdin_stdout" }, { "fn_name": null, "in...