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/959/E
Solve the following coding problem using the programming language python: Ehab is interested in the bitwise-xor operation and the special graphs. Mahmoud gave him a problem that combines both. He has a complete graph consisting of n vertices numbered from 0 to n - 1. For all 0 ≤ u < v < n, vertex u and vertex v are co...
```python a = 0 n = int(input()) - 1 for i in range(40): k = 1 << i a += (n + k) // (k * 2) * k print(a) ```
vfc_143700
{ "difficulty": "hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/959/E", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n", "output": "4", "type": "stdin_stdout" }, { "fn_name": null, "input": "10\n", "output": "21", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n", "...
taco
verifiable_code
https://codeforces.com/problemset/problem/549/G
Solve the following coding problem using the programming language python: Do you like summer? Residents of Berland do. They especially love eating ice cream in the hot summer. So this summer day a large queue of n Berland residents lined up in front of the ice cream stall. We know that each of them has a certain amoun...
```python import sys nLine = int(input()) nMoney = list(map(int, input().split())) invariante = [] for i in range(len(nMoney)): invariante.append(nMoney[i] + i) invariante.sort() res = [0] * nLine for i in range(nLine): res[i] = invariante[i] - i for i in range(nLine - 1): if res[i] > res[i + 1]: print(':(') ret...
vfc_143704
{ "difficulty": "hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/549/G", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n11 8\n", "output": "9 10 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n10 9 7 10 6\n", "output": ":(\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1622/C
Solve the following coding problem using the programming language python: You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$. In one step you can either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$); or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_...
```python from math import ceil from sys import stdin input = stdin.readline for _ in range(int(input())): (n, k) = map(int, input().split()) l = sorted(map(int, input().split()), reverse=True) (s, pref) = (sum(l), 0) ans = s - k for i in range(n - 1): pref += l[i] extra = s - pref + l[-1] * (i + 1) - k diff...
vfc_143709
{ "difficulty": "medium_hard", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1622/C", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1 10\n20\n2 69\n6 9\n7 8\n1 2 1 3 1 2 1\n10 1\n1 2 3 1 2 6 1 6 8 10\n", "output": "10\n0\n2\n7\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Estimating the Flood Risk Mr. Boat is the owner of a vast extent of land. As many typhoons have struck Japan this year, he became concerned of flood risk of his estate and he wants to know the average altitude of his land. The land is too vast ...
```python import os import sys def main(): (W, D, N) = read_ints() M = [tuple(read_ints()) for _ in range(N)] ans = solve(W, D, N, M) if ans is None: print('No') else: print(ans) def solve(W, D, N, M): INF = 999 H = [[INF] * W for _ in range(D)] hmap = {} for h in range(-210, 101): hmap[h] = set() for...
vfc_143713
{ "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": "5 4 2\n2 1 10\n5 4 3", "output": "No\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 5 2\n1 1 10\n5 4 3", "output": "150\n", "type": "stdin_stdout" }, { "fn_nam...
taco
verifiable_code
https://codeforces.com/problemset/problem/378/C
Solve the following coding problem using the programming language python: Pavel loves grid mazes. A grid maze is an n × m rectangle maze where each cell is either empty, or is a wall. You can go from one cell to another only if both cells are empty and have a common side. Pavel drew a grid maze with all empty cells f...
```python import random, math, sys from copy import deepcopy as dc from bisect import bisect_left, bisect_right from collections import Counter input = sys.stdin.readline def input_test(): (n, m, k) = map(int, input().strip().split(' ')) grid = [] for i in range(n): grid.append(list(input().strip())) def dfsUti...
vfc_143722
{ "difficulty": "medium_hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/378/C", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "19 20 196\n###.....##.#..#..##.\n####............##..\n###....#..#.#....#.#\n##....###......#...#\n.####...#.....#.##..\n.###......#...#.#.#.\n...##.#...#..#..#...\n.....#.....#..#....#\n.#.....##..#........\n.##....#......#....#\n...
taco
verifiable_code
https://codeforces.com/problemset/problem/414/A
Solve the following coding problem using the programming language python: It's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh. In this game Mashmokh writes sequence of n distinct integers on the board. Then Bimokh makes several (possibly zero) moves. On the first move he removes the ...
```python from __future__ import division, print_function import os import sys from io import BytesIO, IOBase def main(): (n, k) = [int(x) for x in input().split()] x = k - (n // 2 - 1) if x < 1 or (n < 2 and k > 0): print(-1) return sequence = [0] * n sequence[0] = x if n > 1: sequence[1] = 2 * x if n >=...
vfc_143726
{ "difficulty": "medium", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/414/A", "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 1257\n", "output": "1256 2512 2513 2514 ", "type": "stdin_stdout" }, { "fn_name": null, "input": "25095 2372924\n", "output": "2360378 4720756 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ...
taco
verifiable_code
https://www.hackerrank.com/challenges/coolguy-and-two-subsequences/problem
Solve the following coding problem using the programming language python: Coolguy gives you a simple problem. Given a $1$-indexed array, $\mbox{A}$, containing $N$ elements, what will $\textit{and}$ be after this pseudocode is implemented and executed? Print $and\%(10^9+7)$. //f(a, b) is a function that returns the m...
```python def smart(): left = [0] * (n + 2) right = [0] * (n + 2) singles = pairs = 0 ans = 0 def remove(k): nonlocal singles, pairs s = k * (k + 1) // 2 singles -= s pairs -= (k + 2) * (k + 1) * k * (k - 1) // 24 + s * singles def add(k): nonlocal singles, pairs s = k * (k + 1) // 2 pairs += (k +...
vfc_143734
{ "difficulty": "hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.hackerrank.com/challenges/coolguy-and-two-subsequences/problem", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3 2 1\n", "output": "6\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/XDS
Solve the following coding problem using the programming language python: Problem description. Winston and Royce love sharing memes with each other. They express the amount of seconds they laughed ar a meme as the number of ‘XD’ subsequences in their messages. Being optimization freaks, they wanted to find the string ...
```python import sys from math import * t = int(input()) while t: l = [] f = [] s = '' n = int(input()) if sqrt(n) % 1.0 == 0: y = sqrt(n) for x in range(int(y)): l.append('X') for x in range(int(y)): l.append('D') s = ''.join(l) else: count = 0 for x in range(1, int(sqrt(n)) + 3): if x ** 2 ...
vfc_143738
{ "difficulty": "medium_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/XDS", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n9\n", "output": "XXXDDD\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: My flatmate, Sayan, once invited all his relatives and friends from all over the city to join him on his birthday party. He is also famous for boasting that all his friends and relatives belong to "proper" families. Now, he appointed a gaurd to ...
```python def isSumInSubset(inputSet, n, m): T = [] for i in range(0, n+1): col = [] for j in range(0, m+1): col.append(False) T.append(col) for i in range(0,n+1): T[i][0] = True for i in range(1,m+1): T[0][i] = False for i in range(1,n+1): for j in range(1,m+1): if j < inputSet[i-1]: T[i][j...
vfc_143742
{ "difficulty": "hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n321 920\n1 2 3 4 5 6 7 8 9 10 11 13 14 15 18 19 20 21 22 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 ...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/linked-list-that-is-sorted-alternatingly/1
Solve the following coding problem using the programming language python: Given a Linked list of size N, the list is in alternating ascending and descending orders. Sort the given linked list in non-decreasing order. Example 1: Input: LinkedList: 1->9->2->8->3->7 Output: 1 2 3 7 8 9 Explanation: After sorting the gi...
```python def sort(h1): l = [] temp1 = h1 while temp1: l.append(temp1.data) temp1 = temp1.next j = 0 l.sort() temp = h1 while temp: temp.data = l[j] j += 1 temp = temp.next return h1 ```
vfc_143746
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/linked-list-that-is-sorted-alternatingly/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "LinkedList:1->9->2->8->3->7", "output": "1 2 3 7 8 9", "type": "stdin_stdout" }, { "fn_name": null, "input": "LinkedList:13->99->21->80->50", "output": "13 21 50 80 99", "type": "stdin_st...
taco
verifiable_code
Solve the following coding problem using the programming language python: You are given a N x N square matrix of integers where each cell represents the amount of gold in it. You need to travel from the top left cell to the bottom right cell, and back, maximizing the amount of gold you collect as you pass by the cell ...
```python def main(): n = eval(input()) w = [] v = [] for i in range(n): st = input() spl = st.split() w.append([]) v.append([]) for j in range(n): w[i].append(int(spl[j])) v[i].append(-999999999) q = [] s = 0 q.append((0,1)) v[0][0] = w[0][0] for i in q: x, y = i[0] , i...
vfc_143755
{ "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\n5 11 4 6\n3 2 10 3\n1 3 1 3\n4 2 8 8", "output": "67", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\n5 11 4 60\n3 2 10 3\n10 13 1 3\n4 2 8 8", "output": "135", "type": "std...
taco
verifiable_code
https://codeforces.com/problemset/problem/1406/A
Solve the following coding problem using the programming language python: Given a set of integers (it can contain equal elements). You have to split it into two subsets $A$ and $B$ (both of them can contain equal elements or be empty). You have to maximize the value of $mex(A)+mex(B)$. Here $mex$ of a set denotes th...
```python for _ in range(int(input())): n = int(input()) a = sorted(list(map(int, input().split()))) (A, B) = (0, 0) for i in a: if A == i: A += 1 elif B == i: B += 1 print(A + B) ```
vfc_143759
{ "difficulty": "easy", "memory_limit": "512 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1406/A", "time_limit": "1 second" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n6\n0 2 1 5 0 1\n3\n0 1 2\n4\n0 2 0 1\n6\n1 2 3 4 5 6\n", "output": "5\n3\n4\n0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "15\n1\n0\n1\n1\n2\n0 0\n2\n0 1\n2\n1 1\n2\n0 2\n2\n1 2\n3\...
taco
verifiable_code
Solve the following coding problem using the programming language python: curtain Summer is coming soon. You decide to redecorate your room for the summer. It is expected that the sun will be very strong this summer, and it will be a difficult season for you who are not good at dazzling. So you thought about installi...
```python from collections import defaultdict INF = 10 ** 9 while 1: N = int(input()) if N == 0: break P = [list(map(int, input().split())) for i in range(N)] S = defaultdict(list) X = set() x0 = y0 = INF x1 = y1 = -INF for i in range(4): (x, y) = map(int, input().split()) x0 = min(x0, x) x1 = max(x1, x...
vfc_143767
{ "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": "4\n0 0\n10 0\n10 10\n0 10\n0 0\n5 0\n5 10\n0 10\n6\n0 0\n10 0\n10 5\n5 5\n5 10\n0 10\n2 0\n8 0\n8 10\n2 10\n12\n1 1\n1 3\n-1 3\n-1 1\n-3 1\n-3 -1\n-1 -1\n-1 -3\n1 -3\n1 -1\n3 -1\n3 1\n2 2\n-2 2\n-2 -2\n2 -2\n4\n20000 20000\n-20000 ...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/charul-and-vessels0209/1
Solve the following coding problem using the programming language python: Charul has been given a task by Ishaan. He challenges him to fill a large container of capacity K liters. Charul has N vessels with him with different capacities. The capacities of the vessels are given by an array A. The condition is that the c...
```python def vessel(arr, n, k): store = set([k]) for item in arr: temp = set() for num in store: while num - item >= 0: num -= item temp.add(num) if 0 in temp: return True store.update(temp) return False ```
vfc_143771
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/charul-and-vessels0209/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": "vessel", "input": "arr[ ] = {6, 3, 4, 2, 1} and K = 20", "output": "1", "type": "function_call" }, { "fn_name": "vessel", "input": "arr[] = {2, 4, 3} and K = 15", "output": "1", "type": "function_call" ...
taco
verifiable_code
https://www.hackerrank.com/challenges/itertools-combinations/problem
Solve the following coding problem using the programming language python: itertools.combinations(iterable, r) This tool returns the $\textbf{r}$ length subsequences of elements from the input iterable. Combinations are emitted in lexicographic sorted order. So, if the input iterable is sorted, the combination tuple...
```python from itertools import combinations (S, l) = input().split(' ') l = int(l) S = sorted(S) for i in range(l): C = list(combinations(S, i + 1)) for c in C: print(''.join(c)) ```
vfc_143780
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.hackerrank.com/challenges/itertools-combinations/problem", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "HACK 2\n", "output": "A\nC\nH\nK\nAC\nAH\nAK\nCH\nCK\nHK\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.hackerrank.com/challenges/sherlock-and-cost/problem
Solve the following coding problem using the programming language python: In this challenge, you will be given an array $\mbox{B}$ and must determine an array $\mbox{A}$. There is a special rule: For all $\boldsymbol{i}$, $A[i]\leq B[i]$. That is, $A[i]$ can be any number you choose such that $1\leq A[i]\leq B[i]$....
```python def cost(B): (c0, c1) = (0, 0) for i in range(1, len(B)): (c0, c1) = (max(c0, c1 + B[i - 1] - 1), max(c0 + B[i] - 1, c1 + abs(B[i] - B[i - 1]))) return max(c0, c1) T = int(input()) for _ in range(T): N = int(input()) B = [int(_) for _ in input().strip().split()] print(cost(B)) ```
vfc_143794
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.hackerrank.com/challenges/sherlock-and-cost/problem", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n5\n10 1 10 1 10\n", "output": "36\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/430/D
Solve the following coding problem using the programming language python: Summer is coming! It's time for Iahub and Iahubina to work out, as they both want to look hot at the beach. The gym where they go is a matrix a with n lines and m columns. Let number a[i][j] represents the calories burned by performing workout a...
```python (n, m) = map(int, input().split()) a = [] for i in range(n): a.append(list(map(int, input().split()))) dpa = [[[0, 0] for i in range(m + 2)] for i in range(n + 2)] dpb = [[[0, 0] for i in range(m + 2)] for i in range(n + 2)] ans = 0 for i in range(1, n + 1): for j in range(1, m + 1): dpa[i][j][0] = max(dp...
vfc_143798
{ "difficulty": "medium_hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/430/D", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3\n0 0 0\n0 10000 0\n0 0 0\n", "output": "0\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/PCJ18G
Solve the following coding problem using the programming language python: Chef's pizza is the tastiest pizza to exist, and the reason for that is his special, juicy homegrown tomatoes. Tomatoes can be grown in rectangular patches of any side lengths. However, Chef only has a limited amount of land. Consider the enti...
```python import numpy as np import math import sys import time MOD = 1000000007 def stack(n, x, l): return x * l * (l + 1) * (x + 2 * n + 1) // 4 % MOD def heightsGen(n): (lengths, heights) = ([1], [n]) for i in range(2, int(math.sqrt(n)) + 1): h = n // i if h == heights[-1]: lengths[-1] == i else: he...
vfc_143802
{ "difficulty": "very_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/PCJ18G", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n4\n10000000000\n", "output": "23\n227374950\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/676/E
Solve the following coding problem using the programming language python: 100 years have passed since the last victory of the man versus computer in Go. Technologies made a huge step forward and robots conquered the Earth! It's time for the final fight between human and robot that will decide the faith of the planet. ...
```python (n, k) = map(int, input().split()) a = [] for i in range(n + 1): a.extend(input().split()) if k == 0: if a[0] == '0': print('Yes') elif a[0] == '?' and (n - a.count('?')) % 2 == 0: print('Yes') else: print('No') elif '?' in a: if n % 2 == 0: print('No') else: print('Yes') else: a = list(map(i...
vfc_143806
{ "difficulty": "very_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/676/E", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 2\n-1\n?\n", "output": "Yes\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2 100\n-10000\n0\n1\n", "output": "Yes", "type": "stdin_stdout" }, { "fn_name": null...
taco
verifiable_code
Solve the following coding problem using the programming language python: B: Pivots problem Given a permutation of length N, a_1, a_2, ..., a_N, which is a permutation of integers from 1 to N. Also, Q queries are given in order for this permutation. In the i-th query, you have to do the following: * The value q_i (...
```python def inpl(): return list(map(int, input().split())) (N, _) = inpl() A = inpl() if N == 1: print(*A) exit() L = [0] * (N + 1) R = [0] * (N + 1) for i in range(N - 1): R[A[i]] = A[i + 1] L[A[i + 1]] = A[i] lm = A[0] rm = A[-1] for q in inpl(): if q == rm: l = L[q] R[l] = 0 L[q] = 0 R[q] = lm L[lm...
vfc_143810
{ "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 2\n1 5 3 2 4\n5 3", "output": "2 4 5 1 3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5 0\n1 5 3 2 4\n5 3", "output": "1 5 3 2 4\n", "type": "stdin_stdout" }, { ...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/pattern-searching5231/1
Solve the following coding problem using the programming language python: Given a string str and a pattern pat. You need to check whether the pattern is present or not in the given string. Example 1:- Input: 2 abcdefh bcd axzy xy Output: Present Not present Your task: You need to complete the function searchPattern...
```python def searchPattern(st, pat): if pat in st: return True else: return False ```
vfc_143814
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/pattern-searching5231/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": "searchPattern", "input": "2\r\nabcdefh\r\nbcd\r\naxzy\r\nxy", "output": "Present\nNot present", "type": "function_call" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Example Input 3 NNN NNN NNN Output Taro The input will be stdin and you should print your solution to stdout Now solve the problem and return the code.
```python from collections import deque import sys sys.setrecursionlimit(10 ** 6) readline = sys.stdin.readline write = sys.stdout.write def solve(): N = int(readline()) G = [[] for i in range(N)] for i in range(N): (*vs,) = readline() for j in range(N): if vs[j] == 'Y': G[i].append(j) d = 0 C = [0, 0]...
vfc_143815
{ "difficulty": "unknown_difficulty", "memory_limit": "134.217728 megabytes", "memory_limit_bytes": null, "problem_url": null, "time_limit": "8.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\nNNN\nNNO\nNNN", "output": "Taro\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\nNMN\nNNO\nNNN", "output": "Taro\n", "type": "stdin_stdout" }, { "fn_name": n...
taco
verifiable_code
https://www.codechef.com/ARYS2020/problems/BDYGFT
Solve the following coding problem using the programming language python: Vishal Wants to buy 2 gifts for his best friend whose name is Annabelle(her age is 20), So they both went for shopping in a store. But Annabelle gave, Vishal a condition that she will accept this gifts only when the total price of the gifts is t...
```python test = int(input()) ANS = list() for i in range(test): n = int(input()) items = sorted(list(map(int, input().split()))) c = 1 for j in range(len(items)): if items[j] < 2000: t = 2000 - items[j] if t in items[j + 1:]: ANS.append('Accepted') c = 2 break else: pass else: break...
vfc_143820
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/ARYS2020/problems/BDYGFT", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n5\n10 2 1000 50 1000\n", "output": "Accepted\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.hackerrank.com/challenges/prime-digit-sums/problem
Solve the following coding problem using the programming language python: Chloe is fascinated by prime numbers. She came across the number $283002$ on a sign and, though the number is not prime, found some primes hiding in it by using the following rules: Every three consecutive digits sum to a prime: $\underbrace{...
```python from itertools import product from collections import defaultdict import sys M = 1000000007 p = set([2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43]) def good(a, b, c, d, e): if not a + b + c in p: return False if not b + c + d in p: return False if not c + d + e in p: return False if not a + b...
vfc_143824
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.hackerrank.com/challenges/prime-digit-sums/problem", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n6\n", "output": "95\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: The palindrome is a string that can be read the same way from left to right and from right to left. For example, strings "hanah", "2332" are palindromes, however the string "rahul" is not a palindrome. We define "Easy String" if it has an even...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' n = int(input()) i = 0 while (i < n): tc = int(input()) if (tc % 2 == 0): print(tc) else: print(tc - 1) i = i + 1 ```
vfc_143832
{ "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\n2\n4\n", "output": "2\n4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10000\n41\n18467\n6334\n26500\n19169\n15724\n11478\n29358\n26962\n24464\n5705\n28145\n23281\n16827\n9961\n491\n2...
taco
verifiable_code
https://codeforces.com/problemset/problem/1060/B
Solve the following coding problem using the programming language python: You are given a positive integer $n$. Let $S(x)$ be sum of digits in base 10 representation of $x$, for example, $S(123) = 1 + 2 + 3 = 6$, $S(0) = 0$. Your task is to find two integers $a, b$, such that $0 \leq a, b \leq n$, $a + b = n$ and $S...
```python def digisum(n): sum = 0 while n != 0: sum += n % 10 n = n // 10 return sum def give9(n): num9 = 0 while n >= 10: num9 = num9 * 10 + 9 n = n // 10 return num9 def method3(n): a = give9(n) b = n - a return digisum(a) + digisum(b) n = int(input()) print(method3(n)) ```
vfc_143836
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1060/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "35\n", "output": "17\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "10000000000\n", "output": "91\n", "type": "stdin_stdout" }, { "fn_name": null, "input":...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/mr-modulo-and-arrays2827/1
Solve the following coding problem using the programming language python: Mr. Modulo lives up to his name and is always busy taking modulo of numbers and making new problems. Now he comes up with another problem. He has an array of integers with n elements and wants to find a pair of elements {arr[i], arr[j]} such tha...
```python from bisect import bisect_left def maxModValue(arr, n): arr.sort() ans = 0 for i in range(n): for j in range(2 * arr[i], arr[i] + arr[n - 1], arr[i]): ind = bisect_left(arr, j) - 1 ans = max(ans, arr[ind] % arr[i]) return ans ```
vfc_143844
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/mr-modulo-and-arrays2827/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": "maxModValue", "input": "n=3\narr[] = {3, 4, 7}", "output": "3", "type": "function_call" }, { "fn_name": "maxModValue", "input": "n=4\narr[] = {4, 4, 4, 4}", "output": "0", "type": "function_call" } ...
taco
verifiable_code
https://www.codechef.com/problems/FRIMEET
Solve the following coding problem using the programming language python: Chef and his friend is standing on the X-axis at the points X_{1} and X_{2} respectively. Chef moves one step forward each second (that is he moves to X_{1} + 1 after the 1^{st} second, X_{1} + 2 after the 2^{nd} second, and so on), whereas hi...
```python for _ in range(int(input())): (x1, x2) = map(int, input().split()) print('YES' if x2 <= x1 else 'NO') ```
vfc_143846
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/FRIMEET", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 1\n1 7\n7 1\n", "output": "YES\nNO\nYES", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/70/A
Solve the following coding problem using the programming language python: Fangy collects cookies. Once he decided to take a box and put cookies into it in some way. If we take a square k × k in size, divided into blocks 1 × 1 in size and paint there the main diagonal together with cells, which lie above it, then the p...
```python import math print(math.ceil(3 ** (int(input()) - 1)) % 1000003) ```
vfc_143852
{ "difficulty": "easy", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/70/A", "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "696\n", "output": "695035\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "6\n", "output": "243\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "92...
taco
verifiable_code
https://codeforces.com/problemset/problem/909/E
Solve the following coding problem using the programming language python: You are given a program you want to execute as a set of tasks organized in a dependency graph. The dependency graph is a directed acyclic graph: each task can depend on results of one or several other tasks, and there are no directed circular de...
```python from sys import stdin from collections import deque (n, m) = [int(x) for x in stdin.readline().split()] e = [int(x) for x in stdin.readline().split()] graph = [set() for x in range(n)] reverse = [set() for x in range(n)] root = set([x for x in range(n)]) for edge in range(m): (a, b) = [int(x) for x in stdin....
vfc_143856
{ "difficulty": "hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/909/E", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 3\n0 1 0 1\n0 1\n1 2\n2 3\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 3\n1 1 1 0\n0 1\n0 2\n3 0\n", "output": "1\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/797/A
Solve the following coding problem using the programming language python: Given a positive integer n, find k integers (not necessary distinct) such that all these integers are strictly greater than 1, and their product is equal to n. Input The first line contains two integers n and k (2 ≤ n ≤ 100000, 1 ≤ k ≤ 20). O...
```python from math import sqrt dic = {} def kfact(n, k): if (n, k) in dic: return dic[n, k] if k == 1: return [n] for i in range(2, int(sqrt(n)) + 1): if n % i == 0: if kfact(n // i, k - 1): result = [i] + kfact(n // i, k - 1) dic[n, k] = result return result return None def wrapper(n, k): ...
vfc_143860
{ "difficulty": "easy", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/797/A", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "15 6\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "13 3\n", "output": "-1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "355...
taco
verifiable_code
https://codeforces.com/problemset/problem/50/D
Solve the following coding problem using the programming language python: The commanding officers decided to drop a nuclear bomb on the enemy's forces. You are ordered to determine the power of the warhead that needs to be used. The enemy has N strategically important objects. Their positions are known due to the int...
```python import math n = int(input()) (k, epsilon) = list(map(int, input().split(' '))) (x0, y0) = list(map(int, input().split(' '))) epsilon /= 1000.0 l = [] for i in range(n): l.append(list(map(int, input().split(' ')))) d = sorted([(p[0] - x0) ** 2 + (p[1] - y0) ** 2 for p in l]) rmin = 0 rmax = math.sqrt(d[k - 1]...
vfc_143864
{ "difficulty": "hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/50/D", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2 17\n0 0\n1 0\n35 27\n0 5\n", "output": "4.957678079335892\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "12\n10 186\n-267 -417\n-410 930\n-354 852\n-132 -613\n-342 356\n212 220\n319 ...
taco
verifiable_code
https://codeforces.com/problemset/problem/31/B
Solve the following coding problem using the programming language python: Email address in Berland is a string of the form A@B, where A and B are arbitrary strings consisting of small Latin letters. Bob is a system administrator in «Bersoft» company. He keeps a list of email addresses of the company's staff. This li...
```python def main(): string = input() comps = string.split('@') ans = [] if '@' not in string: print('No solution') return for i in range(len(comps)): if i == 0 or i == len(comps) - 1: if len(comps[i]) < 1: print('No solution') return elif len(comps[i]) < 2: print('No solution') return i...
vfc_143870
{ "difficulty": "medium", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/31/B", "time_limit": "0.5 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "a@mc@ks@gu@rl@gq@zq@iz@da@uq@mi@nf@zs@hi@we@ej@ke@vb@az@yz@yl@rr@gh@um@nv@qe@qq@de@dy@op@gt@vx@ak@q\n", "output": "a@m,c@k,s@g,u@r,l@g,q@z,q@i,z@d,a@u,q@m,i@n,f@z,s@h,i@w,e@e,j@k,e@v,b@a,z@y,z@y,l@r,r@g,h@u,m@n,v@q,e@q,q@d,e@...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/466faca80c3e86f13880710491c634d26abd44a7/1
Solve the following coding problem using the programming language python: Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the conse...
```python class Solution: def removePair(self, S): s = [] for i in S: if s and s[-1] == i: s.pop() else: s.append(i) if len(s) == 0: return -1 else: return ''.join(s) ```
vfc_143874
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/466faca80c3e86f13880710491c634d26abd44a7/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "aaabbaaccd", "output": "ad", "type": "stdin_stdout" }, { "fn_name": null, "input": "aaaa", "output": "Empty String", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/254/B
Solve the following coding problem using the programming language python: In 2013, the writers of Berland State University should prepare problems for n Olympiads. We will assume that the Olympiads are numbered with consecutive integers from 1 to n. For each Olympiad we know how many members of the jury must be involv...
```python (w, r) = (open('output.txt', 'w'), open('input.txt', 'r')) (s, y) = ([0] * 466, [0, 100, 131, 159, 190, 220, 251, 281, 312, 343, 373, 404, 434]) for i in range(int(r.readline())): (m, d, p, t) = map(int, r.readline().split()) x = y[m] + d s[x] -= p s[x - t] += p for i in range(465): s[i + 1] += s[i] w.wr...
vfc_143875
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/254/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5 23 1 2\n3 13 2 3\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n12 9 2 1\n12 8 1 3\n12 8 2 2\n", "output": "3\n", "type": "stdin_stdout" }, { ...
taco
verifiable_code
https://www.codechef.com/problems/LOWSUM
Solve the following coding problem using the programming language python: Read problems statements in Russian here The Head Chef is studying the motivation and satisfaction level of his chefs . The motivation and satisfaction of a Chef can be represented as an integer . The Head Chef wants to know the N th smallest...
```python t = int(input()) for _ in range(t): (k, q) = map(int, input().split()) motivation = sorted(list(map(int, input().split()))) satisfaction = sorted(list(map(int, input().split()))) ans = [] for i in range(min(len(motivation), 10000)): for j in range(min(len(satisfaction), 10000 // (i + 1))): ans.appen...
vfc_143879
{ "difficulty": "very_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/LOWSUM", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n3 1\n1 2 3\n4 5 6\n4", "output": "7", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/COLE2016/problems/CLBMUP
Solve the following coding problem using the programming language python: Batman is about to face Superman so he decides to prepare for the battle by upgrading his Batmobile. He manufactures multiple duplicates of his standard Batmobile each tweaked in a different way such that the maximum speed of each is never less ...
```python t = int(input()) while t: n = int(input()) ar = list(map(int, input().strip().split(' '))) print(len([x for x in ar[1:len(ar)] if ar[0] < x])) t -= 1 ```
vfc_143883
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/COLE2016/problems/CLBMUP", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n4\n1 2 3 4 5\n5\n1 10 100 1000 10000 100000\n", "output": "4\n5\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/86/A
Solve the following coding problem using the programming language python: For each positive integer n consider the integer ψ(n) which is obtained from n by replacing every digit a in the decimal notation of n with the digit (9 - a). We say that ψ(n) is the reflection of n. For example, reflection of 192 equals 807. No...
```python def ref(n): return int(''.join([str(9 - int(x)) for x in str(n)])) (l, r) = map(int, input().split()) ans = 0 ans = max(ans, ref(l) * l) ans = max(ans, ref(r) * r) cur = 5 for i in range(20): if l <= cur <= r: ans = max(ans, ref(cur) * cur) cur *= 10 print(ans) ```
vfc_143888
{ "difficulty": "medium_hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/86/A", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "850 629417171\n", "output": "249999999500000000\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3722 867350896\n", "output": "249999999500000000\n", "type": "stdin_stdout" ...
taco
verifiable_code
https://www.codechef.com/problems/TLG
Solve the following coding problem using the programming language python: The game of billiards involves two players knocking 3 balls around on a green baize table. Well, there is more to it, but for our purposes this is sufficient. The game consists of several rounds and in each round both players obtain a score, bas...
```python n = int(input()) p1 = [] p2 = [] (a, b) = (0, 0) for i in range(n): (s, t) = map(int, input().split(' ')) a += s b += t if a > b: p1.append(a - b) p2.append(0) else: p2.append(b - a) p1.append(0) if max(p1) > max(p2): print('1', max(p1), end=' ') else: print('2', max(p2), end=' ') ```
vfc_143892
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/TLG", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n140 82\n89 134\n90 110\n112 106\n88 90\n", "output": "1 58\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n140 82\n89 134\n90 110\n177 106\n88 90", "output": "1 64\n", "t...
taco
verifiable_code
Solve the following coding problem using the programming language python: Aka Beko, trying to escape from 40 bandits, got lost in the city of A. Aka Beko wants to go to City B, where the new hideout is, but the map has been stolen by a bandit. Kobborg, one of the thieves, sympathized with Aka Beko and felt sorry for ...
```python import sys def solve(s): path = {'A': {'0': 'X', '1': 'Y'}, 'B': {'0': 'Y', '1': 'X'}, 'W': {'0': 'B', '1': 'Y'}, 'X': {'0': None, '1': 'Z'}, 'Y': {'0': 'X', '1': None}, 'Z': {'0': 'W', '1': 'B'}} pos = 'A' for ch in s: pos = path[pos][ch] if pos is None: return 'No' return 'Yes' if pos == 'B' els...
vfc_143896
{ "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": "0100\n0101\n10100\n01000\n0101011\n0011\n011110\n#", "output": "Yes\nNo\nYes\nNo\nYes\nNo\nNo\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "0100\n1101\n10100\n11000\n0001011\n0011\n01111...
taco
verifiable_code
Solve the following coding problem using the programming language python: Solve the mystery. INPUT : First line contains T No. of test cases. Each test case contains two lines. First line contains two space separated integers ( N and K). Second line contains N space separated integers A [i]. OUTPUT : Print the sol...
```python t = eval(input()) while t>0: t-=1 n, k = list(map(int, input().split())) a = list(map(int, input().split())) a.sort() print(a[k-1]) ```
vfc_143902
{ "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\n74 45\n6182 9670 28431 30442 17832 12848 32575 18761 23544 1077 4754 6767 20845 19039 10423 2395 11995 30918 31156 28940 6673 14726 29831 31894 27046 16752 4365 16756 9718 23808 31012 21536 7015 18831 19724 2785 25073 11978 181...
taco
verifiable_code
Solve the following coding problem using the programming language python: A positive integer may be expressed as a sum of different prime numbers (primes), in one way or another. Given two positive integers n and k, you should count the number of ways to express n as a sum of k different primes. Here, two ways are con...
```python primes = [] flag = [0 for i in range(1121)] for i in range(2, 1121): if flag[i] == 0: primes.append(i) count = 2 while i * count < 1121: flag[i * count] = 1 count += 1 dp = [[0 for i in range(15)] for j in range(1121)] dp[0][0] = 1 for p in primes: for k in range(13, -1, -1): for n in range(1121):...
vfc_143907
{ "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": "24 3\n24 2\n2 1\n1 1\n4 2\n18 3\n17 1\n17 3\n17 4\n110 5\n1000 10\n1120 14\n0 0", "output": "2\n3\n1\n0\n0\n2\n1\n0\n1\n79\n200102899\n2079324314\n", "type": "stdin_stdout" }, { "fn_name": null, "inp...
taco
verifiable_code
https://www.codechef.com/problems/JGAMES
Solve the following coding problem using the programming language python: Janmansh and Jay are playing a game. They start with a number X and they play a total of Y moves. Janmansh plays the first move of the game, after which both the players make moves alternatingly. In one move, a player can increment or decremen...
```python num = int(input()) for i in range(num): n1 = list(map(int, input().split(' '))) if sum(n1) % 2 == 0: print('Janmansh') else: print('Jay') ```
vfc_143911
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/JGAMES", "time_limit": "0.5 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2 2\n4 3\n", "output": "Janmansh\nJay\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/ADJSUMPAR
Solve the following coding problem using the programming language python: Chef has an array A of length N. Chef forms a binary array B of length N using the parity of the sums of adjacent elements in A. Formally, B_{i} = (A_{i} + A_{i+1}) \, \% \, 2 for 1 ≤ i ≤ N - 1 B_{N} = (A_{N} + A_{1}) \, \% \, 2 Here x \, \% ...
```python for i in range(int(input())): a = int(input()) s = input() c = s.count('1') if c % 2 == 0: print('YES') else: print('NO') ```
vfc_143915
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/ADJSUMPAR", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n2\n0 0\n2\n1 0\n4\n1 0 1 0\n3\n1 0 0\n", "output": "YES\nNO\nYES\nNO\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Lexicographical order is a generalization of the way the alphabetical order of words is based on the alphabetical order of their component letters. An example of lexicographical arrangement is a dictionary or a contact directory. You are given ...
```python import re romanNumeralMap = (('M', 1000), ('CM', 900), ('D', 500), ('CD', 400), ('C', 100), ('XC', 90), ('L', 50), ('XL', 40), ('X', 10), ('IX', 9), ('V', 5), ('IV', 4), ('I', 1)) romanNumeralPattern = re.compile(""" ^ # beginning of string M{0,4} # th...
vfc_143919
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "Bruce XXII\nHenri XX\nMaru XXXVI\nPhilippe XL\nLou XVI\nLovro XVI\nKubus XXXII\nMaru XXXIX\nBob XXXVIII\nRichard XXXIX\nCarlos II\nJames XXXIII\nAnne XXIV\nAnne XXVI\nPhilip XLVII\nIlya III\nKubus XLII\nJulka XIX\nMary XLVII\nLukas...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/greater-on-right-side4305/1
Solve the following coding problem using the programming language python: You are given an array Arr of size N. Replace every element with the next greatest element (greatest element on its right side) in the array. Also, since there is no element next to the last element, replace it with -1. Example 1: Input: N = 6 A...
```python class Solution: def nextGreatest(self, arr, n): for i in range(n - 1, -1, -1): temp = arr[i] arr[i] = arr[n - 1] if temp >= arr[n - 1]: arr[n - 1] = temp arr[n - 1] = -1 return arr ```
vfc_143923
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/greater-on-right-side4305/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 6\nArr[] = {16, 17, 4, 3, 5, 2}", "output": "17 5 5 5 2 -1", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 4\nArr[] = {2, 3, 1, 9}", "output": "9 9 9 -1", "type": "stdin_...
taco
verifiable_code
Solve the following coding problem using the programming language python: Chandu and Kundu are bored of dramatic games around. As they are very good friends and scholars they decided to discover a new game. In total they had N number of marbles with value inscribed on each of them from 1 to N. Chandu being from roy...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' import sys while True: line = sys.stdin.readline() if not line: break marble_num = int(line.strip()) marble_stack = [] cont_stack = [] for i in range(1, marble_num): ...
vfc_143924
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "85\n25 43 35 23 9 3 38 28 29 1 7 18 36 37 12 32 5 41 17 13 19 26 14 8 10 16 21 33 11 39 2 27 15 40 30 22 20 34 31 42 4 6 24\n75\n16 23 42 8 2 27 24 5 17 19 20 28 38 30 21 4 43 44 34 31 12 35 39 22 11 7 6 45 14 32 9 15 36 10 26 29 3...
taco
verifiable_code
https://www.hackerrank.com/challenges/long-permutation/problem
Solve the following coding problem using the programming language python: 、Consider an inifite array, $a$, of positive numbers, $a_1,a_2,\ldots$, where each $a_i=i$. You can apply a permutation, ${p}$, of size $n$ (i.e., $n$ different numbers $1\leq p_1,\ldots,p_n\leq n$) to the $n$-element subset of your array from $...
```python (n, m) = map(int, input().split()) (*p,) = map(lambda x: int(x) - 1, input().split()) p = p[1:] + p[:1] order = [] idx = n - 1 while p[idx] != -1: order.append(p[idx]) tmp = p[idx] p[idx] = -1 idx = tmp if m > len(order): print(m + (n - len(order))) else: print(order[m - 1] + 1) ```
vfc_143928
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.hackerrank.com/challenges/long-permutation/problem", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 10\n2 1\n", "output": "11\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/TICKETS5
Solve the following coding problem using the programming language python: Every day, Mike goes to his job by a bus, where he buys a ticket. On the ticket, there is a letter-code that can be represented as a string of upper-case Latin letters. Mike believes that the day will be successful in case exactly two different ...
```python for _ in range(int(input())): s = input() ls = set() for i in s: ls.add(i) if len(ls) != 2: print('NO') else: print('YES') ```
vfc_143932
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/TICKETS5", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\nABABAB\nABC\n", "output": "YES\nNO\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: The CS & IT Department students have been facing tough competitions from each other since ages, in being the best in research & innovation. This time CS Department is taken the edge over IT Department by designing a special weather predictor dev...
```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): D=input() A=input() opp=0 l=[] if len(D)==len(A): for i in range(0,len(D)): if A[i]!=D[i]: opp+=1 print(opp...
vfc_143936
{ "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\nTOPCODER\nKODER\nONLYPROGRAMMINGPLATFORMHACKEREARTHININDIAISTHEBEST\nHABKRTEARGH", "output": "4\n3", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\nMBNMVBDSJFHDFJDHFAKFHAKLFHFLKFURIFRFR...
taco
verifiable_code
https://codeforces.com/problemset/problem/92/D
Solve the following coding problem using the programming language python: There are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginning of the queue. The i-th walrus has the age equal ...
```python from bisect import bisect_left n = int(input()) a = list(map(int, input().split())) b = [0] * n for i in range(n - 1, -1, -1): b[i] = bisect_left(a, a[i], i + 1, len(a)) - i - 2 a[i] = min(a[i + 1], a[i]) if i != n - 1 else a[i] print(*b) ```
vfc_143940
{ "difficulty": "medium", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/92/D", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "15\n18 6 18 21 14 20 13 9 18 20 28 13 19 25 21\n", "output": "10 -1 8 8 6 6 0 -1 2 2 3 -1 -1 0 -1 ", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: You are given circle $A$ with radius $r_a$ and with central coordinate $(x_a, y_a)$ and circle $B$ with radius $r_b$ and with central coordinate $(x_b, y_b)$. Write a program which prints: * "2" if $B$ is in $A$, * "-2" if $A$ is in $B$, * "1"...
```python n = int(input()) for _ in range(n): (xa, ya, ra, xb, yb, rb) = map(float, input().split()) dist = ((xa - xb) ** 2 + (ya - yb) ** 2) ** 0.5 if ra + rb < dist: print('0') elif abs(ra - rb) <= dist: print('1') elif rb < ra: print('2') elif ra < rb: print('-2') ```
vfc_143945
{ "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": "2\n0.0 0.0 5.0 0.0 0.0 4.0\n0.0 0.0 2.0 4.1 0.0 2.4515674947137622", "output": "2\n1\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\n0.0 0.0 5.0 0.0 1.5542884595470625 4.0\n0.0 0.0 2.0 ...
taco
verifiable_code
Solve the following coding problem using the programming language python: Rash is known about his love for racing sports. He is an avid Formula 1 fan. He went to watch this year's Indian Grand Prix at New Delhi. He noticed that one segment of the circuit was a long straight road. It was impossible for a car to overtak...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' t = int(input()) for _ in range(t): n = int(input()) nl = list(map(int, input().split())) low = nl[0] count = 1 for i in range(0,n-1): if nl[i] >= nl[i+1]: count += ...
vfc_143949
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1\n10\n3\n8 3 6\n5\n4 5 1 2 3\n", "output": "1\n2\n2", "type": "stdin_stdout" }, { "fn_name": null, "input": "73\n3\n30911761 6706152 39650290 \n3\n37702960 32711386 17722242 \n9\n30035296 3738973...
taco
verifiable_code
https://codeforces.com/problemset/problem/399/B
Solve the following coding problem using the programming language python: User ainta has a stack of n red and blue balls. He can apply a certain operation which changes the colors of the balls inside the stack. While the top ball inside the stack is red, pop the ball from the top of the stack. Then replace the blu...
```python n = int(input()) balls = list(input()) balls.reverse() stack = [] c = 0 pred = balls[0] for b in balls: if b == pred: c += 1 else: stack.append([pred, c]) c = 1 pred = b else: stack.append([pred, c]) cnt = 0 l = len(balls) while True: if stack[-1][0] == 'R': l -= stack[-1][1] stack.pop() else:...
vfc_143953
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/399/B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\nRBR\n", "output": "2\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4\nRBBR\n", "output": "6\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "...
taco
verifiable_code
https://www.codechef.com/problems/CHEFDIV
Solve the following coding problem using the programming language python: Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. Chef has defined a new type of rooted tree - divisor tree. In this tree, every node has a positive integer written on it. It follows some rules: The root can have an...
```python MAX = int(1000000.0) + 1 is_prime = [True] * MAX (a, b) = map(int, input().strip().split()) factor = [list() for _ in range(b - a + 1)] for i in range(2, MAX): if is_prime[i]: for j in range(2 * i, MAX, i): is_prime[j] = False for j in range((a + i - 1) // i * i, b + 1, i): factor[j - a].append(i) ...
vfc_143957
{ "difficulty": "hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CHEFDIV", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "11 12", "output": "14", "type": "stdin_stdout" }, { "fn_name": null, "input": "932451 935212", "output": "101245", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Better things, cheaper. There is a fierce battle at the time sale held in some supermarkets today. "LL-do" here in Aizu is one such supermarket, and we are holding a slightly unusual time sale to compete with other chain stores. In a general tim...
```python from heapq import heappush, heappop from string import digits import sys readline = sys.stdin.readline write = sys.stdout.write dd = ((-1, 0), (0, -1), (1, 0), (0, 1)) INF = 10 ** 9 while 1: (X, Y) = map(int, readline().split()) if X == Y == 0: break MP = [readline().split() for i in range(Y)] N = int(r...
vfc_143969
{ "difficulty": "unknown_difficulty", "memory_limit": "134.217728 megabytes", "memory_limit_bytes": null, "problem_url": null, "time_limit": "5.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 5\n1 1 . 0 0 4\n1 . . . . .\n. . 2 2 . .\n. . 2 2 3 3\nP . - . . .\n5\n0 50 5 10\n1 20 0 10\n2 10 5 15\n3 150 3 5\n4 100 8 9\n0 0", "output": "180\n", "type": "stdin_stdout" }, { "fn_name": null, "...
taco
verifiable_code
https://codeforces.com/problemset/problem/1613/E
Solve the following coding problem using the programming language python: There is a grid, consisting of n rows and m columns. Each cell of the grid is either free or blocked. One of the free cells contains a lab. All the cells beyond the borders of the grid are also blocked. A crazy robot has escaped from this lab. ...
```python import os import sys from io import BytesIO, IOBase import math as M import itertools as ITR from collections import defaultdict as D from collections import Counter as C from collections import deque as Q import threading from functools import cmp_to_key, lru_cache, reduce from functools import cmp_to_key as...
vfc_143976
{ "difficulty": "hard", "memory_limit": "512.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1613/E", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n3 31\n############################..#\n.............................L.\n############################..#\n", "output": "############################++#\n+++++++++++++++++++++++++++++L+\n############################++#\n", ...
taco
verifiable_code
https://codeforces.com/problemset/problem/984/C
Solve the following coding problem using the programming language python: You are given several queries. Each query consists of three integers p, q and b. You need to answer whether the result of p/q in notation with base b is a finite fraction. A fraction in notation with base b is finite if it contains finite numbe...
```python from sys import stdin, stdout n = int(stdin.readline()) s = '' for i in range(n): (p, q, b) = map(int, input().split()) for i in range(6): b = b * b % q if p * b % q: s += 'Infinite\n' else: s += 'Finite\n' print(s) ```
vfc_143980
{ "difficulty": "medium_hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/984/C", "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n10 8 5\n0 6 9\n0 7 6\n5 7 3\n7 6 8\n0 4 8\n2 6 3\n10 2 9\n6 7 9\n9 1 4\n", "output": "Infinite\nFinite\nFinite\nInfinite\nInfinite\nFinite\nFinite\nFinite\nInfinite\nFinite\n", "type": "stdin_stdout" }, { ...
taco
verifiable_code
https://codeforces.com/problemset/problem/49/B
Solve the following coding problem using the programming language python: Vasya studies positional numeral systems. Unfortunately, he often forgets to write the base of notation in which the expression is written. Once he saw a note in his notebook saying a + b = ?, and that the base of the positional notation wasn’t ...
```python (a, b) = list(map(int, input().split())) k = int(max(str(a) + str(b))) + 1 carry = 0 l = max(len(str(a)), len(str(b))) for itr in range(l): if a % 10 + b % 10 + carry < k: carry = 0 else: carry = 1 a //= 10 b //= 10 if carry: print(l + 1) else: print(l) ```
vfc_143984
{ "difficulty": "medium", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/49/B", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "208 997\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "12 34\n", "output": "3\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1...
taco
verifiable_code
https://codeforces.com/problemset/problem/1301/D
Solve the following coding problem using the programming language python: Bashar was practicing for the national programming contest. Because of sitting too much in front of the computer without doing physical movements and eating a lot Bashar became much fatter. Bashar is going to quit programming after the national ...
```python import sys readline = sys.stdin.readline def solve(K): Ans = [] if K > M - 1: K -= M - 1 Ans.append(f'{M - 1} R') else: Ans.append(f'{K} R') return Ans if K > M - 1: K -= M - 1 Ans.append(f'{M - 1} L') else: Ans.append(f'{K} L') return Ans cycle = 4 * M - 3 if K > cycle * (N - 1): K ...
vfc_143988
{ "difficulty": "hard", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1301/D", "time_limit": "1 second" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3 4\n", "output": "YES\n2\n2 R\n2 L\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 3 1000000000\n", "output": "NO\n", "type": "stdin_stdout" }, { "fn_name": ...
taco
verifiable_code
https://codeforces.com/problemset/problem/1530/C
Solve the following coding problem using the programming language python: You and your friend Ilya are participating in an individual programming contest consisting of multiple stages. A contestant can get between $0$ and $100$ points, inclusive, for each stage, independently of other contestants. Points received by ...
```python def readline(): return map(int, input().split()) def solve(): n = int(input()) a = sorted(readline()) b = sorted(readline()) q = n // 4 sa = sum(a[q:]) sb = sum(b[q:]) k = 0 while sa < sb: k += 1 sa += 100 if (n + k) % 4 == 0: sa -= a[q] if q < n else 100 q += 1 else: sb += b[q - k]...
vfc_143996
{ "difficulty": "easy", "memory_limit": "512 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1530/C", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1\n100\n0\n1\n0\n100\n4\n20 30 40 50\n100 100 100 100\n4\n10 20 30 40\n100 100 100 100\n7\n7 59 62 52 27 31 55\n33 35 50 98 83 80 64\n", "output": "0\n1\n3\n4\n2\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/INTEG
Solve the following coding problem using the programming language python: Chef has an array of N integers. He wants to play a special game. In this game he needs to make all the integers in the array greater than or equal to 0. Chef can use two types of operations. The first type is to increase all the integers of t...
```python n = int(input()) l = map(int, input().split()) x = int(input()) l = [i for i in l if i < 0] l.sort() print(-sum(l) if -sum(l) <= x else -sum(l[:x])) ```
vfc_144004
{ "difficulty": "medium_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/INTEG", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n-1 -2 -3\n2\n", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n-2 -2 -3\n2", "output": "5\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1067/C
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 ca...
```python import collections, atexit, math, sys, bisect sys.setrecursionlimit(1000000) def getIntList(): return list(map(int, input().split())) try: import numpy def dprint(*args, **kwargs): print(*args, **kwargs, file=sys.stderr) dprint('debug mode') except Exception: def dprint(*args, **kwargs): pass inId...
vfc_144009
{ "difficulty": "very_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1067/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n", "output": "0 0\n1 0\n1 3\n2 0\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "7\n", "output": "0 0\n1 0\n1 3\n2 0\n3 0\n3 3\n4 0\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1239/C
Solve the following coding problem using the programming language python: There are n seats in the train's car and there is exactly one passenger occupying every seat. The seats are numbered from 1 to n from left to right. The trip is long, so each passenger will become hungry at some moment of time and will go to tak...
```python import sys reader = (s.rstrip() for s in sys.stdin) input = reader.__next__ from heapq import heappop, heappush, heapify from collections import deque class SWAG_Stack: def __init__(self, F): self.stack1 = deque() self.stack2 = deque() self.F = F self.len = 0 def push(self, x): if self.stack2: ...
vfc_144015
{ "difficulty": "hard", "memory_limit": "512.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1239/C", "time_limit": "1.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "100 1000000000\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "outp...
taco
verifiable_code
https://codeforces.com/problemset/problem/1093/C
Solve the following coding problem using the programming language python: Mishka is trying really hard to avoid being kicked out of the university. In particular, he was doing absolutely nothing for the whole semester, miraculously passed some exams so that just one is left. There were $n$ classes of that subject dur...
```python n = int(input()) b = list(map(int, input().split())) ans = [-1] * n ans[0] = 0 ans[-1] = b[0] l = 0 r = n - 1 for i in range(1, n // 2): if b[i] - ans[l] <= ans[r]: ans[l + 1] = ans[l] ans[r - 1] = b[i] - ans[l] l += 1 r -= 1 else: ans[l + 1] = b[i] - ans[r] ans[r - 1] = ans[r] l += 1 r -= 1...
vfc_144019
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1093/C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n5 6\n", "output": "0 1 5 5 \n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abili...
```python p_ch = [True] * 9 rot = ((0, 1, 2, 3), (1, 2, 3, 0), (2, 3, 0, 1), (3, 0, 1, 2)) adj = ['c'] * 13 rec_adj = [[0, 2], [1, 3], [12, 4], [5, 7], [6, 8], [12, 9], [10, 12], [11, 12], [12, 12]] ref_adj = [[12, 12], [12, 0], [12, 1], [2, 12], [3, 5], [4, 6], [7, 12], [8, 10], [9, 11]] tr = dict(zip('RGBWrgbw', 'rgb...
vfc_144024
{ "difficulty": "unknown_difficulty", "memory_limit": "134.217728 megabytes", "memory_limit_bytes": null, "problem_url": null, "time_limit": "3.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\nWwRR wwrg RRGb rGBG RGrb RrRg RGrg rgBB Wrgr\nRrGb WWGR rGgb Wbrg wgBb GgBg WbBG Wwwg WWGG\nRBbr Wrbr wGGG wggR WgGR WBWb WRgB wBgH WBgG\nwBrg rGgb WRrB WWbw wRRB RbbB WRrb wrbb WgrG\nWrwB WWww wRRB WGGb Wbbg WBgG WrbG Wrww RBgg...
taco
verifiable_code
https://codeforces.com/problemset/problem/1472/D
Solve the following coding problem using the programming language python: During their New Year holidays, Alice and Bob play the following game using an array $a$ of $n$ integers: Players take turns, Alice moves first. Each turn a player chooses any element and removes it from the array. If Alice chooses even value...
```python for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) a.sort(reverse=True) bob = alice = 0 cur = 0 for i in range(n): if cur == 0: if a[i] % 2 == 0: alice += a[i] cur = 1 else: if a[i] % 2 == 1: bob += a[i] cur = 0 if alice == bob: print('Tie') el...
vfc_144037
{ "difficulty": "easy", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1472/D", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n4\n5 2 7 3\n3\n3 2 1\n4\n2 2 2 2\n2\n7 8\n", "output": "Bob\nTie\nAlice\nAlice\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/ADDNDIV
Solve the following coding problem using the programming language python: You are given two positive integers a and b. You also have a number x, which is initially set to 0. At first, you can add a to x any number of times. After that, you can divide x by b any number of times as long as x is divisible by b. Print YE...
```python t = int(input()) for i in range(t): (a, b) = tuple(map(int, input().split())) p = False r = b for i in range(100): if r % a == 0: p = True break else: r *= b if p: print('YES') else: print('NO') ```
vfc_144046
{ "difficulty": "medium_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/ADDNDIV", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n3 10\n9 6\n7 30\n8 12", "output": "NO\nYES\nNO\nYES", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/FGFS
Solve the following coding problem using the programming language python: Our chef has recently opened a new restaurant with a unique style. The restaurant is divided into K compartments (numbered from 1 to K) and each compartment can be occupied by at most one customer. Each customer that visits the restaurant has a...
```python from collections import defaultdict for _ in range(int(input())): (n, k) = list(map(int, input().split())) d = defaultdict(list) for i in range(n): (s, f, p) = list(map(int, input().split())) d[p].append([s, f]) ans = 0 for i in d: if len(d[i]) == 1: ans += 1 else: d[i].sort(key=lambda x: x...
vfc_144058
{ "difficulty": "medium_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/FGFS", "time_limit": "0.5 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3 3\n1 3 1\n4 6 2\n7 10 3\n4 2\n10 100 1\n100 200 2\n150 500 2\n200 300 2\n", "output": "3\n3\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/subarrays-with-sum-k/1
Solve the following coding problem using the programming language python: Given an unsorted array of integers, find the number of continuous subarrays having sum exactly equal to a given number k. Example 1: Input: N = 5 Arr = {10 , 2, -2, -20, 10} k = -10 Output: 3 Explaination: Subarrays: arr[0...3], arr[1...4], ar...
```python from collections import defaultdict class Solution: def findSubArraySum(self, Arr, N, k): default = {} res = 0 cur = 0 for i in Arr: cur += i if cur == k: res += 1 if cur - k in default: res += default[cur - k] if cur in default: default[cur] += 1 else: default[cur] =...
vfc_144062
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/subarrays-with-sum-k/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 5\nArr = {10 , 2, -2, -20, 10}\nk = -10", "output": "3", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 6\nArr = {9, 4, 20, 3, 10, 5}\nk = 33", "output": "2", "type": "std...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/surround-the-1s2505/1
Solve the following coding problem using the programming language python: Given a matrix of order nxm, composed of only 0's and 1's, find the number of 1's in the matrix that are surrounded by an even number (>0) of 0's. The surrounding of a cell in the matrix is defined as the elements above, below, on left, on right...
```python class Solution: def Count(self, arr): res = 0 n = len(arr) m = len(arr[0]) for i in range(n): for j in range(m): if arr[i][j] == 1: count = 0 if i != 0 and arr[i - 1][j] == 0: count += 1 if i != 0 and j != 0 and (arr[i - 1][j - 1] == 0): count += 1 if i != 0 an...
vfc_144067
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/surround-the-1s2505/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "matrix = {{1, 0, 0}, {1, 1, 0}, \n{0, 1, 0}}", "output": "1", "type": "stdin_stdout" }, { "fn_name": null, "input": "matrix = {{1}}", "output": "0", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/maximum-sum-increasing-subsequence4749/1
Solve the following coding problem using the programming language python: Given an array of n positive integers. Find the sum of the maximum sum subsequence of the given array such that the integers in the subsequence are sorted in strictly increasing order i.e. a strictly increasing subsequence. Example 1: Input: N ...
```python class Solution: def maxSumIS(self, Arr, n): T = [Arr[i] for i in range(n)] for i in range(1, n): for j in range(i): if Arr[j] < Arr[i]: T[i] = max(T[i], T[j] + Arr[i]) ans = T[0] for i in range(1, n): if T[i] > ans: ans = T[i] return ans ```
vfc_144068
{ "difficulty": "medium", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/maximum-sum-increasing-subsequence4749/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 5, arr[] = {1, 101, 2, 3, 100}", "output": "106", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 3, arr[] = {1, 2, 3}", "output": "6", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Let's play the game using a bag containing several cards with integers written on it. In each game, participants first declare one of their favorite number n. Then, take out an appropriate number of cards from the bag at a time, and if the sum o...
```python import sys readline = sys.stdin.readline write = sys.stdout.write ans = [] while 1: M = int(readline()) if M == 0: break P = [list(map(int, input().split())) for i in range(M)] memo = {} def dfs(i, rest): if i == M: return rest == 0 key = (i, rest) if key in memo: return memo[key] res = ...
vfc_144073
{ "difficulty": "unknown_difficulty", "memory_limit": "134.217728 megabytes", "memory_limit_bytes": null, "problem_url": null, "time_limit": "5.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 10\n5 3\n10 3\n25 2\n50 2\n4\n120\n500\n100\n168\n7\n1 10\n3 10\n5 10\n10 10\n25 10\n10 10\n100 10\n3\n452\n574\n787\n0", "output": "16\n0\n12\n7\n17574\n17580\n17578\n", "type": "stdin_stdout" }, { "...
taco
verifiable_code
https://codeforces.com/problemset/problem/1272/A
Solve the following coding problem using the programming language python: Three friends are going to meet each other. Initially, the first friend stays at the position $x = a$, the second friend stays at the position $x = b$ and the third friend stays at the position $x = c$ on the coordinate axis $Ox$. In one minute...
```python import math nt = int(input()) while nt: nt -= 1 s = 0 li = list(map(int, input().strip().split())) if len(set(li)) == 3: li.sort() dif1 = li[0] - li[1] dif2 = li[1] - li[2] if dif1 < 0: dif1 = -dif1 if dif2 < 0: dif2 = -dif2 if dif1 > dif2: li[0] = li[0] + 1 li[1] = li[1] - 1 li...
vfc_144077
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1272/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "8\n3 3 4\n10 20 30\n5 5 5\n2 4 3\n1 1000000000 1000000000\n1 1000000000 999999999\n3 2 5\n3 2 6\n", "output": "0\n36\n0\n0\n1999999994\n1999999994\n2\n4\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/74/A
Solve the following coding problem using the programming language python: Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document. In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participa...
```python arr = [] for _ in range(0, int(input())): arr.append(list(input().split())) ans = [] for i in range(0, len(arr)): sum = int(arr[i][1]) * 100 - int(arr[i][2]) * 50 for j in range(3, 8): sum += int(arr[i][j]) ans.append(sum) a = max(ans) for i in range(0, len(ans)): if ans[i] == a: print(arr[i][0]) b...
vfc_144085
{ "difficulty": "easy", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/74/A", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\nW22kb1L1 0 39 0 465 0 1961 865\n1MCXiVYmu5ys0afl 0 38 0 0 0 1982 1241\nCxg706kUJtQ 0 23 211 0 0 1785 1056\nmzEY 0 16 0 0 0 1988 1404\nv8JUjmam5SFP 0 48 0 788 1199 1426 0\n7giq 0 21 0 780 1437 1363 1930\nsXsUGbAulj6Lbiq 0 32 205...
taco
verifiable_code
https://www.codechef.com/COJK2020/problems/CKOJ20A
Solve the following coding problem using the programming language python: Zaikia has $N$ sticks of distinct positive lengths $A_1,A_2,\dots,A_N$. For no good reason at all, he wants to know if there is a triplet of sticks which when connected end-to-end will form a non-trivial triangle. Here non-trivial refers to a tr...
```python n = int(input()) l = list(map(int, input().split())) l1 = [] if n < 3: print('NO') else: l.sort() for i in range(n - 2): if l[i] + l[i + 1] > l[i + 2]: l1.append([l[i + 2], l[i + 1], l[i]]) if len(l1) != 0: print('YES') print(*max(l1)) else: print('NO') ```
vfc_144098
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/COJK2020/problems/CKOJ20A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n4 2 10 3 5\n", "output": "YES\n5 4 3\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Chester has been bullied enough all his life and now he seeks revenge. His first victim being Mike, obviously! He found this very interesting question from somewhere but he doesn't have the answers to it. Now without the answers he cannot know i...
```python t=int(input()) while t: t-=1 a,b=list(map(int,input().split())) string = str(a**b) new = list(map(int,string)) print(sum(new)) ```
vfc_144104
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "20000\n23 22\n20 216\n14 404\n95 769\n5 813\n58 999\n65 358\n5 70\n37 603\n32 819\n29 453\n61 476\n45 174\n96 849\n65 122\n49 207\n8 471\n13 192\n45 8\n13 890\n64 76\n95 624\n85 886\n26 115\n33 676\n99 401\n87 697\n27 332\n73 565\n...
taco
verifiable_code
https://www.codechef.com/problems/PROGLANG
Solve the following coding problem using the programming language python: Read problem statements in [Mandarin], [Bengali], [Russian], and [Vietnamese] as well. Chef is a software developer, so he has to switch between different languages sometimes. Each programming language has some features, which are represented b...
```python t = int(input()) for _ in range(t): (a, b, a1, b1, a2, b2) = map(int, input().split()) if a1 == a and b1 == b or (b1 == a and a1 == b): print('1') elif a2 == a and b2 == b or (b2 == a and a2 == b): print('2') else: print('0') ```
vfc_144112
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/PROGLANG", "time_limit": "0.5 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 2 2 1 3 4\n3 4 2 1 4 3\n1 2 1 3 2 4", "output": "1\n2\n0", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/190/C
Solve the following coding problem using the programming language python: Vasya used to be an accountant before the war began and he is one of the few who knows how to operate a computer, so he was assigned as the programmer. We all know that programs often store sets of integers. For example, if we have a problem ab...
```python import os import sys from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = 'x' in file.mode or 'r' not in file.mode self.write = self.buffer.write if self.writable else None def ...
vfc_144116
{ "difficulty": "medium", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/190/C", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "9\npair int int int pair pair int int int int int pair pair pair pair pair pair int\n", "output": "Error occurred\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "2\npair int int\n", ...
taco
verifiable_code
https://www.codechef.com/problems/ODDEVENBS
Solve the following coding problem using the programming language python: Chef had an array A of length N such that 1 ≤ A_{i} ≤ N for all 1 ≤ i ≤ N. Chef constructed another binary array B of length N in the following manner: B_{i} = 1 if the frequency of element i in A is *odd*. B_{i} = 0 if the frequency of element ...
```python for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) if n % 2 == sum(a) % 2: print('YES') else: print('NO') ```
vfc_144120
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/ODDEVENBS", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n4\n0 1 0 1\n5\n1 1 1 1 0\n6\n1 1 1 1 1 1\n", "output": "YES\nNO\nYES\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Russian Translation Available It is very important to understand relationship between variables to draw the right conclusion from a statistical analysis. The relationship between variables determines how the right conclusions are reached. Witho...
```python import heapq for _ in range(eval(input())): node,edge=list(map(int,input().split())) heap=[[1,1]] visit=[0 for _ in range(node+1)] arr=[[] for _ in range(node+1)] for _ in range(edge): a,b,c=list(map(int,input().split())) arr[a].append([c,b]) arr[b].append([c,a]) maximum=1 while len(heap)>0: x,...
vfc_144124
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "20\n46 1035\n21 36 9555\n14 44 810\n10 12 8856\n13 27 6590\n5 20 2196\n20 26 7212\n2 23 8666\n36 40 8380\n25 42 6340\n28 33 31\n13 37 5873\n21 39 4867\n27 28 2782\n7 25 9127\n2 15 2163\n1 10 4898\n6 38 2497\n6 14 8286\n1 29 5674\n1...
taco
verifiable_code
https://codeforces.com/problemset/problem/440/A
Solve the following coding problem using the programming language python: Polycarpus adores TV series. Right now he is ready to finish watching a season of a popular sitcom "Graph Theory". In total, the season has n episodes, numbered with integers from 1 to n. Polycarpus watches episodes not one by one but in a rand...
```python n = int(input()) a = list(map(int, input().split())) a.sort() m = len(a) flag = 1 for i in range(1, m + 1): if i != a[i - 1]: print(i) flag = 0 break if flag == 1: print(n) ```
vfc_144128
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/440/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n3 8 10 1 7 9 6 5 2\n", "output": "4\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n4 3 2 1\n", "output": "5\n", "type": "stdin_stdout" }, { "fn_name": nul...
taco
verifiable_code
https://www.codechef.com/problems/GCDANDLCM
Solve the following coding problem using the programming language python: You are given an integer N. You are asked to find total number of integer pairs (A,B) such that 1 ≤ A,B ≤ N A^{2}+B^{2}+gcd^{2}(A,B)+lcm^{2}(A,B)=N. Note that gcd^{2}(A, B) and lcm^{2}(A, B) denote the square of [gcd] and the square of [lcm] o...
```python import itertools import math def factorize(n): def try_divisor(n, k, pfs): if n % k == 0: pfs[k] = 1 n //= k while n % k == 0: pfs[k] += 1 n //= k return n pfs = {} n = try_divisor(n, 2, pfs) n = try_divisor(n, 3, pfs) for i in itertools.count(start=1): n = try_divisor(n, 6 * i -...
vfc_144132
{ "difficulty": "hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/GCDANDLCM", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n4\n10\n20\n", "output": "1\n2\n2\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/736/A
Solve the following coding problem using the programming language python: Famous Brazil city Rio de Janeiro holds a tennis tournament and Ostap Bender doesn't want to miss this event. There will be n players participating, and the tournament will follow knockout rules from the very first game. That means, that if some...
```python n = int(input()) an = 0 a = 1 b = 0 c = 2 while n >= c: b = a a = c c = a + b an += 1 print(an) ```
vfc_144136
{ "difficulty": "medium_hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/736/A", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "61824012598535\n", "output": "65\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "679891637638612258\n", "output": "85\n", "type": "stdin_stdout" }, { "fn_name": n...
taco
verifiable_code
https://codeforces.com/problemset/problem/1521/E
Solve the following coding problem using the programming language python: You like numbers, don't you? Nastia has a lot of numbers and she wants to share them with you! Isn't it amazing? Let a_i be how many numbers i (1 ≤ i ≤ k) you have. An n × n matrix is called beautiful if it contains all the numbers you have, a...
```python def cheak(x): return x ** 2 - (x // 2) ** 2 >= m and x * (x // 2 + (1 if x % 2 != 0 else 0)) >= mx for test in range(int(input())): (m, k) = (int(i) for i in input().split()) a = [int(i) for i in input().split()] mx = max(a) z = 0 y = m * 4 while z != y: x = (z + y) // 2 if cheak(x): y = x els...
vfc_144140
{ "difficulty": "very_hard", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1521/E", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n9 3\n1 0 8\n", "output": "4\n3 3 3 3 \n0 0 0 0 \n3 3 3 3 \n0 0 1 0 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n12 3\n9 2 1\n", "output": "5\n0 1 0 1 0 \n0 0 0 0 0 \n0 1 0 ...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/find-number-of-numbers/1
Solve the following coding problem using the programming language python: Given an array A[] of n elements. Your task is to complete the Function num which returns an integer denoting the total number of times digit k appears in the whole array. For Example: Input: A[] = {11,12,13,14,15}, k=1 Output: 6 Explanation: ...
```python def num(arr, n, k): arr = list(map(str, arr)) arr = ''.join(arr) return arr.count(str(k)) ```
vfc_144144
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/find-number-of-numbers/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": "num", "input": "A[] = {11,12,13,14,15}, k=1", "output": "6", "type": "function_call" } ] }
taco
verifiable_code
Solve the following coding problem using the programming language python: Sidddharth is very kind-hearted. He doesn't want to give you any stupid problem statement that wastes your time. Given an array of integers, find the sum of the ith largest and jth smallest number from the array. Input Format: First line of th...
```python t=eval(input()) for q in range(t): s=0 n=eval(input()) a=list(map(int,input().split())) b=sorted(a) x,y=input().split() i,j=int(x),int(y) s=b[j-1]+b[n-i] print(s) ```
vfc_144145
{ "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\n42\n24888 11116 26457 28455 17261 26679 9974 28052 12955 29836 10390 22547 31551 32647 24886 2241 9162 30559 16769 15275 3564 13720 312 15516 15634 15226 14807 10036 26158 4801 5238 27962 11446 9878 3821 5939 12527 10430 7227 2...
taco
verifiable_code
https://www.codechef.com/problems/TIDRICE
Solve the following coding problem using the programming language python: Did you know that there are over 40,000 varieties of Rice in the world ? There are so many dishes that can be prepared with Rice too. A famous chef from Mumbai, Tid Gusto prepared a new dish and named it 'Tid Rice'. He posted the recipe in his n...
```python for tc in range(int(input())): kmap = {} n = int(input()) count = 0 for i in range(n): (name, sign) = map(str, input().split()) if name not in kmap: kmap[name] = sign count += 1 if sign == '+' else -1 elif sign != kmap[name]: kmap[name] = sign count += 2 if sign == '+' else -2 print(cou...
vfc_144149
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/TIDRICE", "time_limit": "0.212329 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n4\ntilak +\ntilak +\ntilak -\ntilak +\n3\nratna +\nshashi -\nratna -\n3\nbhavani -\nbhavani +\nbhavani -", "output": "1\n-2\n-1", "type": "stdin_stdout" }, { "fn_name": null, "input": "3\n4\ntilak...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/sum-of-all-divisors-from-1-to-n4738/1
Solve the following coding problem using the programming language python: Given a positive integer N., The task is to find the value of where function F(i) for the number i be defined as the sum of all divisors of ‘i‘. Example 1: Input: N = 4 Output: 15 Explanation: F(1) = 1 F(2) = 1 + 2 = 3 F(3) = 1 + 3 = 4 F(4)...
```python class Solution: def sumOfDivisors(self, N): s = 0 for i in range(1, N + 1): s = s + N // i * i return s ```
vfc_144153
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/sum-of-all-divisors-from-1-to-n4738/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 4", "output": "15", "type": "stdin_stdout" }, { "fn_name": null, "input": "N = 5", "output": "21", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/43/A
Solve the following coding problem using the programming language python: One day Vasya decided to have a look at the results of Berland 1910 Football Championship’s finals. Unfortunately he didn't find the overall score of the match; however, he got hold of a profound description of the match's process. On the whole ...
```python n = int(input()) (a, b) = (input(), '') (x, y) = (1, 0) for i in range(n - 1): s = input() if a == s: x += 1 else: b = s y += 1 print([b, a][x > y]) ```
vfc_144155
{ "difficulty": "easy", "memory_limit": "256.0 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/43/A", "time_limit": "2.0 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "100\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA\nHA...
taco
verifiable_code
https://practice.geeksforgeeks.org/problems/nth-digit-of-pie5851/1
Solve the following coding problem using the programming language python: Calculate the Nth digit in the representation of Pi. Example 1: Input: N = 1 Output: 3 Explanation: Value of Pi is 3.14... So, the first digit is 3. Example 2: Input: N = 2 Output: 1 Explanation: Value of Pi is 3.14... So, the second digit i...
```python def sqrt(n, MAX): float_max = 10 ** 16 n_float = float(n * float_max // MAX) / float_max curr = int(float_max * math.sqrt(n_float)) * MAX // float_max n_MAX = n * MAX while True: prev = curr curr = (curr + n_MAX // curr) // 2 if curr == prev: break return curr def power(n): if n == 0: retur...
vfc_144160
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://practice.geeksforgeeks.org/problems/nth-digit-of-pie5851/1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "N = 1", "output": "3", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/SLOOP
Solve the following coding problem using the programming language python: Chef is a big fan of Coldplay. Every Sunday, he will drive to a park taking M minutes to reach there, and during the ride he will play a single song on a loop. Today, he has got the latest song which is in total S minutes long. He is interested ...
```python t = int(input()) for i in range(t): (m, s) = map(int, input().split()) print(m // s) ```
vfc_144165
{ "difficulty": "easy", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/SLOOP", "time_limit": "0.5 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n10 5\n10 6\n9 10", "output": "2\n1\n0", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/CHIL2020/problems/BININSC
Solve the following coding problem using the programming language python: Given a binary string $S$ consisting of only 1’s and 0’s where 1 represents a Square and 0 represents a Circle. The diameter of the circle and the side of the square must be any integer (obviously > 0) . You will have to perfectly inscribe (as s...
```python for z in range(int(input())): s = input() n = len(s) i = 0 while i < n and s[i] == '1': i += 1 if i == 0: print(0) else: k = 0 while i < n and s[i] == '0': i += 1 k += 1 print(k) ```
vfc_144170
{ "difficulty": "unknown_difficulty", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/CHIL2020/problems/BININSC", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1110\n0010\n1001000\n", "output": "1\n0\n2\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://codeforces.com/problemset/problem/1283/D
Solve the following coding problem using the programming language python: There are $n$ Christmas trees on an infinite number line. The $i$-th tree grows at the position $x_i$. All $x_i$ are guaranteed to be distinct. Each integer point can be either occupied by the Christmas tree, by the human or not occupied at all...
```python from collections import deque (n, m) = map(int, input().split()) trees = [int(i) for i in input().split()] dist = {i: 0 for i in trees} q = deque() for cur in trees: q.append(cur) ans_len = 0 ans_people = [] while len(q) > 0 and len(ans_people) != m: cur = q.popleft() if cur in dist and dist[cur] != 0: a...
vfc_144174
{ "difficulty": "medium_hard", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1283/D", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 6\n1 5\n", "output": "8\n2 3 -1 0 6 4 \n", "type": "stdin_stdout" }, { "fn_name": null, "input": "3 5\n0 3 1\n", "output": "7\n5 2 4 -1 -2 \n", "type": "stdin_stdout" }, { ...
taco
verifiable_code
https://codeforces.com/problemset/problem/1613/A
Solve the following coding problem using the programming language python: Monocarp wrote down two numbers on a whiteboard. Both numbers follow a specific format: a positive integer $x$ with $p$ zeros appended to its end. Now Monocarp asks you to compare these two numbers. Can you help him? -----Input----- The firs...
```python from sys import stdin, stdout from collections import defaultdict input = stdin.readline from random import randint import math import sys for _ in range(int(input())): (a, b) = map(int, input().split()) (c, d) = map(int, input().split()) while a > 1: b += 1 a = a / 10 while c > 1: c = c / 10 d = ...
vfc_144178
{ "difficulty": "easy", "memory_limit": "256 megabytes", "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1613/A", "time_limit": "2 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n2 1\n19 0\n10 2\n100 1\n1999 0\n2 3\n1 0\n1 0\n99 0\n1 2\n", "output": ">\n=\n<\n=\n<\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "1\n100000 1\n100 4\n", "output": "=\n", ...
taco
verifiable_code
Solve the following coding problem using the programming language python: Problem Statement As they say, small is cute and beautiful. Given N distinct positive integers, find the smallest number that can be formed by concatenating all of them. Input Format The first line of the input file contains a positive integer ...
```python def func(a,b): if(len(a) != len(b)): #a = int(a) #b = int(b) str1 = a + b str2 = b + a if str1 > str2: return 1 elif str1 == str2: return 0 else: return -1 else: if a > b: return 1 elif a==b: return 0 else: return -1 lines = int(input()) lst = [] for i in range(lines...
vfc_144182
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n123\n1234\n12345\n123456\n1234567", "output": "123456789014669079876543210", "type": "stdin_stdout" }, { "fn_name": null, "input": "5\n345\n3456\n34562\n345621\n345627", "output": "345345621...
taco
verifiable_code
Solve the following coding problem using the programming language python: Cleartrip decided that they wanted to verify the username and password of its users while they were authenticating for a process. One of the code service forms a GET URL which contains the username and password as its parameters. While parsing t...
```python ''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' temp = input().strip().split('?')[1] index1 = temp.find("username=") index2 = temp.find("&pwd=") index3 = temp.find("&profile=") index4 = temp.find("&role=") index5 = temp.fi...
vfc_144186
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": null, "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "http://www.cleartrip.com/signin/service?username=test@123&pwd=test&123&profile=deve&loper&role=ELITE&key=manager", "output": "username: Arjit\npwd: Cleartrip\nprofile: Genius\nrole: God\nkey: inalock", "type": "stdin_st...
taco
verifiable_code
https://codeforces.com/problemset/problem/1162/A
Solve the following coding problem using the programming language python: You are planning to build housing on a street. There are $n$ spots available on the street on which you can build a house. The spots are labeled from $1$ to $n$ from left to right. In each spot, you can build a house with an integer height betwe...
```python (n, h, m) = map(int, input().split()) li = [h] * (n + 1) for _ in range(m): (l, r, x) = map(int, input().split()) for i in range(l, r + 1): li[i] = min(li[i], x) res = 0 for i in range(1, n + 1): res += li[i] * li[i] print(res) ```
vfc_144194
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/1162/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3 3\n1 1 1\n2 2 3\n3 3 2\n", "output": "14\n", "type": "stdin_stdout" }, { "fn_name": null, "input": "4 10 2\n2 3 8\n3 4 7\n", "output": "262\n", "type": "stdin_stdout" }, { ...
taco
verifiable_code
https://codeforces.com/problemset/problem/454/A
Solve the following coding problem using the programming language python: Twilight Sparkle once got a crystal from the Crystal Mine. A crystal of size n (n is odd; n > 1) is an n × n matrix with a diamond inscribed into it. You are given an odd integer n. You need to draw a crystal of size n. The diamond cells of the...
```python x = int(input()) for i in range(x // 2 + 1): print('*' * (x // 2 - i), 'D' * (i * 2 + 1), '*' * (x // 2 - i), sep='') for i in range(x // 2 - 1, -1, -1): print('*' * (x // 2 - i), 'D' * (i * 2 + 1), '*' * (x // 2 - i), sep='') ```
vfc_144202
{ "difficulty": "easy", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://codeforces.com/problemset/problem/454/A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n", "output": "*D*\nDDD\n*D*\n", "type": "stdin_stdout" } ] }
taco
verifiable_code
https://www.codechef.com/problems/FTOL
Solve the following coding problem using the programming language python: Chef has a grid of size N \times M. In one move, Chef can move from his current cell to an adjacent cell. If the Chef is currently at (i, j) then, in one move, Chef can move to (i + 1, j), (i - 1, j), (i, j + 1) or (i, j - 1). There are also ...
```python import bisect def LII(): return [int(x) for x in input().split()] def longest_incr_length(s): vec_last = [] for x in s: i = bisect.bisect_left(vec_last, x) if i != len(vec_last): vec_last[i] = x else: vec_last.append(x) return len(vec_last) for _ in range(int(input())): (n, m, k) = LII() s...
vfc_144212
{ "difficulty": "very_hard", "memory_limit": "50000 bytes", "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/FTOL", "time_limit": "1 seconds" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3 3 0\n3 3 2\n2 2\n2 3\n", "output": "4\n3\n", "type": "stdin_stdout" } ] }