source stringclasses 4
values | task_type stringclasses 1
value | in_source_id stringlengths 0 138 | problem stringlengths 219 13.2k | gold_standard_solution stringlengths 0 413k | problem_id stringlengths 5 10 | metadata dict | verification_info dict |
|---|---|---|---|---|---|---|---|
taco | verifiable_code | https://codeforces.com/problemset/problem/1467/A | Solve the following coding problem using the programming language python:
There are $n$ digital panels placed in a straight line. Each panel can show any digit from $0$ to $9$. Initially, all panels show $0$.
Every second, the digit shown by each panel increases by $1$. In other words, at the end of every second, a p... | ```python
import sys
t = int(input())
for _ in range(t):
n = int(input())
if n == 1:
print(9)
elif n == 2:
print(98)
else:
res = '989'
n = n - 3
s = '0123456789'
res = res + s * (n // 10) + s[0:n % 10]
print(res)
``` | vfc_87868 | {
"difficulty": "easy",
"memory_limit": "256 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1467/A",
"time_limit": "1 second"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1\n2\n",
"output": "9\n98\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n200000\n",
"output": "98901234567890123456789012345678901234567890123456789012345678901234567890123456... |
taco | verifiable_code | https://www.codechef.com/PTRN2020/problems/ITGUY42 | Solve the following coding problem using the programming language python:
The chef is trying to solve some pattern problems, Chef wants your help to code it. Chef has one number K to form a new pattern. Help the chef to code this pattern problem.
-----Input:-----
- First-line will contain $T$, the number of test case... | ```python
for i in range(int(input())):
n = int(input())
p = 1
l = n - 1
for j in range(n):
for k in range(l):
print(' ', end='')
for k in range(p):
print('*', end='')
print()
for k in range(l):
print(' ', end='')
for k in range(p):
print('*', end='')
print()
p += 2
l -= 1
``` | vfc_87872 | {
"difficulty": "unknown_difficulty",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/PTRN2020/problems/ITGUY42",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n1\n2\n3\n4\n",
"output": "*\n*\n*\n*\n***\n***\n*\n*\n***\n***\n*****\n*****\n*\n*\n***\n***\n*****\n*****\n*******\n*******\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | Solve the following coding problem using the programming language python:
You are a teacher at a cram school for elementary school pupils.
One day, you showed your students how to calculate division of fraction in a class of mathematics. Your lesson was kind and fluent, and it seemed everything was going so well - ex... | ```python
def gcd(a, b):
while b:
(a, b) = (b, a % b)
return a
def f(n, m):
if m == 1:
return 0
x = 1
for i in range(m):
x = x * n % m
if x == 1:
return i + 1
while 1:
(a, b) = map(int, input().split())
if a == 0:
break
c = gcd(a, b)
a //= c
b //= c
cnt = 0
d = gcd(b, 10)
while d != 1:
b //... | vfc_87876 | {
"difficulty": "unknown_difficulty",
"memory_limit": "134.217728 megabytes",
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "8.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 3\n1 6\n3 5\n2 200\n25 99\n0 0",
"output": "0 1\n1 1\n1 0\n2 0\n0 2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 6\n1 5\n3 5\n2 200\n25 99\n0 0",
"output": "0 1\n1 0\n1 0\n2 0... | |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Those of you who are familiar with the TV Show Community and it's 'lovable' character, Abed, who likes to travel around dimensions, parallel universes, and various other parallel time lines, would know that Abed needs your help. And if you aren'... | ```python
no_test_cases = eval(input())
def wrapped_distance(x1, x2, limit):
if x1 > x2:
return abs(limit - x1) + x2
else:
return abs(limit - x2) + x1
for _ in range(no_test_cases):
row, column = [int(x) for x in (input().split(' '))]
x1, y1 = [int(x) for x in (input().split(' '))]
x2, y2 = [int(x) for x in ... | vfc_87888 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10\n67 155\n8 22\n29 71\n1\n75 27\n1 20\n48 3\n2\n51 62\n19 1\n15 5\n3\n180 224\n16 11\n30 152\n3\n134 210\n114 24\n14 87\n3\n27 26\n9 3\n1 4\n2\n173 226\n129 219\n105 162\n3\n173 207\n163 26\n54 97\n1\n165 58\n65 19\n135 4\n2\n12 ... | |
taco | verifiable_code | https://www.codechef.com/ARYS2020/problems/GOLDTRIP | Solve the following coding problem using the programming language python:
The land of Programmers Army is surrounded by many islands. A unique number is associated with each island. The king of the islands is a very generous person, he donates a certain amount of gold coins to travelers for visiting each island that t... | ```python
for i in range(int(input())):
N = int(input())
l = list(map(int, input().split()))
for j in range(int(input())):
(q1, q2) = map(int, input().split())
temp = l[q1 - 1:q2]
print(sum(temp))
``` | vfc_87894 | {
"difficulty": "unknown_difficulty",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/ARYS2020/problems/GOLDTRIP",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n4\n10 2 5 50\n2\n1 3\n2 4\n",
"output": "17\n57\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/longest-path-in-a-directed-acyclic-graph/1 | Solve the following coding problem using the programming language python:
Given a Weighted Directed Acyclic Graph (DAG) and a source vertex s in it, find the longest distances from s to all other vertices in the given graph.
Example 1:
Input:
N=3
M=2
SRC=0
edges[]={{0,2,1},{0,1,1}}
Output:
distance[]={0,1,1}
Explanati... | ```python
from typing import List
import sys
from typing import List
from collections import defaultdict as dict, deque as dq
class Solution:
def maximumDistance(self, v: int, e: int, src: int, edges: List[List[int]]) -> List[int]:
n = v
adj = dict(list)
dist = [-float('inf') for i in range(v)]
visited = set... | vfc_87906 | {
"difficulty": "medium_hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/longest-path-in-a-directed-acyclic-graph/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "N=3\r\nM=2\r\nSRC=0\r\nedges[]={{0,2,1},{0,1,1}}",
"output": "distance[]={0,1,1}",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "N=6\r\nM=10\r\nSRC=1\r\nedges[]={{0,1,5},{0,2,3},{1,3,6},{1,2... |
taco | verifiable_code | https://codeforces.com/problemset/problem/476/E | Solve the following coding problem using the programming language python:
Dreamoon has a string s and a pattern string p. He first removes exactly x characters from s obtaining string s' as a result. Then he calculates $\operatorname{occ}(s^{\prime}, p)$ that is defined as the maximal number of non-overlapping substri... | ```python
(s, p) = (input(), input())
(n, m) = (len(s) + 1, len(p))
d = [[0] * n for t in range(n)]
for x in range(1, n):
(i, j) = (x, m)
while i and j:
j -= s[i - 1] == p[j - 1]
i -= 1
if not j:
for y in range(i + 1):
d[x][y + x - i - m] = d[i][y] + 1
for y in range(x):
d[x][y] = max(d[x][y], d[x - 1][y... | vfc_87907 | {
"difficulty": "hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/476/E",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "aaaaa\naa\n",
"output": "2 2 1 1 0 0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "axbaxxb\nab\n",
"output": "0 1 1 2 1 1 0 0\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/1000/C | Solve the following coding problem using the programming language python:
You are given $n$ segments on a coordinate line; each endpoint of every segment has integer coordinates. Some segments can degenerate to points. Segments can intersect with each other, be nested in each other or even coincide.
Your task is the ... | ```python
n = int(input())
left = []
right = []
for i in range(n):
data = input().split()
left.append(int(data[0]))
right.append(int(data[1]))
left.sort()
right.sort()
i = 0
j = 0
count = 1
ans = [0] * (n + 1)
left += [max(right) + 1]
right += [max(right) + 2]
while i < n and j < n:
while left[i + 1] <= right[j]:
... | vfc_87913 | {
"difficulty": "medium_hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1000/C",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n0 3\n1 3\n3 8\n",
"output": "6 2 1 \n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/778/A | Solve the following coding problem using the programming language python:
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t ... | ```python
t = list(input())
p = list(input())
s = input().split()
v = [0] * len(s)
for i in range(len(s)):
v[i] = int(s[i])
(l, r) = (0, len(t))
while r - l > 1:
m = (l + r) // 2
t1 = t[:]
for i in range(m):
t1[v[i] - 1] = '*'
(i, j) = (0, 0)
while j < len(t1) and i < len(p):
if p[i] == t1[j]:
i += 1
j +... | vfc_87921 | {
"difficulty": "medium_hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/778/A",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "ababcba\nabb\n5 3 4 1 7 6 2\n",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "bbbabb\nbb\n1 6 3 4 2 5\n",
"output": "4",
"type": "stdin_stdout"
},
{
... |
taco | verifiable_code | https://codeforces.com/problemset/problem/875/A | Solve the following coding problem using the programming language python:
Eighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on it the number n. He asked what is this number and the teacher of mathematics Inna Petrovna answered Vova that n is the answe... | ```python
import sys
input = sys.stdin.readline
from math import ceil, floor, factorial
def swaparr(arr, a, b):
temp = arr[a]
arr[a] = arr[b]
arr[b] = temp
def gcd(a, b):
if a == 0:
return b
return gcd(b % a, a)
def nCr(n, k):
if k > n - k:
k = n - k
res = 1
for i in range(k):
res = res * (n - i)
res... | vfc_87925 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/875/A",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "21\n",
"output": "1\n15\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "20\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n",... |
taco | verifiable_code | https://www.hackerrank.com/challenges/cavity-map/problem | Solve the following coding problem using the programming language python:
You are given a square map as a matrix of integer strings. Each cell of the map has a value denoting its depth. We will call a cell of the map a cavity if and only if this cell is not on the border of the map and each cell adjacent to it has str... | ```python
n = int(input())
maplist = []
for i in range(n):
maplist.append(list(input()))
for i in range(1, n - 1):
for j in range(1, n - 1):
c = maplist[i][j]
t = maplist[i - 1][j]
l = maplist[i][j - 1]
r = maplist[i][j + 1]
b = maplist[i + 1][j]
if c > t and c > l and (c > r) and (c > b):
maplist[i][j... | vfc_87929 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.hackerrank.com/challenges/cavity-map/problem",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n1112\n1912\n1892\n1234\n",
"output": "1112\n1X12\n18X2\n1234\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/maximum-path-sum/1 | Solve the following coding problem using the programming language python:
Given a binary tree in which each node element contains a number. Find the maximum possible path sum from one special node to another special node.
Note: Here special node is a node which is connected to exactly one different node.
Example 1:
In... | ```python
class Solution:
def maxPathSum(self, root):
mx = float('-inf')
def maxsum(r):
nonlocal mx
if not r:
return float('-inf')
if not r.left and (not r.right):
return r.data
l = maxsum(r.left)
ri = maxsum(r.right)
mx = max(mx, l + ri + r.data)
return r.data + max(l, ri)
y = max... | vfc_87933 | {
"difficulty": "medium_hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/maximum-path-sum/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 \r\n / \\ \r\n 4 5 \r\n / \\ \r\n -10 4",
"output": "16",
"type": "stdin_stdout"
},
{
"fn... |
taco | verifiable_code | https://www.codechef.com/OCT12/problems/DRGNBOOL | Solve the following coding problem using the programming language python:
In the world of DragonBool there are fierce warriors called Soints. Also there are even fiercer warriors called Sofloats – the mortal enemies of Soints.
The power of each warrior is determined by the amount of chakra he possesses which is some ... | ```python
t = eval(input())
for i in range(0, t):
x = input()
nm = x.split(' ')
nm[0] = int(nm[0])
nm[1] = int(nm[1])
csoint = []
lsoint = []
csofloat = []
lsofloat = []
for j in range(0, nm[0]):
a = input()
b = a.split(' ')
b[0] = int(b[0])
b[1] = int(b[1])
csoint.append(b[0])
lsoint.append(b[1])
... | vfc_87934 | {
"difficulty": "unknown_difficulty",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/OCT12/problems/DRGNBOOL",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2 3\n10 1\n20 2\n5 2\n5 2\n18 1\n5 5\n73 87\n69 13\n36 36\n77 46\n43 93\n49 46\n74 93\n78 87\n99 13\n59 36\n\n\n",
"output": "8\n89\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Example
Input
6 3
1 0 0 1 0 1
1 3 2
Output
1
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code. | ```python
import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 998244353
dd = [(0, -1), (1, 0), (0, 1), (-1, 0)]
ddn = [(0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, -1), (-1, 0), (-... | vfc_87942 | {
"difficulty": "unknown_difficulty",
"memory_limit": "268.435456 megabytes",
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "1.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1 3\n1 0 0 1 0 1\n1 3 2",
"output": "0\n",
"type": "stdin_stdout"
}
]
} | |
taco | verifiable_code | https://www.codechef.com/problems/HUNGALGO | Solve the following coding problem using the programming language python:
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well.
Chef is studying computer science. Tomorrow, he has an exam on algorithms and data structures. One of the algorithms he is required to study... | ```python
for _ in range(int(input())):
n = int(input())
col = set()
row = []
flag = 1
for i in range(n):
row.append(list(map(int, input().split())))
for i in range(n):
if flag:
flag = 0
for j in range(n):
if row[i][j] == 0:
col.add(j + 1)
flag = 1
else:
break
print('YES' if flag and... | vfc_87946 | {
"difficulty": "medium",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/HUNGALGO",
"time_limit": "1 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n3\n0 0 4\n3 0 1\n0 1 0\n2\n0 5\n3 2\n2\n1 3\n5 0\n3\n0 3 4\n4 0 5\n6 5 0\n4\n3 0 2 4\n0 2 3 5\n3 4 3 0\n3 4 0 3",
"output": "YES\nNO\nNO\nYES\nYES",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/269/B | Solve the following coding problem using the programming language python:
Emuskald is an avid horticulturist and owns the world's longest greenhouse — it is effectively infinite in length.
Over the years Emuskald has cultivated n plants in his greenhouse, of m different plant species numbered from 1 to m. His greenho... | ```python
(n, m) = map(int, input().split())
b = [list(map(float, input().split())) for i in range(n)]
k = [0] * n
k[0] = 1
for i in range(1, n):
z = 0
for y in range(i):
if b[y][0] <= b[i][0]:
z = max(k[y], z)
k[i] = max(0, z) + 1
print(n - max(k))
``` | vfc_87951 | {
"difficulty": "medium_hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/269/B",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 2\n2 1\n1 2.0\n1 3.100\n",
"output": "1\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/194/A | Solve the following coding problem using the programming language python:
One day the Codeforces round author sat exams. He had n exams and he needed to get an integer from 2 to 5 for each exam. He will have to re-sit each failed exam, i.e. the exam that gets mark 2.
The author would need to spend too much time and ... | ```python
(n, k) = map(int, input().split())
q = k // n
r = k % n
if q > 2:
print(0)
else:
print(n - r)
``` | vfc_87955 | {
"difficulty": "easy",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/194/A",
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "44 173\n",
"output": "0\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/958/E1 | Solve the following coding problem using the programming language python:
The Rebel fleet is afraid that the Empire might want to strike back again. Princess Heidi needs to know if it is possible to assign R Rebel spaceships to guard B bases so that every base has exactly one guardian and each spaceship has exactly on... | ```python
def check(a, b):
ansa = b[0] - a[0]
ansb = b[1] - a[1]
return [ansa, ansb]
while True:
try:
(n, m) = map(int, input().split())
if n != m:
a = list()
b = list()
for i in range(n):
a.append(list(map(int, input().split())))
for i in range(m):
b.append(list(map(int, input().split())))
... | vfc_87960 | {
"difficulty": "medium_hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/958/E1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 3\n0 0\n2 0\n3 1\n-2 1\n0 3\n2 2\n",
"output": "Yes\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 1\n1 0\n2 2\n3 1\n",
"output": "No\n",
"type": "stdin_stdout"
},
... |
taco | verifiable_code | https://codeforces.com/problemset/problem/388/C | Solve the following coding problem using the programming language python:
Fox Ciel is playing a card game with her friend Fox Jiro. There are n piles of cards on the table. And there is a positive integer on each card.
The players take turns and Ciel takes the first turn. In Ciel's turn she takes a card from the top ... | ```python
from functools import reduce
n = int(input())
cards = [list(map(int, input().split()[1:])) for i in range(n)]
mid = sorted((c[len(c) >> 1] for c in cards if len(c) & 1 == 1), reverse=True)
add = lambda x=0, y=0: x + y
(a, b) = (reduce(add, mid[::2] or [0]), reduce(add, mid[1::2] or [0]))
for c in cards:
m = ... | vfc_87972 | {
"difficulty": "hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/388/C",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1 100\n2 1 10\n",
"output": "101 10\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n9 2 8 6 5 9 4 7 1 3\n",
"output": "30 15\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://www.codechef.com/CUBE2020/problems/BDRYIIST | Solve the following coding problem using the programming language python:
IIST is thinking of acquiring some land nearby to build its new state of the art labs. The land it has chosen incidentaly has some abandoned college buildings which IIST wants to use. The administration decide the value of the building based on ... | ```python
import math
from itertools import permutations as p
def diff(li1, li2):
li_dif = [i for i in li1 if i not in li2]
return li_dif
def segments(b):
poly = [(i[0], i[1]) for i in b]
return zip(poly, poly[1:] + [poly[0]])
def perimeter(poly):
return abs(sum((math.hypot(x0 - x1, y0 - y1) for ((x0, y0), (x1,... | vfc_87977 | {
"difficulty": "unknown_difficulty",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/CUBE2020/problems/BDRYIIST",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n6\n0 0 8 3\n1 4 3 2\n2 1 7 1\n4 1 2 3\n3 5 4 6\n2 3 9 8\n3\n3 0 10 2\n5 5 20 25\n7 -3 30 32\n",
"output": "2 4 5\n3.16\n2\n15.00\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | Solve the following coding problem using the programming language python:
In a game of chess, Check is a game position in which a player's King is under attack by any of the opponent's pieces.
Bob is playing with Chess pieces. He randomly arranges three pieces on 8x8 chessboard: a black's King , a white's King and an... | ```python
#!/usr/bin/python
def getCoords(p):
if p[0] == 'a':
y = 1
elif p[0] == 'b':
y = 2
elif p[0] == 'c':
y = 3
elif p[0] == 'd':
y=4
elif p[0] == 'e':
y=5
elif p[0] == 'f':
y=6
elif p[0] == 'g':
y=7
elif p[0] == 'h':
y=8
x=p[1]
return [int(x),int(y)]
def getSlope(p1,p2):
if p1[0] == p... | vfc_87981 | {
"difficulty": "unknown_difficulty",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10\ne8 e1\nq a4\ne7 d3\nb f6\nh6 g4 \nk h4\nd8 e1\nr d3\ne7 e2\nq e1\nd8 d1\nq b6\nf8 d5\nq b3\nf8 d5\nk g6\na8 h1\nb e4\na7 h1\nb e4",
"output": "check\n-1\ncheck\n-1\n-1\ncheck\n-1\n-1\n-1\ncheck",
"type... | |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Input Format
N K
a_1 a_2 a_3 ... a_N
Output Format
Print the minimum cost in one line. In the end put a line break.
Constraints
* 1 ≤ K ≤ N ≤ 15
* 1 ≤ a_i ≤ 10^9
Scoring
Subtask 1 [120 points]
* N = K
Subtask 2 [90 points]
* N ≤... | ```python
(n, k) = map(int, input().split())
A = list(map(int, input().split()))
ans = float('inf')
for i in range(1, 2 ** n):
num = format(i, 'b').zfill(n)
point = 0
if num.count('1') != k:
continue
highest = A[0]
for j in range(1, n):
if highest >= A[j] and num[j] == '1':
point += highest - A[j] + 1
hi... | vfc_87985 | {
"difficulty": "unknown_difficulty",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "1.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 5\n5960 3774 3598 3469 3424",
"output": "9585\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 5\n3949 3774 4045 3469 3424",
"output": "1376\n",
"type": "stdin_stdout"
}... | |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Marut is now a well settled person. Impressed by the coding skills of Marut, N girls wish to marry him. Marut will consider marriage proposals of only those girls who have some special qualities. Qualities are represented by positive non-zero in... | ```python
M = eval(input())
Second = input()
Second = Second.split(" ")
N = eval(input())
temp = 1
count = 0
for i in range(N):
Quality = input()
Quality = Quality.split(" ")
list = [0]*10000
for k in Quality:
list[int(k)-1]=1
for j in Second:
if list[int(j)-1]==1:
temp = 1
continue
else:
temp = 0
... | vfc_87989 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10\n72 22 35 30 49 89 53 14 95 59\n100\n12 76 38 52 79 17 74 54 35 100 19 44 95 34 30 61 45 47 88 27 25 1 21 39 11 84 66 87 41 78 3 14 83 89 65 33 96 18 85 77 31 29 80 2 32 16 56 46 7 90 49 37 28 13 48 93 9 92 60 81 91 20 8 67 50 2... | |
taco | verifiable_code | https://www.hackerrank.com/challenges/largest-coprime-submatrix/problem | Solve the following coding problem using the programming language python:
Given a matrix you need to find the submatrix with the largest number of elements, where the GCD (Greatest Common Divisor) of its elements is greater than one. A submatrix of the matrix is a sub-section composed of contiguous rows and columns of... | ```python
from sys import stderr
def main():
print(solve(readcase()))
def readcase():
(n, m) = readints()
mtx = []
for _ in range(n):
mtx.append(readints())
assert len(mtx[0]) == m
return mtx
def readints():
return [int(f) for f in input().split()]
def solve(m):
best = 0
(nrows, ncols) = (len(m), len(m[... | vfc_87993 | {
"difficulty": "medium_hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.hackerrank.com/challenges/largest-coprime-submatrix/problem",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 3\n2 6 8\n4 8 3\n6 9 4\n",
"output": "4\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/multiples-power2816/1 | Solve the following coding problem using the programming language python:
Calculate the sum of all the multiples of 3 or 7 below the natural number N.
Example 1:
Input: 10
Output: 25
Explanation:
Numbers that are multiple of 3 or 7
are 3, 6, 7, 9 so sum will be 25.
Example 2:
Input: 25
Output: 84
Explanation:
Numbers... | ```python
class Solution:
def sum(self, N):
s = 0
for i in range(1, N):
if i % 3 == 0 or i % 7 == 0:
s += i
return s
``` | vfc_87997 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/multiples-power2816/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10",
"output": "25",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "25",
"output": "84",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Subodhians are taught to add multi-digit numbers from right-to-left one digit at a time.
Many find the "carry" operation - in which 1 is carried from one digit position
to be added to the next - to be a significant challenge. Your job is to
cou... | ```python
for _ in range(int(input())):
H,M=input().split()
x=list(map(int,H))[::-1]
y=list(map(int,M))[::-1]
carry=0
ans=0
for i in range(len(x)):
if x[i]+y[i] + carry>9:
carry+=1
ans+=1
else:
carry=0
if ans==0:
print("No carry operation")
elif ans==1:
print("1 carry operation")
else:
p... | vfc_87999 | {
"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\n5555555555 5555555555\n1111111111 1111111111\n5111111111 5111111111",
"output": "No carry operation\n3 carry operations\n1 carry operation",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "... | |
taco | verifiable_code | https://www.codechef.com/problems/RNDRND | Solve the following coding problem using the programming language python:
In a Circular City, there are $n$ houses, numbered from 1 to n and arranged in 1,2,...,n,1,2,...
Chef needs to deliver packages to $m$ (m≤n) houses.
Chef is initially at house 1. Chef decides an integer $x$ and stops after every $x$ houses. i.... | ```python
(n, m) = map(int, input().split())
l = set(list(map(int, input().split())))
ans = []
for x in range(n + 1):
(z, ct, b) = (1, 0, 0)
while True:
if z == 1 and ct != 0:
break
if b == m:
break
if z in l:
b += 1
if z + x <= n:
z += x
else:
k = z + x
z = k - n
ct += 1
if b == m:
a... | vfc_88003 | {
"difficulty": "medium_hard",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/RNDRND",
"time_limit": "1 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 3\n1 2 4",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6 2\n3 4",
"output": "4",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/1512/E | Solve the following coding problem using the programming language python:
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four ... | ```python
from collections import defaultdict
for _ in ' ' * int(input()):
(n, l, r, s) = map(int, input().split())
(p, a, f) = ([], [0] * n, [0] * 100000)
for i in range(1, n + 1):
p.append(i)
w = list(p[:r - l + 1])
(b, h) = (sum(w), sum(p[-(r - l + 1):]))
if not b <= s <= h:
print(-1)
else:
c = s - b
... | vfc_88007 | {
"difficulty": "medium_hard",
"memory_limit": "256 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1512/E",
"time_limit": "2 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n5 2 3 5\n5 3 4 1\n3 1 2 4\n2 2 2 2\n2 1 1 3\n",
"output": "1 2 3 4 5 \n-1\n1 3 2 \n1 2 \n-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n500 1 499 125250\n",
"output": "-1\n... |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Let's play Amidakuji.
In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.
<image>
In the starting points (top of the figure), numbers are ass... | ```python
w = int(input()) + 1
l = [i for i in range(w)]
n = int(input())
for i in range(n):
(a, b) = map(int, input().split(','))
(l[a], l[b]) = (l[b], l[a])
for i in range(1, w):
print(l[i])
``` | vfc_88011 | {
"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": "5\n4\n2,4\n3,5\n2,1\n3,4",
"output": "4\n1\n2\n5\n3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n4\n2,4\n4,5\n2,1\n3,4",
"output": "4\n1\n5\n3\n2\n",
"type": "stdin_stdou... | |
taco | verifiable_code | https://codeforces.com/problemset/problem/338/D | Solve the following coding problem using the programming language python:
Consider a table G of size n × m such that G(i, j) = GCD(i, j) for all 1 ≤ i ≤ n, 1 ≤ j ≤ m. GCD(a, b) is the greatest common divisor of numbers a and b.
You have a sequence of positive integer numbers a_1, a_2, ..., a_{k}. We say that this seq... | ```python
def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
def ext(a, b):
if b == 0:
return (1, 0)
else:
(y, x) = ext(b, a % b)
y = y - a // b * x
return (x, y)
(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
lcm = 1
for i in a:
lcm = lcm * i // gcd(lcm, i)
if lcm > n:
... | vfc_88016 | {
"difficulty": "very_hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/338/D",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "100 100 5\n5 2 1 2 1\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100 8 5\n5 2 1 2 1\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_n... |
taco | verifiable_code | https://www.codechef.com/problems/ENTEXAM | Solve the following coding problem using the programming language python:
The faculty of application management and consulting services (FAMCS) of the Berland State University (BSU) has always been popular among Berland's enrollees. This year, N students attended the entrance exams, but no more than K will enter the u... | ```python
for _ in range(int(input())):
(n, k, e, m) = map(int, input().split())
s = []
for i in range(n - 1):
a = [int(x) for x in input().split()]
s.append(sum(a))
s.sort(reverse=True)
a = [int(x) for x in input().split()]
c = s[k - 1] + 1 - sum(a)
if c > m:
print('Impossible')
elif c > 0:
print(c)
e... | vfc_88021 | {
"difficulty": "unknown_difficulty",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/ENTEXAM",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n4 2 3 10\n7 7 7\n4 6 10\n7 10 9\n9 9\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n4 2 3 10\n9 7 7\n4 6 10\n7 10 9\n9 9",
"output": "6\n",
"type": "std... |
taco | verifiable_code | Solve the following coding problem using the programming language python:
My flatmate, Sayan, went to the game show called Takeshi's castle.It is a game show in which you need to pass different game challenges to enter the final.
Now the most famous round of all of them is the "skipping stones".In the game you need t... | ```python
n, L, D = list(map(int, input().split()))
probs = list(map(float, input().split()))
dists = list(map(int, input().split()))
dists.append(D)
probs.append(1.0)
best_p = [0] * (len(probs))
for i in range(n + 1):
if dists[i] <= L:
best_p[i] = max(best_p[i], probs[i])
for j in range(i - 1, -1, -1):
if dists... | vfc_88025 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "710 8098 8685\n0.677856313989 0.300527362186 0.585422317594 0.579903380393 0.627528717602 0.767731549439 0.610653415599 0.885294351688 0.979034022518 0.13779743862 0.0340536649268 0.608253498417 0.742388417086 0.060505705684 0.5583... | |
taco | verifiable_code | https://codeforces.com/problemset/problem/79/B | Solve the following coding problem using the programming language python:
Fox Ciel saw a large field while she was on a bus. The field was a n × m rectangle divided into 1 × 1 cells. Some cells were wasteland, and other each cell contained crop plants: either carrots or kiwis or grapes.
After seeing the field carefu... | ```python
(n, m, k, t) = map(int, input().split(' '))
field = []
for _ in range(k):
(a, b) = map(int, input().split(' '))
field.append((a - 1) * m + (b - 1))
field.sort()
dic = {0: 'Carrots', 1: 'Kiwis', 2: 'Grapes'}
for _ in range(t):
flag = 0
(x, y) = map(int, input().split(' '))
value = (x - 1) * m + (y - 1)
f... | vfc_88029 | {
"difficulty": "medium",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/79/B",
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 5 1 3\n2 2\n2 2\n2 2\n2 2\n",
"output": "Waste\nWaste\nWaste\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 6 3 12\n1 2\n1 4\n1 6\n1 1\n1 2\n1 6\n1 2\n1 5\n1 3\n1 4\n1 5\n1 5\n1 4\n1 ... |
taco | verifiable_code | https://www.codechef.com/CDVA16/problems/CDVA1605 | Solve the following coding problem using the programming language python:
The auditorium of Stanford University is made up of L*R matrix (assume each coordinate has a chair). On the occasion of an event Chef was called as a chief guest. The auditorium was filled with males (M) and females (F), occupying one chair each... | ```python
def matrix(L, row, col, c):
d = {}
dp = []
for i in range(row + 1):
temp = []
for i in range(col + 1):
temp.append([])
dp.append(temp)
for i in range(row + 1):
dp[i][0] = 0
for i in range(col + 1):
dp[0][i] = 0
for i in range(1, row + 1):
for j in range(1, col + 1):
if L[i - 1][j - 1] ... | vfc_88033 | {
"difficulty": "unknown_difficulty",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/CDVA16/problems/CDVA1605",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 3 3\nMMF\nMMM\nFFM\nFFM\n2 F\n3 M\n1 M\n",
"output": "yes\nno\nyes\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | Solve the following coding problem using the programming language python:
An open-top box having a square bottom is placed on the floor. You see a number of needles vertically planted on its bottom.
You want to place a largest possible spheric balloon touching the box bottom, interfering with none of the side walls n... | ```python
from math import sqrt
def getcircle(nee, R):
(x, y, h) = nee
if R <= h:
return (x, y, R)
r = sqrt(R ** 2 - (R - h) ** 2)
return (x, y, r)
def crosscircle(c1, c2):
(x1, y1, r1) = c1
(x2, y2, r2) = c2
if (x1 - x2) ** 2 + (y1 - y2) ** 2 > (r1 + r2) ** 2:
return ()
elif x1 == x2 and y1 == y2:
retu... | vfc_88037 | {
"difficulty": "unknown_difficulty",
"memory_limit": "134.217728 megabytes",
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "8.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 16\n70 66 40\n38 52 20\n40 35 10\n70 30 10\n20 60 10\n1 100\n54 75 200\n1 10\n90 14 1\n1 11\n54 75 200\n3 10\n53 60 1\n61 38 1\n45 48 1\n4 10\n20 20 10\n20 80 10\n80 20 10\n80 80 10\n0 0",
"output": "26.000000\n39.000000\n1... | |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Write a program which manipulates a sequence A = {a1, a2, . . . , an} with the following operations:
* add(s, t, x): add x to as, as+1, ..., at.
* getSum(s, t): report the sum of as, as+1, ..., at.
Note that the initial values of ai (i = 1, ... | ```python
import sys
input = sys.stdin.readline
class LazyPropSegmentTree:
def __init__(self, lst, op, apply, comp, e, identity):
self.n = len(lst)
self.depth = (self.n - 1).bit_length()
self.N = 1 << self.depth
self.op = op
self.apply = apply
self.comp = comp
self.e = e
self.identity = identity
(s... | vfc_88041 | {
"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": "4 3\n1 1 4\n1 1 4 1\n1 1 4",
"output": "0\n0\n0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 3\n1 1 2\n0 1 4 1\n1 1 4",
"output": "0\n4\n",
"type": "stdin_stdout"
},
... | |
taco | verifiable_code | https://codeforces.com/problemset/problem/1719/C | Solve the following coding problem using the programming language python:
Burenka is about to watch the most interesting sporting event of the year — a fighting tournament organized by her friend Tonya.
$n$ athletes participate in the tournament, numbered from $1$ to $n$. Burenka determined the strength of the $i$-th... | ```python
import sys
input = sys.stdin.readline
def int_num():
return int(input())
def int_list():
return list(map(int, input().split()))
def insr():
s = input()
return list(s[:len(s) - 1])
def invr():
return map(int, input().split())
def solve():
(n, q) = int_list()
a = int_list()
d = {}
(max_id, max_fir... | vfc_88045 | {
"difficulty": "medium",
"memory_limit": "256 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1719/C",
"time_limit": "2 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n3 1\n3 1 2\n1 2\n4 2\n1 3 4 2\n4 5\n3 2\n5 2\n1 2 3 5 4\n5 1000000000\n4 6\n",
"output": "2\n0\n1\n0\n4\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/1511/B | Solve the following coding problem using the programming language python:
You are given three integers a, b and c.
Find two positive integers x and y (x > 0, y > 0) such that:
* the decimal representation of x without leading zeroes consists of a digits;
* the decimal representation of y without leading zeroes... | ```python
for _ in range(int(input())):
(a, b, c) = map(int, input().split())
x = (10 ** (a - c) + 1) * 10 ** (c - 1)
y = 10 ** (b - 1)
print(x, y)
``` | vfc_88049 | {
"difficulty": "easy",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1511/B",
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n2 3 1\n2 2 2\n6 6 2\n1 1 1\n",
"output": "70 749\n70 56\n769040 810240\n5 5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "9\n1 1 1\n2 2 2\n3 3 3\n4 4 4\n5 5 5\n6 6 6\n7 7 7\n8 8 8\n9 ... |
taco | verifiable_code | https://www.codechef.com/problems/LEEXAMS | Solve the following coding problem using the programming language python:
Little Elephant from the Zoo of Lviv hates exams. Since Little Elephant lives in Ukraine, he is going to take exams called 'ZNO'. Help him.
There will be n tickets on the table. Each ticket has a number written on it. The i-th ticket can be numb... | ```python
import sys
MAX_N = 16
def produce_ints():
for line in sys.stdin:
for word in line.split():
yield int(word)
def next_int():
return next(produce_ints())
def test(x, bit):
return x >> bit & 1
def one_test():
n = next_int()
a = tuple((tuple(map(int, input().split())) for i in range(n)))
if n > MAX_... | vfc_88053 | {
"difficulty": "medium_hard",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/LEEXAMS",
"time_limit": "1 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2\n50 1 2\n50 2 1\n3\n100 1 3\n47 2 1\n74 3 2",
"output": "0.500000000\n0.347800000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n2\n54 1 2\n50 2 1\n3\n100 1 3\n47 2 1\n74 3 2",
... |
taco | verifiable_code | https://codeforces.com/problemset/problem/1266/D | Solve the following coding problem using the programming language python:
There are $n$ people in this world, conveniently numbered $1$ through $n$. They are using burles to buy goods and services. Occasionally, a person might not have enough currency to buy what he wants or needs, so he borrows money from someone els... | ```python
(n, m) = map(int, input().split())
d = {}
for i in range(m):
(x, y, a) = map(int, input().split())
d[x] = d.get(x, 0) - a
d[y] = d.get(y, 0) + a
pos = []
neg = []
for i in d:
if d[i] < 0:
neg.append([d[i], i])
elif d[i] > 0:
pos.append([d[i], i])
ans = []
i = 0
j = 0
while i < len(neg) and j < len(po... | vfc_88057 | {
"difficulty": "hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1266/D",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 2\n1 2 10\n2 3 5\n",
"output": "2\n1 2 5\n1 3 5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 3\n1 2 10\n2 3 15\n3 1 10\n",
"output": "1\n2 3 5\n",
"type": "stdin_stdout"... |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Tic-tac-toe is a game in which you win when you put ○ and × alternately in the 3 × 3 squares and line up ○ or × in one of the vertical, horizontal, and diagonal lines (Fig.). 1 to Fig. 3)
<image> | <image> | <image>
--- | --- | ---
Figure 1: ○ ... | ```python
ok = [[0, 4, 8], [2, 4, 6], [0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8]]
while True:
try:
s = input()
except EOFError:
break
flag = False
for i in ok:
if s[i[0]] == s[i[1]] == s[i[2]] and s[i[0]] != 's':
print(s[i[0]])
flag = True
break
if flag:
continue
print('d')
... | vfc_88061 | {
"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": "ooosxssxs\nxooswsosx\nooxxxooxo",
"output": "o\nd\nd\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "oopsxssxs\nxooswsosx\noxooxxxoo",
"output": "d\nd\nd\n",
"type": "stdin_std... | |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/check-if-subtree/1 | Solve the following coding problem using the programming language python:
Given two binary trees with head reference as T and S having at most N nodes. The task is to check if S is present as subtree in T.
A subtree of a tree T1 is a tree T2 consisting of a node in T1 and all of its descendants in T1.
Example 1:
Input... | ```python
class Solution:
def check(self, T, S):
if S == None and T == None:
return 1
if T != None and S == None or (T == None and S != None):
return 0
l = self.check(T.left, S.left)
r = self.check(T.right, S.right)
if T.data == S.data and l == 1 and (r == 1):
return 1
else:
return 0
def isS... | vfc_88065 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/check-if-subtree/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "T: 1 S: 3\r\n / \\ /\r\n 2 3 4\r\n / \\ /\r\n N N 4",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "T: 26 ... |
taco | verifiable_code | Solve the following coding problem using the programming language python:
For a given polygon g and target points t, print "2" if g contains t, "1" if t is on a segment of g, "0" otherwise.
g is represented by a sequence of points p1, p2,..., pn where line segments connecting pi and pi+1 (1 ≤ i ≤ n-1) are sides of th... | ```python
def dot(c1, c2):
return c1.real * c2.real + c1.imag * c2.imag
def cross(c1, c2):
return c1.real * c2.imag - c1.imag * c2.real
def string_to_complex(s):
(x, y) = map(int, s.split())
return x + y * 1j
def contains(polygon, point):
flag = False
for (v1, v2) in zip(polygon[0:], polygon[1:]):
a = v1 - p... | vfc_88066 | {
"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": "4\n0 0\n3 1\n2 3\n0 3\n3\n2 1\n0 2\n0 2",
"output": "2\n1\n1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n0 0\n3 0\n2 3\n0 1\n3\n2 1\n0 2\n0 2",
"output": "2\n0\n0\n",
"t... | |
taco | verifiable_code | https://www.hackerrank.com/challenges/equality-in-a-array/problem | Solve the following coding problem using the programming language python:
Given an array of integers, determine the minimum number of elements to delete to leave only elements of equal value.
Example
$arr=[1,2,2,3]$
Delete the $2$ elements $1$ and $3$ leaving $arr=[2,2]$. If both twos plus either the $1$ or the... | ```python
n = input().strip()
a = input().strip().split(' ')
c = {}
m = a[0]
for i in a:
try:
c[i] += 1
if c[i] > c[m]:
m = i
except KeyError:
c[i] = 1
print(len(a) - c[m])
``` | vfc_88070 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.hackerrank.com/challenges/equality-in-a-array/problem",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "STDIN Function\n----- --------\n5 arr[] size n = 5\n3 3 2 1 3 arr = [3, 3, 2, 1, 3]\n",
"output": "2 \n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/1761/A | Solve the following coding problem using the programming language python:
You are given three integers $n$, $a$, and $b$. Determine if there exist two permutations $p$ and $q$ of length $n$, for which the following conditions hold:
The length of the longest common prefix of $p$ and $q$ is $a$.
The length of the long... | ```python
import sys
R = sys.stdin.readline
for _ in range(int(R())):
(n, a, b) = map(int, R().split())
print('Yes' if a == b == n or a + b < n - 1 else 'No')
``` | vfc_88074 | {
"difficulty": "easy",
"memory_limit": "256 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1761/A",
"time_limit": "1 second"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n1 1 1\n2 1 2\n3 1 1\n4 1 1\n",
"output": "Yes\nNo\nNo\nYes\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/1419/C | Solve the following coding problem using the programming language python:
A new agent called Killjoy invented a virus COVID-2069 that infects accounts on Codeforces. Each account has a rating, described by an integer (it can possibly be negative or very large).
Killjoy's account is already infected and has a rating e... | ```python
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = 'x' in file.mode or 'r' not in file.mode
self.write = self.buffer.write if self.writable else None
def ... | vfc_88078 | {
"difficulty": "medium",
"memory_limit": "256 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1419/C",
"time_limit": "1 second"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n2 69\n68 70\n6 4\n4 4 4 4 4 4\n9 38\n-21 83 50 -59 -77 15 -71 -78 20\n",
"output": "1\n0\n2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n4 4\n3 6 6 2\n",
"output": "2\n",
... |
taco | verifiable_code | https://codeforces.com/problemset/problem/225/B | Solve the following coding problem using the programming language python:
Numbers k-bonacci (k is integer, k > 1) are a generalization of Fibonacci numbers and are determined as follows:
* F(k, n) = 0, for integer n, 1 ≤ n < k;
* F(k, k) = 1;
* F(k, n) = F(k, n - 1) + F(k, n - 2) + ... + F(k, n - k), for inte... | ```python
def s():
[s, k] = list(map(int, input().split()))
d = [0]
d.append(1)
t = 0
r = []
while t < s:
t = sum(d[-min(k, len(d)):])
d.append(t)
for i in reversed(d):
if i <= s:
s -= i
r.append(i)
if i == 0:
break
print(len(r))
print(*r)
s()
``` | vfc_88082 | {
"difficulty": "medium_hard",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/225/B",
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "87783 3\n",
"output": "7\n66012 19513 1705 504 44 4 1 ",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1000000000 3\n",
"output": "14\n615693474 334745777 29249425 15902591 2555757 138... |
taco | verifiable_code | https://codeforces.com/problemset/problem/448/D | Solve the following coding problem using the programming language python:
Bizon the Champion isn't just charming, he also is very smart.
While some of us were learning the multiplication table, Bizon the Champion had fun in his own manner. Bizon the Champion painted an n × m multiplication table, where the element on... | ```python
import math
def good(x):
c = 0
for i in range(1, n + 1):
c += min(m, math.floor(x / i))
if c >= k:
return True
return False
(n, m, k) = [int(x) for x in input().split(' ')]
if n * m == k:
print(k)
else:
l = 0
r = k
while r - l > 1 * (10 ** 1) ** int(n == 499997):
h = (l + r) // 2
if good(h)... | vfc_88090 | {
"difficulty": "medium_hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/448/D",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 2 2\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 3 4\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 1... |
taco | verifiable_code | https://www.codechef.com/COH12020/problems/RIPUGEMS | Solve the following coding problem using the programming language python:
Ripul was skilled in the art of lapidary. He used to collect stones and convert it into decorative items for sale. There were n stone shops. Each shop was having one exclusive stone of value s[i] , where 1<=i<=n. If number of stones collected ... | ```python
for u in range(int(input())):
n = int(input())
l = list(map(int, input().split()))
d = []
dd = []
s = 1
for i in range(n - 1):
s = l[i]
d.append(s)
dd.append([i, i])
for j in range(i + 1, n):
s = s * l[j]
d.append(s)
dd.append([i, j])
d.append(l[n - 1])
dd.append([n - 1, n - 1])
k = ... | vfc_88094 | {
"difficulty": "unknown_difficulty",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COH12020/problems/RIPUGEMS",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n3\n1 2 3\n",
"output": "6 1 2\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/1506/G | Solve the following coding problem using the programming language python:
You are given a string $s$, consisting of lowercase Latin letters. While there is at least one character in the string $s$ that is repeated at least twice, you perform the following operation:
you choose the index $i$ ($1 \le i \le |s|$) such t... | ```python
from queue import PriorityQueue
cas = int(input())
while cas:
cas -= 1
a = input()
cnt = [0 for i in range(26)]
vis = [0 for i in range(26)]
for i in range(len(a)):
c = ord(a[i]) - ord('a')
cnt[c] += 1
st = [30]
s = 0
for i in range(len(a)):
tmp = ord(a[i]) - ord('a')
if vis[tmp] == 0:
whil... | vfc_88098 | {
"difficulty": "hard",
"memory_limit": "256 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1506/G",
"time_limit": "2.5 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6\ncodeforces\naezakmi\nabacaba\nconvexhull\nswflldjgpaxs\nmyneeocktxpqjpz\n",
"output": "odfrces\nezakmi\ncba\nconvexhul\nwfldjgpaxs\nmyneocktxqjpz\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/604/D | Solve the following coding problem using the programming language python:
As behooves any intelligent schoolboy, Kevin Sun is studying psycowlogy, cowculus, and cryptcowgraphy at the Bovinia State University (BGU) under Farmer Ivan. During his Mathematics of Olympiads (MoO) class, Kevin was confronted with a weird fun... | ```python
MOD = 10 ** 9 + 7
def f(a, b):
if b == 1:
return a % MOD
elif b % 2 == 0:
return f(a * a % MOD, b // 2)
else:
return a * f(a * a % MOD, b // 2) % MOD
(p, k) = map(int, input().split())
if k == 0:
print(f(p, p - 1))
exit()
if k == 1:
print(f(p, p))
exit()
t = 1
a = k
while a != 1:
a = a * k % p
... | vfc_88102 | {
"difficulty": "medium_hard",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/604/D",
"time_limit": "1.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "40867 37466\n",
"output": "560078799\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "278917 84398\n",
"output": "727771018\n",
"type": "stdin_stdout"
},
{
"fn_nam... |
taco | verifiable_code | Solve the following coding problem using the programming language python:
From tomorrow, the long-awaited summer vacation will begin. So I decided to invite my friends to go out to the sea.
However, many of my friends are shy. They would hate it if they knew that too many people would come with them.
Besides, many o... | ```python
n = int(input())
l = [0 for i in range(n + 2)]
for i in range(n):
[a, b] = list(map(int, input().split()))
if a <= n + 1:
l[a] += 1
if b + 1 <= n + 1:
l[b + 1] -= 1
ans = 0
for i in range(n + 2):
if i != 0:
l[i] = l[i - 1] + l[i]
if l[i] >= i - 1:
ans = i - 1
print(ans)
``` | vfc_88106 | {
"difficulty": "unknown_difficulty",
"memory_limit": "134.217728 megabytes",
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "8.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n8 100001\n14 100001\n12 100001\n8 100001\n3 100001",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n2 5\n4 7\n2 4\n5 6",
"output": "3\n",
"type": "stdin_std... | |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/2d3fc3651507fc0c6bd1fa43861e0d1c43d4b8a1/1 | Solve the following coding problem using the programming language python:
Given two arrays A[] and B[] of same length N. There are N types of sticks of lengths specified. Each stick of length A[i] is present in B[i] units (i=1 to N). You have to construct the squares and rectangles using these sticks. Each unit of a s... | ```python
class Solution:
def maxPossibleValue(self, N, A, B):
ts = 0
ans = 0
m = 1000000007
for i in range(N):
if B[i] // 2 > 0:
ans += 2 * (B[i] // 2) * A[i]
ts += B[i] // 2
m = min(m, A[i])
if ts % 2 != 0:
ans -= 2 * m
return ans
``` | vfc_88110 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/2d3fc3651507fc0c6bd1fa43861e0d1c43d4b8a1/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "N = 4\r\nA[] = {3,4,6,5}\r\nB[] = {2,3,1,6}",
"output": "38",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "N = 1\r\nA[] = {3}\r\nB[] = {2}",
"output": "0",
"type": "stdin_stdout... |
taco | verifiable_code | https://codeforces.com/problemset/problem/1407/C | Solve the following coding problem using the programming language python:
This is an interactive problem.
We hid from you a permutation p of length n, consisting of the elements from 1 to n. You want to guess it. To do that, you can give us 2 different indices i and j, and we will reply with p_{i} mod p_{j} (remainde... | ```python
import sys
DEBUG = False
def debug(*args):
if not DEBUG:
return
print('\x1b[0;31m', end='', file=sys.stderr)
print(*args, file=sys.stderr)
print('\x1b[0m', end='', file=sys.stderr)
sys.stderr.flush()
def readInt():
line = input()
while line == '':
line = input()
result = int(line)
return result... | vfc_88111 | {
"difficulty": "medium_hard",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1407/C",
"time_limit": "1.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "8\n4 8 2 6 3 1 5 7\n",
"output": "? 1 2\n? 2 1\n? 1 3\n? 3 1\n? 1 4\n? 4 1\n? 4 5\n? 5 4\n? 4 6\n? 6 4\n? 4 7\n? 7 4\n? 4 8\n? 8 4\n! 3 8 6 8 7 7 7 7 \n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Little Jhool is an addict. No, unlike the usual drug addicts, he's an addict of the good kind: the shopping addict. Some of his friends also call him a shopaholic, though he tries his level best to deny the title given to him by his friends. Now... | ```python
for t in range(int(eval(input()))):
n,k=list(map(int,input().split()))
l=list(map(int,input().split()))
nl=[]
tt=0
#print n,k
l.sort()
#print l
if n<=2:
tt=0
else:
if len(l)%2==0:
i=0
j=len(l)-1
while i<j:
nl.append(l[i]+l[j])
i+=1
j-=1
tt= max(nl)-min(nl)
print(tt)
if t... | vfc_88116 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10\n2270 7563\n3500 8969 9574 5099 6551 8328 3631 3132 2970 8693 6559 9840 5736 2254 2423 527 5474 8385 8520 5567 7854 2037 3586 9708 710 2889 3242 5455 9969 5655 4140 373 2123 7604 3977 7816 600 5906 3531 6764 221 4262 2406 612 91... | |
taco | verifiable_code | https://www.codechef.com/problems/XORIER | Solve the following coding problem using the programming language python:
Read problems statements [Hindi] ,[Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well.
Chef is stuck at the following problem. Help him solve it!
Chef has a sequence of integers $A_{1}, A_{2}, \dots, A_{N}$. He should find the ... | ```python
from collections import defaultdict
for _ in range(int(input())):
N = int(input())
A = list(map(int, input().split()))
occurances = defaultdict(lambda : 0)
no = 0
ne = 0
ans = 0
for i in range(N):
if A[i] % 2 == 0:
X = 2 ^ A[i]
cne = ne - occurances[X] - occurances[A[i]]
ans += cne
ne += ... | vfc_88124 | {
"difficulty": "medium_hard",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/XORIER",
"time_limit": "1 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n5\n2 4 8 1 3",
"output": "3",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/1091/F | Solve the following coding problem using the programming language python:
Bob is a duck. He wants to get to Alice's nest, so that those two can duck! [Image] Duck is the ultimate animal! (Image courtesy of See Bang)
The journey can be represented as a straight line, consisting of $n$ segments. Bob is located to the ... | ```python
n = int(input())
dis = list(map(lambda x: int(x) << 1, input().split()))
ter = input()
(st, ans) = (0, 0)
time = {'G': 5, 'W': 3, 'L': 1}
delta = {'G': 1, 'W': 1, 'L': -1}
hasWater = False
convert = 0
for i in range(n):
st += dis[i] * delta[ter[i]]
ans += dis[i] * time[ter[i]]
if ter[i] == 'W':
hasWater ... | vfc_88129 | {
"difficulty": "very_hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1091/F",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n10\nG\n",
"output": "30\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n10 10\nWL\n",
"output": "40\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"... |
taco | verifiable_code | https://codeforces.com/problemset/problem/670/E | Solve the following coding problem using the programming language python:
Recently Polycarp started to develop a text editor that works only with correct bracket sequences (abbreviated as CBS).
Note that a bracket sequence is correct if it is possible to get a correct mathematical expression by adding "+"-s and "1"-... | ```python
def main():
(n, m, p) = list(map(int, input().split()))
(xlat, l, s, ll, lr) = ([0] * n, [], input(), list(range(-1, n)), list(range(1, n + 2)))
p -= 1
for (i, c) in enumerate(s):
if c == '(':
l.append(i)
else:
j = l.pop()
xlat[i] = j
xlat[j] = i
for c in input():
if c == 'D':
if s[p... | vfc_88137 | {
"difficulty": "medium_hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/670/E",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "8 4 5\n(())()()\nRDLD\n",
"output": "()\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "12 5 3\n((()())(()))\nRRDLD\n",
"output": "(()(()))\n",
"type": "stdin_stdout"
},
... |
taco | verifiable_code | https://codeforces.com/problemset/problem/1234/C | Solve the following coding problem using the programming language python:
You are given a system of pipes. It consists of two rows, each row consists of $n$ pipes. The top left pipe has the coordinates $(1, 1)$ and the bottom right — $(2, n)$.
There are six types of pipes: two types of straight pipes and four types o... | ```python
def pipetype(i):
if i == '1' or i == '2':
return 1
else:
return 2
def find_way2(arr, n):
count = 0
row = 0
col = 0
prev_row = 0
prev_col = -1
prev_state = 1
while col <= n:
count += 1
prev_i = row
prev_j = col
if col == n and row == 0:
return 'NO'
elif col == n and row == 1:
retu... | vfc_88142 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1234/C",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6\n7\n2323216\n1615124\n1\n3\n4\n2\n13\n24\n2\n12\n34\n3\n536\n345\n2\n46\n54\n",
"output": "YES\nYES\nYES\nNO\nYES\nNO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6\n7\n2323216\n16151... |
taco | verifiable_code | https://codeforces.com/problemset/problem/794/B | Solve the following coding problem using the programming language python:
Igor the analyst has adopted n little bunnies. As we all know, bunnies love carrots. Thus, Igor has bought a carrot to be shared between his bunnies. Igor wants to treat all the bunnies equally, and thus he wants to cut the carrot into n pieces ... | ```python
import math
first_line = list(map(int, input().split()))
(n, h) = first_line
total_area = 0.5 * h
area = total_area / 3
ans = ''
for i in range(n - 1):
ans += str(math.sqrt(2 * h * (total_area * (i + 1) / n)))
ans += ' '
print(ans.strip())
``` | vfc_88150 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/794/B",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 2\n",
"output": "1.154700538379 1.632993161855\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 100000\n",
"output": "70710.678118654752\n",
"type": "stdin_stdout"
},
... |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/longest-alternating-subsequence5951/1 | Solve the following coding problem using the programming language python:
A sequence {x1, x2, .. xn} is alternating sequence if its elements satisfy one of the following relations :
x1 < x2 > x3 < x4 > x5..... or x1 >x2 < x3 > x4 < x5.....
Your task is to find the longest such sequence.
Example 1:
Input: nums = {1,5,... | ```python
class Solution:
def AlternatingaMaxLength(self, nums):
stateMap = [[0 for i in range(2)] for _ in range(len(nums))]
(stateMap[0][0], stateMap[0][1]) = (1, 1)
for i in range(1, len(nums)):
if nums[i] > nums[i - 1]:
stateMap[i][0] = max(stateMap[i - 1][1] + 1, stateMap[i - 1][0])
stateMap[i][... | vfc_88154 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/longest-alternating-subsequence5951/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "nums = {1,5,4}",
"output": "3",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/133/E | Solve the following coding problem using the programming language python:
A lot of people associate Logo programming language with turtle graphics. In this case the turtle moves along the straight line and accepts commands "T" ("turn around") and "F" ("move 1 unit forward").
You are given a list of commands that will... | ```python
import sys
import math
INF = -100000000
memo = dict()
def func(line, r):
if line in memo and r in memo[line]:
return memo[line][r]
if len(line) == 1:
which = line[0] == 'T'
if r % 2 == 1:
which = not which
if which:
return [INF, INF, 0, 0]
else:
return [1, INF, INF, INF]
best = [INF, IN... | vfc_88155 | {
"difficulty": "medium_hard",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/133/E",
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "FTFTFTFFFFTFTFTTTTTTFFTTTTFFTFFFTFTFTFFTFTFTFFFTTTFTTFTTTTTFFFFTTT\n12\n",
"output": "41\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://www.codechef.com/PBK22020/problems/ITGUY25 | Solve the following coding problem using the programming language python:
Chef solved so many hard questions, now he wants to solve some easy problems for refreshment. Chef asks Cheffina for the new question. Cheffina challanges the chef to print the total number of 1's in the binary representation of N(natural number... | ```python
for t in range(int(input())):
n = int(input())
print(bin(n).count('1'))
``` | vfc_88159 | {
"difficulty": "unknown_difficulty",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/PBK22020/problems/ITGUY25",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2\n5\n",
"output": "1\n2\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://www.codechef.com/problems/MEXSTR | 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 a binary string $S$. Chef defines $\mathrm{MEX}(S)$ as the smallest non-negative integer such that its binary representation (without l... | ```python
t = int(input())
for i in range(0, t):
s = input()
l = len(s)
next0 = [-1 for x in range(0, l)]
next1 = [-1 for x in range(0, l)]
lens = [0 for x in range(0, l)]
j = l - 1
z = o = 0
c = 1
n0 = -1
n1 = -1
while j >= 0:
lens[j] = c
next0[j] = n0
next1[j] = n1
if s[j] == '0':
z = 1
n0 = ... | vfc_88167 | {
"difficulty": "hard",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/MEXSTR",
"time_limit": "1 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1001011\n1111",
"output": "1100\n0",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/longest-subsequence-such-that-difference-between-adjacents-is-one4724/1 | Solve the following coding problem using the programming language python:
Given an array A[] of size N, find the longest subsequence such that difference between adjacent elements is one.
Example 1:
Input: N = 7
A[] = {10, 9, 4, 5, 4, 8, 6}
Output: 3
Explaination: The three possible subsequences
{10, 9, 8} , {4, 5, 4... | ```python
class Solution:
def longestSubsequence(self, n, a):
L = [1 for i in range(n)]
for i in range(n):
for j in range(0, i):
if a[i] == a[j] - 1 or a[i] == a[j] + 1:
L[i] = max(L[i], L[j] + 1)
mx = L[0]
for i in range(0, n):
mx = max(mx, L[i])
return mx
``` | vfc_88171 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/longest-subsequence-such-that-difference-between-adjacents-is-one4724/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "N = 7\r\nA[] = {10, 9, 4, 5, 4, 8, 6}",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "N = 5\r\nA[] = {1, 2, 3, 4, 5}",
"output": "5",
"type": "stdin_stdout"
}
... |
taco | verifiable_code | https://codeforces.com/problemset/problem/322/B | Solve the following coding problem using the programming language python:
Fox Ciel has some flowers: r red flowers, g green flowers and b blue flowers. She wants to use these flowers to make several bouquets. There are 4 types of bouquets:
To make a "red bouquet", it needs 3 red flowers. To make a "green bouquet",... | ```python
a = list(map(int, input().split()))
a.sort()
if a[0] == 0:
print(a[1] // 3 + a[2] // 3)
exit()
b = a.copy()
c = a.copy()
ans = min(a)
a[1] -= ans
a[2] -= ans
ans += a[1] // 3
ans += a[2] // 3
ans1 = min(b) - 1
b[1] -= ans1
b[2] -= ans1
ans1 += b[1] // 3
ans1 += b[2] // 3
ans2 = min(c) - 2
c[1] -= ans2
c[2] ... | vfc_88172 | {
"difficulty": "medium_hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/322/B",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 6 9\n",
"output": "6\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 4 4\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "0 0... |
taco | verifiable_code | https://www.hackerrank.com/challenges/python-mod-divmod/problem | Solve the following coding problem using the programming language python:
One of the built-in functions of Python is divmod, which takes two arguments $\boldsymbol{\alpha}$ and $\boldsymbol{b}$ and returns a tuple containing the quotient of $a/b$ first and then the remainder $\boldsymbol{a}$.
For example:
>>> pr... | ```python
operand1 = int(input())
operand2 = int(input())
print(operand1 // operand2)
print(operand1 % operand2)
print(divmod(operand1, operand2))
``` | vfc_88176 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.hackerrank.com/challenges/python-mod-divmod/problem",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "177\n10\n",
"output": "17\n7\n(17, 7)\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/sum-of-leaf-nodes-in-bst/1 | Solve the following coding problem using the programming language python:
Given a Binary Search Tree, find the sum of all leaf nodes. BST has the following property (duplicate nodes are possible):
The left subtree of a node contains only nodes with keys less than the node’s key.
The right subtree of a node contains ... | ```python
def inorder(root):
return [] if not root else [root.data] if not root.right and (not root.left) else inorder(root.left) + inorder(root.right)
def sumOfLeafNodes(root):
return sum(inorder(root))
``` | vfc_88180 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/sum-of-leaf-nodes-in-bst/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\r\n\r\n6\r\n\r\n67 34 82 12 45 78\r\n\r\n1\r\n\r\n45",
"output": "135\r\n\r\n45",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | Solve the following coding problem using the programming language python:
In Square Town, where many people who love squares live, a festival is held to color the town with illuminations that combine square lightning boards. This electric board emits light when electricity is applied, and the plate in contact with the... | ```python
def dot3(O, A, B):
(ox, oy) = O
(ax, ay) = A
(bx, by) = B
return (ax - ox) * (bx - ox) + (ay - oy) * (by - oy)
def cross3(O, A, B):
(ox, oy) = O
(ax, ay) = A
(bx, by) = B
return (ax - ox) * (by - oy) - (bx - ox) * (ay - oy)
def dist2(A, B):
(ax, ay) = A
(bx, by) = B
return (ax - bx) ** 2 + (ay - ... | vfc_88185 | {
"difficulty": "unknown_difficulty",
"memory_limit": "134.217728 megabytes",
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "1.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1\n0 0 0 1 1 1 1 0\n2\n0 0 0 1 1 1 1 0\n100 100 100 200 200 200 200 100\n2\n0 0 0 100 100 100 100 0\n10 10 10 11 20 20 20 10\n2\n1\n30 40 40 50 40 20 20 10\n1\n30 40 40 50 40 20 20 10\n0",
"output": "1\n2\n1\n1\n1\n",
... | |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/evaluation-of-postfix-expression1735/1 | Solve the following coding problem using the programming language python:
Given string S representing a postfix expression, the task is to evaluate the expression and find the final value. Operators will only include the basic arithmetic operators like *, /, + and -.
Example 1:
Input: S = "231*+9-"
Output: -4
Explan... | ```python
class Solution:
def evaluatePostfix(self, S):
stack = []
for i in range(len(S)):
if S[i] in ['+', '-', '/', '*']:
y = stack.pop()
x = stack.pop()
if S[i] == '+':
stack.append(x + y)
elif S[i] == '-':
stack.append(x - y)
elif S[i] == '*':
stack.append(x * y)
elif... | vfc_88189 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/evaluation-of-postfix-expression1735/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "S = \"231*+9-\"",
"output": "-4",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "S = \"123+*8-\"",
"output": "-3",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/perfect-sum-problem5633/1 | Solve the following coding problem using the programming language python:
Given an array arr[] of non-negative integers and an integer sum, the task is to count all subsets of the given array with a sum equal to a given sum.
Note: Answer can be very large, so, output answer modulo 10^{9}+7
Example 1:
Input: N = 6, arr... | ```python
class Solution:
def perfectSum(self, arr, n, sum):
m = 1000000007
t = [[0 for I in range(sum + 1)] for _ in range(n + 1)]
t[0][0] = 1
for i in range(1, n + 1):
for j in range(sum + 1):
if arr[i - 1] <= j:
t[i][j] = (t[i - 1][j - arr[i - 1]] + t[i - 1][j]) % m
else:
t[i][j] = t[i... | vfc_88190 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/perfect-sum-problem5633/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "N = 6, arr[] = {2, 3, 5, 6, 8, 10}\r\n sum = 10",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "N = 5, arr[] = {1, 2, 3, 4, 5}\r\n sum = 10",
"output": "3",
... |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Let A, B, C, D, E be sets of integers and let U is a universal set that includes all sets under consideration. All elements in any set are different (no repetitions).
u - union of two sets, AuB = {x ∈ U : x ∈ A or x ∈ B} is the set of all eleme... | ```python
import sys
def rpn(str):
r = []
stack = []
for i in range(0, len(str)):
c = str[i]
if c in 'idsu':
while len(stack) > 0:
if stack[-1] in 'idsuc':
a = stack.pop()
r.extend(a)
else:
break
stack.extend(c)
elif c == 'c':
stack.extend(c)
elif c == '(':
stack.extend(c)... | vfc_88191 | {
"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": "A 3\n1 3 -1\nB 4\n3 1 5 7\nD 1\n5\nR 0\ncAiBdD\nC 3\n1 2 3\nA 4\n2 9 8 3\nB 3\n2 4 8\nR 0\n(As(AiB))uC",
"output": "7\n1 2 3 9\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "A 3\n1 3 -1\n... | |
taco | verifiable_code | https://codeforces.com/problemset/problem/195/A | Solve the following coding problem using the programming language python:
Valeric and Valerko missed the last Euro football game, so they decided to watch the game's key moments on the Net. They want to start watching as soon as possible but the connection speed is too low. If they turn on the video right now, it will... | ```python
from math import ceil
(a, b, c) = map(int, input().split())
t = (a * c - c * b) / b
print(ceil(t))
``` | vfc_88195 | {
"difficulty": "easy",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/195/A",
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "993 992 991\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100 1 10\n",
"output": "990\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/1768/B | Solve the following coding problem using the programming language python:
You are given a permutation$^\dagger$ $p$ of length $n$ and a positive integer $k \le n$.
In one operation, you:
Choose $k$ distinct elements $p_{i_1}, p_{i_2}, \ldots, p_{i_k}$.
Remove them and then add them sorted in increasing order to the... | ```python
import sys
def in_int():
return int(sys.stdin.readline())
def in_str():
return sys.stdin.readline().rstrip()
def in_map_int():
return map(int, sys.stdin.readline().split())
def in_arr_int():
return list(map(int, sys.stdin.readline().split()))
def in_arr_str():
return sys.stdin.readline().split()
de... | vfc_88203 | {
"difficulty": "easy",
"memory_limit": "256 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1768/B",
"time_limit": "1 second"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n3 2\n1 2 3\n3 1\n3 1 2\n4 2\n1 3 2 4\n4 2\n2 3 1 4\n",
"output": "0\n1\n1\n2\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/787/A | Solve the following coding problem using the programming language python:
A monster is chasing after Rick and Morty on another planet. They're so frightened that sometimes they scream. More accurately, Rick screams at times b, b + a, b + 2a, b + 3a, ... and Morty screams at times d, d + c, d + 2c, d + 3c, .... [Image... | ```python
def compute_gcd(a, b):
if a == 0:
return b
return compute_gcd(b % a, a)
def main():
(a, b) = map(int, input().split())
(c, d) = map(int, input().split())
gcd = compute_gcd(a, c)
if (b - d) % gcd != 0:
print(-1)
steps = 1000
size = max(b, d) + max(a, c) * steps
used = [False] * size
x = b
for _... | vfc_88211 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/787/A",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "20 2\n9 19\n",
"output": "82\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 1\n16 12\n",
"output": "-1\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/1772/F | Solve the following coding problem using the programming language python:
It all started with a black-and-white picture, that can be represented as an $n \times m$ matrix such that all its elements are either $0$ or $1$. The rows are numbered from $1$ to $n$, the columns are numbered from $1$ to $m$.
Several operatio... | ```python
def countHoles(pic):
h = 0
for i in range(1, len(pic) - 1):
for j in range(1, len(pic[i]) - 1):
h += pic[i + 1][j] == pic[i - 1][j] == pic[i][j - 1] == pic[i][j + 1] and pic[i + 1][j] != pic[i][j]
return h
def findDiff(pic1, pic2):
diff = []
for i in range(len(pic)):
for j in range(len(pic[i])):
... | vfc_88215 | {
"difficulty": "hard",
"memory_limit": "256 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1772/F",
"time_limit": "2 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 3 1\n\n010\n111\n010\n\n010\n101\n010\n",
"output": "2\n2\n1 2 2\n2 1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 5 3\n\n00000\n01000\n11100\n01000\n\n00000\n01000\n10100\n01000\n\... |
taco | verifiable_code | https://www.codechef.com/problems/ALPHABET | Solve the following coding problem using the programming language python:
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Not everyone probably knows that Chef has younger brother Jeff. Currently Jeff learns to read.
He knows some subset of the letter of Latin alphabet. In order to hel... | ```python
s = input()
n = int(input())
for i in range(n):
word = input()
for l in word:
if not l in s:
print('No')
break
else:
print('Yes')
``` | vfc_88219 | {
"difficulty": "easy",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/ALPHABET",
"time_limit": "1 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "act\n2\ncat\ndog",
"output": "Yes\nNo",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/1512/F | Solve the following coding problem using the programming language python:
Polycarp is wondering about buying a new computer, which costs $c$ tugriks. To do this, he wants to get a job as a programmer in a big company.
There are $n$ positions in Polycarp's company, numbered starting from one. An employee in position $... | ```python
import math
for _ in range(int(input())):
(n, c) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
days = 0
dp = [(0, 0)]
cost = 0
i = 0
while True:
if i < n - 1 and b[i] <= c:
x = math.ceil((b[i] - cost) / a[i])
days += x
dp.append((cost + ... | vfc_88224 | {
"difficulty": "hard",
"memory_limit": "256 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1512/F",
"time_limit": "2 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n4 15\n1 3 10 11\n1 2 7\n4 100\n1 5 10 50\n3 14 12\n2 1000000000\n1 1\n1\n",
"output": "6\n13\n1000000000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n4 15\n1 3 10 11\n1 2 7\n4 100... |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/lcs-of-0-k-repeated-string5642/1 | Solve the following coding problem using the programming language python:
Given a Binary string st and a number k. You have to find the Longest continuous sequence of '0' after repeating Given string K time.
Example 1:
Input: k = 3
st = 100001
Output: 4
Explaination: The string repeated k times
become 100001100001100... | ```python
class Solution:
def lcsK(self, k, st):
if int(st) > 0:
s = st * k
ans = 0
temp = 0
s = str(s)
r = min(2, k)
for i in range(len(st) * r):
if s[i] == '0':
temp = temp + 1
else:
ans = max(ans, temp)
temp = 0
return ans
else:
return len(st) * k
``` | vfc_88228 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/lcs-of-0-k-repeated-string5642/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "k = 3\nst = 100001",
"output": "4",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "k = 4\nst = 000",
"output": "12",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | Solve the following coding problem using the programming language python:
You have just purchased a new mobile phone and you want to call all of your relatives to brag about your new phone. You have N relatives. You will talk to i^th relative for exactly Ti minutes. Each minute costs you 1 dollar . However, your relat... | ```python
n=int(input())
ppairs=[]
npairs=[]
for i in range(n):
ti,xi=list(map(int,input().split()))
if (xi-ti)>=0:
ppairs.append([ti,xi])
else:
npairs.append([ti,xi])
ppairs.sort(reverse=True,key=lambda x: (x[1]+0.0)/x[0])
#print ppairs
invest=0
profit=0
for i in ppairs:
if profit<i[0]:
invest+=i[0]-profit
... | vfc_88229 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "20603\n707 184\n27262 51\n3115 2793\n23771 2578\n18887 7858\n5970 2028\n9442 3875\n9385 5848\n3739 931\n4126 1058\n1595 1508\n15960 13703\n22981 17946\n21150 4063\n21711 4474\n29767 18026\n20881 6106\n2161 300\n24636 1401\n13302 63... | |
taco | verifiable_code | https://codeforces.com/problemset/problem/1504/B | Solve the following coding problem using the programming language python:
There is a binary string $a$ of length $n$. In one operation, you can select any prefix of $a$ with an equal number of $0$ and $1$ symbols. Then all symbols in the prefix are inverted: each $0$ becomes $1$ and each $1$ becomes $0$.
For example,... | ```python
import sys
import math
inf = float('inf')
def lcm(a, b):
return int(a / math.gcd(a, b) * b)
for _ in range(int(input())):
n = int(input())
a = input()
b = input()
changed = False
count_1 = 0
count_0 = 0
for i in range(n):
if a[i] == '1':
count_1 += 1
else:
count_0 += 1
flag = True
for i i... | vfc_88233 | {
"difficulty": "easy",
"memory_limit": "256 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1504/B",
"time_limit": "1 second"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n10\n0111010000\n0100101100\n4\n0000\n0000\n3\n001\n000\n12\n010101010101\n100110011010\n6\n000111\n110100\n",
"output": "YES\nYES\nNO\nYES\nNO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"inp... |
taco | verifiable_code | https://www.codechef.com/problems/ORMATRIX | Solve the following coding problem using the programming language python:
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_... | ```python
t = input()
t = int(t)
while t:
t = t - 1
n_m = input()
n_m = n_m.split(' ')
n = int(n_m[0])
m = int(n_m[1])
matrix = []
for i in range(n):
row = input()
row = list(row)
row = list(map(int, row))
matrix.append(row)
v_rows = [False] * n
v_cols = [False] * m
ans = [[-1 for j in range(m)] for i... | vfc_88237 | {
"difficulty": "medium_hard",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/ORMATRIX",
"time_limit": "1 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n3 3\n010\n000\n001\n",
"output": "1 0 1\n2 1 1\n1 1 0\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/1442/A | Solve the following coding problem using the programming language python:
You are given an array $a$ of $n$ positive integers.
You can use the following operation as many times as you like: select any integer $1 \le k \le n$ and do one of two things: decrement by one $k$ of the first elements of the array. decreme... | ```python
from sys import stdin
from math import *
for __ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
val = a[0]
for i in range(n - 1, 0, -1):
a[i] -= a[i - 1]
if a[i] < 0:
val += a[i]
if val >= 0:
print('YES')
else:
print('NO')
``` | vfc_88241 | {
"difficulty": "medium_hard",
"memory_limit": "256 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1442/A",
"time_limit": "2 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n3\n1 2 1\n5\n11 7 9 6 8\n5\n1 3 1 3 1\n4\n5 2 1 10\n",
"output": "YES\nYES\nNO\nYES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n3\n1 2 1\n5\n11 7 9 6 9\n5\n1 3 1 3 1\n4\n5 2 1 10... |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/count-the-paths4332/1 | Solve the following coding problem using the programming language python:
Given a directed acyclic graph(DAG) with n nodes labeled from 0 to n-1. Given edges, s and d ,count the number of ways to reach from s to d.There is a directed Edge from vertex edges[i][0] to the vertex edges[i][1].
Example:
Input: edges = {{0... | ```python
class Solution:
def possible_paths(self, edges, n, s, d):
g = [[] for _ in range(n)]
for (a, b) in edges:
g[a].append(b)
path = set()
def helper(node, prev, p):
if node == d:
path.add(tuple(p + [node]))
return p
if node in p:
return False
for neig in g[node]:
if neig != ... | vfc_88247 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/count-the-paths4332/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "edges = {{0,1},{0,3},{1,2},{3,2}}, \r\nn = 4, s = 0, d = 2",
"output": "2",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/1698/B | Solve the following coding problem using the programming language python:
There are $n$ piles of sand where the $i$-th pile has $a_i$ blocks of sand. The $i$-th pile is called too tall if $1 < i < n$ and $a_i > a_{i-1} + a_{i+1}$. That is, a pile is too tall if it has more sand than its two neighbours combined. (Note ... | ```python
z = lambda : map(int, input().split())
(t,) = z()
for _ in '_' * t:
(n, k) = z()
l = [*z()]
if k != 1:
print(sum((x + y < z for (x, z, y) in zip(l, l[1:], l[2:]))))
else:
print((n - 1) // 2)
``` | vfc_88248 | {
"difficulty": "easy",
"memory_limit": "256 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1698/B",
"time_limit": "1 second"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n5 2\n2 9 2 4 1\n4 4\n1 3 2 1\n3 1\n1 3 1\n",
"output": "2\n0\n1\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://www.codechef.com/problems/LCM_GCD | Solve the following coding problem using the programming language python:
Chef has two integers A and B.
Chef wants to find the minimum value of \texttt{lcm}(A, X) - \texttt{gcd}(B, X) where X is any positive integer.
Help him determine this value.
Note: \texttt{gcd}(P, Q) denotes the [greatest common divisor] of ... | ```python
import math
for i in range(int(input())):
(a, b) = map(int, input().split())
print(a - math.gcd(a, b))
``` | vfc_88252 | {
"difficulty": "easy",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/LCM_GCD",
"time_limit": "1 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n12 15\n5 50\n9 11\n",
"output": "9\n0\n8\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/191/B | Solve the following coding problem using the programming language python:
In the capital city of Berland, Bertown, demonstrations are against the recent election of the King of Berland. Berland opposition, led by Mr. Ovalny, believes that the elections were not fair enough and wants to organize a demonstration at one ... | ```python
from sys import stdin, stdout
(n, k) = map(int, stdin.readline().split())
value = int(stdin.readline())
prices = list(map(int, stdin.readline().split()))
used = {}
challengers = prices[:-1]
for i in range(n - 1):
challengers[i] = (challengers[i], i)
challengers.sort(reverse=True)
ind = challengers[k - 1][1]
... | vfc_88256 | {
"difficulty": "medium_hard",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/191/B",
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10 1\n297\n215 281 102 280 243 225 294 296 7383 2623\n",
"output": "9\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 4\n1834\n11 44 49 420 93 653 306 596 535 842\n",
"output": "4... |
taco | verifiable_code | https://codeforces.com/problemset/problem/1515/G | Solve the following coding problem using the programming language python:
In Fire City, there are n intersections and m one-way roads. The i-th road goes from intersection a_i to b_i and has length l_i miles.
There are q cars that may only drive along those roads. The i-th car starts at intersection v_i and has an o... | ```python
import sys
from sys import stdin
import math
from collections import deque
import sys
class scc_graph:
def __init__(self, N):
self.N = N
self.edges = []
def csr(self):
self.start = [0] * (self.N + 1)
self.elist = [0] * len(self.edges)
for e in self.edges:
self.start[e[0] + 1] += 1
for i in... | vfc_88267 | {
"difficulty": "very_hard",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1515/G",
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 1\n2 1 1\n1\n2 1 2\n",
"output": "NO\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://www.codechef.com/problems/MINOPS | Solve the following coding problem using the programming language python:
You are given two strings $S$ and $R$. Each of these strings has length $N$. We want to make $S$ equal to $R$ by performing the following operation some number of times (possibly zero):
- Choose two integers $a$ and $b$ such that $1 \le a \le b ... | ```python
for _ in range(int(input())):
s = input()
r = input()
a = []
l = 0
k = 0
tmp = 0
cnt = 0
for i in range(len(s)):
if s[i] != r[i]:
if cnt == 0:
k += 1
cnt += 1
l += 1
if tmp:
a.append(tmp)
tmp = 0
else:
if k:
tmp += 1
cnt = 0
ans = k * l
a.sort()
if k == 1:
pr... | vfc_88272 | {
"difficulty": "hard",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/MINOPS",
"time_limit": "1 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\nadefb\nbdefa\n",
"output": "4\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/next-right-node/1 | Solve the following coding problem using the programming language python:
Given a Binary tree and a key in the binary tree, find the node right to the given key. If there is no node on right side, then return a node with value -1.
Example 1:
Input:
10
/ \
2 6
/ \ \
8 4 5
and ke... | ```python
from collections import deque
class Solution:
def nextRight(self, root, key):
x = []
q = deque()
q.append(root)
while q:
for i in range(len(q)):
a = q.popleft()
x.append(a.data)
if a.left:
q.append(a.left)
if a.right:
q.append(a.right)
x.append('l')
for i in range(... | vfc_88276 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/next-right-node/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10\r\n / \\\r\n 2 6\r\n / \\ \\\r\n 8 4 5\r\nand key = 2",
"output": "6",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\r\n / \\\r\n 2 6\r\n ... |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/triangle-pattern-1661718013/1 | Solve the following coding problem using the programming language python:
Geek is very fond of patterns. Once, his teacher gave him a pattern to solve. He gave Geek an integer n and asked him to build a pattern.
Help Geek to build a star pattern.
Example 1:
Input: 5
Output:
*
* *
* * *
* * * *
* * * * *
* * * *
... | ```python
class Solution:
def printTriangle(self, N):
x = N - 1
for i in range(1, N + 1):
print(i * '* ')
for j in range(1, N):
print(x * '* ')
x = x - 1
``` | vfc_88283 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/triangle-pattern-1661718013/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5",
"output": "* \n* * \n* * * \n* * * * \n* * * * *\n* * * *\n* * *\n* *\n*\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://www.codechef.com/problems/FUNHAND | Solve the following coding problem using the programming language python:
MoEngage has 3 decks. Each deck consists of N cards, numbered from 1 to N. He draws out 1 card from each deck randomly with each card having an equal probability of being drawn.
MoEngage drew cards numbered A and B from the decks 1 and 2 respec... | ```python
for _ in range(int(input())):
(N, A, B) = map(int, input().split())
if A - B > 2 or B - A > 2 or A == B:
print(0)
elif A == 1 or B == 1 or A - B == 2 or (B - A == 2) or (A == N) or (B == N):
print(1)
else:
print(2)
``` | vfc_88292 | {
"difficulty": "easy",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/FUNHAND",
"time_limit": "1 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n4 2 3\n6 2 1\n5 2 5\n",
"output": "2\n1\n0\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Rose loves to play games. This problem is about a game he recently played. In the game there are N locations, numbered 0 through N-1. Each location has one entrance and one exit. You are given an array aka A with N elements.For each i, A[i] desc... | ```python
noOfTestCases = int(input())
def outCome(values):
alreadyVistedPlaces = {}
currentLoc = '0'
while((currentLoc in alreadyVistedPlaces) == False and currentLoc != '-1'):
alreadyVistedPlaces[currentLoc] = 1
currentLoc = values[int(currentLoc)]
if(currentLoc == '-1'):
return "Win"
else:
return "Lo... | vfc_88296 | {
"difficulty": "unknown_difficulty",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "11\n47\n16 38 18 8 24 32 42 45 2 10 30 26 23 -1 15 35 39 46 37 1 33 19 28 44 43 17 5 34 -1 11 40 41 3 13 6 4 7 31 36 21 27 25 29 20 9 14 22\n47\n30 9 24 10 8 36 4 46 2 -1 1 33 17 28 35 5 25 19 22 34 15 26 12 45 29 43 38 14 37 7 40 ... | |
taco | verifiable_code | https://codeforces.com/problemset/problem/1227/A | Solve the following coding problem using the programming language python:
Your math teacher gave you the following problem:
There are $n$ segments on the $x$-axis, $[l_1; r_1], [l_2; r_2], \ldots, [l_n; r_n]$. The segment $[l; r]$ includes the bounds, i.e. it is a set of such $x$ that $l \le x \le r$. The length of t... | ```python
n = int(input())
ans = []
for i in range(n):
m = int(input())
if m != 1:
s = []
for p in range(m):
s.append(list(map(int, input().split())))
sn = [j[0] for j in s]
sk = [j[1] for j in s]
a = min(sk)
b = max(sn)
fuckuguyspieaceofshit = a - b
if fuckuguyspieaceofshit > 0:
ans.append(0)
... | vfc_88300 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1227/A",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n3\n4 5\n5 9\n7 7\n5\n11 19\n4 17\n16 16\n3 12\n14 17\n1\n1 10\n1\n1 1\n",
"output": "2\n4\n0\n0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n10\n132182352 630066892\n323711215 923... |
taco | verifiable_code | https://www.hackerrank.com/challenges/nimble-game-1/problem | Solve the following coding problem using the programming language python:
Two people are playing Nimble! The rules of the game are:
The game is played on a line of $n$ squares, indexed from $\mbox{0}$ to $n-1$. Each square $\boldsymbol{i}$ (where $0\leq i<n$) contains $c_i$ coins. For example:
The players move in a... | ```python
test = int(input())
for _ in range(test):
n = int(input())
ar = list(map(int, input().strip().split()))
result = []
for i in range(len(ar)):
result.append(ar[i] % 2)
xor = 0
for (i, n) in enumerate(result):
xor = xor ^ i * n
if xor == 0:
print('Second')
else:
print('First')
``` | vfc_88304 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.hackerrank.com/challenges/nimble-game-1/problem",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n5\n0 2 3 0 6\n4\n0 0 0 0\n",
"output": "First\nSecond\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/778/D | Solve the following coding problem using the programming language python:
Peter decided to lay a parquet in the room of size n × m, the parquet consists of tiles of size 1 × 2. When the workers laid the parquet, it became clear that the tiles pattern looks not like Peter likes, and workers will have to re-lay it.
The... | ```python
board = []
(n, m) = (0, 0)
def rotate(x, y):
if board[x][y] == 'L':
board[x][y] = board[x][y + 1] = 'U'
board[x + 1][y] = board[x + 1][y + 1] = 'D'
else:
board[x][y] = board[x + 1][y] = 'L'
board[x][y + 1] = board[x + 1][y + 1] = 'R'
def fix(x, y, moves):
if board[x + 1][y] == 'U':
if board[x +... | vfc_88308 | {
"difficulty": "very_hard",
"memory_limit": "512.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/778/D",
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "34 5\nLRUUU\nUUDDD\nDDULR\nLRDUU\nULRDD\nDULRU\nUDLRD\nDULRU\nUDLRD\nDLRUU\nULRDD\nDLRLR\nLRUUU\nLRDDD\nUUULR\nDDDLR\nLRULR\nLRDLR\nLRLRU\nULRUD\nDLRDU\nLRLRD\nULRUU\nDUUDD\nUDDUU\nDLRDD\nLRLRU\nUUUUD\nDDDDU\nLRUUD\nUUDDU\nDDUUD\nU... |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/max-level-sum-in-binary-tree/1 | Solve the following coding problem using the programming language python:
Given a Binary Tree having positive and negative nodes. Find the maximum sum of a level in the given Binary Tree.
Example 1:
Input :
4
/ \
2 -5
/ \ / \
-1 3 -2 6
Output: ... | ```python
class Solution:
def maxLevelSum(self, root):
q = [root]
res = 0
while q:
l = len(q)
tmp = 0
for i in range(l):
p = q.pop(0)
tmp += p.data
if p.left:
q.append(p.left)
if p.right:
q.append(p.right)
if res == 0 and tmp < 0:
res = tmp
else:
res = max(res, t... | vfc_88312 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/max-level-sum-in-binary-tree/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n / \\\n 2 -5\n / \\ / \\\n -1 3 -2 6",
"output": "6",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n / \\\n 2 3\n ... |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/recursively-remove-all-adjacent-duplicates0744/1 | Solve the following coding problem using the programming language python:
Given a string s, remove all its adjacent duplicate characters recursively.
Note: For some test cases, the resultant string would be an empty string. In that case, the function should return the empty string only.
Example 1:
Input:
S = "geeksfo... | ```python
class Solution:
def rremove(self, S):
def rec(S):
ans = ''
n = len(S)
i = 0
while i < n:
if i < n - 1 and S[i] == S[i + 1]:
while i < n - 1 and S[i] == S[i + 1]:
i += 1
else:
ans += S[i]
i += 1
return ans
s1 = ''
while len(S) != len(s1):
s1 = S
S = rec... | vfc_88313 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/recursively-remove-all-adjacent-duplicates0744/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "S = \"geeksforgeek\"",
"output": "\"gksforgk\"",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "S = \"abccbccba\"",
"output": "\"\"",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/1197/A | Solve the following coding problem using the programming language python:
Let's denote a $k$-step ladder as the following structure: exactly $k + 2$ wooden planks, of which
two planks of length at least $k+1$ — the base of the ladder; $k$ planks of length at least $1$ — the steps of the ladder;
Note that neither... | ```python
for _ in range(int(input())):
n = int(input())
l = [int(x) for x in input().split()]
l.sort()
a = l[-1]
b = l[-2]
if a <= 1 or b <= 1:
print(0)
else:
print(min(b - 1, n - 2))
``` | vfc_88314 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1197/A",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n4\n1 3 1 3\n3\n3 3 2\n5\n2 3 3 4 2\n3\n1 1 2\n",
"output": "2\n1\n2\n0\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://www.hackerrank.com/challenges/closest-numbers/problem | Solve the following coding problem using the programming language python:
Sorting is useful as the first step in many different tasks. The most common task is to make finding things easier, but there are other uses as well. In this case, it will make it easier to determine which pair or pairs of elements have the sma... | ```python
def main():
N = int(input())
ar = sorted(list(map(int, str(input()).split())))
prs = ''
mini = pow(10, 7) + 1
for i in range(1, N):
diff = abs(ar[i - 1] - ar[i])
if diff <= mini:
if diff < mini:
prs = ''
mini = diff
prs += str(ar[i - 1]) + ' ' + str(ar[i]) + ' '
print(prs)
main()
``` | vfc_88318 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.hackerrank.com/challenges/closest-numbers/problem",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10\n-20 -3916237 -357920 -3620601 7374819 -7330761 30 6246457 -6461594 266854 \n",
"output": "-20 30\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "12\n-20 -3916237 -357920 -3620601 73748... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.