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
Solve the following coding problem using the programming language python: Bob is travelling from one city to another. In his way, he sees many other cities pass by. What he does instead of learning the full names of the cities, he learns just the first character of the cities. For example, if he passes by "bhopal", he...
```python t=eval(input('')) cnt=0 while int(t)>int(cnt): s=input('') l=[] for i in range(int(s)): l.append(str(input(''))[0]) if len(l)!=len(set(l)): print("NO") else: print("YES") t-=1 ```
vfc_135631
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "100\n4\nlrbbmqb\ncd\nr\nowkk\n7\nid\nqscdxrjmow\nrxsjybldbe\nsarcbyne\ndyggxxp\nlorel\nnmpa\n6\nfwkho\nkmcoqhnw\nkuewhsqmgb\nuqcljj\nvsw\ndkqtbxi\n10\nv\nrr\nlj\ntnsnfwzqfj\nafadr\nwsofsbcnuv\nhffbsaq\nwp\nc\ncehch\n2\nfrkmlnoz\nkp...
taco
verifiable_code
https://www.codechef.com/problems/HIGHSCORE
Solve the following coding problem using the programming language python: Chef is taking a tough examination. The question paper consists of N objective problems and each problem has 4 options A, B, C, and D, out of which, exactly one option is correct. Since Chef did not study for the exam, he does not know the answ...
```python t = int(input()) for i in range(t): n = int(input()) a = list(map(int, input().strip().split())) print(max(a)) ```
vfc_135639
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/HIGHSCORE", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5\n0 0 5 0\n10\n7 1 1 1\n", "output": "5\n7\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/divisibility-by-9990149/1
Solve the following coding problem using the programming language python: You are given a large number N in the form of a string, you have to check whether it is divisible by 999 without dividing or finding modulo of number by 999. Example 1- Input: N = 1998 Output: Divisible Example 2 - Input: N = 99999999 Output...
```python class Solution: def isDivisible999(self, N): n = int(N) return n % 999 == 0 ```
vfc_135647
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/divisibility-by-9990149/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 1998", "output": "Divisible", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/304/D
Solve the following coding problem using the programming language python: You are given a rectangle grid. That grid's size is n × m. Let's denote the coordinate system on the grid. So, each point on the grid will have coordinates — a pair of integers (x, y) (0 ≤ x ≤ n, 0 ≤ y ≤ m). Your task is to find a maximum sub-r...
```python def gcd(a, b): while a: (a, b) = (b % a, a) return b (n, m, x, y, a, b) = tuple(map(int, input().strip().split())) g = gcd(a, b) a //= g b //= g k = min(n // a, m // b) w = k * a h = k * b ans = [x - w + w // 2, y - h + h // 2, x + w // 2, y + h // 2] if ans[0] < 0: ans[2] -= ans[0] ans[0] = 0 if ans[1]...
vfc_135648
{ "difficulty": "medium_hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/304/D", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1000000000 1000000000 500000000 500000000 500000000 500000001\n", "output": "250000000 249999999 750000000 750000000\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/fake-profile3906/1
Solve the following coding problem using the programming language python: There is a hacker named "Vijay" who has developed a method to check whether an id at some social networking site is fake or real using its username. His method includes: if the number of distinct consonent characters in one's user name is odd, t...
```python class Solution: def solve(self, a): A = set(a) B = 'aeiou' counter = 0 for i in A: if i not in B: counter += 1 if counter % 2 == 0: return 'SHE!' else: return 'HE!' ```
vfc_135652
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/fake-profile3906/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "a = \"jpmztf\"", "output": "SHE!", "type": "stdin_stdout" }, { "fn_name": null, "input": "a = \"plkaitw\"", "output": "HE!", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Chandan is an extremely biased person, and he dislikes people who fail to solve all the problems in the interview he takes for hiring people. There are n people on a day who came to be interviewed by Chandan. Chandan rates every candidate from...
```python #!/usr/bin/python str = input() n = int(str) score = [] newArr=[] sum = 0 for i in range(0, n): str1 = input() score.append(int(str1)) for j in range(0, n): if (score[j] == 0): if j == 0: continue newArr.pop(-1) else: newArr.append(score[j]) for k in newArr: sum += k print(sum) ```
vfc_135661
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2311\n2\n10\n4\n2\n9\n2\n6\n1\n4\n3\n9\n6\n10\n2\n4\n3\n2\n7\n1\n8\n3\n0\n6\n4\n2\n6\n3\n9\n1\n10\n9\n4\n2\n5\n7\n8\n0\n9\n10\n2\n2\n10\n6\n3\n0\n7\n3\n4\n6\n10\n4\n7\n6\n7\n1\n3\n1\n3\n10\n10\n6\n5\n10\n0\n6\n8\n6\n9\n7\n8\n6\n2\n...
taco
verifiable_code
https://codeforces.com/problemset/problem/1686/B
Solve the following coding problem using the programming language python: For an array $[b_1, b_2, \ldots, b_m]$ define its number of inversions as the number of pairs $(i, j)$ of integers such that $1 \le i < j \le m$ and $b_i>b_j$. Let's call array $b$ odd if its number of inversions is odd. For example, array $[4,...
```python import sys input = sys.stdin.readline def solve(): n = int(input()) arr = list(map(int, input().split())) prev = 0 i = ans = 0 while i < n: if not prev: prev = arr[i] elif prev > arr[i]: ans += 1 prev = 0 else: prev = arr[i] i += 1 return ans for _ in range(int(input())): print(sol...
vfc_135665
{ "difficulty": "easy", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1686/B", "time_limit": "1 second" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n3\n1 2 3\n4\n4 3 2 1\n2\n1 2\n2\n2 1\n6\n4 5 6 1 2 3\n", "output": "0\n2\n0\n1\n1\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1717/A
Solve the following coding problem using the programming language python: Madoka is a very strange girl, and therefore she suddenly wondered how many pairs of integers $(a, b)$ exist, where $1 \leq a, b \leq n$, for which $\frac{\operatorname{lcm}(a, b)}{\operatorname{gcd}(a, b)} \leq 3$. In this problem, $\operatorn...
```python import sys n = int(sys.stdin.readline()) for i in range(n): b = int(sys.stdin.readline()) print(b + b // 2 * 2 + b // 3 * 2) ```
vfc_135670
{ "difficulty": "easy", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1717/A", "time_limit": "1 second" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n1\n2\n3\n4\n5\n100000000\n", "output": "1\n4\n7\n10\n11\n266666666\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/109/D
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 got an array consis...
```python def is_lucky(v): while v > 0: r = v % 10 if r != 4 and r != 7: return False v //= 10 return True n = int(input()) arr = list(map(int, input().split())) arr_with_pos = sorted([[a, i] for (i, a) in enumerate(arr)]) (pos, tpos) = (None, None) not_ordered = set() need = [i for (_, i) in arr_with_pos] b...
vfc_135674
{ "difficulty": "hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/109/D", "time_limit": "3.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n8 4 7 5 9 5 8 5 10 1000\n", "output": "10\n2 1\n1 2\n2 4\n4 3\n3 6\n6 4\n4 8\n8 5\n5 6\n6 1\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/651/D
Solve the following coding problem using the programming language python: Vasya's telephone contains n photos. Photo number 1 is currently opened on the phone. It is allowed to move left and right to the adjacent photo by swiping finger over the screen. If you swipe left from the first photo, you reach photo n. Simila...
```python import bisect def preview(n, a, b, t, S): t -= b + 1 if S[0] else 1 S[0] = False if t < 0: return 0 R = [] s = 0 for i in range(1, n): s += a + (b + 1 if S[i] else 1) if s > t: break R.append(s) else: return n L = [] s = 0 for i in reversed(range(1, n)): s += a + (b + 1 if S[i] else ...
vfc_135678
{ "difficulty": "hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/651/D", "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "100 20 100 10202\nwwwwhhwhhwhhwhhhhhwwwhhhwwwhwwhwhhwwhhwwwhwwhwwwhwhwhwwhhhwhwhhwhwwhhwhwhwwwhwwwwhwhwwwwhwhhhwhwhwww\n", "output": "100", "type": "stdin_stdout" }, { "fn_name": null, "input": "7 1 ...
taco
verifiable_code
Solve the following coding problem using the programming language python: Regional Students's are taught to add multi-digit numbers from right-to-left one digit at a time. Many find the "carry" operation - in which 1 is carried from one digit position to be added to the next - to be a significant challenge. Your job ...
```python x=eval(input()) for j in range(x): a,b=input().split() a=[int(i) for i in a] b=[int(i) for i in b] while len(a)<len(b): a=[0]+a while len(b)<len(a): b=[0]+b co=0 c=0 for i in range(len(a)-1,-1,-1): if a[i]+b[i]+c>=10: c=1 co+=1 else: c=0 if co==0: print("No carry operation") elif ...
vfc_135682
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n5555555555 5555555555", "output": "10 carry operations\nNo carry operation\n1 carry operation", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n5555555555 5555555555\n1111111111 11111111...
taco
verifiable_code
Solve the following coding problem using the programming language python: A palindrome is a string that is the same whether it is read from left to right or from right to left. Chota Bheem likes palindromes a lot. As a birthday gift he received two strings A and B. Now he is curious if there is a way to insert string ...
```python test= int(input()) for no in range(0,test): meas= input() mem= input() palin_count = 0 for x in range(0,len(meas)+1): a= meas[:x]+mem+meas[x:] #print a if a == a[::-1]: palin_count= palin_count+1 print(palin_count) ```
vfc_135686
{ "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\naba\nb\naa\na\naca\nbb\nabba\nabba\nahfebbefhbbefha\nhfebb\nakimccmikacmika\nakimc\nioajggjajggjaoi\njggja\ndcbaeeddbbdedddbbdeddedbbddeeabcd\nddedbbd\ndebcdbbbcbecaeeeeeeeacebcbbbdcbed\neeeeeee\naaddcbbaeaedbbdeaedbbdeaeabbcdd...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/right-triangle/1
Solve the following coding problem using the programming language python: Geek is very fond of patterns. Once, his teacher gave him a pattern to solve. He gave Geek an integer n and asked him to build a pattern. Help Geek to build a star pattern. Example 1: Input: 5 Output: * * * * * * * * * * * * * * * Your T...
```python class Solution: def printTriangle(self, N): for i in range(1, N + 1): print('* ' * i) ```
vfc_135690
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/right-triangle/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5", "output": "", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/FALSNUM
Solve the following coding problem using the programming language python: Read problem statements in [Mandarin], [Bengali], [Russian], and [Vietnamese] as well. One day, Chef's friend gave him a wrong number $W$ containing $N + 1$ digits and said that the actual number $A$ is the largest possible number that can be o...
```python for _ in range(int(input())): A = int(input()) k = list(str(A)) if k[0] == '1': k.insert(1, '0') else: k.insert(0, '1') print(int(''.join(k))) ```
vfc_135691
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/FALSNUM", "time_limit": "0.5 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n9876543211\n12345678999", "output": "19876543211\n102345678999", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/number-of-days4543/1
Solve the following coding problem using the programming language python: Find the number of days required to reach the top of the staircase of Q stairs if one moves R stairs upwards during daytime and S stairs downwards during night. Example 1: Input: R = 5, S = 1, Q = 6 Output: 2 Explanation: After end of whole fi...
```python import math class Solution: def noOfDays(self, R, S, Q): return math.ceil((Q - S) / (R - S)) ```
vfc_135696
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/number-of-days4543/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "R = 5, S = 1, Q = 6", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "R = 2, S = 1, Q = 3", "output": "2", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1715/B
Solve the following coding problem using the programming language python: Stanley defines the beauty of an array $a$ of length $n$, which contains non-negative integers, as follows: $$\sum\limits_{i = 1}^{n} \left \lfloor \frac{a_{i}}{k} \right \rfloor,$$ which means that we divide each element by $k$, round it down, ...
```python for _ in range(int(input())): (n, k, b, s) = map(int, input().split()) nums = 0 if k * b <= s <= k * b + n * (k - 1): while s - k >= b * k: s -= k - 1 nums += 1 print('0 ' * (n - nums - 1) + f'{k - 1} ' * nums + str(s)) else: print(-1) ```
vfc_135697
{ "difficulty": "easy", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1715/B", "time_limit": "1 second" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8\n1 6 3 100\n3 6 3 12\n3 6 3 19\n5 4 7 38\n5 4 7 80\n99978 1000000000 100000000 1000000000000000000\n1 1 0 0\n4 1000000000 1000000000 1000000000000000000\n", "output": "-1\n-1\n0 0 19\n0 3 3 3 29\n-1\n-1\n0\n0 0 0 1000000000...
taco
verifiable_code
https://codeforces.com/problemset/problem/104/A
Solve the following coding problem using the programming language python: One rainy gloomy evening when all modules hid in the nearby cafes to drink hot energetic cocktails, the Hexadecimal virus decided to fly over the Mainframe to look for a Great Idea. And she has found one! Why not make her own Codeforces, with b...
```python n = int(input()) if n < 11 or n > 21: print(0) elif n == 20: print(15) else: print(4) ```
vfc_135701
{ "difficulty": "easy", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/104/A", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "15\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "13\n", ...
taco
verifiable_code
https://codeforces.com/problemset/problem/379/C
Solve the following coding problem using the programming language python: One very well-known internet resource site (let's call it X) has come up with a New Year adventure. Specifically, they decided to give ratings to all visitors. There are n users on the site, for each user we know the rating value he wants to ge...
```python import os import sys from io import BytesIO, IOBase import heapq as h from bisect import bisect_left, bisect_right import time from types import GeneratorType BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): import os self.os = os self._fd = file.fileno() self.buffer = B...
vfc_135709
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/379/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n5 1 1\n", "output": "5 1 2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n1000000000\n", "output": "1000000000\n", "type": "stdin_stdout" }, { "fn_name": n...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/count-of-smaller-elements5947/1
Solve the following coding problem using the programming language python: Given an sorted array A of size N. Find number of elements which are less than or equal to given element X. Example 1: Input: N = 6 A[] = {1, 2, 4, 5, 8, 10} X = 9 Output: 5 Example 2: Input: N = 7 A[] = {1, 2, 2, 2, 5, 7, 9} X = 2 Output: 4...
```python def countOfElements(a, n, x): low = 0 high = n - 1 position = -1 while low <= high: mid = low + (high - low) // 2 if a[mid] <= x: position = mid low = mid + 1 else: high = mid - 1 return position + 1 ```
vfc_135713
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/count-of-smaller-elements5947/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": "countOfElements", "input": "N = 6\r\nA[] = {1, 2, 4, 5, 8, 10}\r\nX = 9", "output": "5", "type": "function_call" }, { "fn_name": "countOfElements", "input": "N = 7\r\nA[] = {1, 2, 2, 2, 5, 7, 9}\r\nX = 2", "o...
taco
verifiable_code
Solve the following coding problem using the programming language python: Problem Statement Nathan O. Davis is a student at the department of integrated systems. Today's agenda in the class is audio signal processing. Nathan was given a lot of homework out. One of the homework was to write a program to process an au...
```python INF = float('inf') def judge(src): x_max = INF x_min = -INF for (i, (s1, s2)) in enumerate(zip(src, src[1:])): if s1 == s2: return 'none' if i % 2: (s1, s2) = (s2, s1) if s1 != 'x' and s2 != 'x': if s1 < s2: return 'none' else: continue if s1 == 'x': if x_max <= s2: retu...
vfc_135714
{ "difficulty": "unknown_difficulty", "memory_limit": "536.870912 megabytes", "memory_limit_bytes": null, "problem_url": null, "time_limit": "8.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n0 x 2 4 x\n2\nx x\n2\n1 2\n2\n2 1\n2\n1000000000 x\n4\nx 2 1 x\n0", "output": "3\nnone\nambiguous\nnone\nambiguous\nnone\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n1 x 2 0 x\n2\...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/find-unique-element2632/1
Solve the following coding problem using the programming language python: Given an array of size n which contains all elements occurring in multiples of K, except one element which doesn't occur in multiple of K. Find that unique element. Example 1: Input : n = 7, k = 3 arr[] = {6, 2, 5, 2, 2, 6, 6} Output : 5 Exp...
```python class Solution: def findUnique(self, a, n, k): d = {} for i in a: if i in d: d[i] += 1 else: d[i] = 1 for i in d: if d[i] % k != 0: return i ```
vfc_135718
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/find-unique-element2632/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "n = 7, k = 3\narr[] = {6, 2, 5, 2, 2, 6, 6}", "output": "5", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/430/E
Solve the following coding problem using the programming language python: Iahub and Iahubina went to a picnic in a forest full of trees. Less than 5 minutes passed before Iahub remembered of trees from programming. Moreover, he invented a new problem and Iahubina has to solve it, otherwise Iahub won't give her the foo...
```python def DFS(x): for i in range(x): if Seen[i][x]: continue if Rem[i] >= C[x]: if Rem[i] == C[x] and len(Children[i]) == 0: continue Rem[i] -= C[x] Parent[x] = i Children[i].append(x) return True for i in range(x): if Seen[i][x]: continue Y = [] for j in range(len(Children[i]))...
vfc_135723
{ "difficulty": "hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/430/E", "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "18\n6 1 1 3 1 1 1 1 1 1 4 1 8 1 1 18 1 5\n", "output": "YES\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "19\n9 7 1 8 1 1 1 13 1 1 3 3 19 1 1 1 1 1 1\n", "output": "NO\n", "t...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/search-insert-position-of-k-in-a-sorted-array/1
Solve the following coding problem using the programming language python: Given a sorted array Arr[](0-index based) consisting of N distinct integers and an integer k, the task is to find the index of k, if its present in the array Arr[]. Otherwise, find the index where k must be inserted to keep the array sorted. Exa...
```python from bisect import bisect_left class Solution: def searchInsertK(self, Arr, N, k): return bisect_left(Arr, k) ```
vfc_135728
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/search-insert-position-of-k-in-a-sorted-array/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 4\r\nArr = {1, 3, 5, 6}\r\nk = 5", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 4\r\nArr = {1, 3, 5, 6}\r\nk = 2", "output": "1", "type": "stdin_stdout" ...
taco
verifiable_code
Solve the following coding problem using the programming language python: Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29. Input The input is a sequence of datasets. The end...
```python days = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] ans = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] while True: idx = 3 (m, d) = map(int, input().split()) if m == 0: break print(ans[(idx + sum(days[:m - 1]) + d - 1) % 7]) ```
vfc_135729
{ "difficulty": "unknown_difficulty", "memory_limit": "134.217728 megabytes", "memory_limit_bytes": null, "problem_url": null, "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 1\n2 26\n0 0", "output": "Thursday\nThursday\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 1\n2 26\n0 0", "output": "Sunday\nThursday\n", "type": "stdin_stdout" }, ...
taco
verifiable_code
https://codeforces.com/problemset/problem/121/A
Solve the following coding problem using the programming language python: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Let next(x) be the minimu...
```python n = input().split() l = int(n[0]) r = int(n[1]) a = [] x = [] a.append([]) a[0].append('4') a[0].append('7') for i in range(1, 10): a.append([]) for j in a[i - 1]: a[i].append('4' + j) a[i].append('7' + j) for j in a[i]: x.append(int(j)) x.append(4) x.append(7) x.sort() sum = [16] for i in range(1, l...
vfc_135737
{ "difficulty": "easy", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/121/A", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "47 47\n", "output": "47", "type": "stdin_stdout" }, { "fn_name": null, "input": "747 748\n", "output": "1521", "type": "stdin_stdout" }, { "fn_name": null, "input": "9...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/max-sum-subarray-by-removing-at-most-one-element/1
Solve the following coding problem using the programming language python: You are given array A of size n. You need to find the maximum-sum sub-array with the condition that you are allowed to skip at most one element. Example 1: Input: n = 5 A[] = {1,2,3,-4,5} Output: 11 Explanation: We can get maximum sum subarray b...
```python class Solution: def maxSumSubarray(self, arr, n): left = [0] * n right = [0] * n right[-1] = arr[-1] left[0] = arr[0] ans = left[0] for i in range(1, n): left[i] = max(left[i - 1] + arr[i], arr[i]) ans = max(ans, left[i]) right[n - 1 - i] = max(right[n - i] + arr[n - 1 - i], arr[n - 1 -...
vfc_135741
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/max-sum-subarray-by-removing-at-most-one-element/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "n = 5\nA[] = {1,2,3,-4,5}", "output": "11", "type": "stdin_stdout" }, { "fn_name": null, "input": "n = 8\nA[] = {-2,-3,4,-1,-2,1,5,-3}", "output": "9", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: A: Alphabet block Wakana Nakawa loves palindromes. Because my name is also a palindrome. Wakana got a set with some alphabet blocks. An alphabet block is a block in which one lowercase alphabet is written for each block, and you can create you...
```python import collections print(sum([v % 2 for v in collections.Counter(input()).values()]) // 2) ```
vfc_135743
{ "difficulty": "unknown_difficulty", "memory_limit": "267.38688 megabytes", "memory_limit_bytes": null, "problem_url": null, "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "gcpc", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "bgnc", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "gcoc", ...
taco
verifiable_code
https://codeforces.com/problemset/problem/1332/C
Solve the following coding problem using the programming language python: Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "...
```python def main(): return '\n'.join((nCharactersToReplaceMin() for _ in range(int(input())))) def nCharactersToReplaceMin(): def nDesiredCharacters(limit1, limit2): def countOfMostRepeatedCharacter(i1, i2): lettersCount = {} for (j1, j2) in zip(range(i1, len(word), period), range(i2, len(word), period))...
vfc_135748
{ "difficulty": "medium", "memory_limit": "512 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1332/C", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n6 2\nabaaba\n6 3\nabaaba\n36 9\nhippopotomonstrosesquippedaliophobia\n21 7\nwudixiaoxingxingheclp\n", "output": "2\n0\n23\n16\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n6 2\naba...
taco
verifiable_code
https://www.codechef.com/problems/KTTABLE
Solve the following coding problem using the programming language python: Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. There are N students living in the dormitory of Berland State University. Each of them sometimes wants to use the kitchen, so the head of the dormitory came up with ...
```python for x in range(int(input())): studentsCount = int(input()) successfulStudentsCount = 0 allocatedTimes = [int(y) for y in input().split(' ')] requiredTimes = [int(z) for z in input().split(' ')] for student in range(studentsCount): if student == 0: if requiredTimes[student] <= allocatedTimes[student]...
vfc_135752
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/KTTABLE", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3\n1 10 15\n1 10 3\n3\n10 20 30\n15 5 20", "output": "2\n1", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/flying-jet4644/1
Solve the following coding problem using the programming language python: The jet's speed is changed after every mile covered on it's runway. It follows a specific pattern for the speed. Starting from 1 it goes like 1, 7, 16, 21, 81, 63, 256 . . . and so on. Given N find its speed after Nth mile. Example 1: Input :...
```python class Solution: def Nth_mileSpeed(self, n): if n % 2 != 0: return (n - n // 2) ** 4 else: return 7 * 3 ** (n // 2 - 1) ```
vfc_135756
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/flying-jet4644/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 3", "output": "16", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 5", "output": "81", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/ASP
Solve the following coding problem using the programming language python: Read problems statements in Mandarin Chinese and Russian as well. Given a sequence of n distinct numbers a[1..n], we want to sort them in an ascending order. An interesting property of some sequences is that all numbers are almost at their co...
```python for _ in range(int(input())): n = int(input()) arr = list(map(int, input().split())) fl = True for i in range(n - 2): if arr[i] > arr[i + 2]: fl = False break if fl: print('YES') else: print('NO') ```
vfc_135758
{ "difficulty": "medium_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/ASP", "time_limit": "0.2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3\n1 2 3\n5\n2 4 1 3 5", "output": "YES\nNO", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1141/B
Solve the following coding problem using the programming language python: Each day in Berland consists of $n$ hours. Polycarp likes time management. That's why he has a fixed schedule for each day — it is a sequence $a_1, a_2, \dots, a_n$ (each $a_i$ is either $0$ or $1$), where $a_i=0$ if Polycarp works during the $i...
```python n = int(input()) a = list(map(int, input().split())) a += a i = 0 maxx = 0 while i < 2 * n: cnt = 0 if a[i] == 0: i += 1 continue while i < 2 * n and a[i] == 1: cnt += 1 i += 1 maxx = max(cnt, maxx) print(maxx) ```
vfc_135766
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1141/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 0 1 0 1\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n0 1 0 1 1 0\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, ...
taco
verifiable_code
https://codeforces.com/problemset/problem/1746/C
Solve the following coding problem using the programming language python: You are given a permutation $a$ of size $n$ and you should perform $n$ operations on it. In the $i$-th operation, you can choose a non-empty suffix of $a$ and increase all of its elements by $i$. How can we perform the operations to minimize the...
```python import sys input = sys.stdin.readline print = sys.stdout.write for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) inx = [0] * (n + 1) for i in range(n): inx[a[i]] = i + 1 print(' '.join((str(inx[n - i]) for i in range(n)))) print('\n') ```
vfc_135770
{ "difficulty": "easy", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1746/C", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n4\n1 2 3 4\n5\n1 3 2 4 5\n3\n2 3 1\n1\n1\n", "output": "4 3 2 1 \n5 4 2 3 1 \n2 1 3 \n1 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n8\n7 6 5 4 3 2 8 1\n", "output": "7 1 2...
taco
verifiable_code
https://www.codechef.com/problems/DISTOPPSUMS
Solve the following coding problem using the programming language python: Given an even integer N, output a *permutation* P of length N, such that: The value of P_{i} + P_{N+1-i} is distinct for all 1 ≤ i ≤ \frac{N}{2}. It is guaranteed that a possible solution always exists. If multiple such permutations exist, prin...
```python for _ in range(int(input())): n = int(input()) a = [] for i in range(n // 2, 0, -1): a.append(i) for j in range(n // 2 + 1, n + 1): a.append(j) print(*a) ```
vfc_135774
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/DISTOPPSUMS", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2\n6\n4\n", "output": "2 1\n1 3 2 4 5 6\n2 1 3 4\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: A prime number is an integer that is greater than 1 and can only be divided by itself or 1. For example, 2 is a prime number because it is divisible only by 2 and 1, but 12 is not a prime number because it is divisible by 2, 3, 4, 6 in addition ...
```python from math import sqrt, ceil N = 53000 temp = [True] * (N + 1) temp[0] = temp[1] = False for i in range(2, ceil(sqrt(N + 1))): if temp[i]: temp[i + i::i] = [False] * len(temp[i + i::i]) while True: try: n = int(input()) print(n - 1 - temp[n - 1:0:-1].index(True), n + 1 + temp[n + 1:].index(True)) exce...
vfc_135778
{ "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": "19\n5214", "output": "17 23\n5209 5227\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "19\n3257", "output": "17 23\n3253 3259\n", "type": "stdin_stdout" }, { "fn_...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/6cb0782855c0f11445b8d70e220f888e6ea8e22a/1
Solve the following coding problem using the programming language python: You are given the head of a linked list. You have to replace all the values of the nodes with the nearest prime number. If more than one prime number exists at an equal distance, choose the smallest one. Example 1: Input: 2 → 6 → 10 Output: 2 → ...
```python from typing import Optional import math class Solution: def primeList(self, head: Optional['Node']) -> Optional['Node']: def newprime(n): i = n j = n while not (isprime(i) or isprime(j)): i -= 1 j += 1 if isprime(i): return i return j def isprime(n): if n <= 1: retur...
vfc_135783
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/6cb0782855c0f11445b8d70e220f888e6ea8e22a/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 → 6 → 10", "output": "2 → 5 → 11", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 → 15 → 20", "output": "2 → 13 → 19", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Recent improvements in information and communication technology have made it possible to provide municipal service to a wider area more quickly and with less costs. Stimulated by this, and probably for saving their not sufficient funds, mayors o...
```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_135784
{ "difficulty": "unknown_difficulty", "memory_limit": "134.217728 megabytes", "memory_limit_bytes": null, "problem_url": null, "time_limit": "8.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\nFUKUOKA\nOKAYAMA\nYAMAGUCHI\n3\nFUKUOKA\nFUKUYAMA\nOKAYAMA\n2\nABCDE\nEDCBA\n4\nGA\nDEFG\nCDDE\nABCD\n2\nABCDE\nC\n14\nAAAAA\nBBBBB\nCCCCC\nDDDDD\nEEEED\nFFFFF\nGGGGG\nHHHHH\nIIIII\nJJJJJ\nKKKKK\nLLLLL\nMMMMM\nNNNNN\n0", "...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/anagram-1587115620/1
Solve the following coding problem using the programming language python: Given two strings a and b consisting of lowercase characters. The task is to check whether two given strings are an anagram of each other or not. An anagram of a string is another string that contains the same characters, only the order of chara...
```python class Solution: def isAnagram(self, a, b): return sorted(a) == sorted(b) ```
vfc_135789
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/anagram-1587115620/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "a = geeksforgeeks, b = forgeeksgeeks", "output": "YES", "type": "stdin_stdout" }, { "fn_name": null, "input": "a = allergy, b = allergic", "output": "NO", "type": "stdin_stdout" } ]...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/find-minimum-adjustment-cost-of-an-array4628/1
Solve the following coding problem using the programming language python: Given an array arr[] of positive integers of size N and an integer target, replace each element in the array such that the difference between adjacent elements in the array is less than or equal to a given target. We need to minimize the adjustm...
```python class Solution: def minAdjustmentCost(self, A, n, target): M = max(A) dp = [[0 for i in range(M + 1)] for i in range(n)] for j in range(M + 1): dp[0][j] = abs(j - A[0]) for i in range(1, n): for j in range(M + 1): dp[i][j] = 100000000 for k in range(max(j - target, 0), min(M, j + targe...
vfc_135790
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/find-minimum-adjustment-cost-of-an-array4628/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 4, target = 1\r\narr[] = { 1, 3, 0, 3 }", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 4, target = 1\r\narr[] = {2, 3, 2, 3}", "output": "0", "type": "std...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/count-number-of-equal-pairs-in-a-string0520/1
Solve the following coding problem using the programming language python: Given a string, find the number of pairs of characters that are same. Pairs (s[i], s[j]), (s[j], s[i]), (s[i], s[i]), (s[j], s[j]) should be considered different. Example 1: Input: S = "air" Output: 3 Explanation: 3 pairs that are equal: (S[0], ...
```python class Solution: def equalPairs(self, s): result = 0 d = {} for i in s: d[i] = d.get(i, 0) + 1 for i in d.values(): result += i * i return result ```
vfc_135796
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/count-number-of-equal-pairs-in-a-string0520/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "S = \"air\"", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "S = \"aa\"", "output": "4", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/numbers-with-one-absolute-difference2416/1
Solve the following coding problem using the programming language python: Given a number N. The task is to return all the numbers less than or equal to N in increasing order, with the fact that absolute difference between any adjacent digits of number should be 1. Example 1: Input: N = 20 Output: 10 12 Explanation: ...
```python class Solution: def absDifOne(self, X): l = [] for i in range(1, 10): def numbers(k): if k > X: return if k > 9: l.append(k) d = k % 10 if d != 0: numbers(k * 10 + d - 1) if d != 9: numbers(k * 10 + d + 1) numbers(i) l.sort() return l ```
vfc_135798
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/numbers-with-one-absolute-difference2416/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 20", "output": "10 12", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 9", "output": "-1", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/CHEALG
Solve the following coding problem using the programming language python: Read problem statements in [Hindi],[Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. One day, Saeed was teaching a string compression algorithm. This algorithm finds all maximal substrings which contains only one character rep...
```python t = int(input()) for i in range(t): s = input() final = '' prev = s[0] c = 1 for i in range(1, len(s)): if s[i] == prev: c += 1 else: final += prev + str(c) prev = s[i] c = 1 final += prev + str(c) if len(final) < len(s): print('YES') else: print('NO') ```
vfc_135799
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CHEALG", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\nbbbbbbbbbbaa\nc\naaaaaaaaaabcdefgh", "output": "YES\nNO\nNO", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/CTHREE
Solve the following coding problem using the programming language python: Read problems statements in Mandarin chinese, Russian and Vietnamese as well. Today, Chef was trying to solve a problem he found pretty hard: Given an integer N and a triple of integers (a, b, c), compute the number of triples of positive inte...
```python def divisor(num): a = () div = list(a) i = 1 while i * i < num: if num % i == 0: div.append(i) div.append(num // i) i += 1 if i * i == num: div.append(i) return div test = int(input()) while test: (n, a, b, c) = map(int, input().split()) d = divisor(n) ct = 0 for i in d: if i <= a: ...
vfc_135809
{ "difficulty": "medium_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CTHREE", "time_limit": "0.5 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n100 8 23 11\n497296800 1000000 1000000 1000000\n1 1 2 3", "output": "10\n97800\n1", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.hackerrank.com/challenges/morgan-and-a-string/problem
Solve the following coding problem using the programming language python: Jack and Daniel are friends. Both of them like letters, especially uppercase ones. They are cutting uppercase letters from newspapers, and each one of them has his collection of letters stored in a stack. One beautiful day, Morgan visited Ja...
```python import io def pick_smaller_char(s1, s2, idx1, idx2, len1, len2, i1, i2): if len1 <= idx1[0]: idx2[0] += 1 return s2[idx2[0] - 1] if len2 <= idx2[0]: idx1[0] += 1 return s1[idx1[0] - 1] if s1[idx1[0]] > s2[idx2[0]]: idx2[0] += 1 return s2[idx2[0] - 1] elif s1[idx1[0]] < s2[idx2[0]]: idx1[0] ...
vfc_135814
{ "difficulty": "hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.hackerrank.com/challenges/morgan-and-a-string/problem", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\nJACK\nDANIEL\nABACABA\nABACABA\n", "output": "DAJACKNIEL\nAABABACABACABA\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/COSQ2020/problems/PRGOTHAM
Solve the following coding problem using the programming language python: Gotham City is again under attack. This time Joker has given an open challenge to solve the following problem in order to save Gotham. Help Batman in protecting Gotham by solving the problem. You are given two strings A and B composed of lowerca...
```python try: (a, b, da) = (list(input()), input(), list(map(int, input().split()))) print(len(a) - len(b)) except: pass ```
vfc_135818
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/COSQ2020/problems/PRGOTHAM", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "#1:\nxxyxxy\nxyy\n1 5 4 6 3 2\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "jphokenixr\njoker\n2 9 3 7 8 1 6 5 4 10\n", "output": "5\n", "type": "stdin_stdou...
taco
verifiable_code
Solve the following coding problem using the programming language python: One day alice and bob were playing with their old toys , they had moved all the rakes and drawers to in the pursuit of their childhood toys. Finally they found bunch of cubes ,with letters and digits written on it ,which they recalled they use...
```python a,b=list(map(str,input().split())) fnd=[] f=0 for i in range(int(b)): l=list(map(str,input().split())) for i in range(len(a)): if i not in fnd: if a[i] in l: fnd.append(i) break if len(fnd)==len(a): f=1 break if(f): print('YES') else: print('NO') ```
vfc_135822
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "nana 12\nb a 7 8 9 1\nn 1 7 7 7 6\na 9 6 3 7 8\nk 8 2 4 7 9\na 7 8 9 1 3\ns 7 1 1 2 7\nd a 7 8 9 1\nn 1 7 7 7 6\na 9 6 3 7 8\nn 8 2 4 7 9\na 7 8 9 1 3\ns 7 1 1 2 7", "output": "YES", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.hackerrank.com/challenges/unfriendly-numbers/problem
Solve the following coding problem using the programming language python: Given $\mbox{1}$ friendly number and $n$ unfriendly numbers, determine how many numbers are divisors of the friendly number but not the unfriendly numbers. Input Format The first line contains $2$ space-separated integers, $n$ (the number of u...
```python from fractions import gcd (nU, F) = [int(i) for i in input().strip().split()] Us = [int(i) for i in input().strip().split()] divs = [] for i in range(1, int(F ** 0.5)): if F % i == 0: divs.append(i) divs.append(F // i) if int(F ** 0.5) == F ** 0.5: divs.append(int(F ** 0.5)) ndivs = {} for i in Us: ndi...
vfc_135826
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.hackerrank.com/challenges/unfriendly-numbers/problem", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8 16\n2 5 7 4 3 8 3 18\n", "output": "1\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1579/D
Solve the following coding problem using the programming language python: An important meeting is to be held and there are exactly $n$ people invited. At any moment, any two people can step back and talk in private. The same two people can talk several (as many as they want) times per meeting. Each person has limited...
```python import math import os import sys from io import BytesIO, IOBase from types import GeneratorType from collections import defaultdict BUFSIZE = 8192 from bisect import bisect_left from bisect import bisect_right class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.b...
vfc_135836
{ "difficulty": "medium", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1579/D", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8\n2\n2 3\n3\n1 2 3\n4\n1 2 3 4\n3\n0 0 2\n2\n6 2\n3\n0 0 2\n5\n8 2 0 1 1\n5\n0 1 0 0 6\n", "output": "2\n2 1\n2 1\n3\n3 2\n3 2\n3 1\n5\n4 3\n4 3\n4 2\n4 3\n2 1\n0\n2\n1 2\n1 2\n0\n4\n1 2\n1 5\n1 4\n1 2\n1\n5 2\n", "typ...
taco
verifiable_code
https://codeforces.com/problemset/problem/460/B
Solve the following coding problem using the programming language python: Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some prede...
```python def s(x): res = 0 while x > 0: res += x % 10 x //= 10 return res (a, b, c) = map(int, input().split()) ans = [] for i in range(100): x = b * i ** a + c if x < 0: continue if s(x) == i and 0 < x < 10 ** 9: ans.append(x) ans.sort() print(len(ans)) if len(ans) != 0: print(*ans) ```
vfc_135841
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/460/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2 8\n", "output": "3\n10 2008 13726 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 2 -18\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, ...
taco
verifiable_code
Solve the following coding problem using the programming language python: I and my flatmate ,Sayan, went to see the magnificient fountains in the Jubilee park on 3rd March.It was the eve of the 184rd Bithday of the late Mr. J.N.Tata and the fountains were set to blow at regular intervals. I sat down praising the sceni...
```python def gcd(a,b): if(a<b): return gcd(b,a) if(a%b == 0): return b else: return gcd(b,a%b) def lcm(a,b): return a*b/(gcd(a,b)) test = eval(input()) for i in range(test): n = eval(input()) arr = list(map(int,input().split())) lcm_result= arr[0] for i in range(1,n): lcm_result = lcm(lcm_result,ar...
vfc_135845
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n547\n8525 5819 4013 8968 8274 5988 4769 987 5282 5171 5482 6883 4247 395 1531 378 1414 9511 3866 9344 5324 1619 1707 2038 890 5044 6484 5713 5475 3714 1301 5463 8029 4275 4620 6553 1698 7368 3270 5430 4521 3284 9707 5053 4188 59...
taco
verifiable_code
https://www.hackerrank.com/challenges/primsmstsub/problem
Solve the following coding problem using the programming language python: Given a graph which consists of several edges connecting its nodes, find a subgraph of the given graph with the following properties: The subgraph contains all the nodes present in the original graph. The subgraph is of minimum overall weig...
```python from collections import defaultdict import heapq def prim(S, N, G): E = defaultdict(int) D = {} T = [0 for _ in range(N + 1)] H = [(0, S)] for n in range(1, N + 1): D[n] = float('inf') D[S] = 0 while H: t = heapq.heappop(H) for h in G[t[1]]: if E[h[1]] == 0 and D[h[1]] > h[0]: D[h[1]] = h...
vfc_135854
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.hackerrank.com/challenges/primsmstsub/problem", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 6\n1 2 3\n1 3 4\n4 2 6\n5 2 2\n2 3 5\n3 5 7\n1\n", "output": "15\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Alice is a geeky girl. She has a lot of codes to execute but she always choose a lucky time to execute a code. Time is shown in 24 hour format as hh:mm:ss Time is said to be lucky if all the 6 characters (except ':') are different. Given the t...
```python #lucky time 2 def time_split(l2): d1={} hh=int(l2[0]) mm=int(l2[1]) ss=int(l2[2]) s=set([1,2,3,4,5,6,7,8,9,0]) d1['h1']=hh/10 d1['h2']=hh%10 d1['m1']=mm/10 d1['m2']=mm%10 d1['s1']=ss/10 d1['s2']=ss%10 return d1 def clocktick(dict1): ss = dict1['s1']*10 + dict1['s2'] mm = dict1['m1']*10...
vfc_135858
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "675\n20:48:44\n11:54:44\n11:09:08\n12:01:47\n19:12:34\n08:17:22\n05:41:14\n21:47:55\n19:34:43\n11:45:28\n20:31:40\n16:56:50\n00:34:20\n04:40:03\n03:27:46\n15:36:05\n22:42:23\n14:15:19\n18:51:11\n21:00:46\n04:04:37\n18:51:41\n13:35:...
taco
verifiable_code
https://codeforces.com/problemset/problem/1691/C
Solve the following coding problem using the programming language python: You are given a binary string $s$ of length $n$. Let's define $d_i$ as the number whose decimal representation is $s_i s_{i+1}$ (possibly, with a leading zero). We define $f(s)$ to be the sum of all the valid $d_i$. In other words, $f(s) = \sum...
```python from sys import stdin def input(): return stdin.readline().strip() def read_int(): return int(input()) def read_ints(): return map(int, input().split()) t = read_int() for case_num in range(t): (n, k) = read_ints() s = input() m = s.count('1') if m == 0: print(0) elif m == n: print(11 * (n - 1)...
vfc_135868
{ "difficulty": "medium", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1691/C", "time_limit": "1 second" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n4 0\n1010\n7 1\n0010100\n5 2\n00110\n", "output": "21\n22\n12\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n2 1000000000\n01\n", "output": "1\n", "type": "stdin_stdout"...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/top-k-frequent-elements-in-array/1
Solve the following coding problem using the programming language python: Given a non-empty array of integers, find the top k elements which have the highest frequency in the array. If two numbers have the same frequency then the larger number should be given preference. Note: Print the elements according to the freq...
```python class Solution: def topK(self, nums, k): d = {} (max, min) = (1, 1) for i in nums: if i in d: d[i] += 1 else: d[i] = 1 return sorted(d, key=lambda i: (d[i], i), reverse=True)[:k] ```
vfc_135872
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/top-k-frequent-elements-in-array/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 6\r\nnums = {1,1,1,2,2,3}\r\nk = 2", "output": "{1, 2}", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 8\r\nnums = {1,1,2,2,3,3,3,4}\r\nk = 2", "output": "{3, 2}", "type"...
taco
verifiable_code
Solve the following coding problem using the programming language python: Walter and Jesse's friend Mike had helped them in making Crymeth and hence, they wanted to give him a share. For deciding the share, they both decided to choose one number each, X and Y and found out that K^th Highest Common Factor of their two ...
```python from fractions import gcd import math def kFactorEven(a, maxA, curK, gcd, lowerList): if a >= maxA: if a == maxA and gcd % a == 0: lowerList.append(a) if curK > len(lowerList): return -1 else: return lowerList[len(lowerList) - curK] if gcd % a == 0: if curK - 1 == 0: return gcd / a else: lower...
vfc_135873
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n66 132 2\n66 264 2\n66 528 2\n66 1056 2\n66 2112 2\n66 4224 2\n", "output": "No crymeth today\nNo crymeth today\nNo crymeth today\nNo crymeth today\nNo crymeth today\nNo crymeth today\nNo crymeth today\nNo crymeth today\nN...
taco
verifiable_code
https://codeforces.com/problemset/problem/70/B
Solve the following coding problem using the programming language python: Fangy the little walrus, as all the modern walruses, loves to communicate via text messaging. One day he faced the following problem: When he sends large texts, they are split into parts each containing n characters (which is the size of one tex...
```python import re n = int(input()) (ans, sumL) = (1, 0) for s in re.split('[.?!]', input()): s = s.strip() + '.' L = len(s) if L > 1: if L > n: print('Impossible') exit() if sumL + L + (sumL > 0) > n: ans += 1 sumL = L else: sumL = sumL + L + (sumL > 0) print(ans) ```
vfc_135878
{ "difficulty": "medium_hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/70/B", "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "16\nAbacaba. Abacaba. abacaba. abacab.\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "123\nOjg CVJm qfE RnHislFds nNKKt TCPLWukqNGAsVBplYbTfq? VeYKjfFGTzXWA ydpVZLIImNub ...
taco
verifiable_code
https://codeforces.com/problemset/problem/583/B
Solve the following coding problem using the programming language python: Robot Doc is located in the hall, with n computers stand in a line, numbered from left to right from 1 to n. Each computer contains exactly one piece of information, each of which Doc wants to get eventually. The computers are equipped with a se...
```python import sys input = sys.stdin.readline n = int(input()) a = list(map(int, input().split())) Power = 0 res = -1 E = [0] * n while Power != n: res += 1 for i in range(n): if E[i] == 0 and Power >= a[i]: Power += 1 E[i] = 1 if Power != n: res += 1 for i in range(n - 1, -1, -1): if E[i] == 0 and ...
vfc_135882
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/583/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n0 2 0\n", "output": "1\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/steps-by-knight5927/1
Solve the following coding problem using the programming language python: Given a square chessboard, the initial position of Knight and position of a target. Find out the minimum steps a Knight will take to reach the target position. Note: The initial and the target position coordinates of Knight have been given accor...
```python class Solution: def minStepToReachTarget(self, KnightPos, TargetPos, N): vis = [[-1] * (N + 1) for i in range(N + 1)] if KnightPos == TargetPos: return 0 q = [(KnightPos[0], KnightPos[1], 0)] vis[KnightPos[0]][KnightPos[1]] = 0 d = [[2, 1], [2, -1], [-2, 1], [-2, -1], [1, 2], [1, -2], [-1, -2],...
vfc_135886
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/steps-by-knight5927/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N=6\nknightPos[ ] = {4, 5}\ntargetPos[ ] = {1, 1}", "output": "3", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/252/D
Solve the following coding problem using the programming language python: Little Petya likes permutations a lot. Recently his mom has presented him permutation q1, q2, ..., qn of length n. A permutation a of length n is a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ n), all integers there are distinct. There is o...
```python def Solve(x, L): if x == k[0]: return L == S if (x, tuple(L)) in Mem: return False if L == S: return False E = [] for i in range(len(L)): E.append(L[Q[i] - 1]) if Solve(x + 1, E): return True E = [0] * len(L) for i in range(len(L)): E[Q[i] - 1] = L[i] if Solve(x + 1, E): return True Me...
vfc_135888
{ "difficulty": "medium_hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/252/D", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10 10\n2 3 1 5 6 7 8 4 10 9\n2 3 1 4 5 6 7 8 10 9\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 3\n2 1 4 3\n4 3 1 2\n", "output": "NO\n", "type": "stdin_s...
taco
verifiable_code
https://www.codechef.com/problems/TVDISC
Solve the following coding problem using the programming language python: Chef is looking to buy a TV and has shortlisted two models. The first one costs A rupees, while the second one costs B rupees. Since there is a huge sale coming up on Chefzon, Chef can get a flat discount of C rupees on the first TV, and a flat...
```python for _ in range(int(input())): (a, b, c, d) = map(int, input().split()) x = a - c y = b - d if x < y: print('First') elif x > y: print('Second') else: print('Any') ```
vfc_135893
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/TVDISC", "time_limit": "0.5 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n85 75 35 20\n100 99 0 0\n30 40 0 10\n", "output": "First\nSecond\nAny\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1031/A
Solve the following coding problem using the programming language python: You have a plate and you want to add some gilding to it. The plate is a rectangle that we split into $w\times h$ cells. There should be $k$ gilded rings, the first one should go along the edge of the plate, the second one — $2$ cells away from t...
```python (w, h, k) = [int(i) for i in input().split()] s = 0 for i in range(k): s = s + 2 * w + 2 * h - 4 w = w - 4 h = h - 4 print(s) ```
vfc_135897
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1031/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3 1\n", "output": "8\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7 9 1\n", "output": "28\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/GOHAN
Solve the following coding problem using the programming language python: Gohan has found his way into Dr. Gero's lab. There, he finds a circuit. He starts to toy with it. He finds the inverse transverse function $(V_{in}/V_{out})$ i.e (itf) of the circuit. Dr. Gero finds out about this. He gives Gohan an $s$-contro...
```python t = int(input()) for _ in range(t): (r, l, c, lol) = [float(a) for a in input().split()] R = r C = c L = l val = -R / (2 * L) ans = val * val * L * C + 1 + R * val * c print(ans) ```
vfc_135901
{ "difficulty": "medium_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/GOHAN", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n4 5 78 60\n4 5 6 3", "output": "-61.4\n-3.8", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1223/A
Solve the following coding problem using the programming language python: Let's denote correct match equation (we will denote it as CME) an equation $a + b = c$ there all integers $a$, $b$ and $c$ are greater than zero. For example, equations $2 + 2 = 4$ (||+||=||||) and $1 + 2 = 3$ (|+||=|||) are CME but equations $...
```python x = int(input()) j = [] for i in range(x): n = int(input()) if n < 4: if n == 2: j.append('2') if n == 1: j.append('3') if n == 3: j.append('1') elif n % 2 == 0: j.append('0') else: j.append('1') for i in range(len(j)): print(j[i]) ```
vfc_135907
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1223/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n2\n5\n8\n11\n", "output": "2\n1\n0\n1\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1282/B2
Solve the following coding problem using the programming language python: This is the hard version of this problem. The only difference is the constraint on $k$ — the number of gifts in the offer. In this version: $2 \le k \le n$. Vasya came to the store to buy goods for his friends for the New Year. It turned out th...
```python import sys input = sys.stdin.buffer.readline def getMinCost(nItems): idx = nItems - 1 cost = 0 if idx >= k - 1: cost += kBatchSum[idx] idx = (idx + 1) % k - 1 if idx >= 0: cost += aSum[idx] return cost t = int(input()) for _ in range(t): (n, p, k) = [int(x) for x in input().split()] a = [int(x) ...
vfc_135911
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1282/B2", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8\n5 6 2\n2 4 3 5 7\n5 11 2\n2 4 3 5 7\n3 2 3\n4 2 6\n5 2 3\n10 1 3 9 2\n2 10000 2\n10000 10000\n2 9999 2\n10000 10000\n4 6 4\n3 2 3 2\n5 5 3\n1 2 2 1 2\n", "output": "3\n4\n1\n1\n2\n0\n4\n5\n", "type": "stdin_stdout" ...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/count-alphabets3649/1
Solve the following coding problem using the programming language python: Given a string, The task is to count the number of alphabets present in the string. Example 1: Input: S = "adjfjh23" Output: 6 Explanation: only last 2 are not alphabets. Example 2: Input: S = "n0ji#k$" Output: 4 Explanation: #, $, 0 are not al...
```python class Solution: def Count(self, S): import re x = re.findall('[a-zA-Z]+', S) x = ''.join(x) return len(x) ```
vfc_135915
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/count-alphabets3649/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "S = \"adjfjh23\"", "output": "6", "type": "stdin_stdout" }, { "fn_name": null, "input": "S = \"n0ji#k$\"", "output": "4", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Determine whether a text T includes a pattern P. Your program should answer for given queries consisting of P_i. Constraints * 1 ≤ length of T ≤ 1000000 * 1 ≤ length of P_i ≤ 1000 * 1 ≤ Q ≤ 10000 * The input consists of alphabetical characters...
```python base = 127 mask = (1 << 32) - 1 def calc_hash(f, pl, tl): dl = tl - pl tmp = set() t = 1 for _ in range(pl): t = t * base & mask e = 0 for i in range(pl): e = e * base + f[i] & mask for i in range(dl): tmp.add(e) e = e * base - t * f[i] + f[i + pl] & mask tmp.add(e) return tmp t = tuple((ord...
vfc_135916
{ "difficulty": "unknown_difficulty", "memory_limit": "268.435456 megabytes", "memory_limit_bytes": null, "problem_url": null, "time_limit": "3.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "aabaaa\n4\nab\nba\nbb\nxyz", "output": "1\n1\n0\n0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "aabaaa\n4\nab\nba\nba\nxyz", "output": "1\n1\n1\n0\n", "type": "stdin_stdout"...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/burst-balloons/1
Solve the following coding problem using the programming language python: You are given N balloons, indexed from 0 to n - 1. Each balloon is painted with a number on it represented by an array arr. You are asked to burst all the balloons. If you burst the ith balloon, you will get arr[ i - 1 ] * arr[ i ] * arr[ i + 1]...
```python from typing import List import sys class Solution: def maxCoins(self, n: int, nums: List[int]) -> int: nums.insert(0, 1) nums.append(1) dp = [[0 for i in range(n + 2)] for j in range(n + 2)] for i in range(n, 0, -1): for j in range(1, n + 1): if i > j: continue maxi = -sys.maxsize -...
vfc_135921
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/burst-balloons/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 4\r\n\r\narr[ ] = {3, 1, 5, 8}", "output": "167", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 2\r\n\r\narr[ ] = {1, 10}", "output": "20", "type": "stdin_stdout" } ...
taco
verifiable_code
https://www.codechef.com/problems/CIELNUM2
Solve the following coding problem using the programming language python: Recently, chef Ciel often hears about lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not....
```python n = int(input()) count1 = 0 for _ in range(n): arr = list(input().split()) price = int(arr[-1]) c = 0 l = [] price while price > 0: a = price % 10 c = c + 1 if a == 3 or a == 5 or a == 8: l.append(a) else: break price = int(price / 10) if c == len(l) and l.count(8) >= l.count(5) and (l....
vfc_135926
{ "difficulty": "medium", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CIELNUM2", "time_limit": "0.621212 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\nmilk 58\nCiel's Drink 80\nThe curry 2nd edition 888888\nrice omelet 85855\nunagi 1\n The first and last letters can be a space 358", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, ...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/the-remaining-cake1349/1
Solve the following coding problem using the programming language python: Given a circle of radius R, divide it into N pieces such that every piece is 1/Mth of the original circle, where N and M are positive non-zero integers and M>=N. Find the arc length of the piece of the circle that is left over after the distribu...
```python class Solution: def remainingCircle(self, R, N, M): return 2 * 3.14 * R * ((M - N) / M) ```
vfc_135930
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/the-remaining-cake1349/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "R=7.50\nN=4\nM=7", "output": "20.19", "type": "stdin_stdout" }, { "fn_name": null, "input": "R=6.66\nN=3\nM=4", "output": "10.46", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/NOTEBOOK
Solve the following coding problem using the programming language python: You know that 1 kg of pulp can be used to make 1000 pages and 1 notebook consists of 100 pages. Suppose a notebook factory receives N kg of pulp, how many notebooks can be made from that? ------ Input Format ------ - First line will contain...
```python for _ in range(int(input())): n = int(input()) print(round(n * 1000 / 100)) ```
vfc_135935
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/NOTEBOOK", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1\n100\n50\n", "output": "10\n1000\n500\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Akshit and Rahul are playing a game. Initially, two positive integers A and B are written on a blackboard. The players take turns, starting with Akshit. On his or her turn, a player can replace A with A - kB for any positive integer k, or replac...
```python from fractions import gcd def isprime(n): i = 2 while i*i <= n: if n % i == 0: return False i = i + 1 return True for p in range(int(input())): a, b, c, d = list(map(int,input().split(" "))) count = 0 for i in range(a, b+1): for j in range(c ,d+1): if i == j: continue elif gcd(i, j) != 1: ...
vfc_135939
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5 5 8 8\n11 11 2 2", "output": "Case #1: 0\nCase #2: 1\nCase #3: 20", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n5 5 8 8\n11 11 2 2\n1 6 1 6", "output": "Case #1: 0\nCase #2: ...
taco
verifiable_code
https://codeforces.com/problemset/problem/13/C
Solve the following coding problem using the programming language python: Little Petya likes to play very much. And most of all he likes to play the following game: He is given a sequence of N integer numbers. At each step it is allowed to increase the value of any number by 1 or to decrease it by 1. The goal of the ...
```python from bisect import insort def min_steps_N(arr): pri_q = [] ans = 0 for n in arr: if pri_q: if pri_q[-1] > n: ans += pri_q[-1] - n pri_q.pop() insort(pri_q, n) insort(pri_q, n) return ans N = input() arr = list(map(int, input().split(' '))) print(min_steps_N(arr)) ```
vfc_135943
{ "difficulty": "hard", "memory_limit": "64.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/13/C", "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n0 0 0 0 0\n", "output": "0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n10 2\n", "output": "8\n", "type": "stdin_stdout" }, { "fn_name": null, "inp...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/kth-prime-factor-of-a-number0132/1
Solve the following coding problem using the programming language python: Given two numbers n and k, find the k^{th} prime factor of n. Example 1: Input: n = 225, k = 2 Output: 3 Explaination: The prime factors 3, 3, 5 and 5. So 3 is the 2nd one. Example 2: Input: n = 81, k = 5 Output: -1 Explaination: The 4 prime f...
```python class Solution: def prime(self, n): for i in range(2, int(n ** 0.5) + 1): if n % i == 0: return False return True def kthPrime(self, n, k): l = [] c = 0 for i in range(2, n + 1): if self.prime(i): while n % i == 0: l.append(i) n = n // i if len(l) >= k: return l[k - ...
vfc_135948
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/kth-prime-factor-of-a-number0132/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "n = 225, k = 2", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "n = 81, k = 5", "output": "-1", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/18/D
Solve the following coding problem using the programming language python: Last year Bob earned by selling memory sticks. During each of n days of his work one of the two following events took place: * A customer came to Bob and asked to sell him a 2x MB memory stick. If Bob had such a stick, he sold it and got 2x ...
```python N = int(input()) L = [-1] * 2010 DP = [0] * 5010 for i in range(N): (type, cost) = input().split() cost = int(cost) if type == 'win': L[cost] = i elif L[cost] >= 0: DP[i + 1] = DP[L[cost]] + 2 ** cost DP[i + 1] = max(DP[i], DP[i + 1]) print(DP[N]) ```
vfc_135949
{ "difficulty": "hard", "memory_limit": "128.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/18/D", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\nsell 1898\nsell 173\nsell 1635\nsell 29\nsell 881\nsell 434\nsell 1236\nsell 14\nwin 29\nsell 1165\n", "output": "0", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\nsell 573\nwin 1304...
taco
verifiable_code
Solve the following coding problem using the programming language python: Rahul and Rashi are bored with playing the game of Nim, particularly after Rahul gained a thorough understanding of game theory, and would always win. Now, they are going to play on a variation. There are only 2 piles of coins. Each player can...
```python a = {} def winOrLose(x, y): if (x > y): return winOrLose(y, x) if (a[x] == y): return False return True def compute(): a[0] = 0 d = 1 for i in range(1000007): if(i in a): continue else: a[i] = i + d a[i + d] = i d += 1 compute() numOfInput = int(input()) for x in range(numOfInput)...
vfc_135953
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "90601\n66 141\n139 260\n46 91\n197 111\n154 168\n252 11\n94 283\n2 176\n205 146\n78 65\n104 107\n260 216\n112 96\n297 216\n248 222\n91 296\n22 284\n15 134\n14 74\n200 113\n112 3\n76 220\n296 59\n296 196\n106 278\n69 67\n8 23\n121 7...
taco
verifiable_code
https://www.codechef.com/problems/EQUINOX
Solve the following coding problem using the programming language python: Sarthak and Anuradha are very good friends and are eager to participate in an event called *Equinox*. It is a game of words. In this game, $N$ strings $S_{1},\ldots, S_{N}$ are given. For each string $S_{i}$, if it starts with one of the letters...
```python t = int(input()) for i in range(t): (n, a, b) = map(int, input().split()) scount = 0 acount = 0 for i in range(n): s = input() if s[0] in 'EQUINOX': scount += a else: acount += b if scount > acount: print('SARTHAK') elif scount < acount: print('ANURADHA') else: print('DRAW') ```
vfc_135957
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/EQUINOX", "time_limit": "0.5 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n4 1 3\nABBBCDDE\nEARTH\nINDIA\nUUUFFFDDD\n2 5 7\nSDHHD\nXOXOXOXO", "output": "DRAW\nANURADHA", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.hackerrank.com/challenges/cipher/problem
Solve the following coding problem using the programming language python: Jack and Daniel are friends. They want to encrypt their conversations so that they can save themselves from interception by a detective agency so they invent a new cipher. Every message is encoded to its binary representation. Then it is wri...
```python (n, k) = [int(i) for i in input().split()] code = [int(i) for i in input()] solution = [0] * n xorSolution = 0 for i in range(n): if i >= k: xorSolution ^= solution[~(i - k)] i = ~i e = code[i] solution[i] ^= code[i] ^ xorSolution xorSolution ^= solution[i] print(*solution, sep='') ```
vfc_135965
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.hackerrank.com/challenges/cipher/problem", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7 4\n1110100110\n", "output": "1001010\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6 2\n1110001\n", "output": "101111\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/AVGPR
Solve the following coding problem using the programming language python: Read problems statements in Mandarin chinese, Russian and Vietnamese as well. You are given an integer sequence $A$ with length $N$. Find the number of (unordered) pairs of elements such that the average of these two elements is also present ...
```python def ti(): return tuple(map(int, input().split())) def li(): return list(map(int, input().split())) def si(): return input().split() def ii(): return int(input()) def ip(): return input() for tastcas in range(int(input())): n = ii() a = li() d = {} ans = 0 for i in range(-1000, 1001): d[i] = 0 ...
vfc_135969
{ "difficulty": "medium_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/AVGPR", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2\n2 2\n3\n2 1 3\n6\n4 2 5 1 3 5", "output": "1\n1\n7", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1051/B
Solve the following coding problem using the programming language python: You are given a set of all integers from $l$ to $r$ inclusive, $l < r$, $(r - l + 1) \le 3 \cdot 10^5$ and $(r - l)$ is always odd. You want to split these numbers into exactly $\frac{r - l + 1}{2}$ pairs in such a way that for each pair $(i, j...
```python def gcd(A, B): if B == 0: return A remainder = A % B return gcd(B, remainder) def verify_input(input): if input[0] < input[1]: if input[0] > 0 and input[1] <= 10 ** 18: if input[1] - input[0] + 1 <= 3 * 10 ** 5: if (input[1] - input[0]) % 2 == 1: return True return False def solution(S)...
vfc_135982
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1051/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 8\n", "output": "YES\n1 2\n3 4\n5 6\n7 8\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 2\n", "output": "YES\n1 2\n", "type": "stdin_stdout" }, { "fn_name": ...
taco
verifiable_code
https://codeforces.com/problemset/problem/454/C
Solve the following coding problem using the programming language python: Twilight Sparkle was playing Ludo with her friends Rainbow Dash, Apple Jack and Flutter Shy. But she kept losing. Having returned to the castle, Twilight Sparkle became interested in the dice that were used in the game. The dice has m faces: th...
```python (n, m) = map(int, input().split()) s = 0 for i in range(n): s += (i + 1) * (pow((i + 1) / n, m) - pow(i / n, m)) print(s) ```
vfc_135986
{ "difficulty": "medium_hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/454/C", "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "50000 100000\n", "output": "49999.843487110797\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "53033 3\n", "output": "39775.249995285820\n", "type": "stdin_stdout" }, {...
taco
verifiable_code
https://codeforces.com/problemset/problem/584/D
Solve the following coding problem using the programming language python: Dima loves representing an odd number as the sum of multiple primes, and Lisa loves it when there are at most three primes. Help them to represent the given number as the sum of at most than three primes. More formally, you are given an odd num...
```python def main(): n = int(input()) limit = int(n ** 0.5) + 1 lim12 = max(limit, 12) lim = lim12 // 6 l = [False, True, True] * lim lim = lim * 3 - 1 for (i, s) in enumerate(l): if s: (p, pp) = (i * 2 + 3, (i + 3) * i * 2 + 3) le = (lim - pp) // p + 1 if le > 0: l[pp::p] = [False] * le else:...
vfc_135991
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/584/D", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "27\n", "output": "3\n2 2 23", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n", "output": "1\n3", "type": "stdin_stdout" }, { "fn_name": null, "input": "25\...
taco
verifiable_code
https://www.codechef.com/JULY12/problems/GRAYSC
Solve the following coding problem using the programming language python: The Gray code (see wikipedia for more details) is a well-known concept. One of its important properties is that every two adjacent numbers have exactly one different digit in their binary representation. In this problem, we will give you n non-...
```python dic = {} n = int(input()) flag = 0 if n >= 68: inp = input() print('Yes') else: inp = [int(x) for x in input().split()] for i in range(len(inp) - 1): for j in range(i + 1, len(inp)): xor = inp[i] ^ inp[j] if xor in list(dic.keys()): for pair in dic[xor]: (x, y) = pair if x != i and y...
vfc_136000
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/JULY12/problems/GRAYSC", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 0 2 3 7\n", "output": "Yes\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/174/C
Solve the following coding problem using the programming language python: Polycarpus is an amateur programmer. Now he is analyzing a friend's program. He has already found there the function rangeIncrement(l, r), that adds 1 to each element of some array a for all indexes in the segment [l, r]. In other words, this fu...
```python n = int(input()) big = 10 ** 5 last = (big + 1) * [-1] data = list(map(int, input().split())) data.insert(0, 0) data.append(0) result = [] previous = 0 for (pos, current) in enumerate(data): if current > previous: for x in range(previous + 1, current + 1): last[x] = pos elif current < previous: for x...
vfc_136004
{ "difficulty": "medium_hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/174/C", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2 1\n", "output": "2\n1 1\n1 2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n2 4 2\n", "output": "4\n2 2\n2 2\n1 3\n1 3\n", "type": "stdin_stdout" }, { "f...
taco
verifiable_code
https://codeforces.com/problemset/problem/808/C
Solve the following coding problem using the programming language python: Polycarp invited all his friends to the tea party to celebrate the holiday. He has n cups, one for each of his n friends, with volumes a_1, a_2, ..., a_{n}. His teapot stores w milliliters of tea (w ≤ a_1 + a_2 + ... + a_{n}). Polycarp wants to ...
```python (n, w) = input().split() (n, w) = (int(n), int(w)) x = [int(i) for i in input().split()] need = 0 ans = [] for i in range(0, n): need += (x[i] + 1) // 2 ans.append([(x[i] + 1) // 2, x[i], i]) if w < need: print(-1) else: w -= need ans.sort(key=lambda x: x[1], reverse=1) for i in range(n): now = ans[i]...
vfc_136011
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/808/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 10\n8 7\n", "output": "6 4 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 4\n1 1 1 1\n", "output": "1 1 1 1 \n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/closest-triplet3807/1
Solve the following coding problem using the programming language python: Given three sorted arrays A[] of size P, B[] of size Q and C[] of size R.Find a number X such that when 3 elements i, j and k are chosen from A, B and C respectively,then X=max(abs(A[i] – B[j]), abs(B[j] – C[k]), abs(C[k] – A[i])) is minimized....
```python class Solution: def findClosest(self, P, Q, R, A, B, C): (i, j, k) = (0, 0, 0) l1 = P l2 = Q l3 = R ans = float('inf') while i < l1 and j < l2 and (k < l3): temp = max(abs(A[i] - B[j]), abs(B[j] - C[k]), abs(C[k] - A[i])) if temp < ans: ans = temp if A[i] <= B[j] and A[i] <= C[k]: ...
vfc_136016
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/closest-triplet3807/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "P=3\r\nA[] = {1, 4, 10}\r\nQ=3\r\nB[] = {2, 15, 20}\r\nR=2\r\nC[] = {10, 12}", "output": "5", "type": "stdin_stdout" }, { "fn_name": null, "input": "P=3\r\nA[] = {20, 24, 100}\r\nQ=5\r\nB[] = {2, 19,...
taco
verifiable_code
https://codeforces.com/problemset/problem/12/E
Solve the following coding problem using the programming language python: Before the start of the football season in Berland a strange magic ritual is held. The most experienced magicians have to find a magic matrix of the size n × n (n is even number). Gods will never allow to start the championship without it. Matri...
```python n = int(input()) a = [[0 for j in range(n)] for i in range(n)] for i in range(n - 1): for j in range(n - 1): if i != j: a[i][j] = (i + j) % n + int(i + j >= n) a[i][n - 1] = ((n - 1 + 2 * i) % n + int(n - 1 + 2 * i >= n)) % n + int(n - 1 + 2 * i > 2 * (n - 1)) for i in range(n - 1): a[n - 1][i] = ((n ...
vfc_136017
{ "difficulty": "hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/12/E", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "16\n", "output": "0 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 \n2 0 4 5 6 7 8 9 10 11 12 13 14 15 1 3 \n3 4 0 6 7 8 9 10 11 12 13 14 15 1 2 5 \n4 5 6 0 8 9 10 11 12 13 14 1...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/smallest-subarray-with-all-occurrences-of-a-most-frequent-element2258/1
Solve the following coding problem using the programming language python: Given an array A. Let X be an element in the array which has the maximum frequency. The task is to find the smallest sub segment of the array which also has X as the maximum frequency element. Note: if two or more elements have the same frequenc...
```python class Solution: def smallestSubsegment(self, arr, n): left = dict() count = dict() mx = 0 mn = 0 startindex = 0 for i in range(n): ele = arr[i] if ele not in count.keys(): left[ele] = i count[ele] = 1 else: count[ele] += 1 if count[ele] > mx: mx = count[ele] mn = ...
vfc_136022
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/smallest-subarray-with-all-occurrences-of-a-most-frequent-element2258/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "A[] = {1, 2, 2, 3, 1}", "output": "2 2", "type": "stdin_stdout" }, { "fn_name": null, "input": "A[] = {1, 4, 3, 3, 5, 5}", "output": "3 3", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/FUZZYCON
Solve the following coding problem using the programming language python: Raj is a math pro and number theory expert. One day, he met his age-old friend Chef. Chef claimed to be better at number theory than Raj, so Raj gave him some fuzzy problems to solve. In one of those problems, he gave Chef a 3$3$-tuple of non-ne...
```python for _ in range(int(input())): (a, b, c, x, y, z) = map(int, input().split()) if a == 0 and b == 0 and (c == 0) and (x == 0) and (y == 0) and (z == 0): print(0) continue ans = 0 if a == 0 and b == 0 and (c == 0): st = set((abs(x - a) % 2, abs(y - b) % 2, abs(z - c) % 2)) if st == {0, 1}: ans = 1...
vfc_136023
{ "difficulty": "very_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/FUZZYCON", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1 1 1 2 2 2\n1 2 3 2 4 2\n", "output": "0\n1\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/multiply-left-and-right-array-sum1555/1
Solve the following coding problem using the programming language python: Pitsy needs help with the given task by her teacher. The task is to divide an array into two sub-array (left and right) containing n/2 elements each and do the sum of the subarrays and then multiply both the subarrays. Note: If the length of the...
```python def multiply(arr, n): s1 = 0 s2 = 0 x = n // 2 for i in range(n): if i < x: s1 += arr[i] else: s2 += arr[i] return s1 * s2 ```
vfc_136031
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/multiply-left-and-right-array-sum1555/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": "multiply", "input": "arr[ ] = {1, 2, 3, 4}", "output": "21", "type": "function_call" }, { "fn_name": "multiply", "input": "arr[ ] = {1, 2}", "output": "2", "type": "function_call" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1776/H
Solve the following coding problem using the programming language python: Beppa and her circle of geek friends keep up to date on a group chat in the instant messaging app SwerChat$^{\text{TM}}$. The group has $n$ members, excluding Beppa. Each of those members has a unique ID between $1$ and $n$. When a user opens a...
```python from sys import stdin, stdout input = stdin.readline t = int(input()) for i in range(t): n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) p = q = n - 1 c = 0 while p >= 0: if a[p] == b[q]: q -= 1 else: c += 1 p -= 1 print(c) ```
vfc_136032
{ "difficulty": "easy", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1776/H", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n5\n1 4 2 5 3\n4 5 1 2 3\n6\n1 2 3 4 5 6\n1 2 3 4 5 6\n8\n8 2 4 7 1 6 5 3\n5 6 1 4 8 2 7 3\n1\n1\n1\n", "output": "2\n0\n4\n0\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/544/C
Solve the following coding problem using the programming language python: Programmers working on a large project have just received a task to write exactly m lines of code. There are n programmers working on a project, the i-th of them makes exactly ai bugs in every line of code that he writes. Let's call a sequence...
```python a = list(map(int, input().split())) n = a[0] m = a[1] b = a[2] mod = a[3] ac = list(map(int, input().split())) ac = [0] + ac dp = [[[0 for k in range(b + 1)] for _ in range(m + 1)] for z in range(2)] for i in range(n + 1): for x in range(b + 1): dp[i % 2][0][x] = 1 for i in range(1, n + 1): for j in range...
vfc_136036
{ "difficulty": "medium_hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/544/C", "time_limit": "3.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 1 1 1\n0\n", "output": "0\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1767/C
Solve the following coding problem using the programming language python: You are given an integer $n$. You have to calculate the number of binary (consisting of characters 0 and/or 1) strings $s$ meeting the following constraints. For every pair of integers $(i, j)$ such that $1 \le i \le j \le n$, an integer $a_{i,...
```python n = int(input()) pr = [i for i in range(n)] a = [list(map(int, input().split())) for i in range(n)] for e in a: if e[0] == 2: print(0) quit() for i in range(n): for j in range(n - i): if a[i][j] == 1: for k in range(i + 1, i + j + 1): pr[k] = pr[k - 1] d = [[0] * n for i in range(n)] d[0][0] = ...
vfc_136040
{ "difficulty": "hard", "memory_limit": "512 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1767/C", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 0 2\n1 0\n1\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1 1 2\n1 0\n1\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": nul...
taco
verifiable_code
https://www.codechef.com/LTIME29/problems/STDPRGS
Solve the following coding problem using the programming language python: Leha is a usual student at 'The Usual University for Usual Students'. Sometimes he studies hard; at other times he plays truant and gets busy with other things besides academics. He has already studied at the university for N months. For the ith...
```python n = eval(input()) grades = list(map(int, input().split())) m = eval(input()) for df in range(m): (x, y) = list(map(int, input().split())) arr = [] arr = grades[x - 1:y] arr.sort() sum = 0 for nh in range(0, len(arr) - 1, 1): sum = sum + (arr[nh + 1] - arr[nh]) ** 2 print(sum) ```
vfc_136044
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/LTIME29/problems/STDPRGS", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 3 2 4 5\n5\n1 5\n1 4\n2 4\n3 3\n3 5\n", "output": "4\n3\n2\n0\n5\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/PERMGCD
Solve the following coding problem using the programming language python: Chef is interested in the sum of [GCD]s of all prefixes of a permutation of the integers \{1, 2, \ldots, N\}. Formally, for a permutation P = [P_{1}, P_{2}, \ldots, P_{N}] of \{1, 2, \ldots, N\}, let us define a function F_{i} = \gcd(A_{1}, A_{...
```python code = int(input()) for i in range(code): (vij, hyd) = list(map(int, input().split())) if hyd < vij: print(-1) continue print(hyd - vij + 1, end=' ') for i in range(1, vij + 1): if i != hyd - vij + 1: print(i, end=' ') print(' ') ```
vfc_136053
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/PERMGCD", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 1\n2 1\n4 6\n3 5\n", "output": "1\n-1\n2 4 3 1\n3 2 1\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/reverse-spiral-form-of-matrix4033/1
Solve the following coding problem using the programming language python: Given a matrix as 2D array. Find the reverse spiral traversal of the matrix. Example 1: Input: R = 3, C = 3 a = {{9, 8, 7}, {6, 5, 4}, {3, 2, 1}} Output: 5 6 3 2 1 4 7 8 9 Explanation: Spiral form of the matrix in reverse order ...
```python class Solution: def reverseSpiral(self, R, C, a): (top, left) = (0, 0) (bottom, right) = (R - 1, C - 1) ans = [] while top <= bottom and left <= right: for i in range(left, right + 1): ans.append(a[top][i]) top += 1 for i in range(top, bottom + 1): ans.append(a[i][right]) right -...
vfc_136058
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/reverse-spiral-form-of-matrix4033/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "R = 3, C = 3\r\n a = {{9, 8, 7},\r\n {6, 5, 4},\r\n {3, 2, 1}}", "output": "5 6 3 2 1 4 7 8 9", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1042/E
Solve the following coding problem using the programming language python: Vasya has got a magic matrix a of size n × m. The rows of the matrix are numbered from 1 to n from top to bottom, the columns are numbered from 1 to m from left to right. Let a_{ij} be the element in the intersection of the i-th row and the j-th...
```python import io, os ns = iter(os.read(0, os.fstat(0).st_size).split()).__next__ MX = 10 ** 6 MOD = 998244353 (n, m) = (int(ns()), int(ns())) a = [int(ns()) for i in range(n * m)] s = (int(ns()) - 1) * m + int(ns()) - 1 inv = [1] * MX for i in range(2, MX): inv[i] = -(MOD // i) * inv[MOD % i] % MOD ind = sorted(lis...
vfc_136059
{ "difficulty": "hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1042/E", "time_limit": "3.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3\n2 0 1\n1 0 0\n0 0 0\n1 1\n", "output": "499122181\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "13 8\n5 7 7 7 9 1 10 7\n2 10 5 4 5 4 9 1\n8 6 10 8 10 9 9 5\n7 10 9 8 6 7 5 8\n1 6 4 ...
taco
verifiable_code
https://codeforces.com/problemset/problem/1515/D
Solve the following coding problem using the programming language python: To satisfy his love of matching socks, Phoenix has brought his $n$ socks ($n$ is even) to the sock store. Each of his socks has a color $c_i$ and is either a left sock or right sock. Phoenix can pay one dollar to the sock store to either: reco...
```python import sys input = sys.stdin.readline def inI(): inputLine = input().split() return int(inputLine[0]) if len(inputLine) == 1 else map(int, inputLine) def inIL(): return list(map(int, input().split())) def inCL(): return list(input())[:-1] def out(*liste): if isinstance(liste[0], list): liste = list...
vfc_136075
{ "difficulty": "medium", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1515/D", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n6 3 3\n1 2 3 2 2 2\n6 2 4\n1 1 2 2 2 2\n6 5 1\n6 5 4 3 2 1\n4 0 4\n4 4 4 3\n", "output": "2\n3\n5\n3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n6 3 3\n1 2 6 2 2 2\n6 2 4\n1 1 2 ...
taco
verifiable_code
Solve the following coding problem using the programming language python: In the good old Hachioji railroad station located in the west of Tokyo, there are several parking lines, and lots of freight trains come and go every day. All freight trains travel at night, so these trains containing various types of cars are ...
```python def solve(file_input, x, y): exch1 = [] exch2 = [] exch3 = [] for i in range(y): (p, P, space, q, Q) = file_input.readline().rstrip() p = int(p) q = int(q) if P == 'E': if Q == 'W': exch1.append((p, q)) else: exch2.append((p, q)) elif Q == 'E': exch1.append((q, p)) else: ex...
vfc_136081
{ "difficulty": "unknown_difficulty", "memory_limit": "134.217728 megabytes", "memory_limit_bytes": null, "problem_url": null, "time_limit": "8.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 5\n0W 1W\n0W 2W\n0W 2E\n0E 1E\n1E 2E\naabbcdcee\n-\n-\n-\n-\nbbaadeecc\n3 3\n0E 1W\n1E 2W\n2E 0W\naabb\nbbcc\naa\nbbbb\ncc\naaaa\n3 4\n0E 1W\n0E 2E\n1E 2W\n2E 0W\nababab\n-\n-\naaabbb\n-\n-\n0 0", "output": "5\n2\n5\n", ...
taco
verifiable_code
https://codeforces.com/problemset/problem/529/D
Solve the following coding problem using the programming language python: Polycarpus got an internship in one well-known social network. His test task is to count the number of unique users who have visited a social network during the day. Polycarpus was provided with information on all user requests for this time per...
```python def main(): mode = 'filee' if mode == 'file': f = open('test.txt', 'r') get = lambda : [int(x) for x in (f.readline() if mode == 'file' else input()).split()] gets = lambda : [str(x) for x in (f.readline()[:-1] if mode == 'file' else input()).split(':')] [n, m, t] = get() a = [0] * 20002 b = [0] * 20...
vfc_136085
{ "difficulty": "hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/529/D", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10 3 30000\n00:06:54\n00:42:06\n03:49:45\n04:38:35\n05:33:30\n05:51:46\n10:46:34\n14:34:59\n14:40:06\n14:53:13\n", "output": "6\n1\n2\n3\n3\n3\n3\n4\n5\n6\n6\n", "type": "stdin_stdout" }, { "fn_name": null...
taco
verifiable_code
https://www.codechef.com/problems/WSTRING
Solve the following coding problem using the programming language python: Kira likes to play with strings very much. Moreover he likes the shape of 'W' very much. He takes a string and try to make a 'W' shape out of it such that each angular point is a '#' character and each sides has same characters. He calls them W ...
```python def frequency(s, n): f = [[0 for i in range(26)] for j in range(n + 1)] count = 0 for i in range(n): if s[i] != '#': f[count][ord(s[i]) - 97] += 1 else: count += 1 for j in range(26): f[count][j] = f[count - 1][j] return (f, count) def solve(s): n = len(s) (f, count) = frequency(s, n) ...
vfc_136089
{ "difficulty": "medium_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/WSTRING", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\naaaaa#bb#cc#dddd\nacb#aab#bab#accba\nabc#dda#bb#bb#aca\n\n\n", "output": "16\n10\n11\n", "type": "stdin_stdout" } ] }