source stringclasses 4
values | task_type stringclasses 1
value | in_source_id stringlengths 0 138 | problem_statement stringlengths 219 13.2k | gold_standard_solution stringlengths 0 413k | problem_id stringlengths 5 10 | metadata dict | verification_info dict |
|---|---|---|---|---|---|---|---|
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/strongly-connected-components-kosarajus-algo/1 | Solve the following coding problem using the programming language python:
Given a Directed Graph with V vertices (Numbered from 0 to V-1) and E edges, Find the number of strongly connected components in the graph.
Example 1:
Input:
Output:
3
Explanation:
We can clearly see that there are 3 Strongly
Connected Compone... | ```python
class Solution:
def kosaraju(self, V, adj):
def time(G):
n = len(G)
visited = [False for _ in range(n)]
time_tab = [0 for _ in range(n)]
t = n - 1
def dfsVisit(G, u):
nonlocal visited, time_tab, t
visited[u] = True
for v in G[u]:
if not visited[v]:
dfsVisit(G, v)
... | vfc_142544 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/strongly-connected-components-kosarajus-algo/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "",
"output": "1",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://www.hackerrank.com/challenges/strange-advertising/problem | Solve the following coding problem using the programming language python:
HackerLand Enterprise is adopting a new viral advertising strategy. When they launch a new product, they advertise it to exactly $5$ people on social media.
On the first day, half of those $5$ people (i.e., $floor(\frac{5}{2})=2$) like the adv... | ```python
people = 5
total = 0
n = int(input())
for i in range(n):
receive = int(people / 2)
total += receive
people = receive * 3
print(total)
``` | vfc_142545 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.hackerrank.com/challenges/strange-advertising/problem",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n",
"output": "9\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of Mysterious Light.
Three mirrors of length N are set so that they form an equilateral triangle. Let the vertices of the triangle be a, b and c.
Inside t... | ```python
(N, X) = (int(i) for i in input().split())
def MysteriousLight(tmp, rem):
while rem:
(tmp, rem) = (rem, tmp % rem)
return tmp
print(3 * (N - MysteriousLight(N, X)))
``` | vfc_142549 | {
"difficulty": "unknown_difficulty",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 4",
"output": "12\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7 4",
"output": "18\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6 1",
... | |
taco | verifiable_code | https://codeforces.com/problemset/problem/521/E | Solve the following coding problem using the programming language python:
You are organizing a cycling race on the streets of the city. The city contains n junctions, some pairs of them are connected by roads; on each road you can move in any direction. No two roads connect the same pair of intersections, and no road ... | ```python
from typing import List
import sys
(n, m) = [int(a) for a in input().split(' ')]
adj: List[List[int]] = [[]] + [[] for _ in range(n)]
visited: List[bool] = [False] * (n + 1)
parent: List[int] = [0] * (n + 1)
depth: List[int] = [0] * (n + 1)
low: List[int] = [0] * (n + 1)
cx: List[int] = [0] * (n + 1)
cy: List... | vfc_142554 | {
"difficulty": "very_hard",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/521/E",
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "70 1\n61 39\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 5\n6 2\n2 1\n2 7\n10 7\n4 6\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn... |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/8a644e94faaa94968d8665ba9e0a80d1ae3e0a2d/1 | Solve the following coding problem using the programming language python:
Given a collection of Intervals, the task is to merge all of the overlapping Intervals.
Example 1:
Input:
Intervals = {{1,3},{2,4},{6,8},{9,10}}
Output: {{1, 4}, {6, 8}, {9, 10}}
Explanation: Given intervals: [1,3],[2,4]
[6,8],[9,10], we have on... | ```python
class Solution:
def overlappedInterval(self, Intervals):
i = 0
Intervals.sort()
ans = []
while i < len(Intervals):
first = Intervals[i][0]
last = Intervals[i][1]
while i < len(Intervals) - 1 and Intervals[i + 1][0] <= last:
last = max(last, Intervals[i + 1][1])
i += 1
ans.append(... | vfc_142558 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/8a644e94faaa94968d8665ba9e0a80d1ae3e0a2d/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "Intervals = {{1,3},{2,4},{6,8},{9,10}}",
"output": "{{1, 4}, {6, 8}, {9, 10}}",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "Intervals = {{6,8},{1,9},{2,4},{4,7}}",
"output": "{{1, 9}... |
taco | verifiable_code | https://atcoder.jp/contests/abc134/tasks/abc134_f | Solve the following coding problem using the programming language python:
Let us define the oddness of a permutation p = {p_1,\ p_2,\ ...,\ p_n} of {1,\ 2,\ ...,\ n} as \sum_{i = 1}^n |i - p_i|.
Find the number of permutations of {1,\ 2,\ ...,\ n} of oddness k, modulo 10^9+7.
-----Constraints-----
- All values in in... | ```python
def main():
import sys
input = sys.stdin.readline
mod = 1000000007
(N, K) = map(int, input().split())
n = N // 2
dp = [[[0] * (N ** 2 + 1) for _ in range(n + 1)] for _ in range(N + 1)]
dp[0][0][0] = 1
for i in range(N):
for j in range(n + 1):
for k in range(N ** 2 + 1):
if k + 2 * j <= N ** 2... | vfc_142559 | {
"difficulty": "medium_hard",
"memory_limit": "1024.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://atcoder.jp/contests/abc134/tasks/abc134_f",
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 2\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "39 14\n",
"output": "74764168\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input":... |
taco | verifiable_code | https://atcoder.jp/contests/abc044/tasks/abc044_b | Solve the following coding problem using the programming language python:
Let w be a string consisting of lowercase letters.
We will call w beautiful if the following condition is satisfied:
- Each lowercase letter of the English alphabet occurs even number of times in w.
You are given the string w. Determine if w is... | ```python
w = input()
s = set(list(w))
for x in s:
if w.count(x) % 2 != 0:
print('No')
exit()
print('Yes')
``` | vfc_142564 | {
"difficulty": "easy",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://atcoder.jp/contests/abc044/tasks/abc044_b",
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "abaccaba\n",
"output": "Yes\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "hthth\n",
"output": "No\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input"... |
taco | verifiable_code | https://codeforces.com/problemset/problem/1248/A | Solve the following coding problem using the programming language python:
DLS and JLS are bored with a Math lesson. In order to entertain themselves, DLS took a sheet of paper and drew $n$ distinct lines, given by equations $y = x + p_i$ for some distinct $p_1, p_2, \ldots, p_n$.
Then JLS drew on the same paper sheet... | ```python
t = int(input())
while t > 0:
t -= 1
n = int(input())
p = [int(x) for x in input().split()]
m = int(input())
q = [int(x) for x in input().split()]
p_o = 0
p_e = 0
for x in p:
if x % 2 == 0:
p_e += 1
else:
p_o += 1
q_o = 0
q_e = 0
for x in q:
if x % 2 == 0:
q_e += 1
else:
q_o += ... | vfc_142568 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1248/A",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n3\n1 3 2\n2\n0 3\n1\n1\n1\n1\n1\n2\n1\n1\n",
"output": "3\n1\n0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7\n2\n1000000000 0\n2\n1000000000 0\n2\n1 0\n2\n1000000000 0\n2\n1 0\n2\n... |
taco | verifiable_code | https://codeforces.com/problemset/problem/476/A | Solve the following coding problem using the programming language python:
Dreamoon wants to climb up a stair of n steps. He can climb 1 or 2 steps at each move. Dreamoon wants the number of moves to be a multiple of an integer m.
What is the minimal number of moves making him climb to the top of the stairs that sati... | ```python
(n, m) = input().split(' ')
n = int(n)
m = int(m)
def how_many_moves(n, m):
for i in range(n):
if m * 2 * i >= n:
return m * i
total_moves = how_many_moves(n, m)
if n >= m:
print(total_moves)
else:
print(-1)
``` | vfc_142572 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/476/A",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10 2\n",
"output": "6\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 5\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "29 7\... |
taco | verifiable_code | https://atcoder.jp/contests/abc160/tasks/abc160_e | Solve the following coding problem using the programming language python:
You are going to eat X red apples and Y green apples.
You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C.
Before eating a... | ```python
(X, Y, A, B, C) = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
hoge = p[:X] + q[:Y] + r
hoge.sort(reverse=True)
print(sum(hoge[:X + Y]))
``` | vfc_142576 | {
"difficulty": "medium",
"memory_limit": "1024.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://atcoder.jp/contests/abc160/tasks/abc160_e",
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1 2 2 2 1\n2 4\n5 1\n3\n",
"output": "12\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 2 2 2 2\n8 6\n9 1\n2 1\n",
"output": "25\n",
"type": "stdin_stdout"
},
{
... |
taco | verifiable_code | https://www.codechef.com/problems/CHFSPL | Solve the following coding problem using the programming language python:
Read problem statements in [Mandarin], [Bengali], [Russian], and [Vietnamese] as well.
Chef has three spells. Their powers are A, B, and C respectively. Initially, Chef has 0 hit points, and if he uses a spell with power P, then his number of h... | ```python
t = int(input())
for i in range(t):
(a, b, c) = map(int, input().split())
print(max(a + b, b + c, a + c))
``` | vfc_142580 | {
"difficulty": "easy",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/CHFSPL",
"time_limit": "0.5 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n4 2 8\n10 14 18",
"output": "12\n32",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://www.codechef.com/problems/PREZ | Solve the following coding problem using the programming language python:
You are given a string S of length N, which consists of digits from 0 to 9. You can apply the following operation to the string:
Choose an integer L with 1≤ L ≤ N and apply S_{i} = (S_{i} + 1) \mod 10 for each 1 ≤ i ≤ L.
For example, if S=3959... | ```python
def solve(n, k, arr):
def moves_needed(m):
offset = 0
for i in range(m, -1, -1):
num = (arr[i] + offset) % 10
if num != 0:
offset += 10 - num
return offset
l = 0
r = n - 1
while l < r:
m = (l + r) // 2
if moves_needed(m) > k:
r = m
else:
l = m + 1
if l == n - 1 and moves_need... | vfc_142585 | {
"difficulty": "medium_hard",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/PREZ",
"time_limit": "1 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6\n3 5\n380\n3 9\n380\n4 2\n0123\n5 13\n78712\n6 10\n051827\n8 25\n37159725\n\n",
"output": "0\n3\n1\n3\n2\n5\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/queue-using-stack/1 | Solve the following coding problem using the programming language python:
Implement a Queue using two stack s1 and s2.
Example 1:
Input:
enqueue(2)
enqueue(3)
dequeue()
enqueue(4)
dequeue()
Output: 2 3
Explanation:
enqueue(2) the queue will be {2}
enqueue(3) the queue will be {3 2}
dequeue() the poped element will be ... | ```python
class Queue:
def __init__(self):
self.s1 = []
self.s2 = []
def enqueue(self, X):
self.s1.append(X)
def dequeue(self):
if len(self.s2) != 0:
return self.s2.pop()
while len(self.s1) != 0:
self.s2.append(self.s1.pop())
return self.s2.pop()
``` | vfc_142589 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/queue-using-stack/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "enqueue(2)\nenqueue(3)\ndequeue()\nenqueue(4)\ndequeue()",
"output": "2 3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "enqueue(2)\ndequeue()\ndequeue()",
"output": "2 -1",
"ty... |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/matrix-exponentiation2711/1 | Solve the following coding problem using the programming language python:
Given an equation of the form f(n) = f(n-1) + f(n-2) where f(0) = 1, f(1) = 1 , the task is to find the n^{th} term of this sequence.
Example 1:
Input: n = 3
Output: 3
Explanation: f(3) = f(2) + f(1) = 3
Example 2:
Input: n = 2
Output: 2
Expla... | ```python
class Solution:
def multiply(self, a, b):
mul = [[0 for x in range(3)] for y in range(3)]
for i in range(3):
for j in range(3):
mul[i][j] = 0
for k in range(3):
mul[i][j] += a[i][k] * b[k][j]
for i in range(3):
for j in range(3):
a[i][j] = mul[i][j] % int(1000000000.0 + 7)
ret... | vfc_142590 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/matrix-exponentiation2711/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "n = 3",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "n = 2",
"output": "2",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/transform-to-prime4635/1 | Solve the following coding problem using the programming language python:
Given an array of n integers. Find the minimum positive number to be inserted in array, so that sum of all elements of array becomes prime. If sum is already prime, then return 0.
Example 1:
Input:
N=5
arr[] = { 2, 4, 6, 8, 12 }
Output: 5
Exp... | ```python
def isprime(n):
if n == 1:
return False
for i in range(2, int(n ** 0.5) + 1):
if n % i == 0:
return False
return True
def minNumber(arr, N):
a = sum(arr)
i = 0
while True:
if isprime(a + i):
return i
break
i += 1
``` | vfc_142591 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/transform-to-prime4635/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": "minNumber",
"input": "N=5\narr[] = { 2, 4, 6, 8, 12 }",
"output": "5",
"type": "function_call"
},
{
"fn_name": "minNumber",
"input": "N=3\narr[] = { 1, 5, 7 }",
"output": "0",
"type": "function_call"
... |
taco | verifiable_code | https://codeforces.com/problemset/problem/102/C | Solve the following coding problem using the programming language python:
Once when Gerald studied in the first year at school, his teacher gave the class the following homework. She offered the students a string consisting of n small Latin letters; the task was to learn the way the letters that the string contains ar... | ```python
import itertools
import math
import time
def timer(f):
def tmp(*args, **kwargs):
t = time.time()
res = f(*args, **kwargs)
print('Время выполнения функции: %f' % (time.time() - t))
return res
return tmp
s = input()
n = int(input())
array = [[0, chr(i + ord('a'))] for i in range(26)]
for i in range(... | vfc_142592 | {
"difficulty": "easy",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/102/C",
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "halasouqgfxfcrwhqgllaqiphaxekljz\n87\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "fntrmjfquczybyjllywsqwllsxdmqynmyfcqhakftitvvfbxtqktbfsvvvanjbkqubyxu\n63\n",
"o... |
taco | verifiable_code | https://codeforces.com/problemset/problem/1462/B | Solve the following coding problem using the programming language python:
Polycarp has a string $s[1 \dots n]$ of length $n$ consisting of decimal digits. Polycarp performs the following operation with the string $s$ no more than once (i.e. he can perform operation $0$ or $1$ time):
Polycarp selects two numbers $i$ a... | ```python
a = int(input())
for i in range(a):
b = int(input())
c = input()
if c[0:4] == '2020':
print('YES')
elif c[0:3] == '202' and c[b - 1] == '0':
print('YES')
elif c[0:2] == '20' and c[b - 2:b] == '20':
print('YES')
elif c[0] == '2' and c[b - 3:b] == '020':
print('YES')
elif c[b - 4:b] == '2020':
... | vfc_142596 | {
"difficulty": "easy",
"memory_limit": "256 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1462/B",
"time_limit": "2 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6\n8\n20192020\n8\n22019020\n4\n2020\n5\n20002\n6\n729040\n6\n200200\n",
"output": "YES\nYES\nYES\nNO\nNO\nNO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n4\n2021\n",
"output":... |
taco | verifiable_code | https://codeforces.com/problemset/problem/145/C | Solve the following coding problem using the programming language python:
Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya has sequence a co... | ```python
import sys
input = sys.stdin.readline
def solve():
(n, k) = map(int, input().split())
a = [4, 7]
d = dict()
idx = 0
for p in range(1, 10):
for m in range(1 << p):
v = 0
for i in range(p):
v = v * 10 + a[m >> i & 1]
d[v] = idx
idx += 1
c = [0] * idx
b = 0
for v in map(int, input().sp... | vfc_142600 | {
"difficulty": "hard",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/145/C",
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "7 4\n1 2 3 4 5 6 7\n",
"output": "35\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 1\n1 2 3 4 5 6 7 8 9 10\n",
"output": "10\n",
"type": "stdin_stdout"
},
{
... |
taco | verifiable_code | https://codeforces.com/problemset/problem/1025/G | Solve the following coding problem using the programming language python:
There are $n$ startups. Startups can be active or acquired. If a startup is acquired, then that means it has exactly one active startup that it is following. An active startup can have arbitrarily many acquired startups that are following it. An... | ```python
(m, n, a) = (1000000007, int(input()), input().split())
print(pow(2, n - 1, m) - 1 - sum((pow(2, a.count(x), m) - 1 for x in set(a) if x != '-1')) % m)
``` | vfc_142604 | {
"difficulty": "very_hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1025/G",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n-1 -1 -1\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n2 -1\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"inpu... |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Problem
Gaccho loses motivation as the final exam approaches and often misses school.
There are N days left until the final exam.
Gaccho's motivation on day i is Xi, and the motivation needed to go to school on day i is Yi.
Gaccho goes to schoo... | ```python
(N, P) = map(int, input().split())
xs = []
ys = []
dp = [[[1000000000.0 for i in range(N + 1)] for j in range(N + 1)] for k in range(N + 1)]
memo = [[0 for i in range(N + 1)] for j in range(N + 1)]
for i in range(N):
(x, y) = map(int, input().split())
xs.append(x)
ys.append(y)
for start in range(N):
preus... | vfc_142608 | {
"difficulty": "unknown_difficulty",
"memory_limit": "267.38688 megabytes",
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "1.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6 5\n1 1\n1 2\n1 2\n1 3\n1 3",
"output": "5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 10\n1 9\n5 10\n0 5",
"output": "2\n",
"type": "stdin_stdout"
},
{
"f... | |
taco | verifiable_code | https://codeforces.com/problemset/problem/569/D | Solve the following coding problem using the programming language python:
Little Johnny has recently learned about set theory. Now he is studying binary relations. You've probably heard the term "equivalence relation". These relations are very important in many areas of mathematics. For example, the equality of the tw... | ```python
def main():
mod = 10 ** 9 + 7
n = int(input())
a = [[0] * (n + 1) for i in range(n + 1)]
a[0][0] = 1
for i in range(1, n + 1):
a[i][0] = a[i - 1][i - 1]
for j in range(1, i + 1):
a[i][j] = (a[i][j - 1] + a[i - 1][j - 1]) % mod
print(a[n][n - 1])
main()
``` | vfc_142612 | {
"difficulty": "hard",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/569/D",
"time_limit": "1.5 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n",
"output": "37\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n",
"output": "151\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4000\n",... |
taco | verifiable_code | https://codeforces.com/problemset/problem/611/A | Solve the following coding problem using the programming language python:
Today is Wednesday, the third day of the week. What's more interesting is that tomorrow is the last day of the year 2015.
Limak is a little polar bear. He enjoyed this year a lot. Now, he is so eager to the coming year 2016.
Limak wants to pro... | ```python
(d, b, c) = input().split()
a = int(d)
if c == 'week':
if a == 5 or a == 6:
print('53')
else:
print('52')
elif a <= 29:
print('12')
elif a == 30:
print('11')
else:
print('7')
``` | vfc_142616 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/611/A",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 of week\n",
"output": "52\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "30 of month\n",
"output": "11\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"... |
taco | verifiable_code | Solve the following coding problem using the programming language python:
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the ax... | ```python
n = int(input())
a = [0] + list(map(int, input().split())) + [0]
s = 0
for i in range(n + 1):
s += abs(a[i + 1] - a[i])
for i in range(n):
ans = s + abs(a[i + 2] - a[i]) - (abs(a[i] - a[i + 1]) + abs(a[i + 1] - a[i + 2]))
print(ans)
``` | vfc_142620 | {
"difficulty": "unknown_difficulty",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6\n-679 -3431 -3258 3095 -3291 -4462",
"output": "21976\n21630\n21976\n9270\n21976\n19634\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n1 1 0 2 0",
"output": "6\n6\n4\n2\n6\n",
... | |
taco | verifiable_code | https://codeforces.com/problemset/problem/556/B | Solve the following coding problem using the programming language python:
Andrewid the Android is a galaxy-famous detective. He is now investigating a case of frauds who make fake copies of the famous Stolp's gears, puzzles that are as famous as the Rubik's cube once was.
Its most important components are a button an... | ```python
n = int(input())
arr = list(map(int, input().split()))
r = n - arr[0]
p = 1
c = -1
for i in range(n):
if p == 1:
t = (arr[i] + r) % n
else:
t = (n - (r - arr[i])) % n
p = -p
if t > c:
c = t
else:
print('No')
break
else:
print('Yes')
``` | vfc_142624 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/556/B",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 0 0\n",
"output": "Yes\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n4 2 1 4 3\n",
"output": "Yes\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
taco | verifiable_code | https://codeforces.com/problemset/problem/334/B | Solve the following coding problem using the programming language python:
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except fo... | ```python
s = set()
w = set()
d = dict()
for _ in range(8):
l = list(map(int, input().split()))
s.add(l[0])
w.add(l[1])
if l[0] in d:
d[l[0]].append(l[1])
d[l[0]].sort()
else:
d[l[0]] = list()
d[l[0]].append(l[1])
if len(d) > 3:
print('ugly')
exit()
if len(s) < 3 or len(w) < 3 or len(s) > 3 or (len(w)... | vfc_142628 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/334/B",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "0 0\n0 1\n0 2\n1 0\n1 2\n2 0\n2 1\n2 2\n",
"output": "respectable\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "0 0\n1 0\n2 0\n3 0\n4 0\n5 0\n6 0\n7 0\n",
"output": "ugly\n",
... |
taco | verifiable_code | https://www.codechef.com/CFUN2020/problems/CODSTAN6 | Solve the following coding problem using the programming language python:
Recently Rocky had participated in coding competition and he is sharing one of the problem with you which he was unable to solve. Help Rocky in solving the problem.
Suppose the alphabets are arranged in a row starting with index 0$0$ from AtoZ$A... | ```python
s = input().strip()
start_w = 27
w_dict = {}
words = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
for word in words:
w_dict[word] = start_w
start_w = start_w - 1
total_wt = 0
for c in s:
total_wt = total_wt + w_dict[c]
pr... | vfc_142633 | {
"difficulty": "unknown_difficulty",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/CFUN2020/problems/CODSTAN6",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "A\nAND\n",
"output": "27\n65\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/1290/C | Solve the following coding problem using the programming language python:
There are $n$ lamps on a line, numbered from $1$ to $n$. Each one has an initial state off ($0$) or on ($1$).
You're given $k$ subsets $A_1, \ldots, A_k$ of $\{1, 2, \dots, n\}$, such that the intersection of any three subsets is empty. In othe... | ```python
from sys import stdin
class disjoinSet(object):
def __init__(self, n):
self.father = [x for x in range(0, n + 1)]
self.rank = [0 for x in range(0, n + 1)]
def setOf(self, x):
if self.father[x] != x:
self.father[x] = self.setOf(self.father[x])
return self.father[x]
def Merge(self, x, y):
xR... | vfc_142637 | {
"difficulty": "hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1290/C",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "7 3\n0011100\n3\n1 4 6\n3\n3 4 7\n2\n2 3\n",
"output": "1\n2\n3\n3\n3\n3\n3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "8 6\n00110011\n3\n1 3 8\n5\n1 2 5 6 7\n2\n6 8\n2\n3 5\n2\n4 7\n1... |
taco | verifiable_code | https://www.codechef.com/problems/NUMCOMP1 | Solve the following coding problem using the programming language python:
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given all $N - 1$ integers in the range $[2, N]$. In each step, you choose $2$ distinct integers and if they share a common factor greater th... | ```python
from bisect import bisect_right
def Sieve(n):
prime = [True for i in range(n + 1)]
p = 2
while p * p <= n:
if prime[p] == True:
for i in range(p * p, n + 1, p):
prime[i] = False
p += 1
prime[2] = False
lst = []
for p in range(2, n + 1):
if prime[p]:
lst.append(p)
return lst
m = 10 ** ... | vfc_142641 | {
"difficulty": "medium_hard",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/NUMCOMP1",
"time_limit": "1 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n2\n4\n8",
"output": "1\n2\n3",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/202/C | Solve the following coding problem using the programming language python:
Consider some square matrix A with side n consisting of zeros and ones. There are n rows numbered from 1 to n from top to bottom and n columns numbered from 1 to n from left to right in this matrix. We'll denote the element of the matrix which i... | ```python
from sys import stdin
import math
def make_dp():
dp = [0] * 1001
dp[1] = 1
dp[3] = 5
for i in range(5, 100, 2):
dp[i] = dp[i - 2] + i + i - 2
return dp
x = int(stdin.readline().strip())
if x == 3:
print(5)
exit()
dp = make_dp()
for i in range(1, len(dp)):
if x <= dp[i]:
print(i)
break
``` | vfc_142645 | {
"difficulty": "medium_hard",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/202/C",
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "61\n",
"output": "11",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "13\n",
"output": "5",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "38\n",
... |
taco | verifiable_code | https://codeforces.com/problemset/problem/1107/D | Solve the following coding problem using the programming language python:
You are given a binary matrix $A$ of size $n \times n$. Let's denote an $x$-compression of the given matrix as a matrix $B$ of size $\frac{n}{x} \times \frac{n}{x}$ such that for every $i \in [1, n], j \in [1, n]$ the condition $A[i][j] = B[\lce... | ```python
import sys
hex2bin = [''] * 256
hex2bin[ord('0')] = '0000'
hex2bin[ord('1')] = '0001'
hex2bin[ord('2')] = '0010'
hex2bin[ord('3')] = '0011'
hex2bin[ord('4')] = '0010'
hex2bin[ord('5')] = '0010'
hex2bin[ord('6')] = '0110'
hex2bin[ord('7')] = '0111'
hex2bin[ord('8')] = '1000'
hex2bin[ord('9')] = '1001'
hex2bin[... | vfc_142649 | {
"difficulty": "medium_hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1107/D",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "8\nE7\nE7\nE7\n00\n00\nE7\nE7\nE7\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n7\nF\nF\nF\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
... |
taco | verifiable_code | https://www.codechef.com/problems/CHEFQUER | Solve the following coding problem using the programming language python:
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given a sequence $A_{1}, A_{2}, \ldots, A_{N}$. Chef wants you to handle $Q$ queries. There are two types of queries:
1 L R X: for each $i$ ($L ≤ i ≤ R$... | ```python
class Ftree:
def __init__(self, N):
self.st = [0] * (N + 1)
self.n = N
def Update(self, l, r, diff):
while l <= self.n:
self.st[l] += diff
l += l & -l
r += 1
while r <= self.n:
self.st[r] -= diff
r += r & -r
def Query(self, i):
sum = 0
while i > 0:
sum += self.st[i]
i -= ... | vfc_142654 | {
"difficulty": "medium_hard",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/CHEFQUER",
"time_limit": "1 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 4\n1 10 3 6 5\n1 1 3 5\n2 3\n1 4 5 7\n2 5",
"output": "52\n69",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/1475/E | Solve the following coding problem using the programming language python:
Masha works in an advertising agency. In order to promote the new brand, she wants to conclude contracts with some bloggers. In total, Masha has connections of $n$ different bloggers. Blogger numbered $i$ has $a_i$ followers.
Since Masha has a ... | ```python
import sys
import math
def fn(n, k, a):
h = []
a.sort(reverse=True)
for i in range(k):
h.append(a[i])
h1 = h.count(min(h))
h2 = a.count(min(h))
p = 1
for i in range(h1):
p = p * (h2 - i)
for i in range(h1):
p = p // (h1 - i)
return p % 1000000007
input = sys.stdin.read()
data = list(map(int, i... | vfc_142658 | {
"difficulty": "medium_hard",
"memory_limit": "256 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1475/E",
"time_limit": "2 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n4 3\n1 3 1 2\n4 2\n1 1 1 1\n2 1\n1 2\n",
"output": "2\n6\n1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n4 3\n1 3 1 2\n4 2\n1 2 1 1\n2 1\n1 2\n",
"output": "2\n3\n1\n",
... |
taco | verifiable_code | https://www.codechef.com/LOCAPR16/problems/ACDEMY | Solve the following coding problem using the programming language python:
Sherlock Holmes has decided to start a new academy to some of the young lads. He has conducted several tests and finally selected N equally brilliant
students.Now he don't know whether to train all the N students or not. Now since Holmes was in... | ```python
t = eval(input())
for i in range(t):
n = eval(input())
a = list(map(int, input().split()))
cnt = 2
cnt1 = 2
ll = len(a)
if ll < 3:
cnt1 = ll
else:
for j in range(2, ll):
if a[j - 1] + a[j - 2] == a[j]:
cnt += 1
cnt1 = max(cnt1, cnt)
else:
cnt1 = max(cnt1, cnt)
cnt = 2
print(c... | vfc_142662 | {
"difficulty": "unknown_difficulty",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/LOCAPR16/problems/ACDEMY",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n5\n2 3 5 1 2\n3\n1 2 3\n",
"output": "3\n3\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/smaller-on-left20360700/1 | Solve the following coding problem using the programming language python:
Given an array arr[ ] of N positive integers, the task is to find the greatest element on the left of every element in the array which is strictly smaller than itself, if this element does not exist for an index print "-1".
Example 1:
Input:
N =... | ```python
def Smallestonleft(arr, n):
ans = []
s = []
from bisect import bisect_left
def BinarySearch(a, x):
i = bisect_left(a, x)
if i:
return i - 1
else:
return -1
res = [-1] * (n + 1)
lst = []
lst.append(arr[0])
for i in range(1, n):
idx = BinarySearch(lst, arr[i])
if idx != -1:
res[i] = ... | vfc_142666 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/smaller-on-left20360700/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": "Smallestonleft",
"input": "N = 5\r\narr[] = {2, 3, 4, 5, 1}",
"output": "-1 2 3 4 -1",
"type": "function_call"
},
{
"fn_name": "Smallestonleft",
"input": "N = 3\r\narr[] = {1, 2, 3}",
"output": "-1 1 2",
... |
taco | verifiable_code | https://www.hackerrank.com/challenges/binary-search-tree-insertion/problem | Solve the following coding problem using the programming language python:
You are given a pointer to the root of a binary search tree and values to be inserted into the tree. Insert the values into their appropriate position in the binary search tree and return the root of the updated binary tree.
You just have to com... | ```python
class Node:
def __init__(self, info):
self.info = info
self.left = None
self.right = None
self.level = None
def __str__(self):
return str(self.info)
def preOrder(a):
if a == None:
return
print(a.info, end=' ')
try:
preOrder(a.left.root)
except AttributeError:
print('', end='')
try:
... | vfc_142667 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.hackerrank.com/challenges/binary-search-tree-insertion/problem",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": " 4\n / \\n 2 7\n / \\n 1 3\n",
"output": " 4\n / \\n 2 7\n / /\n 1 3 6\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | Solve the following coding problem using the programming language python:
For a given array $a_1, a_2, a_3, ... , a_N$ of $N$ elements and an integer $L$, find the minimum of each possible sub-arrays with size $L$ and print them from the beginning. For example, for an array $\\{1, 7, 7, 4, 8, 1, 6\\}$ and $L = 3$, the... | ```python
from collections import deque
(N, L) = map(int, input().split())
a = list(map(lambda x: int(x), input().split()))
que: deque = deque()
ans = []
for (i, elem) in enumerate(a):
while que and elem <= que[-1][1]:
que.pop()
que.append((i, elem))
ans.append(que[0][1])
if que and que[0][0] <= i + 1 - L:
que.... | vfc_142671 | {
"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": "7 3\n1 7 7 4 6 1 6",
"output": "1 4 4 1 1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7 3\n1 7 3 4 6 1 6",
"output": "1 3 3 1 1\n",
"type": "stdin_stdout"
},
{
... | |
taco | verifiable_code | https://codeforces.com/problemset/problem/577/C | Solve the following coding problem using the programming language python:
Vasya and Petya are playing a simple game. Vasya thought of number x between 1 and n, and Petya tries to guess the number.
Petya can ask questions like: "Is the unknown number divisible by number y?".
The game is played by the following rules:... | ```python
def get_primes(n):
numbers = set(range(n, 1, -1))
primes = []
while numbers:
p = numbers.pop()
primes.append(p)
numbers.difference_update(set(range(p * 2, n + 1, p)))
return primes
n = int(input())
l = get_primes(n + 1)
ans = []
for x in l:
p = x
while p <= n:
ans.append(p)
p *= x
print(len(an... | vfc_142677 | {
"difficulty": "medium",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/577/C",
"time_limit": "1.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "784\n",
"output": "160\n2 4 8 16 32 64 128 256 512 3 9 27 81 243 729 5 25 125 625 7 49 343 11 121 13 169 17 289 19 361 23 529 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163... |
taco | verifiable_code | https://codeforces.com/problemset/problem/38/C | Solve the following coding problem using the programming language python:
The blinds are known to consist of opaque horizontal stripes that can be rotated thus regulating the amount of light flowing in the room. There are n blind stripes with the width of 1 in the factory warehouse for blind production. The problem is... | ```python
(m, l) = map(int, input().split())
a = list(map(int, input().split()))
print(max((i * sum((ai // i for ai in a)) for i in range(l, 101))))
``` | vfc_142681 | {
"difficulty": "medium",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/38/C",
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "93 10\n6 47 6 89 21 91 51 72 32 48 54 89 36 12 25 38 58 62 54 16 5 52 52 85 67 33 81 72 6 42 91 16 29 78 56 62 75 48 69 12 89 34 27 15 7 80 14 57 29 6 80 46 64 94 83 96 1 42 11 41 15 26 17 36 44 11 68 73 93 45 73 35 91 14 84 48 7 8... |
taco | verifiable_code | https://www.codechef.com/BYTE2016/problems/BYTES11 | Solve the following coding problem using the programming language python:
We all know how great ABD aka AB-DE-VILLIERS is. However his team mates were jealous of him and posed a problem for him to solve.The problem description is as follows :
Given an array of integers,find the length of the largest subarray(contiguo... | ```python
n = eval(input())
a = list(map(int, input().split()))
c = m = 0
maxi = max(a)
for i in range(n):
if a[i] == maxi:
c += 1
m = max(c, m)
else:
c = 0
print(m)
``` | vfc_142687 | {
"difficulty": "unknown_difficulty",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/BYTE2016/problems/BYTES11",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n2 4 8 3\n",
"output": "1\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/453/C | Solve the following coding problem using the programming language python:
Twilight Sparkle learnt that the evil Nightmare Moon would return during the upcoming Summer Sun Celebration after one thousand years of imprisonment on the moon. She tried to warn her mentor Princess Celestia, but the princess ignored her and s... | ```python
import sys
readline = sys.stdin.readline
(N, M) = map(int, readline().split())
Edge = [[] for _ in range(N)]
for _ in range(M):
(u, v) = map(int, readline().split())
u -= 1
v -= 1
Edge[u].append(v)
Edge[v].append(u)
Pr = list(map(int, readline().split()))
Po = Pr[:]
if sum(Pr) == 0:
print(0)
else:
st =... | vfc_142691 | {
"difficulty": "hard",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/453/C",
"time_limit": "1.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 0\n1 0\n",
"output": "1\n1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 1\n2 3\n0 1 1\n",
"output": "2\n2 3\n",
"type": "stdin_stdout"
},
{
"fn_name": null... |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/return-two-prime-numbers2509/1 | Solve the following coding problem using the programming language python:
Given an even number N (greater than 2), return two prime numbers whose sum will be equal to given number. There are several combinations possible. Print only the pair whose minimum value is the smallest among all the minimum values of pairs and... | ```python
class Solution:
def primeDivision(self, N):
def check_prime(n):
for i in range(2, int(n ** 0.5) + 1):
if n % i == 0:
return False
return True
for i in range(N - 2, 1, -1):
if check_prime(i) and check_prime(N - i):
return (N - i, i)
break
``` | vfc_142695 | {
"difficulty": "medium_hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/return-two-prime-numbers2509/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "N = 74",
"output": "12",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4",
"output": "19",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://www.codechef.com/problems/FREQARRRET | Solve the following coding problem using the programming language python:
Consider an array A consisting of N positive elements. The *frequency array* of A is the array B of size N such that B_{i} = *frequency* of element A_{i} in A.
For example, if A = [4, 7, 4, 11, 2, 7, 7], the *frequency array* B = [2, 3, 2, 1, 1... | ```python
import numpy as np
def inp():
return int(input())
def st():
return input().rstrip('\n')
def lis():
return list(map(int, input().split()))
def ma():
return map(int, input().split())
def lexsmall(freqarr):
for j in np.unique(freqarr):
if freqarr.count(j) % j != 0:
print(-1)
return
num = 1
di... | vfc_142696 | {
"difficulty": "medium_hard",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/FREQARRRET",
"time_limit": "1 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n5\n2 3 3 3 2\n5\n1 1 1 1 1\n5\n5 5 5 5 5\n3\n1 2 4\n8\n1 3 2 3 2 2 2 3",
"output": "1 2 2 2 1\n1 2 3 4 5\n1 1 1 1 1\n-1\n1 2 3 2 3 4 4 2\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/front-back-transformation1659/1 | Solve the following coding problem using the programming language python:
Given a string S, consisting only of english alphabets, replace all the alphabets with the alphabets occuring at the same position when counted in reverse order of alphabets. For example, 'a' would be replaced by 'z', 'b' by 'y', 'c' by 'x' and ... | ```python
class Solution:
def convert(self, s):
ans = ''
for i in s:
if ord('a') <= ord(i) and ord(i) <= ord('z'):
i = chr(ord('z') - (ord(i) - ord('a')))
elif ord('A') <= ord(i) and ord(i) <= ord('Z'):
i = chr(ord('Z') - (ord(i) - ord('A')))
ans += i
return ans
``` | vfc_142700 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/front-back-transformation1659/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "S = \"Hello\"",
"output": "Svool",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "S = \"GfG\"",
"output": "TuT",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/print-table0303/1 | Solve the following coding problem using the programming language python:
Create the multiplication table of a given number N and return the table as an array.
Example 1:
Input:
N = 9
Output:
9 18 27 36 45 54 63 72 81 90
Explanation:
The table of 9 is the output whose 1st
term is 9 and the 10th term is 90.
Example 2:... | ```python
class Solution:
def getTable(self, N):
tables = []
for i in range(1, 11):
tables.append(N * i)
return tables
``` | vfc_142701 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/print-table0303/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "N = 9",
"output": "9 18 27 36 45 54 63 72 81 90",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "N = 2",
"output": "2 4 6 8 10 12 14 16 18 20",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Solve the mystery.
Input:
String which consists of words(all the characters of any word are lower case letters) and punctuation marks(consists of {'.' , ',' , '?' , '!'}). Also every input string consists of one '*' in it.
It is guaranteed tha... | ```python
T=eval(input())
while T>0:
l = input()
st=""
for char in l:
if char.isalnum() or char=='*':
st=st+char
le = len(st)
for i in range(0,le/2):
if(st[i]=='*' or st[le-1-i]=='*'):
if(st[i]=='*'):
print(st[le-1-i])
else:
print(st[i])
T=T-1
``` | vfc_142702 | {
"difficulty": "unknown_difficulty",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "981\nr.o,k.y!?y!k o!*\nr!m w!r ,w?m!*\ne s!r b.n?.n,b!r.*?e\nl r?l?n,p p!f k o,k!c?q,n,n u!w?swun*qckokfppnlrl\nb q.l,j?v!w!d?q.?q d w v.j l?*!b\np.n!n?w,q.j,a a?r w o,s.c ,s.o?w?r?*.a j,q wnnp\nq,a e !*,a?q\nm?n?z,k!q?x.j!k,t,y?ac... | |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Write a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$... | ```python
(a, b, x, y, r) = map(int, input().split())
if r <= y and y <= b - r and (r <= x) and (x <= a - r):
print('Yes')
else:
print('No')
``` | vfc_142706 | {
"difficulty": "unknown_difficulty",
"memory_limit": "134.217728 megabytes",
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "1.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 4 2 2 1",
"output": "No\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 8 2 0 0",
"output": "Yes\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input... | |
taco | verifiable_code | https://codeforces.com/problemset/problem/181/D | Solve the following coding problem using the programming language python:
Let's consider one interesting word game. In this game you should transform one word into another through special operations.
Let's say we have word w, let's split this word into two non-empty parts x and y so, that w = xy. A split operation i... | ```python
MOD = int(1000000000.0) + 7
a = input()
b = input()
k = int(input())
if len(a) != len(b):
print(0)
exit()
a = a + a
x = 0
y = 0
for i in range(len(a) // 2):
flag = 1
for j in range(len(b)):
if a[j + i] != b[j]:
flag = 0
break
if flag == 1:
x += 1
else:
y += 1
flag = 0
for i in range(len(b)):... | vfc_142710 | {
"difficulty": "medium_hard",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/181/D",
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "aaeddddadbcacbdccaeeeddecadbecbbcebdcdbcddcadcadccecccecdbabd\nadbecbbcebdcdbcddcadcadccecccecdbabdaaeddddadbcacbdccaeeeddec\n55400\n",
"output": "471327413\n",
"type": "stdin_stdout"
},
{
"fn_name": null,... |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Please find the greatest common divisor of two natural numbers. A clue is: The Euclid's algorithm is a way to resolve this task.
Input
The input file consists of several lines with pairs of two natural numbers in each line. The numbers do no... | ```python
import sys
def gcd(a, b):
if b:
return gcd(b, a % b)
else:
return a
List = []
for i in sys.stdin:
List.append(i)
for data in List:
print(gcd(int(data.split()[0]), int(data.split()[1])))
``` | vfc_142715 | {
"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": "57 38\n19 84",
"output": "19\n1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "57 38\n6 84",
"output": "19\n6\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... | |
taco | verifiable_code | https://codeforces.com/problemset/problem/1559/C | Solve the following coding problem using the programming language python:
The city where Mocha lives in is called Zhijiang. There are $n+1$ villages and $2n-1$ directed roads in this city.
There are two kinds of roads:
$n-1$ roads are from village $i$ to village $i+1$, for all $1\leq i \leq n-1$.
$n$ roads can be d... | ```python
N = int(input())
for _ in range(N):
n = int(input())
nums = [0] + list(map(int, input().strip().split())) + [1]
for (i, (cur_r, next_r)) in enumerate(zip(nums[:], nums[1:])):
if cur_r == 0 and next_r == 1:
break
out_nums = list(range(1, i + 1)) + [n + 1] + list(range(i + 1, n + 1))
print(' '.join(ma... | vfc_142719 | {
"difficulty": "easy",
"memory_limit": "256 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1559/C",
"time_limit": "1 second"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3\n0 1 0\n3\n1 1 0\n",
"output": "1 4 2 3 \n4 1 2 3 \n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n1\n1\n1\n0\n",
"output": "2 1 \n1 2 \n",
"type": "stdin_stdout"
}... |
taco | verifiable_code | Solve the following coding problem using the programming language python:
The huge maze The Squares has been newly completed in the famous theme park. Evacuation drills must be conducted under the guidance of the fire department, but the time required for the drills cannot be predicted due to the huge maze. Therefore,... | ```python
from sys import stdin
def main():
head = [[8, 1, 2, 4], [1, 2, 4, 8], [2, 4, 8, 1], [4, 8, 1, 2]]
while True:
(W, H) = map(int, stdin.readline().split())
m = [[0] * W for _ in range(H)]
ps = []
if not (W or H):
break
for h in range(H):
s = stdin.readline()
for w in range(W):
if s[w] ... | vfc_142723 | {
"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 3\n##########\n#E.......X\n##########\n4 4\n####\n#N.#\n#..X\n####\n5 5\n#####\n#N..#\n###.X\n#S..#\n#####\n6 6\n######\n#..#X#\n#.EE.#\n####N#\n#....#\n######\n8 8\n##X#####\n#....E.#\n#####.##\n#.#...##\n#.W.#..#\n#-#.N#.X\n#X... | |
taco | verifiable_code | https://www.hackerrank.com/challenges/degree-of-an-algebraic-number/problem | Solve the following coding problem using the programming language python:
A number is algebraic if it is a root of some nonzero polynomial with integer coefficients. A number is transcendental if it is not algebraic.
For example, ${11}$, ${i}$, $\sqrt[3]{2}$ and $\phi$ (golden ratio) are algebraic, because they are r... | ```python
MAXA = 10 ** 7
def main():
ncases = int(input())
for _ in range(ncases):
n = int(input())
a = [int(f) for f in input().split()]
assert n == len(a)
print(mindegree(a))
def mindegree(a):
factors = [set(factoroddpow(item)) for item in a]
adjoins = 0
for (i, factor) in enumerate(factors):
if len(... | vfc_142727 | {
"difficulty": "hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.hackerrank.com/challenges/degree-of-an-algebraic-number/problem",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1\n4\n3\n2 4 4\n4\n1 2 3 5\n",
"output": "1\n2\n8\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Jal Mahal Lake is famous tourist place in Jaipur. The lake has floating planks in a straight line. The planks are currently not attached to each other, and there may be gaps between some of them. You have to push them all together and connect th... | ```python
t=eval(input())
for i in range(0,t):
n=eval(input())
pos=input()
leng=input()
pos=pos.split()
leng=leng.split()
pos=list(map(int,pos))
leng=list(map(int,leng))
diff=[]
adiff=[]
for j in range(0,n):
diff.append([pos[j],leng[j]])
diff.sort()
#print diff
for j in range(0,n-1):
#print diff[j+1][0... | vfc_142731 | {
"difficulty": "unknown_difficulty",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n4\n1 3 10 20\n2 2 5 3\n3\n100 50 1\n10 2 1\n5\n4 10 100 13 80\n5 3 42 40 9\n10\n5606451 63581020 81615191 190991272 352848147 413795385 468408016 615921162 760622952 791438427\n42643329 9909484 58137134 99547272 39849232 1514670... | |
taco | verifiable_code | https://www.codechef.com/problems/HXOR | Solve the following coding problem using the programming language python:
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given a sequence $A_{1}, A_{2}, \ldots, A_{N}$ and you have to perform the following operation exactly $X$ times:
Choose two integer... | ```python
for _ in range(int(input())):
(n, x) = map(int, input().split())
arr = list(map(int, input().split()))
rem = 0
for i in range(n - 1):
a = arr[i]
d = a & rem
(a, rem) = (a ^ d, rem ^ d)
b = bin(a).count('1')
if b <= x:
x -= b
rem ^= a
a = 0
elif x > 0:
d = 0
for j in range(31, -1... | vfc_142735 | {
"difficulty": "medium_hard",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/HXOR",
"time_limit": "1 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n3 3\n2 2 3",
"output": "0 0 3",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/1521/B | Solve the following coding problem using the programming language python:
Nastia has received an array of $n$ positive integers as a gift.
She calls such an array $a$ good that for all $i$ ($2 \le i \le n$) takes place $gcd(a_{i - 1}, a_{i}) = 1$, where $gcd(u, v)$ denotes the greatest common divisor (GCD) of integer... | ```python
from math import gcd
for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
print(n - 1)
(val, idx) = min(((val, idx) for (idx, val) in enumerate(a)))
counter = 1
for i in range(idx + 1, n):
a[i] = val + counter
counter += 1
print(idx + 1, i + 1, val, a[i])
counter = 1... | vfc_142739 | {
"difficulty": "easy",
"memory_limit": "256 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1521/B",
"time_limit": "2 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n5\n9 6 3 11 15\n3\n7 5 13\n",
"output": "4\n3 1 3 5\n3 2 3 4\n3 4 3 4\n3 5 3 5\n2\n2 1 5 6\n2 3 5 6\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n5\n9 6 3 11 15\n3\n7 5 13\n",
... |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/matrix-game-20508/1 | Solve the following coding problem using the programming language python:
Given a string S which contains only small letters. The task is to make a square matrix from string S. Then perform the following operations.
1. In each column delete the characters which occur more than one.
2. Column-wise sort the remaining ch... | ```python
class Solution:
def matrixGame(self, S):
if len(S) == 1:
return S
elif len(S) < 5:
return 0
l = len(S)
import math
k = int(math.sqrt(l))
M = []
for i in range(0, len(S), k):
M.append(S[i:i + k])
W = []
for i in range(k):
b = ''
for j in range(k):
b += M[j][i]
g = ''
... | vfc_142744 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/matrix-game-20508/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "S = \"adgkbdhlceilcfjm\"",
"output": "abefgjhikm",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "S = \"abcabcabc\"",
"output": "0",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/847/L | Solve the following coding problem using the programming language python:
In the computer network of the Berland State University there are n routers numbered from 1 to n. Some pairs of routers are connected by patch cords. Information can be transmitted over patch cords in both direction. The network is arranged in s... | ```python
import math
import sys
read = sys.stdin.readline
n = int(read())
sub = [[] for _ in range(n)]
for i in range(n):
data = read().strip()
for j in data.split('-'):
tree = list(map(int, j.split(':')[1].split(',')))
for k in range(len(tree)):
tree[k] -= 1
sub[i].append(sorted(tree))
sub[i].sort()
dp = ... | vfc_142745 | {
"difficulty": "very_hard",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/847/L",
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n2:2,3-1:4\n3:4,3,1\n3:2,4,1\n1:2-2:1,3\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\n2:7,4-2:5,8-1:3-1:6-1:2-2:10,9\n9:6,7,3,4,10,8,9,5,1\n9:2,1,7,6,9,4,8,10,5\n... |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/arrange-balls0052/1 | Solve the following coding problem using the programming language python:
There are p balls of type P, q balls of type Q and r balls of type R. Using the balls we want to create a straight line such that no two balls of same type are adjacent.
Example 1:
Input: p = 2, q = 2, r = 2
Output: 30
Explanation: There are 3... | ```python
MAX = 101
dp = [[[[-1] * 4 for i in range(MAX)] for j in range(MAX)] for k in range(MAX)]
def countWayss(p, q, r, last):
if p < 0 or q < 0 or r < 0:
return 0
if p == 1 and q == 0 and (r == 0) and (last == 0):
return 1
if p == 0 and q == 1 and (r == 0) and (last == 1):
return 1
if p == 0 and q == 0 ... | vfc_142749 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/arrange-balls0052/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "p = 2, q = 2, r = 2",
"output": "30",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "p = 1, q = 1, r = 1",
"output": "6",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/minimum-swaps/1 | Solve the following coding problem using the programming language python:
Given an array of n distinct elements. Find the minimum number of swaps required to sort the array in strictly increasing order.
Example 1:
Input:
nums = {2, 8, 5, 4}
Output:
1
Explaination:
swap 8 with 4.
Example 2:
Input:
nums = {10, 19, 6, 3,... | ```python
from collections import OrderedDict
class Solution:
def minSwaps(self, nums):
dic = OrderedDict()
for i in range(len(nums)):
dic[nums[i]] = i
sorted_dic = OrderedDict(sorted(dic.items()))
swaps = 0
for (i, v) in enumerate(sorted_dic.values()):
if i != v:
(nums[i], nums[v]) = (nums[v], n... | vfc_142750 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/minimum-swaps/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "nums = {2, 8, 5, 4}",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "nums = {10, 19, 6, 3, 5}",
"output": "2",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | Solve the following coding problem using the programming language python:
On Unix computers, data is stored in directories. There is one root directory, and this might have several directories contained inside of it, each with different names. These directories might have even more directories contained inside of them... | ```python
for it in range(eval(input())):
n, m = list(map(int, input().split()))
ans = 0
f = {'':[]}
for i in range(n):
k=input().split('/')
while len(k)>1:
l=k.pop()
s='/'.join(k)
if s not in f:
f[s] = []
if l not in f[s]:
f[s].append(l)
for i in range(m):
k=input().split('/')
while le... | vfc_142751 | {
"difficulty": "unknown_difficulty",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n0 2\n/home/gcj/finals\n/home/gcj/quals\n2 1\n/chicken\n/chicken/egg\n/chicken\n1 3\n/a\n/a/b\n/a/c\n/b/b",
"output": "Case #1: 4\nCase #2: 0",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input":... | |
taco | verifiable_code | https://www.hackerrank.com/challenges/triangle-numbers/problem | Solve the following coding problem using the programming language python:
Given a triangle of numbers where each number is equal to the sum of the three numbers on top of it, find the first even number in a row.
Explanatory Note:
The vertex of the triangle (at the top) is 1.
The structure of the triangle is shown b... | ```python
def number(n):
if n == 1 or n == 2:
return -1
elif n % 2 == 1:
return 2
elif n % 4 == 0:
return 3
else:
return 4
n = int(input())
row_num = []
for i in range(n):
row_num.append(int(input()))
for j in range(n):
print(number(row_num[j]))
``` | vfc_142755 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.hackerrank.com/challenges/triangle-numbers/problem",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3\n4\n",
"output": "2\n3\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://www.hackerrank.com/challenges/wet-shark-and-42/problem | Solve the following coding problem using the programming language python:
As punishment for attacking Sunland, Wet Shark is now forced to walk on a line of numbered squares, starting from $\mbox{1}$ and going to infinity. Wet Shark initially has a strength of $\mbox{S}$. To make the experience harder for Wet Shark, ea... | ```python
def calc(x):
MOD = 10 ** 9 + 7
twenties = x // 20
rem = x % 20
if rem == 0:
return (42 * twenties - 2) % MOD
else:
return (42 * twenties + 2 * rem) % MOD
tcs = int(input())
for i in range(tcs):
print(calc(int(input())))
``` | vfc_142760 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.hackerrank.com/challenges/wet-shark-and-42/problem",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3\n4\n",
"output": "6 \n8\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://www.codechef.com/problems/XORK | Solve the following coding problem using the programming language python:
Given an array A having N elements, a subarray S of A is called good if XOR(S) ≥ K, where XOR(S) denotes the [bitwise XOR] of all the elements of the subarray S.
Find the length of the smallest subarray S which is good. If there is no good suba... | ```python
T = int(input())
for _ in range(T):
(N, K) = map(int, input().split())
A = list(map(int, input().split()))
def length(getMask, ignoreMask):
assert getMask & ignoreMask == 0
C = [0]
D = {0: 0}
res = float('inf')
for (i, elt) in enumerate(A):
presum = C[-1] ^ elt & ~ignoreMask
C.append(presu... | vfc_142764 | {
"difficulty": "very_hard",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/XORK",
"time_limit": "2 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n5 15\n1 4 2 8 1\n5 7\n1 4 2 8 1\n5 20\n1 4 2 8 1",
"output": "4\n1\n-1",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/711/C | Solve the following coding problem using the programming language python:
ZS the Coder and Chris the Baboon has arrived at Udayland! They walked in the park where n trees grow. They decided to be naughty and color the trees in the park. The trees are numbered with integers from 1 to n from left to right.
Initially, t... | ```python
INF = 10 ** 18
MX_SZ = 112
dp = [[[INF for k in range(MX_SZ)] for j in range(MX_SZ)] for i in range(MX_SZ)]
best = [[[(INF, INF) for k in range(MX_SZ)] for j in range(MX_SZ)] for i in range(MX_SZ)]
def read():
return [int(x) for x in input().split()]
(n, m, k_res) = read()
arr = read()
cost = []
for i in ra... | vfc_142768 | {
"difficulty": "medium_hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/711/C",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 2 2\n0 0 0\n1 2\n3 4\n5 6\n",
"output": "10",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 2 2\n2 1 2\n1 3\n2 4\n3 5\n",
"output": "-1",
"type": "stdin_stdout"
},
{
... |
taco | verifiable_code | https://codeforces.com/problemset/problem/415/A | Solve the following coding problem using the programming language python:
Mashmokh works in a factory. At the end of each day he must turn off all of the lights.
The lights on the factory are indexed from 1 to n. There are n buttons in Mashmokh's room indexed from 1 to n as well. If Mashmokh pushes button with index... | ```python
from array import *
from itertools import *
(n, m) = list(map(int, input().split()))
bs = map(int, input().split())
a = array('i', repeat(0, n))
for b in bs:
for i in range(b - 1, n):
if a[i] != 0:
break
a[i] = b
for i in a:
print(i, end=' ')
``` | vfc_142772 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/415/A",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 4\n4 3 1 2\n",
"output": "1 1 3 4 4 \n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 5\n5 4 3 2 1\n",
"output": "1 2 3 4 5 \n",
"type": "stdin_stdout"
},
{
"f... |
taco | verifiable_code | https://codeforces.com/problemset/problem/727/B | Solve the following coding problem using the programming language python:
Vasily exited from a store and now he wants to recheck the total price of all purchases in his bill. The bill is a string in which the names of the purchases and their prices are printed in a row without any spaces. Check has the format "name_1p... | ```python
s = input()
a = 0
r = ''
l = []
for i in s:
if 48 <= ord(i) <= 57 or ord(i) == 46:
r += i
elif len(r) > 0:
if len(r) > 3 and r[-3] == '.':
a += float(''.join(r[:-3].split('.')) + r[-3:])
else:
a += float(''.join(r.split('.')) + '.00')
r = ''
if len(r) > 0:
if len(r) > 3 and r[-3] == '.':
a ... | vfc_142776 | {
"difficulty": "medium_hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/727/B",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "chipsy48.32televizor12.390\n",
"output": "12.438.32\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "a1b2c3.38\n",
"output": "6.38\n",
"type": "stdin_stdout"
},
{
... |
taco | verifiable_code | https://www.codechef.com/problems/CCD | Solve the following coding problem using the programming language python:
Chef has 2 strings A and B of equal length N. Both strings contain lowercase english alphabets only.
Chef can perform several moves on string A. In one move, Chef has to:
Select an index i \space (1 ≤ i ≤ N-1).
Replace A[i] with (A[i]+1).
Repla... | ```python
t = int(input())
for _ in range(t):
(n, q) = map(int, input().split())
a = list(input())
b = list(input())
alt_sum = [0] * n
for i in range(n):
k = (ord(b[i]) - ord(a[i])) % 26
if i == 0:
alt_sum[i] = k
continue
if i % 2 == 0:
alt_sum[i] = k + alt_sum[i - 1]
else:
alt_sum[i] = -k + al... | vfc_142780 | {
"difficulty": "hard",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/CCD",
"time_limit": "1 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n5 3\nabcdz\nnbhea\n2 2\n1 3\n4 5\n",
"output": "Yes\nNo\nYes\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/893/D | Solve the following coding problem using the programming language python:
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.
She starts with 0 money on her account.
In the evening of i-th day a transaction a_{i} occurs. If a_{i} > 0, then a_{i} bourles are de... | ```python
(n, d) = map(int, input().split())
a = [0] + list(map(int, input().split()))
b = [0] * (n + 2)
b[n] = a[n]
now = a[n]
for i in range(n - 1, 0, -1):
now = a[i] + max(now, 0)
b[i] = now
now = 0
res = 0
for i in range(1, n + 1):
if a[i] == 0:
if now < 0:
res += 1
now = min(d, max(0, d - b[i + 1]))
el... | vfc_142784 | {
"difficulty": "hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/893/D",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 10\n-1 5 0 -5 3\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 4\n-10 0 20\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null... |
taco | verifiable_code | https://codeforces.com/problemset/problem/1534/F1 | Solve the following coding problem using the programming language python:
This is the easy version of the problem. The difference between the versions is the constraints on a_i. You can make hacks only if all versions of the problem are solved.
Little Dormi has recently received a puzzle from his friend and needs you... | ```python
import sys
input = lambda : sys.stdin.readline().rstrip()
def scc(E):
n = len(E)
iE = [[] for _ in range(n)]
for (i, e) in enumerate(E):
for v in e:
iE[v].append(i)
T = []
done = [0] * n
ct = 0
for i0 in range(n):
if done[i0]:
continue
Q = [~i0, i0]
while Q:
i = Q.pop()
if i < 0:
... | vfc_142788 | {
"difficulty": "unknown_difficulty",
"memory_limit": "512.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1534/F1",
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 6\n..#..#\n......\n#####.\n1 1 2 1 1 1\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 10\n#..###..##\n...#..###.\n.###..##..\n1 1 1 3 1 1 2 2 2 1\n",
"output": ... |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/check-squares2421/1 | Solve the following coding problem using the programming language python:
Given an integer N, check if it is possible to represent it as a function(a, b) such that : a^{2} + b^{2} = N where "a" and "b" are whole numbers. Print 1 if it's possible, else Print 0.
Example 1:
Input:
N = 1
Output:
1
Explanation:
1^{2} + 0... | ```python
import math
class Solution:
def checkSquares(self, N):
flag = 0
for a in range(int(math.sqrt(N)) + 1):
for b in range(int(math.sqrt(N)) + 1):
if a * a + b * b == N:
flag = 1
break
if flag == 1:
break
return flag
``` | vfc_142792 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/check-squares2421/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "N = 1",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "N = 2",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "N = 7",
... |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/deque-implementations/1 | Solve the following coding problem using the programming language python:
A deque is a double-ended queue that allows enqueue and dequeue operations from both the ends.
Given a deque and Q queries. The task is to perform some operation on dequeue according to the queries as given below:
1. pb: query to push back the e... | ```python
def push_front_pf(dq, x):
dq.appendleft(x)
def push_back_pb(dq, x):
dq.append(x)
def front_dq(dq):
if not dq:
return -1
return dq[0]
def pop_back_ppb(dq):
if not dq:
return -1
return dq.pop()
``` | vfc_142794 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/deque-implementations/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": "push_front_pf",
"input": "5\npf 5\npf 10\npb 6\nf\npp_b",
"output": "10",
"type": "function_call"
},
{
"fn_name": "push_front_pf",
"input": "2\npf 5 \nf",
"output": "5",
"type": "function_call"
}
... |
taco | verifiable_code | https://www.codechef.com/problems/SUMOFPROD2 | Solve the following coding problem using the programming language python:
For an array A of length N, let F(A) denote the sum of the product of all the subarrays of A. Formally,
F(A) = \sum_{L=1}^N \sum_{R=L}^N (\prod_{i=L}^R A_{i}\right )
For example, let A = [1, 0, 1], then there are 6 possible subarrays:
Subarr... | ```python
MOD = 998244353
cpraid1 = [1] * 100001
cpraid2 = [1] * 100001
cpraid3 = [1] * 100001
for i in range(2, 100001):
cpraid1[i] = cpraid1[i - 1] * i % MOD
cpraid2[i] = MOD - MOD // i * cpraid2[MOD % i] % MOD
cpraid3[i] = cpraid3[i - 1] * cpraid2[i] % MOD
def C(x, y):
return 0 if x < 0 or y > x else cpraid1[x]... | vfc_142797 | {
"difficulty": "medium_hard",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/SUMOFPROD2",
"time_limit": "1 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n3\n1 0 1\n1\n0\n2\n1 1\n4\n1 1 0 1\n",
"output": "16\n0\n6\n120\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://www.hackerrank.com/challenges/runningtime/problem | Solve the following coding problem using the programming language python:
In a previous challenge you implemented the Insertion Sort algorithm. It is a simple sorting algorithm that works well with small or mostly sorted data. However, it takes a long time to sort large unsorted data. To see why, we will analyze its r... | ```python
size = int(input())
array = input().split(' ')
arr = ['None'] * size
for i in range(size):
arr[i] = int(array[i])
i = 1
count = 0
while i < size:
tmp = arr[i]
j = i - 1
while arr[j] > tmp and j > -1:
arr[j + 1] = arr[j]
j = j - 1
count = count + 1
arr[j + 1] = tmp
i = i + 1
print(count)
``` | vfc_142801 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.hackerrank.com/challenges/runningtime/problem",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 \n2 1 3 1 2 \n",
"output": "4\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/middle-of-three2926/1 | Solve the following coding problem using the programming language python:
Given three distinct numbers A, B and C. Find the number with value in middle (Try to do it with minimum comparisons).
Example 1:
Input:
A = 978, B = 518, C = 300
Output:
518
Explanation:
Since 518>300 and 518<978, so
518 is the middle element.... | ```python
class Solution:
def middle(self, A, B, C):
if A > B > C or C > B > A:
return B
elif A > C > B or B > C > A:
return C
else:
return A
``` | vfc_142805 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/middle-of-three2926/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "A = 978, B = 518, C = 300",
"output": "518",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "A = 162, B = 934, C = 200",
"output": "200",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Regional College is having N branches, where each branches have positive integral student. A minimize operation is performed on the branch such that all of them are reduced by the minimum number student in a branch.
Suppose we have 5 branches a... | ```python
n=eval(input())
s=input()
lst=s.split(' ')
ar=[0]*n
for i in range(0,n):
ar[i]=int(lst[i])
ar.sort()
cnt=1
mn=ar[0]
print(len(ar))
while(cnt!=0):
cnt=0
for i in range(0,n):
ar[i]=ar[i]-mn
if(ar[i]>0):
cnt=cnt+1
for i in range(0,n):
if(ar[i]>0):
mn=ar[i]
break
if(cnt>0):
print(cnt)
``` | vfc_142806 | {
"difficulty": "unknown_difficulty",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6\n5 4 4 2 2 8",
"output": "6\n4\n2\n1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1000\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1... | |
taco | verifiable_code | https://codeforces.com/problemset/problem/1030/E | Solve the following coding problem using the programming language python:
Vasya has a sequence $a$ consisting of $n$ integers $a_1, a_2, \dots, a_n$. Vasya may pefrom the following operation: choose some number from the sequence and swap any pair of bits in its binary representation. For example, Vasya can transform n... | ```python
from bisect import bisect_left
n = int(input())
b = list(map(int, input().split()))
pre = [0]
res = []
for j in range(n):
res.append(bin(b[j]).count('1'))
pre.append(pre[-1] + res[-1])
ans = 0
e = 1
o = 0
for j in range(n):
if pre[j + 1] % 2 == 0:
ans += e
e += 1
else:
ans += o
o += 1
s = 0
m = ... | vfc_142811 | {
"difficulty": "hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1030/E",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n6 7 14\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n1 2 1 16\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"in... |
taco | verifiable_code | Solve the following coding problem using the programming language python:
E-training
Nene is writing a program to look up $ N $ integers $ V_1, V_2, V_3, \ cdots, V_N $ for programming training.
As told by his instructor, Umiko, Nene wrote a program to look up multiples of 2, 3, and 6.
Multiples of 2 were $ A $, mu... | ```python
(n, a, b, c) = map(int, input().split())
print(n - (a + b - c))
``` | vfc_142815 | {
"difficulty": "unknown_difficulty",
"memory_limit": "268.435456 megabytes",
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "1.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6 5 2 1",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "9 5 2 1",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "12 ... | |
taco | verifiable_code | https://atcoder.jp/contests/abc168/tasks/abc168_c | Solve the following coding problem using the programming language python:
Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively.
An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant an... | ```python
import math
(a, b, h, m) = map(int, input().split())
alpha = 2 * math.pi * h / 12 + math.pi / 6 * m / 60
beta = 2 * math.pi * m / 60
ans = (a * a + b * b - 2 * a * b * math.cos(alpha - beta)) ** 0.5
print(ans)
``` | vfc_142820 | {
"difficulty": "easy",
"memory_limit": "1024.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://atcoder.jp/contests/abc168/tasks/abc168_c",
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 4 9 0\n",
"output": "5.00000000000000000000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 4 10 40\n",
"output": "4.56425719433005567605\n",
"type": "stdin_stdout"
},
... |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/k-palindrome/1 | Solve the following coding problem using the programming language python:
A string is k palindrome if it can be transformed into a palindrome on removing at most k characters from it. Your task is to complete the function is_k_palin which takes two arguments a string str and a number N . Your function should return tr... | ```python
def is_k_palin(string, n):
k = n
n = len(string)
dp = [[-1 for j in range(n)] for i in range(n)]
for i in range(n - 1, -1, -1):
for j in range(n):
if i >= j:
dp[i][j] = 0
elif string[i] == string[j]:
dp[i][j] = dp[i + 1][j - 1]
else:
dp[i][j] = 1 + min(dp[i + 1][j], dp[i][j - 1])
i... | vfc_142824 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/k-palindrome/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": "is_k_palin",
"input": "2\r\n\nabcdecba 1\r\n\nacdcb 1",
"output": "1\n0",
"type": "function_call"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/1133/D | Solve the following coding problem using the programming language python:
You are given two arrays $a$ and $b$, each contains $n$ integers.
You want to create a new array $c$ as follows: choose some real (i.e. not necessarily integer) number $d$, and then for every $i \in [1, n]$ let $c_i := d \cdot a_i + b_i$.
Your... | ```python
from collections import defaultdict
from math import gcd
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
Pairs = defaultdict(int)
already = 0
for i in range(N):
if A[i] and B[i]:
b = -B[i]
a = A[i]
x = gcd(abs(b), abs(a))
bb = int(b / x)
aa = int(a / x)
... | vfc_142825 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1133/D",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n1 2 3 4 5\n2 4 7 11 3\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n13 37 39\n1 2 3\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_... |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Jack stays in a n-storey hostel. His dorm room is on the jth floor. Every morning, he is in so much hurry for classes that he cannot not decide whether to take Lift or Stairs to reach ground-floor. He asks you to help him choose either Stairs or... | ```python
t = input()
for _ in range(int(t)):
inp = input().split()
n, J, L = list(map(int, inp[:-1]))
d = inp[-1]
stairs = 10*(J)
lift = 0
if d == 'U':
if J != n:
lift = 30 + (n-L)*5 + (n*5)
if J == n:
lift = 20 + (n-L)*5 + (n*5)
elif d =='D':
if L >= J:
lift = 20 + L*5
else:
lift = 40 + L*5... | vfc_142829 | {
"difficulty": "unknown_difficulty",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "32\n10 5 5 U\n10 5 5 D\n10 3 3 D\n10 9 9 U\n10 10 10 U\n10 10 10 D\n100 80 20 U\n100 80 45 U\n100 80 46 U\n100 80 40 D\n100 80 0 D\n100 80 79 D\n100 100 3 U\n100 100 4 U\n100 100 5 U\n100 100 2 U\n100 100 1 D\n100 53 100 U\n100 52 ... | |
taco | verifiable_code | https://www.codechef.com/problems/HIGHFREQ | Solve the following coding problem using the programming language python:
Chef has an array A of length N.
Let F(A) denote the maximum frequency of any element present in the array.
For example:
If A = [1, 2, 3, 2, 2, 1], then F(A) = 3 since element 2 has the highest frequency = 3.
If A = [1, 2, 3, 3, 2, 1], then ... | ```python
from collections import Counter
from math import ceil, floor, gcd
for _ in range(int(input())):
n = int(input())
a = list(Counter([int(x) for x in input().strip().split()]).values())
if len(a) == 1:
print(ceil(a[0] / 2))
else:
a.sort()
print(max(ceil(a[-1] / 2), a[-2]))
``` | vfc_142834 | {
"difficulty": "medium",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/HIGHFREQ",
"time_limit": "0.5 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n4\n1 2 1 2\n5\n1 1 1 1 1\n6\n1 2 2 1 2 2\n",
"output": "2\n3\n2\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/1608/D | Solve the following coding problem using the programming language python:
You are given $n$ dominoes. Each domino has a left and a right cell. Each cell can be colored either black or white. Some cells are already colored, while some aren't yet.
The coloring is said to be valid if and only if it is possible to rearra... | ```python
MOD = 998244353
MAX = 200005
fact = [1]
for zz in range(1, MAX + 1):
fact.append(fact[-1] * zz % MOD)
def nCr(n, r):
num = fact[n]
den = fact[r] * fact[n - r] % MOD
return num * pow(den, MOD - 2, MOD) % MOD
from collections import Counter
def main():
MOD = 998244353
cnts = Counter()
n = int(input())
... | vfc_142840 | {
"difficulty": "very_hard",
"memory_limit": "256 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1608/D",
"time_limit": "1 second"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n?W\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n??\nW?\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": ... |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/next-greater-element-2/1 | Solve the following coding problem using the programming language python:
Given a circular interger array arr of size N (i.e ., the next element of arr [N-1] is arr[0] ), return the next greater number for every element in arr.
The next greater element of a number x is the first greater number to its traversing-order ... | ```python
class Solution:
def nextGreaterElement(self, N, arr):
ans = [-2] * N
ma = max(arr)
for i in range(N):
if arr[i] == ma:
ans[i] = -1
pos = i
stack = [ma]
for i in range(N - 1, -1, -1):
j = (i + pos) % N
if ans[j] == -1:
stack[:] = [ma]
else:
while stack[-1] <= arr[j]:
... | vfc_142845 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/next-greater-element-2/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "N = 3\r\narr[ ] = {1, 2, 1}",
"output": "{2, -1, 2}",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "N = 5\r\narr[ ] = {5, 4, 3, 2, 1}",
"output": "{-1, 5, 5, 5, 5}",
"type": "std... |
taco | verifiable_code | https://www.codechef.com/problems/DAILY | Solve the following coding problem using the programming language python:
A daily train consists of N cars. Let's consider one particular car. It has 54 places numbered consecutively from 1 to 54, some of which are already booked and some are still free. The places are numbered in the following fashion:
The car is sep... | ```python
import math
(x, n) = map(int, input().split())
counter = 0
equals = 0
for _ in range(n):
a = input()
(i, j) = (0, 54)
for __ in range(9):
lst = a[i:i + 4] + a[j - 2:j]
counter += math.comb(lst.count('0'), x)
i += 4
j -= 2
print(counter)
``` | vfc_142846 | {
"difficulty": "easy",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/DAILY",
"time_limit": "2.992 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1 3\n100101110000001011000001111110010011110010010111000101\n001010000000101111100000000000000111101010101111111010\n011110011110000001010100101110001011111010001001111010",
"output": "85",
"type": "stdin_stdout"
},... |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/linear-diophantine-equations5649/1 | Solve the following coding problem using the programming language python:
A Diophantine equation is a polynomial equation, usually in two or more unknowns, such that only the integral solutions are required. An Integral solution is a solution such that all the unknown variables take only integer values.
Given three in... | ```python
import math
class Solution:
def isPossible(self, A, B, C):
k = math.gcd(A, B)
if C % k == 0:
return 1
else:
return 0
``` | vfc_142850 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/linear-diophantine-equations5649/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "A = 3\nB = 6\nC = 9",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "A = 4\nB = 2\nC = 3",
"output": "0",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/1179/C | Solve the following coding problem using the programming language python:
Serge came to the school dining room and discovered that there is a big queue here. There are $m$ pupils in the queue. He's not sure now if he wants to wait until the queue will clear, so he wants to know which dish he will receive if he does. A... | ```python
import sys
from itertools import accumulate
class Lazysegtree:
def __init__(self, A, intv, initialize=True, segf=min):
self.N = len(A)
self.N0 = 2 ** (self.N - 1).bit_length()
self.intv = intv
self.segf = segf
self.lazy = [0] * (2 * self.N0)
if initialize:
self.data = [intv] * self.N0 + A + ... | vfc_142851 | {
"difficulty": "hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1179/C",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1 1\n1\n1\n1\n1 1 100\n",
"output": "100\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 1\n1\n1\n1\n2 1 100\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"... |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Sherlock is following N criminals, which are right now in a 2D grid. Each criminal at t=0, decides to move in certain fixed direction. Each criminal moves with same speed. These fixed directions are North, East, West and South. Two or more crim... | ```python
for _ in range(eval(input())):
n = eval(input())
m = n
D = {}
C = []
i = 0
mnx, mxx, mny, mxy = 0, 0, 0, 0
for __ in range(n):
x, y, d = input().split()
x = int(x) * 2
y = int(y) * 2
mxx = max(mxx, x)
mxy = max(mxy, y)
mnx = min(mnx, x)
mny = min(mny, y)
C.append([x, y, d])
D[(x, y)] ... | vfc_142855 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "20\n4\n0 0 N\n10 10 W\n20 20 N\n30 30 E\n4\n-10 0 N\n0 -10 E\n0 10 W\n10 0 S\n4\n0 0 E\n9 0 W\n0 4 S\n0 5 S\n9\n-1 0 E\n1 0 E\n0 0 N\n-1 -1 W\n1 -1 W\n0 1 S\n0 -1 W\n-1 1 S\n1 1 E\n5\n-2 -1 S\n-3 -1 W\n-2 -3 N\n1 3 S\n-3 -2 E\n9\n-... | |
taco | verifiable_code | https://www.codechef.com/problems/CHEFSTR1 | Solve the following coding problem using the programming language python:
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Having already mastered cooking, Chef has now decided to learn how to play the guitar. Often while trying to play a song, Chef has to skip s... | ```python
t = int(input())
while t > 0:
n = int(input())
arr = list(map(int, input().split()))
count = 0
for i in range(n - 1):
count += max(arr[i], arr[i + 1]) - min(arr[i], arr[i + 1]) - 1
print(count)
t -= 1
``` | vfc_142859 | {
"difficulty": "easy",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/CHEFSTR1",
"time_limit": "1 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n6\n1 6 11 6 10 11\n4\n1 3 5 7",
"output": "15\n3",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://atcoder.jp/contests/abc108/tasks/abc108_b | Solve the following coding problem using the programming language python:
There is a square in the xy-plane. The coordinates of its four vertices are (x_1,y_1),(x_2,y_2),(x_3,y_3) and (x_4,y_4) in counter-clockwise order.
(Assume that the positive x-axis points right, and the positive y-axis points up.)
Takahashi reme... | ```python
(x1, y1, x2, y2) = tuple(map(int, input().split()))
x3 = x2 - (y2 - y1)
y3 = y2 + (x2 - x1)
x4 = x3 - (y3 - y2)
y4 = y3 + (x3 - x2)
print(x3, y3, x4, y4)
``` | vfc_142863 | {
"difficulty": "easy",
"memory_limit": "1024.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://atcoder.jp/contests/abc108/tasks/abc108_b",
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "0 0 0 1\n",
"output": "-1 1 -1 0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 3 6 6\n",
"output": "3 10 -1 7\n",
"type": "stdin_stdout"
},
{
"fn_name": null,... |
taco | verifiable_code | Solve the following coding problem using the programming language python:
A sequence a_1,a_2,... ,a_n is said to be /\/\/\/ when the following conditions are satisfied:
* For each i = 1,2,..., n-2, a_i = a_{i+2}.
* Exactly two different numbers appear in the sequence.
You are given a sequence v_1,v_2,...,v_n whose... | ```python
n = int(input())
l = [int(i) for i in input().split()]
o = [[0, i] for i in range(100001)]
e = [[0, i] for i in range(100001)]
for i in range(n // 2):
o[l[i * 2]][0] += 1
e[l[i * 2 + 1]][0] += 1
o.sort(reverse=True)
e.sort(reverse=True)
res = 10000000000000000
for i in range(2):
for j in range(2):
if o[i... | vfc_142867 | {
"difficulty": "unknown_difficulty",
"memory_limit": "1024.0 megabytes",
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n3 2 3 2",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6\n105 119 204 119 105 119",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": nul... | |
taco | verifiable_code | https://atcoder.jp/contests/abc123/tasks/abc123_d | Solve the following coding problem using the programming language python:
The Patisserie AtCoder sells cakes with number-shaped candles.
There are X, Y and Z kinds of cakes with 1-shaped, 2-shaped and 3-shaped candles, respectively.
Each cake has an integer value called deliciousness, as follows:
- The deliciousness ... | ```python
(x, y, z, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ab = []
for i in a:
for j in b:
ab.append(i + j)
ab.sort(reverse=True)
ab = ab[:k]
abc = []
for i in ab:
for j in c:
abc.append(i + j)
abc.sort(reverse=Tru... | vfc_142872 | {
"difficulty": "medium",
"memory_limit": "1024.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://atcoder.jp/contests/abc123/tasks/abc123_d",
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 2 2 8\n4 6\n1 5\n3 8\n",
"output": "19\n17\n15\n14\n13\n12\n10\n8\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 3 3 5\n1 10 100\n2 20 200\n1 10 100\n",
"output": "400\n310\n310... |
taco | verifiable_code | https://codeforces.com/problemset/problem/1187/A | Solve the following coding problem using the programming language python:
Your favorite shop sells n Kinder Surprise chocolate eggs. You know that exactly s stickers and exactly t toys are placed in n eggs in total.
Each Kinder Surprise can be one of three types:
* it can contain a single sticker and no toy;
* ... | ```python
for _ in range(int(input())):
(n, s, t) = map(int, input().split())
print(max(n - s + 1, n - t + 1))
``` | vfc_142876 | {
"difficulty": "easy",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1187/A",
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n1 1 1\n1000000000 1000000000 1000000000\n1000000000 999999999 1\n999999999 666666667 666666666\n",
"output": "1\n1\n1000000000\n333333334\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": ... |
taco | verifiable_code | https://www.codechef.com/problems/REMOVEBAD | Solve the following coding problem using the programming language python:
Chef has an array A of length N.
In one operation, Chef can remove any one element from the array.
Determine the minimum number of operations required to make all the elements same.
------ Input Format ------
- The first line of input will... | ```python
from collections import Counter
n = int(input())
for j in range(n):
n1 = int(input())
l = list(map(int, input().split()))
count = Counter(l)
x = [int(x) for x in count.values()]
print(len(l) - max(x))
``` | vfc_142880 | {
"difficulty": "easy",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/REMOVEBAD",
"time_limit": "0.5 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n3\n3 3 3\n6\n1 3 2 1 2 2\n4\n1 2 1 2\n5\n1 3 2 4 5\n",
"output": "0\n3\n2\n4\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/union-find/1 | Solve the following coding problem using the programming language python:
This problem is to implement disjoint set union. There will be 2 incomplete functions namely union and find. You have to complete these functions.
Union: Join two subsets into a single set.
isConnected: Determine which subset a particular eleme... | ```python
class Solution:
@staticmethod
def find(par, r):
while par[r] != r:
r = par[r]
return r
@staticmethod
def compress(par, x, r):
while x != r:
par[x] = r
x = par[x]
def union_(self, a, b, par, rank1):
r1 = self.find(par, a)
r2 = self.find(par, b)
if r1 != r2:
par[r1] = r2
self.c... | vfc_142884 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/union-find/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "N = 5\r\nq = 4\r\nQueries = \r\nUnion(1,3)\r\nisConnected(1,2)\r\nUnion(1,5)\r\nisConnected(3,5)",
"output": "0\r\n1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "N = 5\r\nq = 4\r\nQueries... |
taco | verifiable_code | https://codeforces.com/problemset/problem/1086/A | Solve the following coding problem using the programming language python:
The Squareland national forest is divided into equal 1 × 1 square plots aligned with north-south and east-west directions. Each plot can be uniquely described by integer Cartesian coordinates (x, y) of its south-west corner.
Three friends, Alic... | ```python
s = [[int(i) for i in input().split()] for j in range(3)]
s.sort()
a = s[0]
b = s[1]
c = s[2]
print(c[0] - a[0] + max(a[1], b[1], c[1]) - min(a[1], b[1], c[1]) + 1)
for i in range(a[0], b[0]):
print('{} {}'.format(i, a[1]))
for i in range(min(a[1], b[1], c[1]), max(a[1], b[1], c[1]) + 1):
print('{} {}'.form... | vfc_142885 | {
"difficulty": "medium_hard",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1086/A",
"time_limit": "1.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1 0\n2 2\n1 1\n",
"output": "4\n1 0\n1 1\n1 2\n2 2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "670 672\n593 626\n593 792\n",
"output": "244\n593 626\n593 627\n593 628\n593 629\n5... |
taco | verifiable_code | https://codeforces.com/problemset/problem/1343/C | Solve the following coding problem using the programming language python:
Recall that the sequence $b$ is a a subsequence of the sequence $a$ if $b$ can be derived from $a$ by removing zero or more elements without changing the order of the remaining elements. For example, if $a=[1, 2, 1, 3, 1, 2, 1]$, then possible s... | ```python
for _ in range(int(input())):
n = int(input())
seq = [int(x) for x in input().split()]
sign = seq[0] > 0
mmax = 0
mmin = float('-inf')
ans = 0
for val in seq:
if val > 0 and sign:
mmax = max(mmax, val)
elif val < 0 and (not sign):
mmin = max(mmin, val)
elif val > 0 and (not sign):
ans +=... | vfc_142890 | {
"difficulty": "easy",
"memory_limit": "256 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1343/C",
"time_limit": "1 second"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000\n",
"output": "2\n-1\n6\n-2999999997\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"i... |
taco | verifiable_code | https://www.codechef.com/problems/CHFRICH | Solve the following coding problem using the programming language python:
Read problem statements in [Mandarin], [Bengali], [Russian], and [Vietnamese] as well.
Chef aims to be the richest person in Chefland by his new restaurant franchise. Currently, his assets are worth $A$ billion dollars and have no liabilities. ... | ```python
t = int(input())
for i in range(t):
(a, b, x) = map(int, input().split())
print((b - a) // x)
``` | vfc_142894 | {
"difficulty": "easy",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/CHFRICH",
"time_limit": "0.5 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n100 200 10\n111 199 11\n190 200 10",
"output": "10\n8\n1",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/1015/A | Solve the following coding problem using the programming language python:
You are given a set of $n$ segments on the axis $Ox$, each segment has integer endpoints between $1$ and $m$ inclusive. Segments may intersect, overlap or even coincide with each other. Each segment is characterized by two integers $l_i$ and $r_... | ```python
(n, m) = map(int, input().split())
L = (m + 2) * [0]
for _ in range(n):
(l, r) = map(int, input().split())
L[l] += 1
L[r + 1] -= 1
ans = []
for i in range(1, m + 1):
L[i] += L[i - 1]
if L[i] == 0:
ans.append(i)
print(len(ans))
print(*ans)
``` | vfc_142898 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1015/A",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 5\n2 2\n1 2\n5 5\n",
"output": "2\n3 4 \n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 7\n1 7\n",
"output": "0\n\n",
"type": "stdin_stdout"
},
{
"fn_name": n... |
taco | verifiable_code | https://atcoder.jp/contests/abc120/tasks/abc120_c | Solve the following coding problem using the programming language python:
There are N cubes stacked vertically on a desk.
You are given a string S of length N. The color of the i-th cube from the bottom is red if the i-th character in S is 0, and blue if that character is 1.
You can perform the following operation any... | ```python
S = list(input())
print(2 * min(S.count('1'), S.count('0')))
``` | vfc_142902 | {
"difficulty": "easy",
"memory_limit": "1024.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://atcoder.jp/contests/abc120/tasks/abc120_c",
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "0011\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "11011010001011\n",
"output": "12\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"inp... |
taco | verifiable_code | https://codeforces.com/problemset/problem/362/B | Solve the following coding problem using the programming language python:
Little boy Petya loves stairs very much. But he is bored from simple going up and down them — he loves jumping over several stairs at a time. As he stands on some stair, he can either jump to the next one or jump over one or two stairs at a time... | ```python
(n, m) = map(int, input().split())
if m == 0:
print('YES')
exit(0)
a = set(map(int, input().split()))
l = 0
for i in a:
if i + 1 in a and i + 2 in a:
l += 1
if 1 in a or n in a or l > 0:
print('NO')
else:
print('YES')
``` | vfc_142906 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/362/B",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10 5\n2 4 8 3 6\n",
"output": "NO",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 5\n2 4 5 7 9\n",
"output": "YES",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
Subsets and Splits
Random Hard Python Problems
Retrieves a random sample of 10 hard difficulty questions along with their answers and problem IDs, providing basic filtering but limited analytical value.