source
stringclasses
4 values
task_type
stringclasses
1 value
in_source_id
stringlengths
0
138
problem
stringlengths
219
13.2k
gold_standard_solution
stringlengths
0
413k
problem_id
stringlengths
5
10
metadata
dict
verification_info
dict
taco
verifiable_code
https://codeforces.com/problemset/problem/798/D
Solve the following coding problem using the programming language python: Mike has always been thinking about the harshness of social inequality. He's so obsessed with it that sometimes it even affects him while solving problems. At the moment, Mike has two sequences of positive integers A = [a1, a2, ..., an] and B = ...
```python n = int(input()) A = [int(x) for x in input().split()] B = [int(x) for x in input().split()] idAB = zip(range(n), A, B) idAB = sorted(idAB, key=lambda x: x[1], reverse=True) ans = [idAB[0][0] + 1] i = 1 while i < n: choice = max(idAB[i:i + 2], key=lambda x: x[2]) ans.append(choice[0] + 1) i += 2 ans = sort...
vfc_86926
{ "difficulty": "very_hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/798/D", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n319645572 758298525 812547177 459359946 355467212 304450522 807957797 916787906 239781206 242840396\n862552539 873867121 975802175 647540462 425058513 132645393 542726039 946723283 689442435 88379179\n", "output": "6\n8 3...
taco
verifiable_code
Solve the following coding problem using the programming language python: Description KMC sells CDs every year at a coterie spot sale called Comic Market. F was supposed to sell CDs at the comic market, but due to the popularity of F, the KMC sales floor was flooded with people, and the calculation of change could no...
```python while True: (a, b) = map(int, input().split()) if a == 0 and b == 0: break w = b - a x = w // 1000 w %= 1000 y = w // 500 w %= 500 z = w // 100 print(z, y, x) ```
vfc_86930
{ "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": "500 1001\n100 10000\n400 700\n600 5000\n10000 10000\n0 0", "output": "0 1 0\n4 1 9\n3 0 0\n4 0 4\n0 0 0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "500 1001\n100 10100\n400 700\n600 50...
taco
verifiable_code
https://codeforces.com/problemset/problem/245/H
Solve the following coding problem using the programming language python: You've got a string s = s1s2... s|s| of length |s|, consisting of lowercase English letters. There also are q queries, each query is described by two integers li, ri (1 ≤ li ≤ ri ≤ |s|). The answer to the query is the number of substrings of str...
```python import os import sys from io import BytesIO, IOBase def main(): s = input() n = len(s) palin = [[0 for _ in range(n)] for _ in range(n)] dp = [[0 for _ in range(n)] for _ in range(n)] for sz in range(n): for i in range(n - sz): j = i + sz if sz == 0: palin[i][j] = 1 elif s[i] == s[j]: ...
vfc_86934
{ "difficulty": "medium_hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/245/H", "time_limit": "5.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "ab\n100\n1 2\n1 2\n1 1\n1 1\n1 1\n1 1\n1 2\n1 2\n1 2\n1 2\n1 2\n1 1\n1 1\n1 1\n1 2\n1 1\n1 2\n1 2\n2 2\n1 1\n1 1\n2 2\n1 1\n1 2\n1 1\n1 2\n1 2\n1 1\n1 1\n1 2\n1 2\n1 1\n2 2\n1 2\n2 2\n2 2\n2 2\n2 2\n2 2\n1 2\n2 2\n1 2\n1 2\n1 2\n1 ...
taco
verifiable_code
https://codeforces.com/problemset/problem/1301/A
Solve the following coding problem using the programming language python: You are given three strings $a$, $b$ and $c$ of the same length $n$. The strings consist of lowercase English letters only. The $i$-th letter of $a$ is $a_i$, the $i$-th letter of $b$ is $b_i$, the $i$-th letter of $c$ is $c_i$. For every $i$ (...
```python import sys import math import time c = int(input()) for _ in range(c): a = input() b = input() c = input() yea = True for n in range(len(a)): i = a[n] j = b[n] k = c[n] if i != k and j != k: yea = False break print('YES' if yea else 'NO') ```
vfc_86942
{ "difficulty": "easy", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1301/A", "time_limit": "1 second" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\naaa\nbbb\nccc\nabc\nbca\nbca\naabb\nbbaa\nbaba\nimi\nmii\niim\n", "output": "NO\nYES\nYES\nNO\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/coverage-of-all-zeros-in-a-binary-matrix4024/1
Solve the following coding problem using the programming language python: Given a binary matrix having n rows and m columns, your task is to find the sum of coverage of all zeros in the matrix where coverage for a particular 0 is defined as total number of ones around a zero in left, right, up and bottom directions. ...
```python class Solution: def FindCoverage(self, matrix): coverageTotal = 0 for i in range(len(matrix)): for j in range(len(matrix[0])): if matrix[i][j] == 0: if j - 1 >= 0 and matrix[i][j - 1] == 1: coverageTotal += 1 if j + 1 < len(matrix[0]) and matrix[i][j + 1] == 1: coverageTotal...
vfc_86947
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/coverage-of-all-zeros-in-a-binary-matrix4024/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "matrix = {{0, 1, 0},\n{0, 1, 1}, {0, 0, 0}}", "output": "6", "type": "stdin_stdout" }, { "fn_name": null, "input": "matrix = {{0, 1}}", "output": "1", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1075/B
Solve the following coding problem using the programming language python: Palo Alto is an unusual city because it is an endless coordinate line. It is also known for the office of Lyft Level 5. Lyft has become so popular so that it is now used by all $m$ taxi drivers in the city, who every day transport the rest of t...
```python (n, m) = map(int, input().split()) x = list(map(int, input().split())) t = list(map(int, input().split())) ans = [0 for i in range(m)] tax = [] for i in range(n + m): if t[i] == 1: tax.append(x[i]) j = 0 for i in range(n + m): if t[i] == 0: while j < m - 1 and abs(x[i] - tax[j]) > abs(x[i] - tax[j + 1])...
vfc_86948
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1075/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 1\n1 2 3 10\n0 0 1 0\n", "output": "3 ", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/root-to-leaf-path-sum/1
Solve the following coding problem using the programming language python: Given a binary tree and an integer S, check whether there is root to leaf path with its sum as S. Example 1: Input: Tree = 1 / \ 2 3 S = 2 Output: 0 Explanation: There is no root to leaf path with sum 2. Exa...
```python class Solution: def hasPathSum(self, root, S): def path(rt, c, s): if rt is None: return if rt.left is None and rt.right is None: return s == c + rt.data return path(rt.left, c + rt.data, s) or path(rt.right, c + rt.data, s) return path(root, 0, S) ```
vfc_86953
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/root-to-leaf-path-sum/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "Tree = \n 1\n / \\\n 2 3\nS = 2", "output": "0", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/sum-of-elements-between-k1th-and-k2th-smallest-elements3133/1
Solve the following coding problem using the programming language python: Given an array A[] of N positive integers and two positive integers K_{1} and K_{2}. Find the sum of all elements between K_{1}^{th} and K_{2}^{th} smallest elements of the array. It may be assumed that (1 <= k1 < k2 <= n). Example 1: Input: N...
```python class Solution: def sumBetweenTwoKth(self, A, N, K1, K2): A.sort() d = [x for x in A if x > A[K1 - 1] and x < A[K2 - 1]] return sum(d) ```
vfc_86958
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/sum-of-elements-between-k1th-and-k2th-smallest-elements3133/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 7\r\nA[] = {20, 8, 22, 4, 12, 10, 14}\r\nK1 = 3, K2 = 6", "output": "26", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 6\r\nA[] = {10, 2, 50, 12, 48, 13}\r\nK1= 2, K2 = 6", "...
taco
verifiable_code
https://codeforces.com/problemset/problem/330/B
Solve the following coding problem using the programming language python: A country has n cities. Initially, there is no road in the country. One day, the king decides to construct some roads connecting pairs of cities. Roads can be traversed either way. He wants those roads to be constructed in such a way that it is ...
```python ROADS = 0 def find_center_citie(condition, num_of_citie): res = [] for i in range(number_of_city): count = [j for j in condition if j[0] == i + 1 or j[1] == i + 1] res.append(len(count)) center = res.index(min(res)) + 1 return center def acess(i, j, cities): citie_1 = i + 1 citie_2 = j + 1 if cit...
vfc_86959
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/330/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 1\n1 3\n", "output": "3\n1 2\n4 2\n2 3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "34 7\n10 28\n10 19\n10 13\n24 10\n10 29\n20 10\n10 26\n", "output": "33\n1 2\n1 3\n1 4\n1 5\n...
taco
verifiable_code
Solve the following coding problem using the programming language python: We all know that every positive integer can be represented as the sum of one or more odd integers. For eg: 4 = 1 + 1 + 1 + 1. Now, your task in this question is to find out the value of G(n), which equals to the number of all possible represent...
```python fib_matrix = [[1,1], [1,0]] def matrix_square(A, mod): return mat_mult(A,A,mod) def mat_mult(A,B, mod): if mod is not None: return [[(A[0][0]*B[0][0] + A[0][1]*B[1][0])%mod, (A[0][0]*B[0][1] + A[0][1]*B[1][1])%mod], [(A[1][0]*B[0][0] + A[1][1]*B[1][0])%mod, (A[1][0]*B[0][1] + A[1][1]...
vfc_86964
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1000\n25681017298294515\n312600462688402121\n833646696039112627\n223491184116692039\n162199167831855427\n534855812752103589\n300213762583795578\n991699364918096631\n403692356889424907\n669013150942454609\n570806843129162652\n358076...
taco
verifiable_code
Solve the following coding problem using the programming language python: Do you know Just Odd Inventions? The business of this company is to "just odd inventions". Here, it is abbreviated as JOI. JOI is conducting research to confine many microorganisms in one petri dish alive. There are N microorganisms to be inves...
```python import heapq tbl = [] N = int(input()) for i in range(N): (a, b) = map(int, input().split()) tbl.append((a, b)) tbl.sort() Q = [] ans = s = sz = 0 for t in tbl: s += t[0] heapq.heappush(Q, (t[1], t[0])) sz += 1 while sz and sz * Q[0][0] < s: s -= Q[0][1] heapq.heappop(Q) sz -= 1 if sz > ans: an...
vfc_86968
{ "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": "6\n12 8\n5 9\n2 4\n10 12\n6 7\n6 9", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n12 9\n5 9\n2 4\n10 12\n6 12\n6 9", "output": "5\n", "type": "stdin_stdout" ...
taco
verifiable_code
https://codeforces.com/problemset/problem/490/E
Solve the following coding problem using the programming language python: Peter wrote on the board a strictly increasing sequence of positive integers a_1, a_2, ..., a_{n}. Then Vasil replaced some digits in the numbers of this sequence by question marks. Thus, each question mark corresponds to exactly one lost digit....
```python def solve(s, t, i, l): if i == l: return False if s[i] == '?': if solve(s, t, i + 1, l): s[i] = t[i] return True elif t[i] == '9': return False s[i] = nxt[t[i]] for j in range(i, l): if s[j] == '?': s[j] = '0' return True elif s[i] > t[i]: for j in range(i, l): if s[j] == '...
vfc_86972
{ "difficulty": "hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/490/E", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n?\n18\n1?\n", "output": "YES\n1\n18\n19\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n??\n?\n", "output": "NO\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/SCALENE
Solve the following coding problem using the programming language python: Given A, B, and C as the sides of a triangle, find whether the triangle is *scalene*. Note: A triangle is said to be *scalene* if all three sides of the triangle are distinct. It is guaranteed that the sides represent a valid triangle. ------ ...
```python t = int(input()) for i in range(t): (n, m, p) = map(int, input().split()) if n != m != p: print('YES') else: print('NO') ```
vfc_86976
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/SCALENE", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n2 3 4\n1 2 2\n2 2 2\n3 5 6\n", "output": "YES\nNO\nNO\nYES", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/fibonacci-expression3939/1
Solve the following coding problem using the programming language python: Given a number N, evaluate the following expression. f(n-1)*f(n+1) - f(n)*f(n) where f(n) is the n-th Fibonacci number with n >= 1. Fibonacci Sequence is 0, 1, 1, 2, 3, 5, 8, 13,… (here 0 is the 0th Fibonacci number) Example 1: Input: N = 1 Out...
```python class Solution: def fibExpression(self, N): if N & 1: return -1 return 1 ```
vfc_86980
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/fibonacci-expression3939/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 1", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 2", "output": "1", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Example Input 3 Output 1 The input will be stdin and you should print your solution to stdout Now solve the problem and return the code.
```python N = int(input()) def gcd(m, n): while n: (m, n) = (n, m % n) return m def lcm(m, n): return m // gcd(m, n) * n def carmichael(x): r = 1 b = 0 while x & 1 == 0: b += 1 x >>= 1 if b > 1: r = 2 if b == 2 else 2 ** (b - 2) y = 3 while y * y <= x: if x % y == 0: c = 0 while x % y == 0: ...
vfc_86981
{ "difficulty": "unknown_difficulty", "memory_limit": "268.435456 megabytes", "memory_limit_bytes": null, "problem_url": null, "time_limit": "5.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2", "output": "1\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/PBK02020/problems/ITGUY12
Solve the following coding problem using the programming language python: The chef is trying to solve some pattern problems, Chef wants your help to code it. Chef has one number K to form new pattern. Help the chef to code this pattern problem. -----Input:----- - First line will contain $T$, number of testcases. Then...
```python import copy for _ in range(int(input())): k = int(input()) c = [] d = [] start = 0 while True: c = [] for i in range(start): c.append(' ') for i in range(start, k + 1): c.append(str(i)) start += 1 d.append(c) if start > k: break e = copy.copy(d[1:]) d.reverse() d = d + e for i in...
vfc_86985
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/PBK02020/problems/ITGUY12", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2\n4\n", "output": "2\n12\n012\n12\n2\n4\n34\n234\n1234\n01234\n1234\n234\n34\n4\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: A line on the plane is described by an equation Ax + By + C = 0. You are to find any point on this line, whose coordinates are integer numbers from  - 5·1018 to 5·1018 inclusive, or to find out that such points do not exist. Input The first lin...
```python a,b,c = list(map(int,input().split())) flag=1; for x in range(6,7): for y in range(-10,10): if (a*x)+(y*b)+c==0: print(x,y) flag=0 if flag==0: break if flag==1: print("-1") ```
vfc_86989
{ "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 5 3", "output": "6 -3", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: We understand that reading English is a great pain to many of you. So we’ll keep this problem statememt simple. Write a program that reports the point equally distant from a set of lines given as the input. In case of no solutions or multiple so...
```python import sys readline = sys.stdin.readline write = sys.stdout.write EPS = 1e-09 def line_cross_point(P1, P2, Q1, Q2): (x0, y0) = P1 (x1, y1) = P2 (x2, y2) = Q1 (x3, y3) = Q2 dx0 = x1 - x0 dy0 = y1 - y0 dx1 = x3 - x2 dy1 = y3 - y2 s = (y0 - y2) * dx1 - (x0 - x2) * dy1 sm = dx0 * dy1 - dy0 * dx1 if -E...
vfc_86993
{ "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": "2\n-35 -35 100 100\n-49 49 2000 -2000\n4\n0 0 0 3\n0 0 3 0\n0 3 3 3\n6 0 3 3\n4\n0 3 -4 6\n3 0 6 -4\n2 3 6 6\n-1 2 -4 6\n0", "output": "Many\nNone\n1.000000 1.000000\n", "type": "stdin_stdout" }, { "fn_nam...
taco
verifiable_code
Solve the following coding problem using the programming language python: You are given an integer n find its next greater or equal number whose binary representation must not contain consecutive ones. For eg. given n=6 whose binary is 110 and the next number with no consecutive ones is 8 whose binary is 1000. INPU...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' #print 'Hello World!' t=eval(input()) while t>0: t-=1 n=eval(input()) for i in range(n,100001): if "11" not in str(bin(i)): print(i) break ```
vfc_86997
{ "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\n71\n8497\n6364\n6530\n9199\n5754\n1508\n9388\n6992\n4494", "output": "72\n8512\n8192\n8192\n9216\n8192\n2048\n9472\n8192\n4608", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n38\n144...
taco
verifiable_code
Solve the following coding problem using the programming language python: Ketan and Dhruv are playing a very interesting game. They have 2 boxes - red and black. The red box contains all the natural numbers in increasing order(1,2,3,.....) and the black box contains all the natural numbers except "1" and each number i...
```python from bisect import bisect_left, bisect result = [(n*(n+1)*(n+2)*(3*n+5))/12 for n in range(25150)] for _ in range(eval(input())): n = int(input()) pos = bisect(result,n) if pos <= 1: print("0\nDraw") elif pos&1: print(pos-1) print("Ketan") else: print(pos-1) print("Dhruv") ```
vfc_87001
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n6\n100\n75\n85\n70", "output": "23070\nKetan\n15411\nDhruv\n21210\nKetan\n13780\nKetan\n23001\nDhruv\n13811\nDhruv\n24269\nDhruv\n22555\nDhruv\n19409\nDhruv\n18494\nKetan", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/reverse-a-string-using-stack/1
Solve the following coding problem using the programming language python: You are given a string S, the task is to reverse the string using stack. Example 1: Input: S="GeeksforGeeks" Output: skeeGrofskeeG Your Task: You don't need to read input or print anything. Your task is to complete the function reverse() whi...
```python def reverse(s): stack = [] list1 = [] for i in range(len(s)): stack.append(s[i]) for i in range(len(stack)): list1.append(stack.pop()) return ''.join(list1) ```
vfc_87005
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/reverse-a-string-using-stack/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": "reverse", "input": "S=\"GeeksforGeeks\"", "output": "skeeGrofskeeG", "type": "function_call" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1405/B
Solve the following coding problem using the programming language python: You're given an array $a$ of $n$ integers, such that $a_1 + a_2 + \cdots + a_n = 0$. In one operation, you can choose two different indices $i$ and $j$ ($1 \le i, j \le n$), decrement $a_i$ by one and increment $a_j$ by one. If $i < j$ this ope...
```python def cost(a): s = 0 for x in a: if x < 0: m = min(s, abs(x)) s -= m else: s += x return s t = int(input()) for _ in range(t): n = int(input()) a = list(map(int, input().split(' '))) print(cost(a)) ```
vfc_87006
{ "difficulty": "easy", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1405/B", "time_limit": "1 second" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7\n4\n-3 5 -3 1\n2\n1 -1\n4\n-3 2 -3 4\n4\n-1 1 1 -1\n7\n-5 7 -6 -4 17 -13 4\n6\n-1000000000 -1000000000 -1000000000 1000000000 1000000000 1000000000\n1\n0\n", "output": "3\n0\n4\n1\n8\n3000000000\n0\n", "type": "stdin_...
taco
verifiable_code
Solve the following coding problem using the programming language python: problem Cryptography is all the rage at xryuseix's school. Xryuseix, who lives in a grid of cities, has come up with a new cryptography to decide where to meet. The ciphertext consists of the $ N $ character string $ S $, and the $ S_i $ chara...
```python N = int(input()) word = list(input()) X1 = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M'] X2 = ['N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'] Y1 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm'] Y2 = ['n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x'...
vfc_87010
{ "difficulty": "unknown_difficulty", "memory_limit": "268.435456 megabytes", "memory_limit_bytes": null, "problem_url": null, "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\nAzaNA", "output": "1\nA\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\nAMazA", "output": "3\nAAA\n", "type": "stdin_stdout" }, { "fn_name": null, "in...
taco
verifiable_code
https://codeforces.com/problemset/problem/1393/C
Solve the following coding problem using the programming language python: Pinkie Pie has bought a bag of patty-cakes with different fillings! But it appeared that not all patty-cakes differ from one another with filling. In other words, the bag contains some patty-cakes with the same filling. Pinkie Pie eats the patt...
```python from collections import Counter for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) x = Counter(a) m = max(x.values()) s = list(x.values()).count(m) x = n - s * m x = x // (m - 1) print(x + s - 1) ```
vfc_87014
{ "difficulty": "medium_hard", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1393/C", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n7\n1 7 1 6 4 4 6\n8\n1 1 4 6 4 6 4 7\n3\n3 3 3\n6\n2 5 2 3 1 4\n", "output": "3\n2\n0\n4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n15\n1 2 3 4 5 1 2 3 4 5 1 2 3 4 5\n", "...
taco
verifiable_code
https://codeforces.com/problemset/problem/1517/G
Solve the following coding problem using the programming language python: At the foot of Liyushan Mountain, n tents will be carefully arranged to provide accommodation for those who are willing to experience the joy of approaching nature, the tranquility of the night, and the bright starry sky. The i-th tent is locat...
```python import sys, io, os try: Z = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline except: Z = lambda : sys.stdin.readline().encode() Y = lambda : map(int, Z().split()) INF = float('inf') big = 10 ** 13 class D: def __init__(self, n): self.lvl = [0] * n self.ptr = [0] * n self.q = [0] * n self.adj ...
vfc_87018
{ "difficulty": "very_hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1517/G", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n999999998 999999998 1\n999999998 999999999 1\n999999999 999999999 1\n-999999999 -999999998 1\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n963610297 -512417928 19...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/pair-cube-count4132/1
Solve the following coding problem using the programming language python: Given N, count all ‘a’(>=1) and ‘b’(>=0) that satisfy the condition a^{3} + b^{3 }= N. Example 1: Input: N = 9 Output: 2 Explanation: There are two solutions: (a=1, b=2) and (a=2, b=1). Example 2: Input: N = 27 Output: 1 Explanation: Thereis ...
```python class Solution: def pairCubeCount(self, N): count = 0 max_a = int(pow(N, 1 / 3)) + 1 for a in range(1, max_a): b_cube = N - pow(a, 3) if b_cube < 0: break b = int(round(pow(b_cube, 1 / 3))) if pow(b, 3) == b_cube: count += 1 if pow(a, 3) == N and b_cube == 0: count += 1 if...
vfc_87023
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/pair-cube-count4132/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 9", "output": "2", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1237/E
Solve the following coding problem using the programming language python: Recall that a binary search tree is a rooted binary tree, whose nodes each store a key and each have at most two distinguished subtrees, left and right. The key in each node must be greater than any key stored in the left subtree, and less than ...
```python import sys, math input = sys.stdin.readline n = int(input()) q = [1, 2] for i in range(34): if q[-1] % 2 != 0: q = q + [q[-1] + q[-2], q[-1] + q[-2] + 1] else: q = q + [2 * q[-1], 2 * q[-1] + 1] if n in q: print(1) else: print(0) ```
vfc_87024
{ "difficulty": "very_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1237/E", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n", "output": "1\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/camelcase-pattern-matching2259/1
Solve the following coding problem using the programming language python: Given a dictionary of words where each word follows CamelCase notation, print all words (in lexicographical order) in the dictionary that match with a given pattern consisting of uppercase characters only. Example: GeeksForGeeks matches the patt...
```python class Solution: def CamelCase(self, N, Dictionary, Pattern): s = '' l = [] ll = {} ll1 = {} for i in range(len(Dictionary)): for j in Dictionary[i]: if j.isupper(): s = s + j ll[Dictionary[i]] = s if Dictionary[i] not in ll1: ll1[Dictionary[i]] = 1 else: ll1[Dictionary...
vfc_87032
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/camelcase-pattern-matching2259/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N=3\nDictionary=[\"WelcomeGeek\",\n\"WelcomeToGeeksForGeeks\",\"GeeksForGeeks\"]\nPattern=\"WTG\"", "output": "WelcomeToGeeksForGeeks", "type": "stdin_stdout" }, { "fn_name": null, "input": "N=8\nDic...
taco
verifiable_code
https://www.hackerrank.com/challenges/mark-and-toys/problem
Solve the following coding problem using the programming language python: Mark and Jane are very happy after having their first child. Their son loves toys, so Mark wants to buy some. There are a number of different toys lying in front of him, tagged with their prices. Mark has only a certain amount to spend, and he ...
```python x = input() parts = x.split() part1 = int(parts[0]) part2 = int(parts[1]) y = input() arr = [] y = y.split() for i in range(0, part1): arr.append(int(y[i])) arr.sort() i = 0 j = 0 while j < part1 and part2 > arr[j]: part2 -= arr[j] j += 1 i += 1 print(i) ```
vfc_87035
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.hackerrank.com/challenges/mark-and-toys/problem", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7 50\n1 12 5 111 200 1000 10\n", "output": "4\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.hackerrank.com/challenges/time-conversion/problem
Solve the following coding problem using the programming language python: Given a time in $12$-hour AM/PM format, convert it to military (24-hour) time. Note: - 12:00:00AM on a 12-hour clock is 00:00:00 on a 24-hour clock. - 12:00:00PM on a 12-hour clock is 12:00:00 on a 24-hour clock. Example $\textbf{s}=...
```python ins = input().strip() is_pm = ins[-2:].lower() == 'pm' time_list = list(map(int, ins[:-2].split(':'))) if is_pm and time_list[0] < 12: time_list[0] += 12 if not is_pm and time_list[0] == 12: time_list[0] = 0 print(':'.join(map(lambda x: str(x).rjust(2, '0'), time_list))) ```
vfc_87043
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.hackerrank.com/challenges/time-conversion/problem", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "07:05:45PM\n", "output": "19:05:45\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/897/D
Solve the following coding problem using the programming language python: This is an interactive problem. Refer to the Interaction section below for better understanding. Ithea and Chtholly want to play a game in order to determine who can use the kitchen tonight. <image> Initially, Ithea puts n clear sheets of pap...
```python import sys (n, m, c) = map(int, input().split()) free = n nums = [0] * n for i in range(m): pi = int(input()) if pi > c // 2: current = n - 1 while nums[current] > 0 and nums[current] >= pi and (current >= 0): current -= 1 if current == -1: current = 0 if nums[current] == 0: free -= 1 num...
vfc_87049
{ "difficulty": "hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/897/D", "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 4 2\n2\n2\n2\n1\n", "output": "4\n3\n2\n1\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/376/A
Solve the following coding problem using the programming language python: You have a description of a lever as string s. We'll represent the string length as record |s|, then the lever looks as a horizontal bar with weights of length |s| - 1 with exactly one pivot. We will assume that the bar is a segment on the Ox ax...
```python s = input() suc = 0 p = 0 kde = 0 for i in range(len(s)): c = s[i] if c == '^': kde = i for i in range(len(s)): c = s[i] if '1' <= c <= '9': suc += (kde - i) * int(c) p += 1 if suc < 0: print('right') elif suc > 0: print('left') else: print('balance') ```
vfc_87054
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/376/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "=^==\n", "output": "balance\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "9===^==1\n", "output": "left\n", "type": "stdin_stdout" }, { "fn_name": null, "i...
taco
verifiable_code
Solve the following coding problem using the programming language python: Ronit is working on HackerEarth Profile. Right now he is working on User Statistics. One of the statistics data (Code Streak) is as follows: Given the User Activity Data, find the maximum number of continuous correct solutions submitted by any ...
```python noOfTestCases = int(input()) def maxSequence(lis): excludeList = {} counts = [] count = 0 for n in lis: #print n if(n[1] == '1' and (n[0] in excludeList) == False): count += 1 excludeList[n[0]] = 1 elif(n[1] == '0'): counts.append(count) count = 0 if(lis[len(lis) - 1][1] == '1'): ...
vfc_87058
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "11\n8\n1 1\n2 0\n3 1\n2 1\n1 1\n4 1\n2 1\n2 0\n4\n1 1\n2 0\n2 1\n3 1\n4\n1 1\n2 1\n2 0\n3 1\n4\n1 0\n2 1\n2 1\n3 1\n4\n1 1\n2 1\n2 1\n3 0\n4\n1 1\n3 1\n1 1\n2 0\n4\n1 1\n3 1\n1 1\n2 1\n4\n1 0\n3 0\n1 1\n2 0\n4\n1 1\n3 0\n1 1\n2 0\n...
taco
verifiable_code
https://codeforces.com/problemset/problem/1705/D
Solve the following coding problem using the programming language python: Mark has just purchased a rack of $n$ lightbulbs. The state of the lightbulbs can be described with binary string $s = s_1s_2\dots s_n$, where $s_i={1}$ means that the $i$-th lightbulb is turned on, while $s_i={0}$ means that the $i$-th lightbul...
```python def f(s, t, n): if s[0] != t[0] or s[n - 1] != t[n - 1]: return -1 (i, j, edits) = (0, 0, 0) while True: while i < n - 1 and s[i] == s[i + 1]: i += 1 while j < n - 1 and t[j] == t[j + 1]: j += 1 if i < n - 1 and j < n - 1: edits += abs(i - j) elif i == n - 1 and j == n - 1: return edi...
vfc_87062
{ "difficulty": "medium_hard", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1705/D", "time_limit": "1.5 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n4\n0100\n0010\n4\n1010\n0100\n5\n01001\n00011\n6\n000101\n010011\n", "output": "2\n-1\n-1\n5\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: D: Sunburn-Suntan- story Aizunyan is a second-year student who belongs to the programming contest club of Wakagamatsu High School, commonly known as the Prokon club. Cute like an angel. Aizu Nyan is planning to participate in this summer festi...
```python from bisect import bisect_left (T, N) = (int(input()), int(input())) (a, s, t) = ([0], [0], [0]) for i in range(N): (_s, _t) = map(int, input().split()) s.append(_s) t.append(_t) a.append(a[-1] + _t - _s) s.append(1 << 62) t.append(1 << 62) ans = 0 k = bisect_left(t, T, 0) - 1 for i in range(1, N + 1): x...
vfc_87066
{ "difficulty": "unknown_difficulty", "memory_limit": "268.435456 megabytes", "memory_limit_bytes": null, "problem_url": null, "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "20\n1\n1 10", "output": "9\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "20\n1\n0 7", "output": "7\n", "type": "stdin_stdout" }, { "fn_name": null, "input...
taco
verifiable_code
https://www.codechef.com/problems/TRIP2
Solve the following coding problem using the programming language python: Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef and his friend Chefu decided to go on a trip. The trip takes place over the next $N$ days (numbered 1 through $N$). There are $K$ diffe...
```python def func(arr, l, r, k): n = len(arr) if l == -1 and r == n: if k <= 1 and n != k: return False for i in range(n): arr[i] = i % 2 + 1 return True elif r == n: tbf = r - l - 1 if k <= 1 and tbf != 0: return False for i in range(l + 1, n): if (i - l) % 2 != 0: arr[i] = 1 if arr[l] ...
vfc_87074
{ "difficulty": "hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/TRIP2", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n5 3\n-1 -1 -1 -1 -1\n4 5\n1 2 3 5\n3 2\n1 -1 2\n4 2\n1 -1 -1 1\n6 4\n-1 -1 4 -1 2 -1", "output": "YES\n1 2 1 2 1\nYES\n1 2 3 5\nNO\nNO\nYES\n1 2 4 1 2 1", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.hackerrank.com/challenges/introduction-to-regex/problem
Solve the following coding problem using the programming language python: Check Tutorial tab to know how to to solve. You are given a string $N$. Your task is to verify that $N$ is a floating point number. In this task, a valid float number must satisfy all of the following requirements: $>$ Number can star...
```python import re for _ in range(int(input())): print(bool(re.search('^[-+]?[0-9]*\\.[0-9]+$', input()))) ```
vfc_87078
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.hackerrank.com/challenges/introduction-to-regex/problem", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n4.0O0\n-1.00\n+4.54\nSomeRandomStuff\n", "output": "False\nTrue\nTrue\nFalse\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/game-with-nos3123/1
Solve the following coding problem using the programming language python: You are given an array arr[], and you have to re-construct an array arr[]. The values in arr[] are obtained by doing Xor of consecutive elements in the array. Example 1: Input : n=5, arr[ ] = {10, 11, 1, 2, 3} Output : 1 10 3 1 3 Explanation: At...
```python def game_with_number(arr, n): total = [] for i in range(n - 1): tot_val = arr[i] ^ arr[i + 1] total.append(tot_val) total.append(arr[n - 1]) return total ```
vfc_87091
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/game-with-nos3123/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": "game_with_number", "input": "n=5, arr[ ] = {10, 11, 1, 2, 3}", "output": "1 10 3 1 3", "type": "function_call" }, { "fn_name": "game_with_number", "input": "n=4, arr[ ] = {5, 9, 7, 6}", "output": "12 14 1 6",...
taco
verifiable_code
https://www.codechef.com/problems/EGBOBRD
Solve the following coding problem using the programming language python: Read problems statements in Mandarin Chinese and Russian. Some chefs go for a tour lasting N days. They take packages of bread for food. Each package has K pieces of breads. On the i^{th} day, they eat A_{i} pieces of bread. Unfortunately, che...
```python import sys from itertools import * from pprint import pprint def solve(): (N, K) = tuple((int(x) for x in sys.stdin.readline().split())) AS = tuple((int(x) for x in sys.stdin.readline().split())) assert len(AS) == N total = 0 left = 0 for a in AS: if left > 0: left -= 1 total += a // K a = a %...
vfc_87093
{ "difficulty": "medium", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/EGBOBRD", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3 4\n3 1 2\n1 1\n1\n2 4\n8 8", "output": "2\n1\n4", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n3 4\n3 1 2\n1 1\n1\n2 4\n8 1", "output": "2\n1\n3\n", "type": "stdin_stdou...
taco
verifiable_code
https://www.hackerrank.com/challenges/die-hard-3/problem
Solve the following coding problem using the programming language python: Simon: On the fountain, there should be 2 jugs - a 5 gallon and a 3 gallon. Do you see them? Fill one of the jugs with exactly 4 gallons of water and place it on the scale and the timer will stop. You must be precise; one ounce more or less will...
```python from fractions import gcd import fractions def ok(a, b, c): if c >= a and c >= b: return False else: gcd = fractions.gcd(a, b) if c % gcd == 0: return True else: return False sa = int(input()) for t in range(sa): sa2 = input().split(' ') if ok(int(sa2[0]), int(sa2[1]), int(sa2[2])): print...
vfc_87097
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.hackerrank.com/challenges/die-hard-3/problem", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5 3 4\n3 6 4\n", "output": "YES\nNO\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/PEND2020/problems/ITGUY04
Solve the following coding problem using the programming language python: The chef is trying to solve some series problems, Chef wants your help to code it. Chef has one number N. Help the chef to find N'th number in the series. 0, 1, 5, 14, 30, 55 ….. -----Input:----- - First-line will contain $T$, the number of tes...
```python T = int(input()) for i in range(T): n = int(input()) if n == 1: print('0') else: n = n - 2 l = (n + 1) * (2 * n + 3) * (n + 2) / 6 print(int(l)) ```
vfc_87101
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/PEND2020/problems/ITGUY04", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1\n7\n8\n", "output": "0\n91\n140\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1475/B
Solve the following coding problem using the programming language python: Polycarp remembered the $2020$-th year, and he is happy with the arrival of the new $2021$-th year. To remember such a wonderful moment, Polycarp wants to represent the number $n$ as the sum of a certain number of $2020$ and a certain number of ...
```python from sys import stdin, stdout from collections import * from math import gcd, floor, ceil def st(): return list(stdin.readline().strip()) def li(): return list(map(int, stdin.readline().split())) def mp(): return map(int, stdin.readline().split()) def inp(): return int(stdin.readline()) def pr(n): r...
vfc_87105
{ "difficulty": "easy", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1475/B", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1\n4041\n4042\n8081\n8079\n", "output": "NO\nYES\nYES\nYES\nNO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n2020\n", "output": "YES\n", "type": "stdin_stdout" }, ...
taco
verifiable_code
Solve the following coding problem using the programming language python: Example Input 1+2*3+4 11 Output M The input will be stdin and you should print your solution to stdout Now solve the problem and return the code.
```python (s, ans) = (input(), int(input())) x = int(s[0]) for i in range(1, len(s), 2): y = int(s[i + 1]) x = x * y if s[i] == '*' else x + y print('IMLU'[int(eval(s) == ans) + (int(x == ans) << 1)]) ```
vfc_87109
{ "difficulty": "unknown_difficulty", "memory_limit": "268.435456 megabytes", "memory_limit_bytes": null, "problem_url": null, "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1+2*3+4\n9", "output": "I\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "0+1*3+4\n7", "output": "U\n", "type": "stdin_stdout" }, { "fn_name": null, "input"...
taco
verifiable_code
https://codeforces.com/problemset/problem/1198/B
Solve the following coding problem using the programming language python: There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social se...
```python n = int(input()) a = list(map(int, input().split())) last_updated = [0 for _ in range(n)] q = int(input()) pay_days = [0 for _ in range(q)] for i in range(q): qu = list(map(int, input().split())) if qu[0] == 1: (_, p, x) = qu a[p - 1] = x last_updated[p - 1] = i else: (_, x) = qu pay_days[i] = x ...
vfc_87113
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1198/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 2 3 4\n3\n2 3\n1 2 2\n2 1\n", "output": "3 2 3 4 \n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1285/C
Solve the following coding problem using the programming language python: Today, Osama gave Fadi an integer $X$, and Fadi was wondering about the minimum possible value of $max(a, b)$ such that $LCM(a, b)$ equals $X$. Both $a$ and $b$ should be positive integers. $LCM(a, b)$ is the smallest positive integer that is d...
```python import math x = int(input()) sq = int(math.sqrt(x)) if x == 1: print('1 1') else: for i in range(sq, 0, -1): if x % i == 0: if i * (x // i) // math.gcd(i, x // i) != x: continue if x // i == i: continue print(x // i, i) break ```
vfc_87117
{ "difficulty": "medium", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1285/C", "time_limit": "1 second" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n", "output": "1 2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n", "output": "2 3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n", ...
taco
verifiable_code
https://www.codechef.com/problems/EMITL
Solve the following coding problem using the programming language python: You are given a string S constisting of uppercase Latin letters. Is it possible to reorder the characters in this string to get a string with prefix "LTIME" and suffix "EMITL"? We remind you that a prefix of a string is any substring which conta...
```python T = int(input()) for t in range(T): S = input() letter_count = {'L': 0, 'T': 0, 'I': 0, 'M': 0, 'E': 0} for c in S: if c in letter_count: letter_count[c] += 1 lc_list = [letter_count['L'], letter_count['T'], letter_count['I'], letter_count['M'], letter_count['E']] print('YES') if all((count >= 2 for...
vfc_87121
{ "difficulty": "medium", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/EMITL", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\nLTIMEAZAZAITLME\nLLLTTTIIIMMMEEEAHA\nLTIMEM\n", "output": "YES\nYES\nNO\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.hackerrank.com/challenges/manasa-and-factorials/problem
Solve the following coding problem using the programming language python: Manasa was sulking her way through a boring class when suddenly her teacher singled her out and asked her a question. He gave her a number n and Manasa has to come up with the smallest number m which contains atleast n number of zeros at the end...
```python from sys import stdin from math import log, ceil T = int(stdin.readline()) def invf(n): if n == 0: return 0 return sum((n // 5 ** i for i in range(1, int(log(n, 5)) + 1))) def bsearch(inv, y): lb = 1 ub = y * 5 while ub - lb > 1: mid = (ub + lb) // 2 if inv(mid) >= y: ub = mid elif inv(mid) ...
vfc_87126
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.hackerrank.com/challenges/manasa-and-factorials/problem", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1\n2\n3\n", "output": "5\n10\n15\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/subset-with-sum-divisible-by-m2546/1
Solve the following coding problem using the programming language python: Given a set of n non-negative integers, and a value m, determine if there is a subset of the given set with sum divisible by m. Example 1: Input: n = 4 m = 6 nums[] = {3 1 7 5} Output: 1 Explanation: If we take the subset {7, 5} then sum will ...
```python class Solution: def DivisibleByM(self, nums, m): def f(i, rem, nums, dp): if rem == 0: return True if i >= len(nums): return False if dp[i][rem] != -1: return dp[i][rem] if rem == -1: take = f(i + 1, nums[i] % m, nums, dp) ntake = f(i + 1, rem, nums, dp) else: take ...
vfc_87135
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/subset-with-sum-divisible-by-m2546/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "n = 4 m = 6 \nnums[] = {3 1 7 5}", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "n = 3, m = 5\nnums[] = {1 2 6}", "output": "0", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Rohan bought new book Puzzleria in which he has to solve the puzzle. So,now he need your help to solve one of the puzzle were he is given X consonant and Y vowels to make a word from it whose length is equals to X + Y. So now your are given the ...
```python import math f=math.factorial for _ in range(eval(input())): x,y=list(map(int,input().split())) k=0 k=x+y print((f(5)/f(y)/f(5-y))*(f(7)/f(x)/f(7-x))*(f(k))) ```
vfc_87136
{ "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\n5 2 \n4 2 \n5 3 \n6 5 \n3 3 \n3 4 \n2 5 \n2 2 \n4 1\n5 4", "output": "1058400\n252000\n8467200\n279417600\n252000\n882000\n105840\n5040\n21000\n38102400", "type": "stdin_stdout" }, { "fn_name": null, ...
taco
verifiable_code
Solve the following coding problem using the programming language python: Heading ##There are two integers A and B. You are required to compute the bitwise AND amongst all natural numbers lying between A and B, both inclusive. Input Format First line of the input contains T, the number of testcases to follow. Each te...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' #print 'Hello World!' t=eval(input()) while t>0: t-=1 m,n=list(map(int,input().split())) print(min(m,n)) ```
vfc_87140
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "50\n170459136 170524671\n40173568 40239103\n105250816 105316351\n104267776 104333311\n125566976 125632511\n227934208 227999743\n235012096 235077631\n206700544 206766079\n655360 720895\n234094592 234160127\n27525120 27590655\n239140...
taco
verifiable_code
https://codeforces.com/problemset/problem/745/A
Solve the following coding problem using the programming language python: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by ...
```python n = input().strip() l = [] ans = 0 for i in range(len(n)): if n[i:] + n[:i] not in l: l.append(n[i:] + n[:i]) ans += 1 else: break print(ans) ```
vfc_87144
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/745/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "abcd\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "bbb\n", "output": "1\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/88/A
Solve the following coding problem using the programming language python: Vasya studies music. He has learned lots of interesting stuff. For example, he knows that there are 12 notes: C, C#, D, D#, E, F, F#, G, G#, A, B, H. He also knows that the notes are repeated cyclically: after H goes C again, and before C stan...
```python import sys input = sys.stdin.readline from itertools import permutations def check_chord(tup): notes = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'B', 'H'] notes += notes (x, y, z) = tup x_y = 0 y_z = 0 for i in range(notes.index(x), len(notes)): if notes[i] == y: break else: x_y ...
vfc_87148
{ "difficulty": "easy", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/88/A", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "E G# C\n", "output": "strange\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "D# C G\n", "output": "minor\n", "type": "stdin_stdout" }, { "fn_name": null, "...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/find-the-highest-occurring-digit-in-prime-numbers-in-a-range3634/1
Solve the following coding problem using the programming language python: Given a range L to R, the task is to find the highest occurring digit in prime numbers which lie between L and R (both inclusive). If multiple digits have same highest frequency return the largest of them. If no prime number occurs between L and...
```python class Solution: def isprime(self, n): if n == 1: return False for i in range(2, int(n ** 0.5) + 1): if n % i == 0: return False return True def maxDigit(self, L, R): l = [] for i in range(L, R + 1, 1): if self.isprime(i): c = i while c != 0: l.append(c % 10) c = c ...
vfc_87156
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/find-the-highest-occurring-digit-in-prime-numbers-in-a-range3634/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "L = 2, R = 10", "output": "7", "type": "stdin_stdout" }, { "fn_name": null, "input": "L = 2, R = 20", "output": "1", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1413/E
Solve the following coding problem using the programming language python: Meka-Naruto plays a computer game. His character has the following ability: given an enemy hero, deal $a$ instant damage to him, and then heal that enemy $b$ health points at the end of every second, for exactly $c$ seconds, starting one second ...
```python import sys s = sys.stdin.read().split() p = 0 def getSm(k, a, b, c, d): return (k + 1) * a - (k * (k + 1) >> 1) * b * d t = int(s[p]) p += 1 res = [] for _ in range(t): a = int(s[p]) p += 1 b = int(s[p]) p += 1 c = int(s[p]) p += 1 d = int(s[p]) p += 1 if a - b * c > 0: res.append(-1) elif d >= ...
vfc_87157
{ "difficulty": "hard", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1413/E", "time_limit": "1 second" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7\n1 1 1 1\n2 2 2 2\n1 2 3 4\n4 3 2 1\n228 21 11 3\n239 21 11 3\n1000000 1 1000000 1\n", "output": "1\n2\n1\n5\n534\n-1\n500000500000\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/SDICE
Solve the following coding problem using the programming language python: Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has $N$ [6-sided standard dice]. Each die has dimensions $1 \times 1 \times 1$. Since Chef is bored during the quarantine, he decides to stack d...
```python (L1, L2) = ([0, 20, 36, 51], [16, 21, 22, 22]) for T in range(int(input())): n = int(input()) if n < 4: print(L1[n]) else: print(L2[n % 4] + 11 * n) ```
vfc_87161
{ "difficulty": "medium", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/SDICE", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n1", "output": "20", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/perfect-squares-in-a-range2253/1
Solve the following coding problem using the programming language python: Given two given numbers a and b where 1<=a<=b, find the number of perfect squares between a and b (a and b inclusive). Example 1: Input: a = 9, b = 25 Output: 3 Explanation: There are 3 perfect squares between 9 and 25. They are 9, 16, and 25....
```python class Solution: def numOfPerfectSquares(self, a, b): sum = 0 c = int(b ** 0.5) + 1 for i in range(1, c): if i ** 2 >= a and i ** 2 <= b: sum += 1 else: continue return sum ```
vfc_87165
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/perfect-squares-in-a-range2253/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "a = 9, b = 25", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "a = 1, b = 7", "output": "2", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1343/E
Solve the following coding problem using the programming language python: You are given an undirected unweighted graph consisting of $n$ vertices and $m$ edges (which represents the map of Bertown) and the array of prices $p$ of length $m$. It is guaranteed that there is a path between each pair of vertices (districts...
```python from collections import deque g = [[] for y in range(int(200000.0 + 5))] q = int(input()) while q > 0: q -= 1 (n, m, a, b, c) = map(int, input().split()) def BFS(a): List = [] dist = [-1] * (n + 1) dist[a] = 0 List = deque([a]) while List: u = List.popleft() for v in g[u]: if dist[v] <...
vfc_87167
{ "difficulty": "hard", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1343/E", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7\n", "output": "7\n12\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n4 3 2...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/649205908e04ac00f303626fa845261318adfa8f/1
Solve the following coding problem using the programming language python: Given a list intervals of n intervals, the ith element [s, e, p] denotes the starting point s, ending point e, and the profit p earned by choosing the ith interval. Find the maximum profit one can achieve by choosing a subset of non-overlapping ...
```python from typing import List class Solution: def maximum_profit(self, n: int, intervals: List[List[int]]) -> int: intervals.sort(key=lambda x: (x[1], x[0])) M = intervals[-1][1] dp = [0] * (M + 1) for i in range(n): (s, e, p) = intervals[i] if p + dp[s] > dp[e]: dp[e] = p + dp[s] if i < n -...
vfc_87171
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/649205908e04ac00f303626fa845261318adfa8f/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "n = 3\r\nintervals = {\r\n{1, 2, 4},\r\n{1, 5, 7},\r\n{2, 4, 4}\r\n}", "output": "8", "type": "stdin_stdout" }, { "fn_name": null, "input": "n = 3\r\nintervals = {\r\n{1, 4, 4},\r\n{2, 3, 7},\r\n{2, ...
taco
verifiable_code
https://codeforces.com/problemset/problem/1238/C
Solve the following coding problem using the programming language python: You are playing a game where your character should overcome different obstacles. The current problem is to come down from a cliff. The cliff has height $h$, and there is a moving platform on each height $x$ from $1$ to $h$. Each platform is eit...
```python import sys import math input = sys.stdin.readline q = int(input()) for i in range(q): (h, n) = map(int, input().split()) arr = list(map(int, input().split())) arr.append(0) count = 0 cur = 0 now = arr[cur] cur = 1 while cur < n: try: if now - arr[cur] == 1: if now - arr[cur + 1] == 2: no...
vfc_87172
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1238/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n3 2\n3 1\n8 6\n8 7 6 5 3 2\n9 6\n9 8 5 4 3 1\n1 1\n1\n", "output": "0\n1\n2\n0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "28\n8 4\n8 7 6 3\n8 5\n8 7 6 3 1\n8 5\n8 7 6 3 2\n8 6\n8 7...
taco
verifiable_code
https://www.codechef.com/LOCAUG16/problems/MINMO
Solve the following coding problem using the programming language python: Little Rohu from Pluto is the best bomb defusor on the entire planet. She has saved the planet from getting destruced multiple times now. Of course, she's proud of her achievments. But, to prepare herself for more complicated situations, she kee...
```python (n, b) = list(map(int, input().split())) x = list(map(int, input().split())) y = list(map(int, input().split())) ans = 0 for i in range(b): ans += min(x[i] - 1, n - x[i]) + min(y[i] - 1, n - y[i]) print(ans) ```
vfc_87176
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/LOCAUG16/problems/MINMO", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3\n1 2 3\n3 2 1\n\n\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 1\n1\n1\n\n\n", "output": "0\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/288/A
Solve the following coding problem using the programming language python: Little penguin Polo adores strings. But most of all he adores strings of length n. One day he wanted to find a string that meets the following conditions: The string consists of n lowercase English letters (that is, the string's length equals ...
```python (n, m) = list(map(int, input().split())) if m > n or (m == 1 and n > 1): print(-1) return if m == 1: print('a') return l = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] s = '' for i in range(2, m): s += l[i] n -= m - 2 l...
vfc_87189
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/288/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7 4\n", "output": "ababacd\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1303/C
Solve the following coding problem using the programming language python: Polycarp wants to assemble his own keyboard. Layouts with multiple rows are too complicated for him — his keyboard will consist of only one row, where all $26$ lowercase Latin letters will be arranged in some order. Polycarp uses the same passw...
```python testCases = int(input()) for i1 in range(testCases): used = [False] * 26 s = input() t = s[0] used[ord(s[0]) - ord('a')] = True pos = 0 result = 'YES' for i2 in range(1, len(s), 1): if used[ord(s[i2]) - ord('a')]: if pos > 0 and t[pos - 1] == s[i2]: pos -= 1 elif pos < len(t) - 1 and t[pos ...
vfc_87193
{ "difficulty": "medium_hard", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1303/C", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\nababa\ncodedoca\nabcda\nzxzytyz\nabcdefghijklmnopqrstuvwxyza\n", "output": "YES\nbacdefghijklmnopqrstuvwxyz\nYES\nedocabfghijklmnpqrstuvwxyz\nNO\nYES\nxzytabcdefghijklmnopqrsuvw\nNO\n", "type": "stdin_stdout" } ...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/find-length-of-loop/1
Solve the following coding problem using the programming language python: Given a linked list of size N. The task is to complete the function countNodesinLoop() that checks whether a given Linked List contains a loop or not and if the loop is present then return the count of nodes in a loop or else return 0. C is the ...
```python def countNodesinLoop(head): prev = head curr = head while prev and curr and curr.next: prev = prev.next curr = curr.next.next if prev == curr: c = 1 prev = curr.next while prev != curr: prev = prev.next c += 1 return c return 0 ```
vfc_87197
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/find-length-of-loop/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 10\r\nvalue[]={25,14,19,33,10,21,39,90,58,45}\r\nC = 4", "output": "7", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1005/A
Solve the following coding problem using the programming language python: Little girl Tanya climbs the stairs inside a multi-storey building. Every time Tanya climbs a stairway, she starts counting steps from $1$ to the number of steps in this stairway. She speaks every number aloud. For example, if she climbs two sta...
```python n = int(input()) arr = map(int, input().split()) ans = {} stairs = 0 for x in arr: if x == 1: stairs += 1 ans[stairs] = 1 else: ans[stairs] += 1 print(len(ans)) print(*ans.values()) ```
vfc_87198
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1005/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7\n1 2 3 1 2 3 4\n", "output": "2\n3 4 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n1 1 1 1\n", "output": "4\n1 1 1 1 ", "type": "stdin_stdout" }, { "fn_name...
taco
verifiable_code
https://codeforces.com/problemset/problem/78/B
Solve the following coding problem using the programming language python: The Easter Rabbit laid n eggs in a circle and is about to paint them. Each egg should be painted one color out of 7: red, orange, yellow, green, blue, indigo or violet. Also, the following conditions should be satisfied: * Each of the seven...
```python n = int(input()) s = 'ROYGBIV' s1 = 'GBIV' print(s, (n - 7) // 4 * s1, s1[:(n - 7) % 4], sep='') ```
vfc_87210
{ "difficulty": "easy", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/78/B", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "21\n", "output": "ROYGBIVROYGBIVROYGBIV\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "24\n", "output": "ROYGBIVGBIVGBIVGBIVGBIVG", "type": "stdin_stdout" }, { "...
taco
verifiable_code
https://www.codechef.com/problems/TWOSTR
Solve the following coding problem using the programming language python: Read problems statements in Mandarin Chinese and Russian as well. Chef wants to implement wildcard pattern matching supporting only the wildcard '?'. The wildcard character '?' can be substituted by any single lower case English letter for mat...
```python for _ in range(int(input())): x = input() y = input() flag = 1 for i in range(len(x)): if x[i] != '?' and y[i] != '?': if x[i] != y[i]: flag = 0 break if flag == 1: print('Yes') else: print('No') ```
vfc_87214
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/TWOSTR", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\ns?or?\nsco??\nstor?\nsco??", "output": "Yes\nNo", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\ns?o?r\nsco??\nstor?\nsco??", "output": "Yes\nNo\n", "type": "stdin_stdout" ...
taco
verifiable_code
https://www.codechef.com/problems/SONGSHOP
Solve the following coding problem using the programming language python: Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well. As everybody knows, Reza Shiri is the favourite Iranian artist. Since we love Reza Shiri and his songs, we never download them for free. Rez...
```python from collections import defaultdict (n, m, b) = map(int, input().split()) d = defaultdict(list) for i in range(n): (a, p, v) = map(int, input().split()) d[a].append((p, v)) alb = list(map(int, input().split())) dp = [[0 for x in range(b + 1)] for y in range(n + 1)] s = 1 i = 1 while i <= m: j = 0 sg = 0 ...
vfc_87224
{ "difficulty": "very_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/SONGSHOP", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 2 24\n1 7 2\n1 5 2\n1 4 1\n2 9 1\n2 13 2\n10 15", "output": "7", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/186/C
Solve the following coding problem using the programming language python: Dwarfs have planted a very interesting plant, which is a triangle directed "upwards". This plant has an amusing feature. After one year a triangle plant directed "upwards" divides into four triangle plants: three of them will point "upwards" and...
```python N = int(input()) result = pow(2, N, int(1000000000.0 + 7)) * (pow(2, N, int(1000000000.0 + 7)) + 1) % int(1000000000.0 + 7) result = result * pow(2, int(1000000000.0 + 5), int(1000000000.0 + 7)) % int(1000000000.0 + 7) print(result) ```
vfc_87228
{ "difficulty": "easy", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/186/C", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "615812227854199662\n", "output": "357939938\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "563324730406715801\n", "output": "353494903\n", "type": "stdin_stdout" }, { ...
taco
verifiable_code
Solve the following coding problem using the programming language python: As you know Appu created aversion to Maths after that maths problem given by his teacher.So he stopped studying and began to do farming. He has some land where he starts growing sugarcane. At the end of the season he grew N sugarcanes. Is Appu s...
```python s = int(input()) x = input() arr=x.split(' ') arr = [int(i) for i in arr] # Another method arr=map(int,results) flag=1 i=0 while(i < len(arr)): while(arr[i]%2==0): arr[i]=arr[i]/2 if(i==0): ans=arr[i] else: if(ans!=arr[i]): flag=0 i=i+1 if(flag==1): print("YES") else: print("NO") ```
vfc_87232
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "49\n3 3 1 2 3 3 1 3 2 1 3 1 1 2 2 3 1 1 1 2 3 2 3 3 2 2 2 3 1 3 3 3 1 2 2 2 1 1 1 2 2 2 1 2 3 1 3 2 3", "output": "NO", "type": "stdin_stdout" }, { "fn_name": null, "input": "50\n593877072 74234634 5...
taco
verifiable_code
https://codeforces.com/problemset/problem/1373/D
Solve the following coding problem using the programming language python: You are given an array $a$ consisting of $n$ integers. Indices of the array start from zero (i. e. the first element is $a_0$, the second one is $a_1$, and so on). You can reverse at most one subarray (continuous subsegment) of this array. Reca...
```python def maxSubArraySum(a, size): max_so_far = 0 max_ending_here = 0 for i in range(0, size): max_ending_here = max_ending_here + a[i] if max_ending_here < 0: max_ending_here = 0 elif max_so_far < max_ending_here: max_so_far = max_ending_here return max_so_far for _ in range(int(input())): n = int...
vfc_87236
{ "difficulty": "medium_hard", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1373/D", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n8\n1 7 3 4 7 6 2 9\n5\n1 2 1 2 1\n10\n7 8 4 5 7 6 8 9 7 3\n4\n3 1 2 1\n", "output": "26\n5\n37\n5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n5\n17 6 4 4 4\n7\n19 5 13 11 12 13 5...
taco
verifiable_code
https://codeforces.com/problemset/problem/1674/G
Solve the following coding problem using the programming language python: You are given a directed acyclic graph, consisting of $n$ vertices and $m$ edges. The vertices are numbered from $1$ to $n$. There are no multiple edges and self-loops. Let $\mathit{in}_v$ be the number of incoming edges (indegree) and $\mathit...
```python from collections import deque (n, m) = map(int, input().split()) g = [[] for _ in range(n)] graph = [list(map(int, input().split())) for _ in range(m)] inv = [0] * n outv = [0] * n for i in range(m): graph[i][0] -= 1 graph[i][1] -= 1 inv[graph[i][0]] += 1 outv[graph[i][1]] += 1 S = set() for (u, v) in gra...
vfc_87240
{ "difficulty": "hard", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1674/G", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3\n1 2\n2 3\n1 3\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 0\n", "output": "1\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Example Input 3 y 7 y 6 n 5 Output 1 The input will be stdin and you should print your solution to stdout Now solve the problem and return the code.
```python import sys readline = sys.stdin.readline write = sys.stdout.write def solve(): N = int(readline()) L = [0] * N D = [0] * N for i in range(N): (l, d) = readline().split() L[i] = +(l == 'y') D[i] = int(d) ans = 0 (*I,) = range(N) I.sort(key=D.__getitem__) U = [0] * N for i in I: if not L[i] or...
vfc_87248
{ "difficulty": "unknown_difficulty", "memory_limit": "536.870912 megabytes", "memory_limit_bytes": null, "problem_url": null, "time_limit": "5.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\ny 7\ny 2\nn 5", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\ny 7\ny 3\nn 5", "output": "1\n", "type": "stdin_stdout" }, { "fn_name": null, ...
taco
verifiable_code
https://codeforces.com/problemset/problem/1068/F
Solve the following coding problem using the programming language python: Ivan places knights on infinite chessboard. Initially there are n knights. If there is free cell which is under attack of at least 4 knights then he places new knight in this cell. Ivan repeats this until there are no such free cells. One can pr...
```python n = int(input()) anss = [(0, 0)] for i in range(1, n): anss.append((0, i)) anss.append((i, 0)) anss.append((0, -i)) anss.append((-i, 0)) for i in range(n): print(str(anss[i][0]) + ' ' + str(anss[i][1])) ```
vfc_87252
{ "difficulty": "very_hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1068/F", "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "523\n", "output": "0 1\n0 2\n0 3\n0 4\n0 5\n0 6\n0 7\n0 8\n0 9\n0 10\n0 11\n0 12\n0 13\n0 14\n0 15\n0 16\n0 17\n0 18\n0 19\n0 20\n0 21\n0 22\n0 23\n0 24\n0 25\n0 26\n0 27\n0 28\n0 29\n0 30\n0 31\n0 32\n0 33\n0 34\n0 35\n0 36\...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/e866d887f78664cdbf24c61ef9404691f4fb9e59/1
Solve the following coding problem using the programming language python: Given a set of distinct positive integers nums, return the largest subset answer such that every pair (answer[i], answer[j]) of elements in this subset satisfies: answer[i] % answer[j] == 0, or answer[j] % answer[i] == 0 If there are multiple ...
```python class Solution: def LargestSubset(self, n, arr): arr.sort() dp = [1] * n p = [-1] * n val = 0 pos = 0 for i in range(1, n): for j in range(i): if arr[i] % arr[j] == 0 and dp[i] < dp[j] + 1: dp[i] = dp[j] + 1 p[i] = j if val < dp[i]: val = dp[i] pos = i ans = [] wh...
vfc_87260
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/e866d887f78664cdbf24c61ef9404691f4fb9e59/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "n = 3\r\narr = [1,2,3]", "output": "[1,2]", "type": "stdin_stdout" }, { "fn_name": null, "input": "n = 4\r\narr = [1,2,4,8]", "output": "[1,2,4,8]", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/POPU2021/problems/BXRED
Solve the following coding problem using the programming language python: Rohit has n empty boxes lying on the ground in a line. The size of the boxes is given in the form of an array $a$. The size of the ith box is denoted by $a[i]$. Since Rohit has a tiny room, there is a shortage of space. Therefore, he has to redu...
```python n = int(input()) l = [0] * n for i in range(n): l[i] = int(input()) l.sort() s = 0 i = n - 1 while i >= 0: x = 2 * l[i] if l[-1] >= x: j = i while j < len(l): if l[j] >= x: l.pop(j) l.pop(i) s += 1 break j += 1 i -= 1 s += len(l) print(s) ```
vfc_87261
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/POPU2021/problems/BXRED", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n16\n1\n4\n8\n2\n", "output": "3\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Fukushima Prefecture is also famous for producing fruits, and among them, peaches and apples boast one of the highest production volumes in Japan. By the way, when I made a print manuscript of an English pamphlet for sale, I mistakenly wrote the...
```python (a, p, t) = ('apple', 'peach', '_') print(input().replace(a, t).replace(p, a).replace(t, p)) ```
vfc_87265
{ "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": "the cost of one peach is higher than th`t of one apple.", "output": "the cost of one apple is higher than th`t of one peach.\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "the cost of ooe...
taco
verifiable_code
https://codeforces.com/problemset/problem/1764/A
Solve the following coding problem using the programming language python: Doremy has $n$ buckets of paint which is represented by an array $a$ of length $n$. Bucket $i$ contains paint with color $a_i$. Let $c(l,r)$ be the number of distinct elements in the subarray $[a_l,a_{l+1},\ldots,a_r]$. Choose $2$ integers $l$ ...
```python import sys inputs = ''.join(sys.stdin.readlines()).strip().split('\n')[2::2] for i in inputs: if len(i.split()) > 1: print(1, len(i.split())) else: print(1, 1) ```
vfc_87277
{ "difficulty": "easy", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1764/A", "time_limit": "1 second" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7\n5\n1 3 2 2 4\n5\n1 2 3 4 5\n4\n2 1 2 1\n3\n2 3 3\n2\n2 2\n1\n1\n9\n9 8 5 2 1 1 2 3 3\n", "output": "1 5\n1 5\n1 4\n1 3\n1 2\n1 1\n1 9\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/PATHPAR
Solve the following coding problem using the programming language python: You are given an integer N. Let A be an N \times N grid such that A_{i, j} = i + N\cdot(j-1) for 1 ≤ i, j ≤ N. For example, if N = 4 the grid looks like: You start at the top left corner of the grid, i.e, cell (1, 1). You would like to reach th...
```python for _ in range(int(input())): (n, k) = map(int, input().split()) print('No' if n % 2 and (not k) else 'Yes') ```
vfc_87281
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/PATHPAR", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 0\n2 0\n2 1\n3 1\n", "output": "No\nYes\nYes\nYes\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1659/A
Solve the following coding problem using the programming language python: Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $n$ matches. In the end, it turned out Team Red won $r$ times and Team Blue won $b$ times. Team Blue was less skilled than ...
```python for n in [*open(0)][1:]: (n, r, b) = map(int, n.split()) b += 1 c = r // b * 'R' + 'B' print((('R' + c) * (r % b) + c * n)[:n]) ```
vfc_87285
{ "difficulty": "easy", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1659/A", "time_limit": "1 second" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n7 4 3\n6 5 1\n19 13 6\n", "output": "RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2\n", "out...
taco
verifiable_code
Solve the following coding problem using the programming language python: Hideyuki is allowed by his father Ujisato some 1000 yen bills every month for his pocket money. In the first day of every month, the number of bills is decided as follows. Ujisato prepares n pieces of m-sided dice and declares the cutback k. Hid...
```python import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools sys.setrecursionlimit(10 ** 7) inf = 10 ** 20 eps = 1.0 / 10 ** 10 mod = 998244353 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x) - 1 for x in sys...
vfc_87289
{ "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": "2 6 0\n2 6 3\n3 10 3\n13 3 27\n1 2008 3\n0 0 0", "output": "7.0000000000\n4.1111111111\n13.5010000000\n1.4290259878\n1001.5029880478\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 6 0\n...
taco
verifiable_code
https://codeforces.com/problemset/problem/725/A
Solve the following coding problem using the programming language python: In a new version of the famous Pinball game, one of the most important parts of the game field is a sequence of n bumpers. The bumpers are numbered with integers from 1 to n from left to right. There are two types of bumpers. They are denoted by...
```python n = int(input()) stro = input() ans = 0 x = 0 while stro[x] == '<' and x <= n - 1: x += 1 ans += 1 if x == n - 1 and stro[x] == '<': ans += 1 break if x >= n: break x = 1 while stro[-x] == '>' and x <= n: x += 1 ans += 1 if x == n and stro[-x] == '>': ans += 1 break if x > n: break print(a...
vfc_87298
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/725/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n<<><\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n>>>>>\n", "output": "5\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/979/E
Solve the following coding problem using the programming language python: Kuro has recently won the "Most intelligent cat ever" contest. The three friends then decided to go to Katie's home to celebrate Kuro's winning. After a big meal, they took a small break then started playing games. Kuro challenged Katie to crea...
```python (n, p) = map(int, input().split()) nums = [0] + list(map(int, input().split())) mod = 10 ** 9 + 7 f = [[[[0] * 2 for _ in range(2)] for _ in range(2)] for _ in range(n + 1)] _2 = [0] * (n + 1) _2[0] = 1 for i in range(1, n + 1): _2[i] = (_2[i - 1] << 1) % mod f[0][0][0][0] = 1 if nums[1] != 0: f[1][1][0][1]...
vfc_87306
{ "difficulty": "very_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/979/E", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 1\n-1 0 1\n", "output": "6", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 1\n1 0\n", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input":...
taco
verifiable_code
https://codeforces.com/problemset/problem/462/A
Solve the following coding problem using the programming language python: Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him? Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o'. Is it true that each ce...
```python n = int(input()) a = '' for i in range(n): b = input() a += b if a == a[::-1]: print('YES') else: print('NO') ```
vfc_87311
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/462/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\nxxo\nxox\noxx\n", "output": "YES\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Geeko is in worry now because exam is coming up and he has to know what rank he can get in exams. So he go back into the school records and finds the amazing pattern. He finds that if a student is having a current rank n than his rank i...
```python t = int(input()) for i in range(t): n = int(input()) res = n p = 2 while p**2 <= n: if n % p == 0: while n % p == 0: n /= p res -= res/p p += 1 if n > 1: res -= res/n print(res) ```
vfc_87315
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2000\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n49\n50\n51\n52\n53\n54\n55\n56\n57\n58\n59...
taco
verifiable_code
Solve the following coding problem using the programming language python: B-Mansion and courier Problem Statement Taro lives alone in a mansion. Taro, who loves studying, intends to study in his study in the house today. Taro can't concentrate outside the study, so he always studies in the study. However, on this d...
```python l_raw = input().split() l = [int(n) for n in l_raw] a_raw = input().split() a_ = [int(n) for n in a_raw] study = 0 state = 0 now = 0 for a in a_: if state == 0: if l[1] < a - now: study += a - now - l[1] now = a state = 1 elif state == 1: if 2 * l[1] < a - now: study += a - now - 2 * l[1] no...
vfc_87319
{ "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": "1 1 5\n6", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1 1 10\n6", "output": "8\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Dexter was good in finding the K th smallest number from a set of numbers. He thought he could solve any problem related to K th smallest number. His friend Pipi challenged him with a problem. He gave him various ranges of number, These numbers ...
```python t=eval(input()) while(t): n,q=list(map(int,input().split())) ran=[] l=[] for i in range(n): l=list(map(int,input().split())) ran.append(l) ran.sort() a=[0] b=[0] a[0]=ran[0][0] b[0]=ran[0][1] k=0 for i in range(1,n): if ran[i][0]>b[k]: k+=1 a.append(ran[i][0]) b.append(ran[i][1]) e...
vfc_87331
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "100\n10 30\n765 838\n64 816\n462 725\n440 903\n842 865\n495 735\n376 723\n177 800\n396 507\n257 433\n1417\n660\n1944\n1758\n1249\n1394\n622\n1892\n5\n341\n659\n1539\n660\n797\n685\n248\n1937\n1721\n1443\n920\n123\n1571\n485\n413\n1...
taco
verifiable_code
https://codeforces.com/problemset/problem/393/A
Solve the following coding problem using the programming language python: Alice likes word "nineteen" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string. For example, if she has string "xiineteenppnnnewtnee", she ca...
```python s = input() n = s.count('n') i = s.count('i') e = s.count('e') t = s.count('t') A = [] A.append(i) A.append(e // 3) A.append(t) m = min(A) if n > m * 3 - (m - 1): print(m) else: print(max(0, (n + 1) // (3 - 1) - 1)) ```
vfc_87335
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/393/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "nniinneetteeeenn\n", "output": "2", "type": "stdin_stdout" }, { "fn_name": null, "input": "nneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n", "output": "2", "type": "stdin_stdout" ...
taco
verifiable_code
https://www.hackerrank.com/challenges/direct-connections/problem
Solve the following coding problem using the programming language python: Enter-View $\left({\mbox{EV}}\right)$ is a linear, street-like country. By linear, we mean all the cities of the country are placed on a single straight line - the $\boldsymbol{x}$-axis. Thus every city's position can be defined by a single coor...
```python from bisect import bisect_left class Shell: def __init__(self, distances): self.size = sum(distances) self.list = distances self.elements = len(self.list) def __str__(self): return '({}, {})'.format(self.size, self.list) def FindValue(self, value): i = bisect_left(self.list, value) return i...
vfc_87339
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.hackerrank.com/challenges/direct-connections/problem", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 \n3 \n1 3 6 \n10 20 30 \n5 \n5 55 555 55555 555555 \n3333 333 333 33 35\n", "output": "280 \n463055586\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Now that you have won Code Monk and been hired by HackerEarth as a software engineer, you have been assigned to work on their wildly popular programming contest website. HackerEarth is expecting a lot of participants (P) in Code Monk next year,...
```python noc = eval(input()) cs = 0 while noc: noc -=1 cs += 1 l, p, c = list(map(int , input().split())) x = l k = 0 i = 0 while x < p: x *= c k+=1 while 1 << i < k : i+=1 print("Case #%d: %d" % (cs, i)) ```
vfc_87347
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n50 700 2\n19 57 3\n1 1000 2\n24 97 2", "output": "Case #1: 0\nCase #2: 2", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n19 57 3\n24 97 2", "output": "Case #1: 2\nCase #2: 0\nCas...
taco
verifiable_code
https://codeforces.com/problemset/problem/439/C
Solve the following coding problem using the programming language python: Devu being a small kid, likes to play a lot, but he only likes to play with arrays. While playing he came up with an interesting question which he could not solve, can you please solve it for him? Given an array consisting of distinct integers....
```python def solve(): (n, k, p) = map(int, input().split()) a = list(map(int, input().split())) even = list(filter(lambda x: x % 2 == 0, a)) odd = list(filter(lambda x: x % 2 == 1, a)) if (len(odd) - (k - p)) % 2 != 0: print('NO') return ans = [[] for _ in range(k)] for i in range(k - p): if odd: ans[i...
vfc_87359
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/439/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 5 3\n2 6 10 5 9\n", "output": "YES\n1 9\n1 5\n1 10\n1 6\n1 2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 5 3\n7 14 2 9 5\n", "output": "NO\n", "type": "stdin_stdout" ...
taco
verifiable_code
https://codeforces.com/problemset/problem/637/B
Solve the following coding problem using the programming language python: Polycarp is a big lover of killing time in social networks. A page with a chatlist in his favourite network is made so that when a message is sent to some friend, his friend's chat rises to the very top of the page. The relative order of the oth...
```python def print_in_order(stack): names_appeared = set() while stack: name = stack.pop() if not name in names_appeared: print(name) names_appeared.add(name) n = int(input()) stack = [] for _ in range(n): stack.append(input()) print_in_order(stack) ```
vfc_87363
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/637/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\nalex\nivan\nroman\nivan\n", "output": "ivan\nroman\nalex\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/disarium-number1045/1
Solve the following coding problem using the programming language python: Given a number N, find if it is Disarium or not. A number is called Disarium if sum of its digits powered with their respective positions is equal to the number itself. Output 1 if it's Disarium, and 0 if not. Example 1: Input: N = 89 Output: ...
```python class Solution: def isDisarium(self, N): summ = 0 k = 1 for i in str(N): summ += int(i) ** k k += 1 if summ == N: return 1 return 0 ```
vfc_87369
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/disarium-number1045/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 89", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 81", "output": "0", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/628/A
Solve the following coding problem using the programming language python: A tennis tournament with n participants is running. The participants are playing by an olympic system, so the winners move on and the losers drop out. The tournament takes place in the following way (below, m is the number of the participants o...
```python s = input() a = s.split() n = int(a[0]) b = int(a[1]) p = int(a[2]) t = n c = 1 sm = 0 while n != 1: while True: if c * 2 > n: break c *= 2 sm = sm + c // 2 + c * b n -= c // 2 c = 1 print(sm, t * p, end=' ') ```
vfc_87370
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/628/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 2 3\n", "output": "20 15\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "8 2 4\n", "output": "35 32\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Little Vaishnavi is bored during the vacation which is going on. Being the only little girl in the neighbourhood she did not have any one else to play with. Her parents are so strict that they will not let her out of the house even to see what t...
```python test = eval(input()) for _ in range(test): m, k = list(map(int, input().split(" "))) if m == 1: print(8*k) elif m == 2: if k%2 == 0: print(8*(k/2) + 1) else : print(8*(k/2 + 1) -1) elif m == 3: print(2 + 4*k) elif m == 4: if k%2 == 0: print(4*(k+1) -1) else: print(4*k +1) elif m ...
vfc_87374
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "100\n5 84\n5 78\n5 16\n5 94\n5 36\n5 87\n5 93\n5 50\n5 22\n5 63\n5 28\n5 91\n5 60\n5 64\n5 27\n5 41\n5 27\n5 73\n5 37\n5 12\n5 69\n5 68\n5 30\n5 83\n5 31\n5 63\n5 24\n5 68\n5 36\n5 30\n5 3\n5 23\n5 59\n5 70\n5 68\n5 94\n5 57\n5 12\...
taco
verifiable_code
Solve the following coding problem using the programming language python: Calculate the sum of the series : INPUT: First line contains the number of test cases t, for each test case a single line representing m and n with two space separated integers. OUTPUT: For each test case, a single line representing thee sum...
```python #user shivamzaz from math import * for t in range(int(input())): m, n = list(map(int, input().split())) p, q = 2**(m+n), 2**(n) print(str((p-1))+'/'+str((p*(q-1)))) ```
vfc_87378
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "21\n23 6\n15 10\n24 4\n15 16\n2 29\n22 24\n29 3\n17 11\n18 11\n16 12\n5 30\n5 24\n20 28\n10 3\n13 14\n10 6\n22 29\n3 27\n5 29\n13 5\n5 3", "output": "8589934591/1152921496016912384\n4294967295/70364449210368\n281474976710655/...
taco
verifiable_code
Solve the following coding problem using the programming language python: Xsquare get bored playing with the arrays all the time. So,he decided to buy a new character set to play with. Xsquare's character set contains only lower case alphabets more specifically characters from 'a' to 'z' (both inclusive). Xsquare was ...
```python def powermod(base, exponent, modulus): if (base < 1 or exponent < 0 or modulus < 1): return -1 result = 1 while (exponent > 0): if ((exponent % 2) == 1): result = (result * base) % modulus base = (base * base) % modulus exponent = int(exponent / 2) return result t = eval(input()) for i in rang...
vfc_87382
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n2\n15\n6\n5\n12\n1\n7\n9\n17\n2\n", "output": "26\n827062704\n17576\n17576\n308915776\n26\n456976\n11881376\n503630115\n26\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "100\n72713\n1...
taco
verifiable_code
https://www.codechef.com/problems/PRTAGN
Solve the following coding problem using the programming language python: You are given a set $S$ and $Q$ queries. Initially, $S$ is empty. In each query: - You are given a positive integer $X$. - You should insert $X$ into $S$. - For each $y \in S$ before this query such that $y \neq X$, you should also insert $y \op...
```python from sys import stdin, stdout def parity(n): return bin(n)[2:].count('1') % 2 t = int(stdin.readline()) for _ in range(t): x = [0, 0] s = set() n = int(stdin.readline()) for i in range(n): z = int(stdin.readline()) par = parity(z) if s == set(): x[par] += 1 s.add(z) elif z not in s: se ...
vfc_87386
{ "difficulty": "medium_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/PRTAGN", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n3\n4\n2\n7\n", "output": "0 1\n1 2\n3 4\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.hackerrank.com/challenges/isosceles-triangles/problem
Solve the following coding problem using the programming language python: Sevenkplus has a regular polygon. Each vertex of the polygon has a color, either white or black. Sevenkplus wants to count the number of isosceles triangles whose vertices are vertices of the regular polygon and have the same color. Input For...
```python def all(n): if n % 2 == 1: no = n * (n - 1) / 2 else: no = n * (n / 2 - 1) if n % 3 == 0: no -= n / 3 * 2 return no def non(a, n): if n % 2 == 1: s0 = s1 = 0 i = 0 while i < n: if a[i] == '0': s0 += 1 else: s1 += 1 i += 1 s = s0 * s1 * 6 if n % 3 == 0: n1 = n / 3 n...
vfc_87391
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.hackerrank.com/challenges/isosceles-triangles/problem", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n001\n0001\n10001\n111010\n1101010\n", "output": "Case 1: 0\nCase 2: 1\nCase 3: 1\nCase 4: 2\nCase 5: 3\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1622/B
Solve the following coding problem using the programming language python: Berland Music is a music streaming service built specifically to support Berland local artist. Its developers are currently working on a song recommendation module. So imagine Monocarp got recommended $n$ songs, numbered from $1$ to $n$. The $i...
```python for _ in range(int(input())): n = int(input()) p = list(map(int, input().split())) s = input() liked = [] disliked = [] for i in range(n): if s[i] == '1': liked.append([p[i], i]) else: disliked.append([p[i], i]) liked.sort() disliked.sort() perm = 1 final = [0] * n for _ in disliked: fi...
vfc_87395
{ "difficulty": "easy", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1622/B", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2\n1 2\n10\n3\n3 1 2\n111\n8\n2 3 1 8 5 4 7 6\n01110001\n", "output": "2 1\n3 1 2\n1 6 5 8 3 2 4 7\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n2\n1 2\n10\n7\n1 2 3 4 5 6 7\n01010...
taco
verifiable_code
https://codeforces.com/problemset/problem/1514/A
Solve the following coding problem using the programming language python: Given an array $a$ of length $n$, tell us whether it has a non-empty subsequence such that the product of its elements is not a perfect square. A sequence $b$ is a subsequence of an array $a$ if $b$ can be obtained from $a$ by deleting some (po...
```python from math import * for i in range(int(input())): n = int(input()) cnt = False l = list(map(int, input().split())) for el in l: af = el ** 0.5 if af - trunc(af) != 0: print('YES') cnt = True break if cnt: continue print('NO') ```
vfc_87399
{ "difficulty": "easy", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1514/A", "time_limit": "1 second" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3\n1 5 4\n2\n100 10000\n", "output": "YES\nNO\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n1\n1\n1\n2\n1\n3\n", "output": "NO\nYES\nYES\n", "type": "stdin_stdout" ...