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://www.codechef.com/problems/APPLEORANGE | Solve the following coding problem using the programming language python:
Rushitote went to a programming contest to distribute apples and oranges to the contestants.
He has N apples and M oranges, which need to be divided equally amongst the contestants. Find the maximum possible number of contestants such that:
E... | ```python
from math import gcd
for _ in range(int(input())):
(n, m) = map(int, input().split())
print(gcd(n, m))
``` | vfc_133342 | {
"difficulty": "easy",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/APPLEORANGE",
"time_limit": "1 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 5\n2 4\n4 6",
"output": "1\n2\n2",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/55/A | Solve the following coding problem using the programming language python:
A flea is sitting at one of the n hassocks, arranged in a circle, at the moment. After minute number k the flea jumps through k - 1 hassoсks (clockwise). For example, after the first minute the flea jumps to the neighboring hassock. You should a... | ```python
n = int(input())
visited = [False] * n
k = 0
for i in range(n ** 2 + 1):
k += i + 1
visited[k % n] = True
for i in visited:
if not i:
print('NO')
exit()
print('YES')
``` | vfc_133346 | {
"difficulty": "easy",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/55/A",
"time_limit": "1.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "37\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "24\n",
... |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/count-numbers-divisible-by-m1524/1 | Solve the following coding problem using the programming language python:
Given two numbers A and B which define a range, where A <= B. Find the count of total numbers in the given range [A … B] divisible by M.
Example 1:
Input: A = 6, B = 15, M = 3
Output: 4
Explanation: 6, 9, 12, 15 are divisible
by 3.Hence answer ... | ```python
class Solution:
def countDivisibles(ob, A, B, M):
a = A // M
b = B // M
if A % M == 0:
return b - a + 1
return b - a
``` | vfc_133350 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/count-numbers-divisible-by-m1524/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "A = 6, B = 15, M = 3",
"output": "4",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "A = 25, B = 100, M = 30",
"output": "3",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | Solve the following coding problem using the programming language python:
D: Is greed the best?
story
In Japan, where there are 1, 5, 10, 50, 100, 500 yen coins, it is known that the number of coins can be minimized by using as many coins as possible when paying a certain amount. ..
If the amount of coins is differ... | ```python
(A, B) = map(int, input().split())
if A > B:
(A, B) = (B, A)
if B % A == 0:
print(-1)
else:
for i in range((B // A + 1) * A, B + A * 2, A):
if i // A < i // B + (i - i // B * B) // A + (i - i // B * B) % A:
print(i)
break
else:
print(-1)
``` | vfc_133351 | {
"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": "2 6",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6 7",
"output": "12\n",
"type": "stdin_stdout"
}
]
} | |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/huffman-decoding/1 | Solve the following coding problem using the programming language python:
Given a encoded binary string and a Huffman MinHeap tree, your task is to complete the function decodeHuffmanData(), which decodes the binary encoded string and return the original string.
Note: Each node of the min heap contains 2 data members... | ```python
def decodeHuffmanData(root, binaryString):
length = len(binaryString)
head = root
i = 0
stringAns = ''
while i < length:
char = binaryString[i]
if char == '0' and root.data == '$':
root = root.left
i += 1
elif char == '1' and root.data == '$':
root = root.right
i += 1
elif root.left i... | vfc_133355 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/huffman-decoding/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "binaryString = \n1111111111110001010101010100010010101010101\nMin Heap Tree = \n $(20)\n / \\\n / \\\n $(8) \\\n / \\ \\\n $(3) ... |
taco | verifiable_code | https://codeforces.com/problemset/problem/830/C | Solve the following coding problem using the programming language python:
Vladimir wants to modernize partitions in his office. To make the office more comfortable he decided to remove a partition and plant several bamboos in a row. He thinks it would be nice if there are n bamboos in a row, and the i-th from the left... | ```python
import itertools
unfold = itertools.chain.from_iterable
speedup = 400000
def jumps(a):
d = speedup
while d < a - 1:
c = (a + d - 1) // d
d = (a + c - 2) // (c - 1)
yield d
def calc(d):
return sum((d - 1 - (i - 1) % d for i in a))
def ans():
for (d, pd) in zip(D, D[1:]):
d -= 1
cd = calc(d)
... | vfc_133356 | {
"difficulty": "hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/830/C",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 4\n1 3 5\n",
"output": "3\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://www.hackerrank.com/challenges/sherlock-and-anagrams/problem | Solve the following coding problem using the programming language python:
Two strings are anagrams of each other if the letters of one string can be rearranged to form the other string. Given a string, find the number of pairs of substrings of the string that are anagrams of each other.
Example
$s=mom$
The lis... | ```python
for _ in range(int(input())):
was = dict()
s = input()
n = len(s)
for i in range(n):
for j in range(i, n):
cur = s[i:j + 1]
cur = ''.join(sorted(cur))
was[cur] = was.get(cur, 0) + 1
ans = 0
for x in was:
v = was[x]
ans += v * (v - 1) // 2
print(ans)
``` | vfc_133365 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.hackerrank.com/challenges/sherlock-and-anagrams/problem",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\nabba\nabcd\n",
"output": "4\n0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\nifailuhkqq\nkkkk\n",
"output": "3\n10\n",
"type": "stdin_stdout"
},
{
"fn_nam... |
taco | verifiable_code | https://codeforces.com/problemset/problem/6/A | Solve the following coding problem using the programming language python:
Johnny has a younger sister Anne, who is very clever and smart. As she came home from the kindergarten, she told his brother about the task that her kindergartener asked her to solve. The task was just to construct a triangle out of four sticks ... | ```python
import sys
input = sys.stdin.readline
print = sys.stdout.write
sides = sorted(list(map(int, input().split())))
if sides[3] < sides[2] + sides[1] or sides[2] < sides[1] + sides[0]:
print('TRIANGLE')
elif sides[3] == sides[2] + sides[1] or sides[2] == sides[1] + sides[0]:
print('SEGMENT')
else:
print('IMPOSS... | vfc_133369 | {
"difficulty": "easy",
"memory_limit": "64.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/6/A",
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "7 7 10 7\n",
"output": "TRIANGLE\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 4 4 5\n",
"output": "TRIANGLE\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
taco | verifiable_code | https://codeforces.com/problemset/problem/1669/H | Solve the following coding problem using the programming language python:
Let $\mathsf{AND}$ denote the bitwise AND operation , and $\mathsf{OR}$ denote the bitwise OR operation .
You are given an array $a$ of length $n$ and a non-negative integer $k$. You can perform at most $k$ operations on the array of the follow... | ```python
import functools
for _ in range(int(input())):
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
r = functools.reduce(int.__and__, a)
u = [x.count('0') for x in zip(*(f'{x:031b}' for x in a))]
for (i, x) in enumerate(u):
if x <= k:
break
else:
print(r)
continue
for (i, x) ... | vfc_133373 | {
"difficulty": "easy",
"memory_limit": "256 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1669/H",
"time_limit": "2 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n3 2\n2 1 1\n7 0\n4 6 6 28 6 6 12\n1 30\n0\n4 4\n3 1 3 1\n",
"output": "2\n4\n2147483646\n1073741825\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | Solve the following coding problem using the programming language python:
The earth is under an attack of a deadly virus. Luckily, prompt actions of the Ministry of Health against this emergency successfully confined the spread of the infection within a square grid of areas. Recently, public health specialists found a... | ```python
from collections import deque
import sys
readline = sys.stdin.readline
write = sys.stdout.write
dd0 = ((-1, 0), (-1, -1), (0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 1))
DD = []
for k in range(6):
ddk = []
for y in range(k):
for x in range(k):
v = 0
for (dx, dy) in dd0:
nx = x + dx
ny = y... | vfc_133378 | {
"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\n...\n.@.\n...\n3\n.##\n.#.\n@##\n3\n##.\n#..\n@..\n5\n....@\n##...\n#....\n...#.\n##.##\n5\n#...#\n...#.\n#....\n...##\n..@..\n5\n#..-.\n.....\n.....\n.....\n..@..\n5\n#..#.\n#.#.#\n.#.#.\n....#\n.#@##\n5\n..##.\n..#..\n#....\n#... | |
taco | verifiable_code | https://www.codechef.com/IARCSJUD/problems/CATERCON | Solve the following coding problem using the programming language python:
The government has invited bids from contractors to run canteens at all railway stations. Contractors will be allowed to bid for the catering contract at more than one station. However, to avoid monopolistic price-fixing, the government has decl... | ```python
n = int(input())
l = []
dp = []
d = {}
for i in range(n):
l.append(int(input()))
d[i] = []
dp.append([0, 0])
for i in range(n - 1):
(a, b) = list(map(int, input().split()))
d[a - 1].append(b - 1)
d[b - 1].append(a - 1)
def dfs(ch, pa, visited):
dp[ch][1] = l[ch]
for i in range(len(d[ch])):
if d[ch]... | vfc_133382 | {
"difficulty": "unknown_difficulty",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/IARCSJUD/problems/CATERCON",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6\n10\n20\n25\n40\n30\n30\n4 5\n1 3\n3 4\n2 3\n6 4\n",
"output": "90\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://www.codechef.com/problems/RCBPLAY | Solve the following coding problem using the programming language python:
Team RCB has earned X points in the games it has played so far in this year's IPL. To qualify for the playoffs they must earn at least a total of Y points. They currently have Z games left, in each game they earn 2 points for a win, 1 point for ... | ```python
t = int(input())
while t:
(x, y, z) = map(int, input().split())
if x + z * 2 >= y:
print('YES')
else:
print('NO')
t = t - 1
``` | vfc_133386 | {
"difficulty": "easy",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/RCBPLAY",
"time_limit": "1 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n4 10 8\n3 6 1 \n4 8 2 ",
"output": "YES\nNO\nYES\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/634/F | Solve the following coding problem using the programming language python:
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul... | ```python
(r, c, n, k) = map(int, input().split())
board = [[0 for col in range(c)] for row in range(r)]
for i in range(n):
(x, y) = map(lambda x: int(x) - 1, input().split())
board[x][y] = 1
photos = 0
for x1 in range(r):
for y1 in range(c):
for x2 in range(x1, r):
for y2 in range(y1, c):
s = 0
for row... | vfc_133390 | {
"difficulty": "very_hard",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/634/F",
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "7 5 3 1\n5 5\n4 5\n1 4\n",
"output": "135\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/1061/B | Solve the following coding problem using the programming language python:
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the numbe... | ```python
def solve(xs):
if len(xs) == 1:
return 0
heights = sorted(xs)[::-1]
used = 0
needed = heights[0]
for i in range(len(heights)):
current = heights[i]
if needed <= current:
used += 1
needed -= 1
else:
used += needed - current
used += 1
needed = current - 1
if needed > 0:
used += ne... | vfc_133394 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1061/B",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 6\n3 3 3 3 3\n",
"output": "10",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 5\n1 2 4\n",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"i... |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/maximum-sum-bitonic-subsequence1857/1 | Solve the following coding problem using the programming language python:
Given an array arr[] of N integers. A subsequence of arr[] is called Bitonic if it is first increasing then decreasing. Print the max sum bitonic subsequence.
Example 1:
Input :
N = 9
arr[] = {1, 15, 51, 45, 33,
100, 12, 18, 9... | ```python
def maxSumBS(s1, n):
dp1 = [s1[i] for i in range(n)]
for i in range(n):
for j in range(i):
if s1[i] > s1[j] and dp1[i] < dp1[j] + s1[i]:
dp1[i] = s1[i] + dp1[j]
dp2 = [s1[i] for i in range(n)]
for i in range(n - 1, -1, -1):
for j in range(n - 1, i, -1):
if s1[i] > s1[j] and dp2[i] < dp2[j] +... | vfc_133398 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/maximum-sum-bitonic-subsequence1857/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": "maxSumBS",
"input": "N = 9\r\narr[] = {1, 15, 51, 45, 33,\r\n 100, 12, 18, 9}",
"output": "194",
"type": "function_call"
}
]
} |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/need-some-change/1 | Solve the following coding problem using the programming language python:
Given an array arr of n positive integers. The task is to swap every i^{th} element of the array with (i+2)^{th} element.
Note: When passing array to function, we basically pass the reference to the array. More details here. We'll learn more abo... | ```python
class Solution:
def swapElements(self, arr, n):
for i in range(n - 2):
item1 = arr[i]
item2 = arr[i + 2]
arr[i + 2] = item1
arr[i] = item2
``` | vfc_133407 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/need-some-change/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "n = 5\r\narr[] = 1 2 3 4 5",
"output": "3 4 5 2 1",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Some of you know an old story of Voronoi Island. There were N liege lords and they are always involved in territorial disputes. The residents of the island were despaired of the disputes.
One day, a clever lord proposed to stop the disputes and... | ```python
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def cross3(O, A, B):
(ox, oy) = O
(ax, ay) = A
(bx, by) = B
return (ax - ox) * (by - oy) - (bx - ox) * (ay - oy)
def cross_point(p0, p1, q0, q1):
(x0, y0) = p0
(x1, y1) = p1
(x2, y2) = q0
(x3, y3) = q1
dx0 = x1 - x0
dy0 = y1 - y0
d... | vfc_133408 | {
"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 3\n0 0\n8 -1\n0 8\n2 2\n4 2\n2 4\n0 0",
"output": "9.562500\n11.878676\n10.558824\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 3\n0 0\n8 -1\n-1 8\n2 2\n4 2\n2 4\n0 0",
"output... | |
taco | verifiable_code | https://codeforces.com/problemset/problem/1336/E1 | Solve the following coding problem using the programming language python:
This is the easy version of the problem. The only difference between easy and hard versions is the constraint of $m$. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom![Image]
... | ```python
MOD = 998244353
BOUND = 19
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
basis = []
for p in range(m - 1, -1, -1):
p2 = pow(2, p)
nex = -1
for i in range(n):
if l[i] >= p2:
nex = l[i]
break
if nex != -1:
basis.append(nex)
for i in range(n):
if l[i] >= p2:
l[i] ^... | vfc_133412 | {
"difficulty": "hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1336/E1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 4\n3 5 8 14\n",
"output": "2 2 6 6 0 ",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6 7\n11 45 14 9 19 81\n",
"output": "1 2 11 20 15 10 5 0 ",
"type": "stdin_stdout"
}
... |
taco | verifiable_code | https://codeforces.com/problemset/problem/917/A | Solve the following coding problem using the programming language python:
As Will is stuck in the Upside Down, he can still communicate with his mom, Joyce, through the Christmas lights (he can turn them on and off with his mind). He can't directly tell his mom where he is, because the monster that took him to the Ups... | ```python
st = input()
le = len(st)
ans = 0
for i in range(le):
l = 0
w = 0
for j in range(i, le):
if st[j] == '(':
l += 1
elif st[j] == ')':
l -= 1
else:
w += 1
if l + w < 0:
break
elif w > l:
xx = l
l = w
w = xx
elif l == w:
ans += 1
print(ans)
``` | vfc_133429 | {
"difficulty": "medium_hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/917/A",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "((?))\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "??()??\n",
"output": "7\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "??... |
taco | verifiable_code | https://codeforces.com/problemset/problem/958/A2 | Solve the following coding problem using the programming language python:
The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last ti... | ```python
(n, m) = [int(x) for x in input().split()]
list1 = []
list2 = []
for i in range(n):
list1.append(input())
for j in range(m):
list2.append(input())
list3 = []
for i in range(n - m + 1):
y = ''
for j in range(m):
y += list1[j + i]
list3.append(y)
list4 = []
for i in range(n - m + 1):
y = ''
for j in ra... | vfc_133433 | {
"difficulty": "hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/958/A2",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10 5\nsomer\nandom\nnoise\nmayth\neforc\nebewi\nthyou\nhctwo\nagain\nnoise\nsomermayth\nandomeforc\nnoiseebewi\nagainthyou\nnoisehctwo\n",
"output": "4 6\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
taco | verifiable_code | https://codeforces.com/problemset/problem/1543/A | Solve the following coding problem using the programming language python:
Welcome to Rockport City!
It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet $a$ dollars and Ronnie has bet $b$ dollars. But the fans seem to be disappointed. The excitement of the fans is... | ```python
for _ in range(int(input())):
(a, b) = map(int, input().split())
s = abs(a - b)
m = 0
if s != 0:
m = a % s
print(s, min(m, s - m))
``` | vfc_133437 | {
"difficulty": "easy",
"memory_limit": "256 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1543/A",
"time_limit": "1 second"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n8 5\n1 2\n4 4\n3 9\n",
"output": "3 1\n1 0\n0 0\n6 3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n8 5\n1 2\n4 5\n3 9\n",
"output": "3 1\n1 0\n1 0\n6 3\n",
"type": "std... |
taco | verifiable_code | https://www.codechef.com/TCFL2020/problems/TCFL20A | Solve the following coding problem using the programming language python:
Tired of the overpopulated world, Miu - The introverted cat visits a new continent in search for a new house.
There are $N$ houses lying on the X-axis.
Their positions are given by $X$$i$ , where $i$ refers to the $i$th house. ( $1 <= i <= N$... | ```python
n = int(input())
for i in range(n):
t = int(input())
li = sorted(list(map(int, input().split())))
ans = 1
dp = [li[1] - li[0]] + [0] * (t - 2) + [li[t - 1] - li[t - 2]]
for i in range(1, t - 1):
dp[i] = min(li[i] - li[i - 1], li[i + 1] - li[i])
print(max(dp))
``` | vfc_133445 | {
"difficulty": "unknown_difficulty",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/TCFL2020/problems/TCFL20A",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n6\n7 -1 2 13 -5 15\n4\n6 10 3 12\n",
"output": "5\n3\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/276/B | Solve the following coding problem using the programming language python:
The Little Girl loves problems on games very much. Here's one of them.
Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules: The players move in turns; In one move ... | ```python
import sys
import math
def check(d):
w = 0
for i in d:
if d[i] % 2 != 0:
w = w + 1
return w
def fn(n):
b = []
for i in n:
b.append(n.count(i))
d = dict(zip(n, b))
w = check(d)
if len(n) % 2 == 0 and w == 0:
print('First')
if len(n) % 2 == 0 and w != 0:
print('Second')
if len(n) % 2 != 0... | vfc_133450 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/276/B",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "aba\n",
"output": "First\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/1200/D | Solve the following coding problem using the programming language python:
Gildong has bought a famous painting software cfpaint. The working screen of cfpaint is square-shaped consisting of $n$ rows and $n$ columns of square cells. The rows are numbered from $1$ to $n$, from top to bottom, and the columns are numbered... | ```python
import sys
import math as mt
t = 1
for __ in range(t):
(n, k) = list(map(int, input().split()))
arr = []
lr = {}
d = {}
ans = 0
for i in range(n):
arr.append(input())
lr[i] = []
for j in range(n):
if arr[i][j] == 'B':
lr[i].append(j)
break
for j in range(n - 1, -1, -1):
if arr[i][j... | vfc_133454 | {
"difficulty": "hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1200/D",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 2\nBWWW\nWBBW\nWBBW\nWWWB\n",
"output": "4\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/akku-and-binary-numbers0902/1 | Solve the following coding problem using the programming language python:
Akku likes binary numbers and she likes playing with these numbers. Her teacher once gave her a question.For given value of L and R, Akku have to find the count of number X, which have only three-set bits in it's binary representation such that... | ```python
class Solution:
def solve(self, L, R):
bit_set = {}
ans = 0
for i in range(63):
for j in range(i + 1, 63):
for k in range(j + 1, 63):
curr = 0
curr |= 1 << i
curr |= 1 << j
curr |= 1 << k
if L <= curr <= R:
ans += 1
return ans
def precompute(self):
pass
``` | vfc_133458 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/akku-and-binary-numbers0902/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "L = 11 and R = 19",
"output": "4",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "L = 25 and R = 29",
"output": "3",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/550/D | Solve the following coding problem using the programming language python:
An undirected graph is called k-regular, if the degrees of all its vertices are equal k. An edge of a connected graph is called a bridge, if after removing it the graph is being split into two connected components.
Build a connected undirected ... | ```python
def printWithSymmetry(u, v, offset):
print('{0} {1}'.format(u, v))
print('{0} {1}'.format(u + offset, v + offset))
k = int(input())
if k % 2 == 0:
print('NO')
elif k == 1:
print('YES')
print('2 1')
print('1 2')
else:
print('YES')
nodesNum = k + 2
print('{0} {1}'.format(2 * nodesNum, nodesNum * k))
p... | vfc_133459 | {
"difficulty": "hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/550/D",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n",
"output": "YES\n2 1\n1 2\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://www.codechef.com/problems/BIGARRAY | Solve the following coding problem using the programming language python:
Chef is given two integers N, S.
Consider an array A of size N such that A[i]=i for every 1 ≤ i ≤ N.
You are required to find any position x(1≤ x ≤ N) such that :
(A[1]+A[2]+...A[x-1]) + (A[x+1]+A[x+2]+...A[N]) = S
If there are multiple such... | ```python
for _ in range(int(input())):
l = input('').split()
n = int(l[0])
s = int(l[1])
if 2 <= n <= 10 ** 9 and 1 <= s <= 10 ** 18:
z = n ** 2 + n - 2 * s
if z % 2 == 0 and z != 0 and (1 <= z // 2 <= n):
print(z // 2)
else:
print(-1)
``` | vfc_133467 | {
"difficulty": "easy",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/BIGARRAY",
"time_limit": "0.5 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n4 8\n5 10\n2 3\n",
"output": "2\n5\n-1\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/1303/E | Solve the following coding problem using the programming language python:
You are given a string $s$. You can build new string $p$ from $s$ using the following operation no more than two times: choose any subsequence $s_{i_1}, s_{i_2}, \dots, s_{i_k}$ where $1 \le i_1 < i_2 < \dots < i_k \le |s|$; erase the chosen ... | ```python
tt = int(input())
for _ in range(tt):
s = input()
t = input()
flag = 'NO'
j = 0
ptr = 0
while j < len(s) and ptr < len(t):
if s[j] == t[ptr]:
ptr += 1
j += 1
else:
j += 1
if ptr == len(t):
flag = 'YES'
else:
pos = [0] * 26
for i in range(len(s)):
pos[ord(s[i]) - 97] += 1
for i ... | vfc_133471 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1303/E",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\nababcd\nabcba\na\nb\ndefi\nfed\nxyz\nx\n",
"output": "YES\nNO\nNO\nYES\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/863/B | Solve the following coding problem using the programming language python:
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks.... | ```python
n = int(input())
w = list(map(int, input().split()))
ans = []
w.sort()
ans = float('inf')
n *= 2
for i in range(n - 1):
for j in range(i + 1, n):
cur = 0
a = list(w[:i] + w[i + 1:j] + w[j + 1:])
for k in range(0, len(a) - 1, 2):
cur += a[k + 1] - a[k]
ans = min(ans, cur)
print(ans)
``` | vfc_133475 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/863/B",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1 2 3 4\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n1 3 4 6 3 4 100 200\n",
"output": "5\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Skyscraper "MinatoHarukas"
Mr. Port plans to start a new business renting one or more floors of the new skyscraper with one giga floors, MinatoHarukas. He wants to rent as many vertically adjacent floors as possible, because he wants to show ad... | ```python
import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (... | vfc_133483 | {
"difficulty": "unknown_difficulty",
"memory_limit": "268.435456 megabytes",
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "8.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "15\n16\n2\n3\n9699690\n116276261\n847288609\n900660121\n987698769\n999999999\n0",
"output": "1 5\n16 1\n2 1\n1 2\n16 4389\n1236935 94\n4112949 206\n15006 30011\n46887 17718\n163837 5994\n",
"type": "stdin_stdout"
},... | |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/dearrangement-of-balls0918/1 | Solve the following coding problem using the programming language python:
You are given N balls numbered from 1 to N and there are N baskets numbered from 1 to N in front of you, the i^{th} basket is meant for the i^{th} ball. Calculate the number of ways in which no ball goes into its respective basket.
Example 1:
In... | ```python
class Solution:
def disarrange(self, N):
dp = [0 for i in range(N)]
dp[0] = 0
dp[1] = 1
if N == 2:
return 1
if N == 1:
return 0
for i in range(2, N):
dp[i] = i * (dp[i - 1] + dp[i - 2]) % (10 ** 9 + 7)
return dp[N - 1]
``` | vfc_133487 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/dearrangement-of-balls0918/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "N = 2",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3",
"output": "2",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Interns Mehta and Sharma are waiting for their "build" to complete. Mehta comes up with an interesting game with an array P of integers of size N. She defines the rules of the game as:
Pick a number i from the set {1,2,...N-2}.
Remove P[i] from ... | ```python
n = eval(input())
num = [int(i) for i in input().split()]
score = 0
while(n>2):
mx = -10000
ix = -1
for i in range(1,n-1):
if((num[i-1]*num[i+1])>=mx):
mx=num[i-1]*num[i+1]
ix=i
score+=mx
del num[ix]
n-=1
print(score)
``` | vfc_133488 | {
"difficulty": "unknown_difficulty",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "8\n477 744 474 777 447 747 777 474",
"output": "2937051",
"type": "stdin_stdout"
}
]
} | |
taco | verifiable_code | Solve the following coding problem using the programming language python:
From the childhood we are taught that a comes before b then b comes before c and so on.So whenever we try to sort any given string we sort it in that manner only placing a before b and so on.But what happens if we initially change the pattern of... | ```python
def mysort(alphabet):
return ''.join(sorted(input(), key=lambda word: [alphabet.index(c) for c in word[0]]))
if __name__ == "__main__":
for tc in range(int(input())):
print(mysort(input()))
``` | vfc_133492 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10\nihpcfylbjskmxqogaetnwzdvur\nlvjiwjvzlybrlmclbyxpopnuxlzbqxrvhnizyipzqrvsztylptnwbsvcxegtfwawvradfryklqlezbbowsuqtsyoxrkwcbmmgngaefavwoikahtllsbvowqogdripwevhayxyyjuwcdyuatiwikdoxhkutlvtdkkfjnxatmaxqkokmxpwueiatziwkocrciyvegwsha... | |
taco | verifiable_code | Solve the following coding problem using the programming language python:
In PIET's CS Deparment there is a contest of Geometry. In this contest students are told to find minimum angle between hour and minute hand.
Input:
The first line contains the number of test cases, T. T lines follow, each of which contains two ... | ```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
import math
T = int(sys.stdin.readline())
for i in range(T):
line = sys.stdin.readline().split()
hh = int(line[0])
mm = int(line[1])
hh = hh%12*30 + mm/2
mm = ... | vfc_133497 | {
"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\n12 04\n12 30\n03 37\n09 59\n00 59\n03 26\n00 00\n12 12\n02 02\n07 17",
"output": "22 \n165 \n114 \n55 \n35 \n53 \n0 \n66 \n49 \n116",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\n11... | |
taco | verifiable_code | https://www.hackerrank.com/challenges/list-comprehensions/problem | Solve the following coding problem using the programming language python:
Let's learn about list comprehensions! You are given three integers $x,y$ and $z$ representing the dimensions of a cuboid along with an integer $n$. Print a list of all possible coordinates given by $(i,j,k)$ on a 3D grid where the sum of $i+j+k... | ```python
(x, y, z, n) = [int(input()) for line in range(4)]
coords = [[i, j, k] for i in range(x + 1) for j in range(y + 1) for k in range(z + 1) if i + j + k != n]
print(coords)
``` | vfc_133501 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.hackerrank.com/challenges/list-comprehensions/problem",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n1\n1\n2\n",
"output": "[[0, 0, 0], [0, 0, 1], [0, 1, 0], [1, 0, 0], [1, 1, 1]]\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n2\n2\n2\n",
"output": "[[0, 0, 0], [0, 0, 1], [0,... |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/sum-string3151/1 | Solve the following coding problem using the programming language python:
Given a string of digits, the task is to check if it is a ‘sum-string’. A string S is called a sum-string if a rightmost substring can be written as a sum of two substrings before it and the same is recursively true for substrings before it.
... | ```python
class Solution:
def isSumString(self, S):
n = len(S)
for l in range(1, n):
sub_arr = int(S[n - l:])
if self.is_sum_string_sub(S, n - l, sub_arr, None) == 1:
return 1
return 0
def is_sum_string_sub(self, S, limit, sub_arr, sub_1):
sub_2 = 0
if sub_1 is None:
sub_1 = 0
for l_1 in r... | vfc_133505 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/sum-string3151/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "12243660",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1111112223",
"output": "1",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://www.codechef.com/problems/AVGGIFT | Solve the following coding problem using the programming language python:
Chef has a set S containing N distinct integers.
Chef wants to gift Chefina an array A of any finite length such that the following conditions hold true:
A_{i} \in S \forall i. In other words, each element of the array A should belong to the s... | ```python
T = int(input())
while T > 0:
T -= 1
L = []
(N, X) = [int(i) for i in input().split()]
S = [int(i) for i in input().split()]
if X >= min(S) and X <= max(S):
print('YES')
else:
print('NO')
``` | vfc_133507 | {
"difficulty": "medium_hard",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/AVGGIFT",
"time_limit": "1 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n3 2\n1 2 3\n1 5\n3\n2 5\n4 6\n1 5\n5\n",
"output": "YES\nNO\nYES\nYES\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://www.codechef.com/problems/CHINFL | Solve the following coding problem using the programming language python:
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
A recent glut in Chefland's markets has caused the local currency Peppercorn to devaluate sharply. (Peppercorns are getting cheaper on an average, though there could... | ```python
(n, m, d) = [int(x) for x in input().split()]
rates = []
for _ in range(n):
rates.append([int(x) for x in input().split()])
before_peppercorns = [d] * n
before_dollars = [0] * n
after_peppercorns = [None] * n
after_dollars = [None] * n
for t in range(m):
for i in range(n):
after_peppercorns[i] = max(befor... | vfc_133511 | {
"difficulty": "hard",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/CHINFL",
"time_limit": "2 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 3 5\n2 1 5 3 7 6\n2 1 4 3 6 5\n10 9 8 7 6 5",
"output": "15.0000000000",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/marks-of-pcm2529/1 | Solve the following coding problem using the programming language python:
You are provided with marks of N students in Physics, Chemistry and Maths.
Perform the following 3 operations:
Sort the students in Ascending order of their Physics marks.
Once this is done, sort the students having same marks in Physics in t... | ```python
class Solution:
def customSort(self, phy, chem, math, N):
mark = []
for i in range(N):
mark.append((phy[i], chem[i], math[i]))
mark.sort(key=lambda x: (x[0], -x[1], x[2]))
for i in range(N):
(phy[i], chem[i], math[i]) = mark[i]
``` | vfc_133515 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/marks-of-pcm2529/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "N = 10\nphy[] = {4 1 10 4 4 4 1 10 1 10}\nchem[] = {5 2 9 6 3 10 2 9 14 10}\nmath[] = {12 3 6 5 2 10 16 32 10 4}",
"output": "1 14 10\n1 2 3\n1 2 16\n4 10 10\n4 6 5\n4 5 12\n4 3 2\n10 10 4\n10 9 6\n10 9 32",
"type": "st... |
taco | verifiable_code | https://codeforces.com/problemset/problem/415/B | Solve the following coding problem using the programming language python:
Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tok... | ```python
from math import *
(n, a, b) = map(int, input().split())
x = list(map(int, input().split()))
ans = [0] * n
for i in range(n):
ans[i] = x[i] - ceil(int(x[i] * a / b) * b / a)
print(*ans)
``` | vfc_133516 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/415/B",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 1 4\n12 6 11 9 1\n",
"output": "0 2 3 1 1 ",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 1 2\n1 2 3\n",
"output": "1 0 1 ",
"type": "stdin_stdout"
},
{
"fn_na... |
taco | verifiable_code | https://codeforces.com/problemset/problem/544/B | Solve the following coding problem using the programming language python:
A map of some object is a rectangular field consisting of n rows and n columns. Each cell is initially occupied by the sea but you can cover some some cells of the map with sand so that exactly k islands appear on the map. We will call a set of ... | ```python
(n, k) = input().split()
(n, k) = (int(n), int(k))
if k > (n * n + 1) // 2:
print('NO')
exit()
print('YES')
for i in range(0, n):
for j in range(0, n):
if (i + j) % 2 == 0 and k > 0:
print('L', end='')
k -= 1
else:
print('S', end='')
print()
``` | vfc_133521 | {
"difficulty": "medium",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/544/B",
"time_limit": "1.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "65 617\n",
"output": "YES\nLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSL\nSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLS\nLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLSLS... |
taco | verifiable_code | https://www.hackerrank.com/challenges/picking-cards/problem | Solve the following coding problem using the programming language python:
There are N cards on the table and each has a number between 0 and N. Let us denote the number on the i^{th} card by c_{i}. You want to pick up all the cards. The i^{th} card can be picked up only if at least c_{i} cards have been picked up befo... | ```python
cs = int(input())
for c in range(cs):
l = int(input())
num = [int(i) for i in input().strip().split()]
num.sort()
rt = 1
for i in range(l):
if i < num[i]:
rt = 0
break
else:
rt *= i + 1 - num[i]
rt %= 10 ** 9 + 7
print(rt)
``` | vfc_133525 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.hackerrank.com/challenges/picking-cards/problem",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 \n3 \n0 0 0 \n3 \n0 0 1 \n3 \n0 3 3\n",
"output": "6 \n4 \n0\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/transitive-closure-of-a-graph0930/1 | Solve the following coding problem using the programming language python:
Given a directed graph, find out if a vertex j is reachable from another vertex i for all vertex pairs (i, j) in the given graph. Here reachable mean that there is a path from vertex i to j. The reach-ability matrix is called transitive closure ... | ```python
class Solution:
def transitiveClosure(self, N, graph):
g = [[] for _ in range(N)]
for i in range(N):
for j in range(N):
if i != j and graph[i][j] == 1:
g[i].append(j)
def helper(node, prev, seen):
if node in seen:
return seen
seen.add(node)
for neig in g[node]:
if neig !=... | vfc_133533 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/transitive-closure-of-a-graph0930/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "N = 4\ngraph = {{1, 1, 0, 1}, \n {0, 1, 1, 0}, \n {0, 0, 1, 1}, \n {0, 0, 0, 1}}",
"output": "{{1, 1, 1, 1}, \n {0, 1, 1, 1}, \n {0, 0, 1, 1}, \n {0, 0, 0, 1}}\n",
"type":... |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Benny noticed a random property of numbers. The numbers which followed this property were called as interesting numbers by Benny. Let's dive into what Benny discovered about these numbers.
1 is an interesting number.
For every N > 1 , N is int... | ```python
def rwh_primes(n):
sieve = [True] * n
for i in range(3,int(n**0.5)+1,2):
if sieve[i]:
sieve[i*i::2*i]=[False]*((n-i*i-1)//(2*i)+1)
return [2] + [i for i in range(3,n,2) if sieve[i]]
def test(a, primes):
for p in primes:
n = 0
while (a % p) == 0:
n += 1
a = a // p
if n > 1:
return False
... | vfc_133534 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "100\n177516\n548318\n947070\n996389\n442876\n581113\n232970\n244787\n709020\n235780\n872996\n566711\n910912\n257947\n388443\n388046\n175914\n683712\n477366\n243405\n816041\n749142\n592028\n782210\n136192\n938915\n436231\n584008\n49... | |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Problem Statement
JAG Kingdom is a strange kingdom such that its $N$ cities are connected only by one-way roads. The $N$ cities are numbered $1$ through $N$. ICPC (International Characteristic Product Corporation) transports its products from t... | ```python
import sys
readline = sys.stdin.readline
write = sys.stdout.write
from collections import deque
class Dinic:
def __init__(self, N):
self.N = N
self.G = [[] for i in range(N)]
self.D = {}
def add_edge(self, fr, to, cap):
forward = [to, cap, None]
forward[2] = backward = [fr, 0, forward]
self.G... | vfc_133538 | {
"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 4 1 4\n1 2\n3 1\n4 2\n3 4\n7 8 1 7\n1 2\n1 3\n2 4\n3 4\n4 5\n4 6\n5 7\n7 6\n6 4 5 2\n1 2\n1 3\n4 5\n5 6\n10 21 9 10\n9 1\n9 2\n9 3\n9 4\n10 1\n10 2\n10 3\n10 4\n1 5\n2 5\n2 6\n3 6\n3 7\n4 7\n4 8\n1 8\n5 10\n6 10\n7 10\n10 8\n10 9... | |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Stellar history 2005.11.5. You are about to engage an enemy spacecraft as the captain of the UAZ Advance spacecraft. Fortunately, the enemy spaceship is still unnoticed. In addition, the space coordinates of the enemy are already known, and the ... | ```python
import sys
import os
import math
import random
def det(a, b, c):
return +a[0] * b[1] * c[2] + a[2] * b[0] * c[1] + a[1] * b[2] * c[0] - a[2] * b[1] * c[0] - a[1] * b[0] * c[2] - a[0] * b[2] * c[1]
def sub(v0, v1):
return (v0[0] - v1[0], v0[1] - v1[1], v0[2] - v1[2])
p0 = list(map(int, input().split()))
p1... | vfc_133546 | {
"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": "-10 6 6\n10 2 6\n0 10 0\n0 10 10\n0 0 10",
"output": "MISS\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "-10 0 0\n10 0 0\n0 10 0\n0 10 10\n0 1 10",
"output": "HIT\n",
"type":... | |
taco | verifiable_code | https://codeforces.com/problemset/problem/928/D | Solve the following coding problem using the programming language python:
Arcady is a copywriter. His today's task is to type up an already well-designed story using his favorite text editor.
Arcady types words, punctuation signs and spaces one after another. Each letter and each sign (including line feed) requires o... | ```python
class Trie:
def __init__(self):
self.letter___node = {}
self.words_nr = 0
def add_word(self, word):
word = word + '$'
curr_node = self
for letter in word:
if letter not in curr_node.letter___node:
curr_node.letter___node[letter] = Trie()
curr_node.words_nr += 1
curr_node = curr_node... | vfc_133550 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/928/D",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "snow affects sports such as skiing, snowboarding, and snowmachine travel.\nsnowboarding is a recreational activity and olympic and paralympic sport.\n",
"output": "141\n",
"type": "stdin_stdout"
},
{
"fn_n... |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/c-operators-relational-set-21407/1 | Solve the following coding problem using the programming language python:
Given two numbers A and B and task is to check whether A is greater than or less than or equals to B.
Example 1:
Input:
A = 2, B = 5
Output:
2 is less than 5
Explanation:
The output is self-
explanatory.
Example 2:
Input:
A = 6, B = 3
Outpu... | ```python
class Solution:
def compareNum(ob, A, B):
if A > B:
return str(A) + ' is greater than ' + str(B)
elif A < B:
return str(A) + ' is less than ' + str(B)
else:
return str(A) + ' is equals to ' + str(B)
``` | vfc_133559 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/c-operators-relational-set-21407/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "A = 2, B = 5",
"output": "2 is less than 5",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "A = 6, B = 3",
"output": "6 is greater than 3",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://www.codechef.com/problems/FILLMTR | Solve the following coding problem using the programming language python:
A matrix B (consisting of integers) of dimension N × N is said to be good if there exists an array A (consisting of integers) such that B[i][j] = |A[i] - A[j]|, where |x| denotes absolute value of integer x.
You are given a partially filled mat... | ```python
for _ in range(int(input())):
(n, q) = map(int, input().split())
arr = []
a = [-1] * (n + 1)
b = []
a[1] = 0
ans = 0
for _ in range(q):
(x, y, z) = map(int, input().split())
if x == y:
if z != 0:
ans += 1
else:
arr.append([min(x, y), max(x, y), z])
arr.sort()
for i in arr:
if a[i[0]... | vfc_133564 | {
"difficulty": "hard",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/FILLMTR",
"time_limit": "3 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n2 2\n1 1 0\n1 2 1\n2 3\n1 1 0\n1 2 1\n2 1 0\n3 2\n2 2 0\n2 3 1\n3 3\n1 2 1\n2 3 1\n1 3 1\n",
"output": "yes\nno\nyes\nno\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://www.codechef.com/problems/RECTLIT | Solve the following coding problem using the programming language python:
You are given an axis-aligned rectangle in a 2D Cartesian plane. The bottom left corner of this rectangle has coordinates (0,0)$(0, 0)$ and the top right corner has coordinates (N−1,N−1)$(N-1, N-1)$. You are also given K$K$ light sources; each l... | ```python
def assess(sq, points):
EWct = 0
NSct = 0
for (a, b) in points:
EW = a == 0 or a == sq
NS = b == 0 or b == sq
if EW and NS:
return 'yes'
EWct += EW
NSct += NS
if NSct + EWct == 0 or len(points) == 1:
return 'no'
if EWct >= 2 or NSct >= 2:
return 'yes'
if len(points) == 2:
return 'no'
... | vfc_133579 | {
"difficulty": "unknown_difficulty",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/RECTLIT",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2 10\n0 0\n1 0\n2 10\n1 2\n1 1\n",
"output": "yes\nno\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://www.codechef.com/JUNE16/problems/FRJUMP | Solve the following coding problem using the programming language python:
Chef likes to travel a lot. Every day Chef tries to visit as much cities as possible. Recently he had a quite a few trips of great Chefland for learning various recipes. Chefland had N cities numbered from 1 to N. People in Chefland are very fri... | ```python
n = int(input())
a = list(map(int, input().split()))
q = int(input())
while q > 0:
i = 1
tot = a[0]
b = list(map(int, input().split()))
if b[0] == 1:
a[b[1] - 1] = b[2]
else:
tot = a[0]
while 1 + i * b[1] <= n:
tot = tot * a[i * b[1]]
i = i + 1
m = str(tot)
tot = tot % 1000000007
print(... | vfc_133583 | {
"difficulty": "unknown_difficulty",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/JUNE16/problems/FRJUMP",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n1 2 3 4 5\n3\n2 1\n1 3 10\n2 2\n",
"output": "1 120\n5 50\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/subarray-with-least-average5031/1 | Solve the following coding problem using the programming language python:
Given an array of size n, Find the subarray with least average of size k.
Example 1:
Input: nums = [30, 20, 10], k = 1
Output: 3
Explanation: Subarrays of length 1 are
{30}, {20}, {10}. {10} has the least
average.
Example 2:
Input: nums = [30... | ```python
class Solution:
def least_average(self, nums, k):
minAvg = 0
avg = 0
index = 1
n = len(nums)
for i in range(k):
avg += nums[i]
avg /= k
minAvg = avg
for i in range(1, n - k + 1):
avg = avg * k - nums[i - 1] + nums[i + k - 1]
avg /= k
if minAvg > avg:
minAvg = avg
index = ... | vfc_133587 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/subarray-with-least-average5031/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "nums = [30, 20, 10], k = 1",
"output": "3",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/1374/C | Solve the following coding problem using the programming language python:
You are given a bracket sequence $s$ of length $n$, where $n$ is even (divisible by two). The string $s$ consists of $\frac{n}{2}$ opening brackets '(' and $\frac{n}{2}$ closing brackets ')'.
In one move, you can choose exactly one bracket and ... | ```python
t = int(input())
for _ in range(t):
n = int(input())
s = input()
while '()' in s:
s1 = s.replace('()', '')
s = s1
print(len(s) // 2)
``` | vfc_133588 | {
"difficulty": "easy",
"memory_limit": "256 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1374/C",
"time_limit": "1 second"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n2\n)(\n4\n()()\n8\n())()()(\n10\n)))((((())\n",
"output": "1\n0\n1\n3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n2\n)(\n4\n)()(\n8\n())()()(\n10\n)))((((())\n",
"output": ... |
taco | verifiable_code | https://www.codechef.com/problems/POPCORN | Solve the following coding problem using the programming language python:
Vishesh has gone to watch the new Spider-Man movie, but he is having troubles choosing which Popcorn-and-Coke combo to buy.
There are three combos A, B, and C available at the counter. You are given the time (in minute) for which each Popcorn b... | ```python
t = int(input())
for i in range(t):
(a1, a2) = map(int, input().split())
(b1, b2) = map(int, input().split())
(c1, c2) = map(int, input().split())
print(max(a1 + a2, b1 + b2, c1 + c2))
``` | vfc_133592 | {
"difficulty": "easy",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/POPCORN",
"time_limit": "0.5 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n3 6\n5 10\n8 7\n99 1\n55 55\n33 51\n54 146\n5436 627\n1527 5421\n",
"output": "15\n110\n6948\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://www.hackerrank.com/challenges/python-sort-sort/problem | Solve the following coding problem using the programming language python:
You are given a spreadsheet that contains a list of $N$ athletes and their details (such as age, height, weight and so on). You are required to sort the data based on the $K^{th}$ attribute and print the final resulting table. Follow the example... | ```python
(n, m) = [int(i) for i in input().split()]
narr = [0 for i in range(n)]
for i in range(n):
narr[i] = [int(j) for j in input().split()]
k = int(input())
narr.sort(key=lambda x: int(x[k]))
for i in range(n):
print(*narr[i], sep=' ')
``` | vfc_133596 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.hackerrank.com/challenges/python-sort-sort/problem",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 3\n10 2 5\n7 1 0\n9 9 9\n1 23 12\n6 5 9\n1\n",
"output": "7 1 0\n10 2 5\n6 5 9\n9 9 9\n1 23 12\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://www.codechef.com/CORS2020/problems/JOJO | Solve the following coding problem using the programming language python:
Ganesh lives in Gopalmath. He is looking for Jojo. So he decides to collect Aadhar Card Information of all the citizens of India from UIDAI.
Someone told Ganesh that the sum of all the digits of Jojo’s Aadhar number is divisible by 10 and it is ... | ```python
for _ in range(int(input())):
N = input()
num = list(N)
s = 0
for n in num:
if n.isnumeric():
s += int(n)
x = (10 - s % 10) % 10
print(int(N) * 10 + int(x))
``` | vfc_133600 | {
"difficulty": "unknown_difficulty",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/CORS2020/problems/JOJO",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n3\n",
"output": "37\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://www.codechef.com/problems/HELPVOLD | Solve the following coding problem using the programming language python:
The story of Harry Potter begins when Lord Voldemort arrives at his house at Privet Drive. Harry's house has N rooms placed in one line. Each room has its own energy level and no two rooms have exactly same energy. Lord Voldemort arrives at the ... | ```python
n = int(input())
Ar = list(map(int, input().split()))
Ar.sort()
E = 0
for i in range(n - 1):
e = Ar[i] * Ar[i + 1]
E = E + e
print(E)
``` | vfc_133604 | {
"difficulty": "easy",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/HELPVOLD",
"time_limit": "1 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n4 2 1",
"output": "10",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/distributing-question-papers2513/1 | Solve the following coding problem using the programming language python:
Given a matrix of size n*m. Every cell of matrix contains either 'A' or 'B'. Exchange is defined as swaping the characters between two cells. Your task is to find the minimum number of exchange needed to rearrange the given matrix such that no a... | ```python
class Solution:
def MinimumExchange(self, matrix):
ans = 0
for i in range(n):
for j in range(m):
if (i + j) % 2 == 0 and matrix[i][j] == 'B':
ans += 1
elif (i + j) % 2 == 1 and matrix[i][j] == 'A':
ans += 1
ans2 = 0
for i in range(n):
for j in range(m):
if (i + j) % 2 == ... | vfc_133608 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/distributing-question-papers2513/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "matrix = {{A,A,B,A},{B,A,B,A},{B,B,A,B}}",
"output": "2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "matrix = {{A,B},{B,A}}",
"output": "0",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/index-of-first-1-in-a-sorted-array-of-0s-and-1s4048/1 | Solve the following coding problem using the programming language python:
Given a sorted array consisting 0s and 1s. The task is to find the index of first 1 in the given array.
Example 1:
Input :
arr[] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 1}
Output :
6
Explanation:
The index of first 1 in the array is 6.
Example 2:
Inp... | ```python
class Solution:
def firstIndex(self, arr, n):
lower = 0
higher = n - 1
while lower <= higher:
mid = (lower + higher) // 2
if arr[mid] == 1 and (mid == 0 or arr[mid - 1] == 0):
return mid
elif arr[mid] == 0:
lower = mid + 1
else:
higher = mid - 1
return -1
``` | vfc_133609 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/index-of-first-1-in-a-sorted-array-of-0s-and-1s4048/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "arr[] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 1}",
"output": "6",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "arr[] = {0, 0, 0, 0}",
"output": "-1",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/1722/C | Solve the following coding problem using the programming language python:
Three guys play a game: first, each person writes down $n$ distinct words of length $3$. Then, they total up the number of points as follows:
if a word was written by one person — that person gets 3 points,
if a word was written by two people ... | ```python
T = int(input())
for i in range(T):
n = int(input())
P1 = set(input().split())
P2 = set(input().split())
P3 = set(input().split())
(S1, S2, S3) = (0, 0, 0)
I = P1.intersection(P2, P3)
P1.difference_update(I)
P2.difference_update(I)
P3.difference_update(I)
I12 = P1.intersection(P2)
I23 = P2.intersec... | vfc_133610 | {
"difficulty": "easy",
"memory_limit": "256 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1722/C",
"time_limit": "1 second"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1\nabc\ndef\nabc\n3\norz for qaq\nqaq orz for\ncod for ces\n5\niat roc hem ica lly\nbac ter iol ogi sts\nbac roc lly iol iat\n",
"output": "1 3 1 \n2 2 6 \n9 11 5 \n",
"type": "stdin_stdout"
},
{
"fn_na... |
taco | verifiable_code | https://codeforces.com/problemset/problem/382/B | Solve the following coding problem using the programming language python:
Arthur and Alexander are number busters. Today they've got a competition.
Arthur took a group of four integers a, b, w, x (0 ≤ b < w, 0 < x < w) and Alexander took integer с. Arthur and Alexander use distinct approaches to number bustings. Ale... | ```python
(a, b, w, x, c) = map(int, input().split())
def result(a, b, w, x, c, s):
na = a - (s * x - b) / w
nc = c - s
return (na, nc)
def solve(a, b, w, x, c):
left = 0
right = 1e+16
if c <= a:
return 0
while left < right:
half = (left + right) // 2
ret = result(a, b, w, x, c, half)
if ret[1] <= ret[... | vfc_133618 | {
"difficulty": "hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/382/B",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 2 3 1 6\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 2 3 1 7\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"inpu... |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Suppose you have a string S which has length N and is indexed from 0 to N−1. String R is the reverse of the string S. The string S is funny if the condition |Si−Si−1|=|Ri−Ri−1| is true for every i from 1 to N−1.
(Note: Given a string str, stri ... | ```python
for _ in range(0, eval(input())):
case=list(input())
case2 = list(reversed(case))
ans=True
for x in range(1, len(case)):
a = abs(ord(case[x])-ord(case[x-1]))
# print a
b = abs(ord(case2[x])-ord(case2[x-1]))
# print b
if(a!=b):
ans=False
break
if(ans):
print("Funny")
else:
print("... | vfc_133622 | {
"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\nacxz\nbcxz",
"output": "Not Funny\nNot Funny",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\njkotzxzxrxtzytlruwrxytyzsuzytwyzxuzytryzuzysxvsmupouysywywqlhg\neklrywzvpxtvoptlrskmskszvw... | |
taco | verifiable_code | https://codeforces.com/problemset/problem/588/B | Solve the following coding problem using the programming language python:
Duff is in love with lovely numbers! A positive integer x is called lovely if and only if there is no such positive integer a > 1 such that a^2 is a divisor of x. [Image]
Malek has a number store! In his store, he has only divisors of positive... | ```python
from math import sqrt
def main():
n = int(input())
prime = []
m = int(sqrt(n))
if n % 2 == 0:
prime.append(2)
while n % 2 == 0:
n = n // 2
for i in range(3, m + 1, 2):
if n < i:
break
if n % i == 0:
prime.append(i)
while n % i == 0:
n = n // i
if n > 1:
prime.append(n)
ans = ... | vfc_133626 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/588/B",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10\n",
"output": "10\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "12\n",
"output": "6\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://www.codechef.com/problems/AUDIBLE | Solve the following coding problem using the programming language python:
Chef's dog *binary* hears frequencies starting from 67 Hertz to 45000 Hertz (both inclusive).
If Chef's commands have a frequency of X Hertz, find whether *binary* can hear them or not.
------ Input Format ------
- The first line of input w... | ```python
T = int(input())
for _ in range(T):
x = int(input())
if x >= 67 and x <= 45000:
print('YES')
else:
print('NO')
``` | vfc_133630 | {
"difficulty": "easy",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/AUDIBLE",
"time_limit": "1 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n42\n67\n402\n45000\n45005\n",
"output": "NO\nYES\nYES\nYES\nNO\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://www.codechef.com/SPTC2020/problems/CPCEJC2 | Solve the following coding problem using the programming language python:
Chef has provided with a sequence of integers of length $N$ arranged in an unsorted fashion.
The elements of the sequence are ordered as ${A1,A2,A3.....A'N}$
The task of the chef is to identify the highest and lowest value among the given sequen... | ```python
n = int(input())
a = list(map(int, input().split()))
a.sort()
print(a[-1], a[0])
``` | vfc_133634 | {
"difficulty": "unknown_difficulty",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/SPTC2020/problems/CPCEJC2",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n3 2 7 9 4\n",
"output": "9 2\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/1370/B | Solve the following coding problem using the programming language python:
Ashish has an array a of consisting of 2n positive integers. He wants to compress a into an array b of size n-1. To do this, he first discards exactly 2 (any two) elements from a. He then performs the following operation until there are no eleme... | ```python
t = int(input())
def swap(a, b):
if len(a) > len(b):
return (b, a)
else:
return (a, b)
def printcomb(a, b):
(a, b) = swap(a, b)
for i in range(0, len(a), 2):
print(a[i] + 1, a[i + 1] + 1)
for i in range(0, len(b), 2):
print(b[i] + 1, b[i + 1] + 1)
for i in range(t):
n = int(input())
a = [int(... | vfc_133638 | {
"difficulty": "easy",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1370/B",
"time_limit": "1.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10\n9\n7 5 4 3 1 4 8 8 2 10 5 9 6 9 4 9 8 7\n2\n4 6 4 2\n2\n9 4 7 7\n4\n9 2 3 7 6 7 6 4\n10\n1 3 7 4 6 5 8 2 7 7 1 4 2 10 3 10 9 7 3 7\n10\n6 3 6 10 10 7 6 4 4 2 8 3 9 6 4 3 2 10 3 7\n3\n7 8 7 8 3 9\n5\n7 4 4 4 7 5 9 7 7 3\n3\n7 6 ... |
taco | verifiable_code | https://www.codechef.com/problems/EQUALHAMMING | Solve the following coding problem using the programming language python:
Chef is given two binary strings A and B, each having length N.
Chef wants to find the number of binary strings C, of length N, such that H(A, C) = H(B, C), where H(X, Y) denotes the *hamming distance* between the strings X and Y.
Since the an... | ```python
for _ in range(int(input())):
n = int(input())
a = input()
b = input()
m = 0
for i in range(n):
if a[i] == b[i]:
m += 1
if n - m & 1:
print(0)
continue
mod = 10 ** 9 + 7
ans = pow(2, m, mod)
nr = 1
dr = 1
for i in range(1, n - m + 1):
nr = nr * i % mod
for i in range(1, (n - m) // 2 + 1... | vfc_133642 | {
"difficulty": "medium_hard",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/EQUALHAMMING",
"time_limit": "1 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n2\n11\n00\n5\n10101\n10101\n3\n101\n011\n",
"output": "2\n32\n4\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/1375/C | Solve the following coding problem using the programming language python:
You are given an array $a$ of length $n$, which initially is a permutation of numbers from $1$ to $n$. In one operation, you can choose an index $i$ ($1 \leq i < n$) such that $a_i < a_{i + 1}$, and remove either $a_i$ or $a_{i + 1}$ from the ar... | ```python
for a in [*open(0)][2::2]:
a = a.split()
print('YNEOS'[int(a[0]) >= int(a[-1])::2])
``` | vfc_133647 | {
"difficulty": "medium",
"memory_limit": "256 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1375/C",
"time_limit": "1 second"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n3\n1 2 3\n4\n3 1 2 4\n3\n2 3 1\n6\n2 4 6 1 3 5\n",
"output": "YES\nYES\nNO\nYES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n3\n1 2 3\n4\n3 1 2 4\n3\n2 3 1\n6\n2 4 12 1 3 5\n",
... |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/f7bfa137576243795abb0595962d61b632bbad21/1 | Solve the following coding problem using the programming language python:
Given N nodes of a tree and a list of edges. Find the minimum number of nodes to be selected to light up all the edges of the tree.
An edge lights up when at least one node at the end of the edge is selected.
Example 1:
Input:
N = 6
edges[] = {(... | ```python
class Solution:
def dfs(self, graph, u, p):
(exc, inc) = (0, 1)
for v in graph[u]:
if v != p:
(cexc, cinc) = self.dfs(graph, v, u)
exc += cinc
inc += min(cinc, cexc)
return (exc, inc)
def countVertex(self, N, edges):
graph = [[] for _ in range(N)]
for (u, v) in edges:
graph[u -... | vfc_133652 | {
"difficulty": "medium_hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/f7bfa137576243795abb0595962d61b632bbad21/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "N = 6\r\nedges[] = {(1,2), (1,3), (2,4), (3,5), (3,6)}",
"output": "2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "N = 3\r\narr[] = {(1,2), (1,3)}",
"output": "1",
"type": "st... |
taco | verifiable_code | https://codeforces.com/problemset/problem/1701/D | Solve the following coding problem using the programming language python:
Monocarp had a permutation $a$ of $n$ integers $1$, $2$, ..., $n$ (a permutation is an array where each element from $1$ to $n$ occurs exactly once).
Then Monocarp calculated an array of integers $b$ of size $n$, where $b_i = \left\lfloor \frac... | ```python
import heapq
def solve(arr):
ranges_begin = [[] for _ in range(len(arr) + 1)]
for j in range(len(arr)):
val = arr[j]
i = j + 1
if val == 0:
min_real = i + 1
max_real = len(arr)
else:
max_real = i // val
if i % (val + 1) == 0:
min_real = i // (val + 1) + 1
else:
min_real = i /... | vfc_133657 | {
"difficulty": "hard",
"memory_limit": "256 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1701/D",
"time_limit": "4 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n4\n0 2 0 1\n2\n1 1\n5\n0 0 1 4 1\n3\n0 1 3\n",
"output": "2 1 4 3 \n1 2 \n3 4 2 1 5 \n3 2 1 \n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/flattening-a-linked-list/1 | Solve the following coding problem using the programming language python:
Given a Linked List of size N, where every node represents a sub-linked-list and contains two pointers:
(i) a next pointer to the next node,
(ii) a bottom pointer to a linked list where this node is head.
Each of the sub-linked-list is in sorted... | ```python
def merge(head1, head2):
mergeHead = dummy = Node(None)
(curr1, curr2) = (head1, head2)
while curr1 and curr2:
if curr1.data <= curr2.data:
dummy.bottom = curr1
curr1 = curr1.bottom
else:
dummy.bottom = curr2
curr2 = curr2.bottom
dummy = dummy.bottom
if curr1:
dummy.bottom = curr1
if ... | vfc_133662 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/flattening-a-linked-list/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 -> 10 -> 19 -> 28\r\n| | | | \r\n7 20 22 35\r\n| | | \r\n8 50 40\r\n| | \r\n30 45",
"output": "5-> 7-> 8- > 10 -> 19-> 20->\r\n22-> 28-> 30-> 35->... |
taco | verifiable_code | https://www.hackerrank.com/challenges/number-groups/problem | Solve the following coding problem using the programming language python:
The positive odd numbers are sorted in ascending order as $1,3,5,7,9,11,13,15,17,19\ldots$, and grouped as $(1),(3,5),(7,9,11),(13,15,17,19),...$ and so on.
Thus, the first group is $\left(1\right)$, the second group is $(3,5)$, the third group... | ```python
import sys
def sumOfGroup(k):
return k ** 3
k = int(input().strip())
answer = sumOfGroup(k)
print(answer)
``` | vfc_133663 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.hackerrank.com/challenges/number-groups/problem",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n",
"output": "27\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/missing-element-of-ap2228/1 | Solve the following coding problem using the programming language python:
Find the missing element from an ordered array arr[], consisting of N elements representing an Arithmetic Progression(AP).
Note: There always exists an element which upon inserting into sequence forms Arithmetic progression. Boundary elements (f... | ```python
class Solution:
def findMissing(self, arr, n):
total = (n + 1) / 2 * (arr[0] + arr[n - 1])
for i in arr:
total -= i
return int(total)
``` | vfc_133667 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/missing-element-of-ap2228/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "N = 6\r\nArr[] = {2, 4, 8, 10, 12, 14}",
"output": "6",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "N = 6\r\nArr[] = {1, 6, 11, 16, 21, 31}",
"output": "26",
"type": "stdin_std... |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Little Arihant has always wanted to be the best Pokemon trainer in this world. And he thinks he has achieved his goal, so he wants to quickly go and meet Professor Oak and verify this fact. But like all Pokemon trainers, he has a weird habit, to... | ```python
k = eval(input())
lst = [int(x) for x in input().split()]
lst = sorted(lst,reverse=True)
for i in range(len(lst)):
lst[i] = lst[i]+i+1
count = max(lst)+1
print(count)
``` | vfc_133672 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "20000\n297893 297752 298925 297717 150007 293554 150008 295829 298003 298330 293177 150006 150001 150005 298104 150008 150003 291190 150000 296486 150003 150001 299991 290748 297107 150000 150004 298643 294306 150009 298008 150000 ... | |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/leaf-under-budget/1 | Solve the following coding problem using the programming language python:
Given a binary tree and a budget. Assume you are at the root of the tree(level 1), you need to maximise the count of leaf nodes you can visit in your budget if the cost of visiting a leaf node is equal to the level of that leaf node.
Example 1:... | ```python
class Solution:
def getCount(self, root, n):
q = [root]
lev = 0
m = 0
while q:
l = len(q)
lev += 1
for i in range(l):
p = q.pop(0)
if p.left is None and p.right is None and (n >= lev):
m += 1
n -= lev
if p.left:
q.append(p.left)
if p.right:
q.append(p.rig... | vfc_133677 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/leaf-under-budget/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10\n / \\\n 8 2\n / / \\\n 3 3 6\n \\\n 4\nand budget = 8",
"output": "2",
"type": "stdin_stdout"
},... |
taco | verifiable_code | https://codeforces.com/problemset/problem/136/C | Solve the following coding problem using the programming language python:
Little Petya very much likes arrays consisting of n integers, where each of them is in the range from 1 to 109, inclusive. Recently he has received one such array as a gift from his mother. Petya didn't like it at once. He decided to choose exac... | ```python
n = input()
li = list(map(int, input().split(' ')))
li.sort()
if li[-1] != 1:
li.insert(0, 1)
else:
li.insert(0, 2)
del li[-1]
li.sort()
print(' '.join(map(str, li)))
``` | vfc_133682 | {
"difficulty": "easy",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/136/C",
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n4\n",
"output": "1 ",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n2\n",
"output": "1 ",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\n5 6... |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/cec5db442a5652d07dd41e37ea780345f08c9a3d/1 | Solve the following coding problem using the programming language python:
Elena is the topper of the class. Once her teacher asked her a problem. He gave Elena an array of integers of length n. He calls a subset of array arr good if its product can be represented as a product of one or more distinct prime numbers. He ... | ```python
from typing import List
class Solution:
def goodSubsets(self, n: int, arr: List[int]) -> int:
from functools import reduce
MOD = 10 ** 9 + 7
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]
A = [0] * 31
for v in arr:
A[v] += 1
def exc(*ex):
return [v for v in primes if v not in ex and A[v] ... | vfc_133686 | {
"difficulty": "medium_hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/cec5db442a5652d07dd41e37ea780345f08c9a3d/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "N:4\r\narr:{1,2,3,4}",
"output": "6",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "N:3\r\narr:{2, 2, 3}",
"output": "5",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://www.codechef.com/problems/BESTOFTWO | Solve the following coding problem using the programming language python:
Chef took an examination two times. In the first attempt, he scored X marks while in the second attempt he scored Y marks. According to the rules of the examination, the best score out of the two attempts will be considered as the final score.
... | ```python
t = int(input())
for i in range(t):
(X, Y) = map(int, input().split())
print(max(X, Y))
``` | vfc_133687 | {
"difficulty": "easy",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/BESTOFTWO",
"time_limit": "0.5 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n40 60\n67 55\n50 50\n1 100\n",
"output": "60\n67\n50\n100\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | Solve the following coding problem using the programming language python:
There is the word heuristics. It's a relatively simple approach that usually works, although there is no guarantee that it will work. The world is full of heuristics because it is simple and powerful.
Some examples of heuristics include: In an ... | ```python
import sys
input = sys.stdin.readline
while True:
(n, m, k, l) = map(int, input().split())
if n == 0:
break
ranking = []
for _ in range(n):
(name, x) = input().split()
x = int(x)
ranking.append([x, name])
ranking.sort(key=lambda x: (-x[0], x[1]))
favs = {input().strip() for _ in range(m)}
favs_... | vfc_133691 | {
"difficulty": "unknown_difficulty",
"memory_limit": "134.217728 megabytes",
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "8.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 1 3 4\nyskwcnt 16\nakzakr 7\ntsnukk 12\nfnmyi 13\nakzakr\n4 1 3 5\nakzakr 7\ntsnukk 12\nfnmyi 13\nyskwcnt 16\nakzakr\n4 2 2 1\nakzakr 4\ntsnukk 6\nyskwcnt 6\nfnmyi 12\nakzakr\nfnmyi\n5 2 3 28\nknmmdk 6\nskrkyk 14\ntmemm 14\nakmhm... | |
taco | verifiable_code | https://www.codechef.com/problems/CBSPEED | Solve the following coding problem using the programming language python:
In ChefLand, human brain speed is measured in bits per second (bps). Chef has a threshold limit of X bits per second above which his calculations are prone to errors. If Chef is currently working at Y bits per second, is he prone to errors?
If ... | ```python
(a, b) = map(int, input().split())
if a >= b:
print('NO')
else:
print('YES')
``` | vfc_133695 | {
"difficulty": "easy",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/CBSPEED",
"time_limit": "0.5 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "7 9\n",
"output": "YES",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6 6\n",
"output": "NO",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "31 53\n"... |
taco | verifiable_code | https://www.codechef.com/problems/TAVISUAL | Solve the following coding problem using the programming language python:
At the end of a busy day, The Chef and his assistants play a game together. The game is not just for fun but also used to decide who will have to clean the kitchen. The Chef is a Game Master, so his concern is how to manage the game but not how ... | ```python
T = int(input())
for i in range(T):
(n, c, q) = map(int, input().split())
for i in range(q):
(l, r) = map(int, input().split())
if c <= r and c >= l:
c = r - (c - l)
print(c)
``` | vfc_133704 | {
"difficulty": "easy",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/TAVISUAL",
"time_limit": "1 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n5 2 3\n1 4\n3 5\n1 5",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n5 2 3\n1 4\n3 5\n0 5",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_na... |
taco | verifiable_code | Solve the following coding problem using the programming language python:
In McD's Burger, n hungry burger fans are ordering burgers. The ith order is placed by the ith fan at ti time and it takes di time to procees. What is the order in which the fans will get their burgers?
Input Format
On the first line you will ... | ```python
l=[]
n=int(input())
for ti in range(n):
f,s=list(map(int,input().split()))
l.append(f+s)
while n>=1:
mn=99999999999999999999
for i in range(len(l)):
if mn>l[i]:
mn=l[i]
for i in range(len(l)):
if mn==l[i]:
print(i+1, end=' ')
l[i]=9999999999999999999999
n=n-1
``` | vfc_133708 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "25\n122470 725261\n193218 693005\n355776 603340\n830347 284246\n974815 823134\n251206 572501\n55509 927152\n299590 651593\n222305 641645\n984018 463771\n494787 286091\n217190 833029\n820867 380896\n744986 630663\n875880 667\n449199... | |
taco | verifiable_code | https://www.hackerrank.com/challenges/longest-mod-path/problem | Solve the following coding problem using the programming language python:
In the middle of a nightmare, Maxine suddenly finds herself in a mysterious room with the following items:
A piece of paper with the word score and the integer $\mbox{0}$ written on it.
A map of the castle where the room is located.
There are ... | ```python
from fractions import gcd
n = int(input())
adjlst = [[] for i in range(n)]
for j in range(0, n):
arr = list(map(int, input().split()))
a = arr[0] - 1
b = arr[1] - 1
c = arr[2]
adjlst[a].append((b, c))
adjlst[b].append((a, -c))
dist = [None] * n
parents = [set() for i in range(n)]
dist[0] = 0
stack = [0]... | vfc_133712 | {
"difficulty": "medium_hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.hackerrank.com/challenges/longest-mod-path/problem",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 3 5\n2 3 8\n2 1 31\n1\n1 2 13\n",
"output": "12\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Given a string S, count the number of non empty sub strings that are palindromes.
A sub string is any continuous sequence of characters in the string.
A string is said to be palindrome, if the reverse of the string is same as itself.
Two sub str... | ```python
from sys import *
def longestPallindrome(seq):
seqLen = len(seq)
l = [maxint] * (seqLen*2 + 1)
nl = [0] * (seqLen*2 + 1)
i = 0
k = 0
palLen = 0
numPal = 0
while i < seqLen:
if i > palLen and seq[i - palLen - 1] == seq[i]:
palLen += 2
numPal += 1
i += 1
continue
nl[k] = numPal
l[k] = ... | vfc_133716 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "mygrlbiadhzlabefvjtghfrtydurkpmoveczbqzzlenezq\n",
"output": "48\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "fzxldqljeiiah\n",
"output": "52\n",
"type": "stdin_stdout"
... | |
taco | verifiable_code | https://www.codechef.com/problems/PIANO1 | Solve the following coding problem using the programming language python:
Recently, Chef got obsessed with piano. He is a just a rookie in this stuff and can not move his fingers from one key to other fast enough. He discovered that the best way to train finger speed is to play scales.
There are different kinds of sc... | ```python
for t in range(int(input())):
s = input()
n = int(input())
l = len(s)
c = 0
for i in range(l):
if s[i] == 'T':
c += 2
else:
c += 1
p = 0
r = 12 * n
while r - c > 0:
r -= c
p += r
print(p)
``` | vfc_133720 | {
"difficulty": "medium_hard",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/PIANO1",
"time_limit": "1 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 \nTTTT\n1\nTTSTTTS\n3\n\n\n",
"output": "4\n36\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 \nTTTT\n0\nTTSTTTS\n3",
"output": "0\n36\n",
"type": "stdin_stdout"
},
... |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/minimum-element-whose-n-th-power-is-greater-than-product-of-an-array4640/1 | Solve the following coding problem using the programming language python:
Given an array of N numbers. the task is to find minimum positive integer which can be assigned to every array element such that product of all elements of this new array is strictly greater than product of all elements of the initial array.
Exa... | ```python
import math as m
class Solution:
def findMin(self, a, n):
summ = 0
for i in range(n):
summ += m.log(a[i])
x = m.exp(summ / n)
return int(x + 1)
``` | vfc_133725 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/minimum-element-whose-n-th-power-is-greater-than-product-of-an-array4640/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "Arr[] = {4, 2, 1, 10, 6}",
"output": "4",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "Arr[] = {3, 2, 1, 4}",
"output": "3",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | Solve the following coding problem using the programming language python:
I am a pipe tie craftsman. As long as you get the joints and pipes that connect the pipes, you can connect any pipe. Every day, my master gives me pipes and joints, which I connect and give to my master. But if you have too many pipes, you can't... | ```python
import sys
def solve(n):
pipes = [int(p) for p in input().split()]
joints = sorted([int(j) for j in input().split()])
total_length = sum(pipes)
record = total_length * n
while joints:
total_length += joints.pop()
n -= 1
if total_length * n > record:
record = total_length * n
else:
break
r... | vfc_133727 | {
"difficulty": "unknown_difficulty",
"memory_limit": "134.217728 megabytes",
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "1.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 1 1\n3 3\n4\n3 1 3 3\n1 1 1\n5\n1 2 3 4 5\n4 3 2 1\n0",
"output": "12\n40\n76\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n1 1 1\n3 3\n4\n3 1 3 3\n1 1 1\n5\n1 2 3 4 5\n3 3 2 1\n... | |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/find-the-sum-of-last-n-nodes-of-the-linked-list/1 | Solve the following coding problem using the programming language python:
Given a single linked list of size M, your task is to complete the function sumOfLastN_Nodes(), which should return the sum of last N nodes of the linked list.
Input:
The function takes two arguments as input, the reference pointer to the head o... | ```python
def sumOfLastN_Nodes(head, n):
if n == 0 or head is None:
return 0
slow = head
fast = head
for _ in range(n):
if fast is None:
return 0
fast = fast.next
while fast:
slow = slow.next
fast = fast.next
node_sum = 0
while slow:
node_sum += slow.data
slow = slow.next
return node_sum
``` | vfc_133731 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/find-the-sum-of-last-n-nodes-of-the-linked-list/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\r\n\r\n6 3\r\n\r\n5 9 6 3 4 10\r\n\r\n2 2\r\n\r\n1 2",
"output": "17\r\n\r\n3",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://www.codechef.com/problems/MINLCS | Solve the following coding problem using the programming language python:
Chef is given two strings A and B of length N containing lowercase English letters.
Chef can rearrange both the strings in any way he wants. He wants to minimize the length of LCS ([Longest Common Subsequence] of both the strings.
Find the min... | ```python
for _ in range(int(input())):
input()
ai = [i for i in input()]
bi = [i for i in input()]
count = 0
for i in set(ai):
if i in bi:
x = min(ai.count(i), bi.count(i))
if x > count:
count = x
print(count)
``` | vfc_133732 | {
"difficulty": "easy",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/MINLCS",
"time_limit": "1 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n4\naaaa\naaab\n1\nc\nz\n5\nabcde\ncdefg\n",
"output": "3\n0\n1\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/207/D4 | Solve the following coding problem using the programming language python:
The Smart Beaver from ABBYY came up with another splendid problem for the ABBYY Cup participants! This time the Beaver invites the contest participants to check out a problem on sorting documents by their subjects. Let's describe the problem:
Y... | ```python
print('1')
``` | vfc_133736 | {
"difficulty": "hard",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/207/D4",
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "21000\nSWISS TO LAUNCH NEW SERIES OF MONEY MARKET PAPER\nZURICH, April 9 - The Swiss Federal Government will launch\na new series of three month money market certificates totalling\naround 150 mln Swiss francs, the National Bank sa... |
taco | verifiable_code | https://codeforces.com/problemset/problem/379/B | Solve the following coding problem using the programming language python:
The New Year is coming! That's why many people today are busy preparing New Year presents. Vasily the Programmer is no exception.
Vasily knows that the best present is (no, it's not a contest) money. He's put n empty wallets from left to right ... | ```python
n = int(input())
l = [int(x) for x in input().split()]
s = ''
for x in l[:-1]:
if x:
s += 'P'
for i in range(x - 1):
s += 'RLP'
s += 'R'
if l[-1]:
s += 'P'
for i in range(l[-1] - 1):
s += 'LRP'
print(s)
``` | vfc_133740 | {
"difficulty": "easy",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/379/B",
"time_limit": "1.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10\n2 3 4 0 0 1 1 3 4 2\n",
"output": "PRPRPRRRPRPRPRPRPLPLPLLLLLPLPLPRPRPRRRRRPRPRPLPLLLLLLP\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n6 0\n",
"output": "PRLPRLPRLPRLPRLPR\... |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/3b76f77c1b2107f809b1875aa9fe929ce320be97/1 | Solve the following coding problem using the programming language python:
Given an array of size N, find the number of distinct pairs {i, j} (i != j) in the array such that the sum of a[i] and a[j] is greater than 0.
Example 1:
Input: N = 3, a[] = {3, -2, 1}
Output: 2
Explanation: {3, -2}, {3, 1} are two
possible pai... | ```python
class Solution:
def ValidPair(self, a, n):
a.sort()
count = 0
i = 0
j = n - 1
while i < j:
if a[i] + a[j] > 0:
count += j - i
j -= 1
else:
i += 1
return count
``` | vfc_133744 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/3b76f77c1b2107f809b1875aa9fe929ce320be97/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "N = 3, a[] = {3, -2, 1}",
"output": "2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "N = 4, a[] = {-1, -1, -1, 0}",
"output": "0",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/16/D | Solve the following coding problem using the programming language python:
The main server of Gomble company received a log of one top-secret process, the name of which can't be revealed. The log was written in the following format: «[date:time]: message», where for each «[date:time]» value existed not more than 10 lin... | ```python
from sys import stdin
lines = int(stdin.readline())
days = 1
count = 0
h1 = 0
m1 = 0
for x in range(lines):
log = stdin.readline().strip()
hour = int(log[1:3])
if hour == 12:
hour = 0
if log[7] == 'p':
hour += 12
minute = int(log[4:6])
if hour < h1 or (hour == h1 and minute < m1):
days += 1
coun... | vfc_133745 | {
"difficulty": "hard",
"memory_limit": "64.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/16/D",
"time_limit": "1.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n[11:49 a.m.]: maapapm\n[10:05 a.m.]: apampmmapapa\n[08:48 a.m.]: pampmapmaaappmpa\n[11:15 a.m.]: pmmamppmmapmmpmm\n[08:01 a.m.]: mmammppmapppmpapma\n",
"output": "4\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/166/C | Solve the following coding problem using the programming language python:
A median in an array with the length of n is an element which occupies position number <image> after we sort the elements in the non-decreasing order (the array elements are numbered starting with 1). A median of an array (2, 6, 1, 2, 3) is the ... | ```python
(n, x) = map(int, input().split())
a = list(map(int, input().split()))
ret = 0
if x not in a:
a.append(x)
ret += 1
a.sort()
while a[(len(a) + 1) // 2 - 1] != x:
a.append(x)
a.sort()
ret += 1
print(ret)
``` | vfc_133750 | {
"difficulty": "medium",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/166/C",
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "100 37\n20 20 3 35 36 14 30 9 33 36 32 46 43 22 43 50 34 6 13 25 1 34 10 6 21 30 19 17 1 23 9 23 38 21 7 43 49 28 33 42 4 19 39 23 12 42 31 13 26 23 1 26 24 48 10 6 12 48 40 18 10 26 9 5 22 45 46 23 46 34 34 45 3 7 16 39 14 29 48 1... |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/final-destination4628/1 | Solve the following coding problem using the programming language python:
Consider a 2d plane and a Robot which is located at (0,0) who can move only one unit step at a time in any direction i.e. if its initial position is (x,y), he can go to positions (x + 1, y), (x - 1, y), (x, y + 1) or (x, y - 1). Now Given three ... | ```python
class Solution:
def canReach(self, a, b, x):
a = int(a ** 2) ** 0.5
b = int(b ** 2) ** 0.5
if a + b == x:
return 1
if a + b < x:
y = x - (a + b)
if y % 2 == 0:
return 1
return 0
``` | vfc_133754 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/final-destination4628/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "a = 5, b = 5, x = 11",
"output": "0",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/1089/L | Solve the following coding problem using the programming language python:
The kingdom of Lazyland is the home to $n$ idlers. These idlers are incredibly lazy and create many problems to their ruler, the mighty King of Lazyland.
Today $k$ important jobs for the kingdom ($k \le n$) should be performed. Every job shoul... | ```python
from sys import stdin
(n, k) = map(int, input().split())
jobs = list(map(int, stdin.readline().split()))
t = list(map(int, stdin.readline().split()))
exch = k - len(set(jobs))
doubleJobs = [0] * (k + 1)
timeOfDouble = []
for l in range(len(jobs)):
if doubleJobs[jobs[l]] < t[l]:
if doubleJobs[jobs[l]] != 0:... | vfc_133755 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1089/L",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "8 7\n1 1 3 1 5 3 7 1\n5 7 4 8 1 3 5 2\n",
"output": "10\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 3\n3 1 2\n5 3 4\n",
"output": "0\n",
"type": "stdin_stdout"
},
... |
taco | verifiable_code | Solve the following coding problem using the programming language python:
You are playing a solitaire puzzle called "Connect", which uses several letter tiles.
There are R × C empty cells. For each i (1 ≤ i ≤ R), you must put a string si (1 ≤ |si| ≤ C) in the i-th row of the table, without changing the letter order. ... | ```python
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def gen(N, K):
if K == 0:
yield 0
return
v = (1 << K) - 1
N2 = 1 << N
while v < N2:
yield v
x = v & -v
y = v + x
v = (v & ~y) // x >> 1 | y
def solve():
(R, C) = map(int, readline().split())
S = [readline().strip() for i in ... | vfc_133759 | {
"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": "4 16\nINTERNATIONAL\nCOLLEGIATE\nPROGRAMMJNG\nCONTEST",
"output": "18\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 16\nLANOITANRETNI\nCOLLEGIATE\nPROGRAMMJNG\nCONTEST",
"output"... | |
taco | verifiable_code | https://www.codechef.com/problems/BOTTOM | Solve the following coding problem using the programming language python:
It is known that in regular dice, the sum of opposite faces is 7.
A regular dice is rolled and you are given the value X showing on the top face. Determine the value on the bottom face.
------ Input Format ------
- The first line will contai... | ```python
for i in range(int(input())):
x = int(input())
print(7 - x)
``` | vfc_133763 | {
"difficulty": "easy",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/BOTTOM",
"time_limit": "1 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n3\n1\n6\n",
"output": "4\n6\n1\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/all-divisors-of-a-number/1 | Solve the following coding problem using the programming language python:
Given an integer N, print all the divisors of N in the ascending order.
Example 1:
Input : 20
Output: 1 2 4 5 10 20
Explanation: 20 is completely
divisible by 1, 2, 4, 5, 10 and 20.
Example 2:
Input: 21191
Output: 1 21191
Explanation: As 2119... | ```python
import math
class Solution:
def print_divisors(self, N):
ans = []
for i in range(1, int(N ** 0.5 + 1)):
if N % i == 0:
ans.append(i)
if i != N // i:
ans.append(N // i)
ans.sort()
for i in ans:
print(i, end=' ')
``` | vfc_133778 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/all-divisors-of-a-number/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "20",
"output": "1 2 4 5 10 20",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/aditya-and-his-building-blocks2857/1 | Solve the following coding problem using the programming language python:
Aditya has arranged some of his building blocks in N columns. Each column has a certain number of blocks given by an array A.
Each element of A(i.e. Ai) is the height of the ith column. Aditya now has M blocks left. He doesn't like small columns... | ```python
def maximised_height(arr, n, m):
lo = min(arr)
hi = max(arr) + m
ans = -1
while lo <= hi:
mi = (lo + hi) // 2
if ok(arr, n, mi, m):
ans = mi
lo = mi + 1
else:
hi = mi - 1
return ans
def ok(a, n, mi, m):
ans = 0
for i in range(n):
if a[i] < mi:
ans += mi - a[i]
return ans <= m
``` | vfc_133779 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/aditya-and-his-building-blocks2857/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": "maximised_height",
"input": "arr[ ] = {1, 2, 3, 4, 5} and M = 6",
"output": "4",
"type": "function_call"
},
{
"fn_name": "maximised_height",
"input": "arr[ ] = {2, 8, 9} and M = 4",
"output": "6",
"type... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.