source stringclasses 4
values | task_type stringclasses 1
value | in_source_id stringlengths 0 138 | problem_statement stringlengths 219 13.2k | gold_standard_solution stringlengths 0 413k | problem_id stringlengths 5 10 | metadata dict | verification_info dict |
|---|---|---|---|---|---|---|---|
taco | verifiable_code | Solve the following coding problem using the programming language python:
problem
I want to put as many rectangular tiles as possible on a rectangular wall with a size of $ h $ in height and $ w $ in width, and a size of $ a $ in height and $ b $ in width.
The following conditions must be met when attaching tiles.
... | ```python
(h, w) = map(int, input().split())
(a, b) = map(int, input().split())
high = h // a * a
wide = w // b * b
print(h * w - high * wide)
``` | vfc_144808 | {
"difficulty": "unknown_difficulty",
"memory_limit": "268.435456 megabytes",
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "1.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 8\n3 2",
"output": "16\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 8\n6 2",
"output": "40\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": ... | |
taco | verifiable_code | https://www.hackerrank.com/challenges/distant-pairs/problem | Solve the following coding problem using the programming language python:
We take a line segment of length $\textbf{C}$ on a one-dimensional plane and bend it to create a circle with circumference $\textbf{C}$ that's indexed from $0$ to $\boldsymbol{c-1}$. For example, if $c=4$:
We denote a pair of points, $a$ and $\... | ```python
import math
import os
import random
import re
import sys
import copy
import operator
sys.setrecursionlimit(20000)
def primary_distance(a, b, c):
dist_array = min(abs(a - b), c - abs(a - b))
return dist_array
def distance_array(array, c):
assert len(array) == 2
(a_1, b_1) = tuple(array[0])
(a_2, b_2) = ... | vfc_144812 | {
"difficulty": "hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.hackerrank.com/challenges/distant-pairs/problem",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 8\n0 4\n2 6\n1 5\n3 7\n4 4\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 1000\n0 10\n10 20\n",
"output": "0\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/1742/A | Solve the following coding problem using the programming language python:
You are given three integers $a$, $b$, and $c$. Determine if one of them is the sum of the other two.
-----Input-----
The first line contains a single integer $t$ ($1 \leq t \leq 9261$) — the number of test cases.
The description of each tes... | ```python
output = ''
for caseno in range(int(input())):
answer = 'NO'
(a, b, c) = map(int, input().split())
l = sorted([a, b, c])
if l[0] + l[1] == l[2]:
answer = 'YES'
output += str(answer) + '\n'
print(output)
``` | vfc_144816 | {
"difficulty": "easy",
"memory_limit": "256 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1742/A",
"time_limit": "1 second"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "7\n1 4 3\n2 5 8\n9 11 20\n0 0 0\n20 20 20\n4 12 3\n15 7 8\n",
"output": "YES\nNO\nYES\nYES\nNO\nNO\nYES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "12\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 ... |
taco | verifiable_code | https://codeforces.com/problemset/problem/1020/C | Solve the following coding problem using the programming language python:
As you know, majority of students and teachers of Summer Informatics School live in Berland for the most part of the year. Since corruption there is quite widespread, the following story is not uncommon.
Elections are coming. You know the numbe... | ```python
import sys
f = sys.stdin
out = sys.stdout
(n, m) = map(int, f.readline().rstrip('\r\n').split())
cos = {}
cost = []
nvot = [0 for i in range(m + 1)]
party = [[] for i in range(m + 1)]
for i in range(n):
(p, c) = map(int, f.readline().rstrip('\r\n').split())
if p != 1:
if c in cos:
cos[c] += 1
else:
... | vfc_144821 | {
"difficulty": "medium_hard",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1020/C",
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1 3000\n2006 226621946\n",
"output": "226621946\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 2\n1 1\n1 1\n1 1\n1 1\n1 1\n2 1\n2 1\n2 1\n2 1\n2 1\n",
"output": "1\n",
"typ... |
taco | verifiable_code | https://www.codechef.com/ENNO2020/problems/ENCNOV4 | Solve the following coding problem using the programming language python:
Chef is the event manager of his college. He has been assigned the task to manage the upcoming tech fest. There are $K$ rooms where the event can take place, and at a particular time only one event can be organized in a room for a particular tim... | ```python
import sys
from math import gcd
input = lambda : sys.stdin.readline().strip()
inp = lambda : list(map(int, sys.stdin.readline().strip().split()))
for _ in range(int(input())):
(n, k) = map(int, input().split())
d = [[] for i in range(k + 1)]
for i in range(n):
(l, r, p) = map(int, input().split())
d[p]... | vfc_144825 | {
"difficulty": "unknown_difficulty",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/ENNO2020/problems/ENCNOV4",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n4 2\n1 10 1\n10 20 2\n15 50 2\n20 30 2\n",
"output": "3\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/50/A | Solve the following coding problem using the programming language python:
You are given a rectangular board of M × N squares. Also you are given an unlimited number of standard domino pieces of 2 × 1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as possible on the board so as t... | ```python
(M, N) = map(int, input().split())
d = M * N // 2
print(d)
``` | vfc_144829 | {
"difficulty": "easy",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/50/A",
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 6\n",
"output": "6\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 5\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 6\n",... |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Ringo Mart, a convenience store, sells apple juice.
On the opening day of Ringo Mart, there were A cans of juice in stock in the morning. Snuke buys B cans of juice here every day in the daytime. Then, the manager checks the number of cans of j... | ```python
def main():
import math
def gcd(a, b):
while b:
(a, b) = (b, a % b)
return a
N = int(input())
ABCD = [list(map(int, input().split())) for i in range(N)]
for (A, B, C, D) in ABCD:
if A < B or D < B:
print('No')
continue
A %= B
if C < A:
print('No')
continue
if B == D:
print(... | vfc_144833 | {
"difficulty": "unknown_difficulty",
"memory_limit": "1024.0 megabytes",
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "24\n1 2 3 4\n1 2 4 3\n1 3 2 4\n1 3 4 2\n1 4 1 3\n1 4 3 2\n2 1 3 4\n2 1 4 3\n2 3 1 4\n2 3 4 1\n2 4 1 3\n2 4 3 1\n3 1 2 4\n3 1 4 2\n3 2 1 4\n3 2 4 1\n3 4 1 2\n3 4 2 1\n4 1 2 3\n4 1 3 2\n4 2 1 3\n4 2 3 1\n4 3 1 2\n4 3 2 1",
"out... | |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/e0059183c88ab680b2f73f7d809fb8056fe9dc43/1 | Solve the following coding problem using the programming language python:
Given an array of integers of size n and an integer k, find all the pairs in the array whose absolute difference is divisible by k.
Example 1:
Input:
n = 3
arr[] = {3, 7, 11}
k = 4
Output:
3
Explanation:
(11-3) = 8 is divisible by 4
(11-7) = 4 i... | ```python
class Solution:
def countPairs(self, n, arr, k):
modDic = {}
result = 0
for item in arr:
resToCheck = item % k
inDic = resToCheck in modDic
if inDic:
modDic[resToCheck] = modDic[resToCheck] + 1
else:
modDic[resToCheck] = 1
for item in modDic:
result += modDic[item] * (modDic[i... | vfc_144837 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/e0059183c88ab680b2f73f7d809fb8056fe9dc43/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "n = 3\r\narr[] = {3, 7, 11}\r\nk = 4",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "n = 4\r\narr[] = {1, 2, 3, 4}\r\nk = 2",
"output": "2",
"type": "stdin_stdout"... |
taco | verifiable_code | https://codeforces.com/problemset/problem/616/B | Solve the following coding problem using the programming language python:
Jack decides to invite Emma out for a dinner. Jack is a modest student, he doesn't want to go to an expensive restaurant. Emma is a girl with high taste, she prefers elite places.
Munhattan consists of n streets and m avenues. There is exactly ... | ```python
(n, m) = map(int, input().split())
street = []
for i in range(n):
x = list(map(int, input().split()))
street.append(x)
(emma_ind, emma) = (-1, -1)
for (j, i) in enumerate(street):
mn = min(i)
if mn > emma:
emma = mn
emma_ind = j
print(emma)
``` | vfc_144839 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/616/B",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 4\n4 1 3 5\n2 2 2 2\n5 4 5 1\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 3\n1 2 3\n2 3 1\n3 1 2\n",
"output": "1\n",
"type": "stdin_stdout"
},
... |
taco | verifiable_code | https://codeforces.com/problemset/problem/1611/B | Solve the following coding problem using the programming language python:
The All-Berland Team Programming Contest will take place very soon. This year, teams of four are allowed to participate.
There are $a$ programmers and $b$ mathematicians at Berland State University. How many maximum teams can be made if:
each ... | ```python
for s in [*open(0)][1:]:
(a, b) = sorted(map(int, s.split()))
print(a + min(b, 3 * a) >> 2)
``` | vfc_144843 | {
"difficulty": "easy",
"memory_limit": "256 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1611/B",
"time_limit": "1 second"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6\n5 5\n10 1\n2 3\n0 0\n17 2\n1000000000 1000000000\n",
"output": "2\n1\n1\n0\n2\n500000000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n841409 1\n",
"output": "1\n",
"ty... |
taco | verifiable_code | https://www.codechef.com/problems/ICL1804 | Solve the following coding problem using the programming language python:
Problem Statement
Olivia, another cyborg with crafted legs is a very dear friend of Geneo. On the eve of valentines day, Olivia decides to surprise Geneo by arriving at his home with a gift. The gift is special, so is her way of reaching home.
... | ```python
t = int(input())
for i in range(t):
(x, y, n, s, e, w, p) = map(int, input().split())
wa = x * e + y * n
c = x + y
p -= wa
if p < 0:
print(-1)
elif p == 0:
print(x + y)
else:
li = [n + s, e + w]
li.sort(reverse=True)
j = 0
while p % li[0] != 0:
p -= li[1]
j += 2
if p == 0:
prin... | vfc_144848 | {
"difficulty": "hard",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/ICL1804",
"time_limit": "2 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n10 8 9 1 9 1 90\n2 3 4 4 2 2 20\n346 36 580 403 656 10 906997\n73 544 559 336 831 759 707865",
"output": "-1\n7\n2092\n-1",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Subodh is having N branches, where each branches have positive integral student. A minimize operation is performed on the branch such that all of them are reduced by the minimum number student in a branch.
Suppose we have 5 branches and all of ... | ```python
n=int(input())
s=input().split()
s=list(map(int,s))
g=min(s)
while s!=[]:
i=0
count=0
while i<n:
s[i]-=g
count+=1
if s[i]==0:
s.remove(s[i])
i-=1
n-=1
i+=1
try:
g=min(s)
except:
pass
print(count)
``` | vfc_144852 | {
"difficulty": "unknown_difficulty",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6\n5 4 4 2 2 8",
"output": "6\n4\n2\n1",
"type": "stdin_stdout"
}
]
} | |
taco | verifiable_code | https://www.codechef.com/problems/AGEING | Solve the following coding problem using the programming language python:
Chef's current age is 20 years, while Chefina's current age is 10 years.
Determine Chefina's age when Chef will be X years old.
Note: Assume that Chef and Chefina were born on same day and same month (just different year).
------ Input Forma... | ```python
t = int(input())
for _ in range(t):
x = int(input())
print(x - 10)
``` | vfc_144856 | {
"difficulty": "easy",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/AGEING",
"time_limit": "1 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n25\n36\n50\n44\n",
"output": "15\n26\n40\n34\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://atcoder.jp/contests/abc042/tasks/arc058_b | Solve the following coding problem using the programming language python:
We have a large square grid with H rows and W columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the bottom-right cell.
However, she cannot enter the cells in the inte... | ```python
from operator import mul
from functools import reduce
def cmb(n, r, p):
if r < 0 or n < r:
return 0
r = min(r, n - r)
return fact[n] * factinv[r] * factinv[n - r] % p
p = 10 ** 9 + 7
N = 10 ** 6
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
for i in range(2, N + 1):
fact.append(fact[-1] * i % p)
inv.app... | vfc_144861 | {
"difficulty": "medium_hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://atcoder.jp/contests/abc042/tasks/arc058_b",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 3 1 1\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 7 3 4\n",
"output": "3570\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"inpu... |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Dr. Jimbo, an applied mathematician, needs to calculate matrices all day for solving his own problems. In his laboratory, he uses an excellent application program for manipulating matrix expressions, however, he cannot use it outside his laborat... | ```python
from string import digits
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def parse(S, mp):
M = 32768
cur = 0
def transpose(m):
(p, q, v) = m
res = [[0] * p for i in range(q)]
for i in range(q):
for j in range(p):
res[i][j] = v[j][i]
return (q, p, res)
def submatrix(m, ... | vfc_144865 | {
"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": "1\nA=[1 2 3;4 5 6].\n1\nA=[[1 4 3;4 5 6] [7 8;9 10] [11;12];13 14 15 16 17 18].\n3\nB=[3 -2 1;-9 8 7].\nC=([1 2 3;4 5 6]+B)(2,3).\nD=([1 2 3;4 5 6]+B)([1 2],[2 3]).\n5\nA=2*[1 2;-3 4]'.\nB=A([2 1 2],[2 1]).\nA=[1 2;3 4]*3.\nA=[2]*[... | |
taco | verifiable_code | https://codeforces.com/problemset/problem/46/C | Solve the following coding problem using the programming language python:
Today there is going to be an unusual performance at the circus — hamsters and tigers will perform together! All of them stand in circle along the arena edge and now the trainer faces a difficult task: he wants to swap the animals' positions so ... | ```python
n = int(input())
s = input()
h = 0
for i in s:
if i == 'H':
h += 1
r = []
t = 0
for i in range(0, n):
if s[i] == 'H':
for b in range((i + 1) % n, min((i + 1) % n + h - 1, n)):
if s[b] == 'T':
t += 1
if (i + 1) % n + (h - 1) > n:
for q in range(0, ((i + 1) % n + (h - 1)) % n):
if s[q] == ... | vfc_144869 | {
"difficulty": "medium_hard",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/46/C",
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "13\nHTTTHHHTTTTHH\n",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "35\nTTTTTTHTTHTTTTTHTTTTTTTTTTTHTHTTTTT\n",
"output": "3",
"type": "stdin_stdout"
},
{
... |
taco | verifiable_code | Solve the following coding problem using the programming language python:
You need to find if a number can be expressed as sum of two perfect powers. That is, given x find if there exists non negative integers a, b, m, n such that a^m + b^n = x.
Input
First line of the input contains number of test cases T. It is fo... | ```python
c=[]
hash=[0]*1000009
q=[0]*1000009
hash[1]=1
x=0
for i in range(2,10000):
for j in range(2,10000):
x=i**j
if x<=1000000:
hash[x]=1
c.append(x)
else:
break
y=0
c.append(1)
c.sort()
for num1 in c:
for num2 in c:
if num1+num2<=(1000004):
q[num1+num2]=1
else:
break
d=0
t=int(input())
f... | vfc_144873 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "20\n178461\n767271\n143872\n917783\n642681\n496408\n735441\n899441\n265715\n772194\n797342\n833227\n479407\n800158\n613225\n498438\n818615\n750993\n597881\n142739\n",
"output": "No\nYes\nNo\nNo\nNo\nNo\nYes\nNo\nNo\nYes\nNo\n... | |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Your algorithm is so good at predicting the market that you now know what the share price of Mahindra & Mahindra. (M&M) will be for the next N days.
Each day, you can either buy one share of M&M, sell any number of shares of M&M that you own, o... | ```python
for _ in range(eval(input())):
noc = eval(input())
ins = list(map(int, input().split()))
tmp = ins[::]
cnt = noc-2
while cnt >= 0:
tmp[cnt] = max(tmp[cnt+1], ins[cnt])
cnt-=1
profit = 0
for i in range(noc):
profit += tmp[i] - ins[i]
print(profit)
``` | vfc_144877 | {
"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\n3\n5 3 2\n3\n1 2 100\n4\n1 3 1 2",
"output": "0\n197\n3",
"type": "stdin_stdout"
}
]
} | |
taco | verifiable_code | Solve the following coding problem using the programming language python:
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt.
Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fis... | ```python
d = {}
for _ in [0] * int(input()):
(a, v) = map(int, input().split())
d.setdefault(v, [])
d[v] += [a]
m = max(d)
print(min(d[m]), m)
``` | vfc_144881 | {
"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": "6\n1 14\n4 25\n3 42\n4 11\n5 40\n6 37",
"output": "3 42\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6\n1 14\n4 25\n3 42\n4 11\n5 60\n6 37",
"output": "5 60\n",
"type": "std... | |
taco | verifiable_code | https://codeforces.com/problemset/problem/65/C | Solve the following coding problem using the programming language python:
Brothers Fred and George Weasley once got into the sporting goods store and opened a box of Quidditch balls. After long and painful experiments they found out that the Golden Snitch is not enchanted at all. It is simply a programmed device. It a... | ```python
import math
import functools
import sys
def eulen(x, y):
r = functools.reduce(lambda x, y: x + y, map(lambda x: (x[0] - x[1]) ** 2, zip(x, y)))
return math.sqrt(r)
def output(t, p):
print('YES')
print(t)
print(' '.join(map(str, p)))
n = int(input())
points = []
for i in range(n + 1):
points.append(tup... | vfc_144885 | {
"difficulty": "hard",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/65/C",
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "20\n26 47 23\n1 -2 17\n-14 -22 46\n19 34 -18\n22 -10 -34\n15 14 -48\n-30 -12 -12\n-23 40 -48\n-50 -41 -35\n48 -5 46\n-2 -11 10\n-49 47 -15\n31 6 10\n-41 35 15\n28 28 25\n43 -7 -10\n-19 -48 49\n-10 -29 28\n0 -10 28\n41 12 -26\n-14 4... |
taco | verifiable_code | https://atcoder.jp/contests/arc104/tasks/arc104_b | Solve the following coding problem using the programming language python:
We have a string S of length N consisting of A, T, C, and G.
Strings T_1 and T_2 of the same length are said to be complementary when, for every i (1 \leq i \leq l), the i-th character of T_1 and the i-th character of T_2 are complementary. Here... | ```python
import sys
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
def input():
return sys.stdin.readline().strip()
def main():
(N, S) = input().split()
N = int(N)
ans = 0
for i in range(N):
a = 0
c = 0
for j in range(i, N):
if S[j] == 'A':
a += 1
elif S[j] == 'T':
a -= ... | vfc_144889 | {
"difficulty": "medium_hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://atcoder.jp/contests/arc104/tasks/arc104_b",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 AGCT\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 ATAT\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1... |
taco | verifiable_code | https://codeforces.com/problemset/problem/115/B | Solve the following coding problem using the programming language python:
You have a garden consisting entirely of grass and weeds. Your garden is described by an n × m grid, with rows numbered 1 to n from top to bottom, and columns 1 to m from left to right. Each cell is identified by a pair (r, c) which means that t... | ```python
(n, m) = [int(i) for i in input().split()]
if n == 1 and m == 1:
print(0)
elif n == 1:
lawn = input()
print(lawn.rfind('W'))
elif m == 1:
weeds = 0
for i in range(n):
lawn = input()
if lawn == 'W':
weeds = i
print(weeds)
else:
lawn = []
for i in range(n):
lawn.append(input())
first_weed = [r... | vfc_144893 | {
"difficulty": "medium",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/115/B",
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "150 1\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nW\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nG\nW\nG\nG\nG\nW\nG\nG\nG\nG\nG\... |
taco | verifiable_code | https://codeforces.com/problemset/problem/788/A | Solve the following coding problem using the programming language python:
Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried a... | ```python
n = int(input())
a = list(map(int, input().split()))
b = [0] * n
c = [0] * n
for i in range(n - 1):
x = abs(a[i] - a[i + 1])
if i % 2 == 0:
b[i] = x
c[i] = -x
else:
b[i] = -x
c[i] = x
def maxSubArray(arr):
best = 0
current = 0
for x in arr:
current = max(0, current + x)
best = max(best, cur... | vfc_144897 | {
"difficulty": "medium_hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/788/A",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n1 4 2 3 1\n",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n1 5 4 7\n",
"output": "6",
"type": "stdin_stdout"
},
{
"fn_name": null,
"inpu... |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/total-count2415/1 | Solve the following coding problem using the programming language python:
Given an array Arr of N positive integers and a number K where K is used as a threshold value to divide each element of the array into sum of different numbers. Find the sum of count of the numbers in which array elements are divided.
Example 1:... | ```python
class Solution:
def totalCount(self, arr, n, k):
l = []
for i in arr:
if i // k == i / k:
l.append(i // k)
else:
l.append(i // k + 1)
return sum(l)
``` | vfc_144902 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/total-count2415/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "N = 4, K = 3\r\nArr[] = {5, 8, 10, 13}",
"output": "14",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "N = 5, K = 4\r\nArr[] = {10, 2, 3, 4, 7}",
"output": "8",
"type": "stdin_st... |
taco | verifiable_code | https://codeforces.com/problemset/problem/1688/A | Solve the following coding problem using the programming language python:
Even if it's a really easy question, she won't be able to answer it
— Perfect Memento in Strict Sense
Cirno's perfect bitmasks classroom has just started!
Cirno gave her students a positive integer $x$. As an assignment, her students need to ... | ```python
t = int(input())
for _ in range(t):
x = int(input())
if x == 1:
print(3)
else:
y = x & -x
if y == x:
print(x + 1)
else:
print(y)
``` | vfc_144903 | {
"difficulty": "easy",
"memory_limit": "256 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1688/A",
"time_limit": "1 second"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "7\n1\n2\n5\n9\n16\n114514\n1000000\n",
"output": "3\n3\n1\n1\n17\n2\n64\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n1073741824\n",
"output": "1073741825\n",
"type": "std... |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Your task is to calculate the distance between two $n$ dimensional vectors $x = \\{x_1, x_2, ..., x_n\\}$ and $y = \\{y_1, y_2, ..., y_n\\}$.
The Minkowski's distance defined below is a metric which is a generalization of both the Manhattan dis... | ```python
n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
d = []
for i in range(n):
d.append(abs(x[i] - y[i]))
print(sum(d))
print(sum(list(map(lambda x: x ** 2, d))) ** (1 / 2))
print(sum(list(map(lambda x: x ** 3, d))) ** (1 / 3))
print(max(d))
``` | vfc_144907 | {
"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\n2 2 3\n2 0 4",
"output": "3.000000\n2.236068\n2.080084\n2.000000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n2 2 3\n2 -1 4",
"output": "4.000000\n3.162278\n3.036589\n3.0000... | |
taco | verifiable_code | https://codeforces.com/problemset/problem/1028/D | Solve the following coding problem using the programming language python:
Let's consider a simplified version of order book of some stock. The order book is a list of orders (offers) from people that want to buy or sell one unit of the stock, each order is described by direction (BUY or SELL) and price.
At every mome... | ```python
import math
import random
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
from collections import defaultdict
mod = 10 ** 9 + 7
mod1 = 998244353
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newli... | vfc_144912 | {
"difficulty": "hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1028/D",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6\nADD 1\nACCEPT 1\nADD 2\nACCEPT 2\nADD 3\nACCEPT 3\n",
"output": "8\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\nADD 1\nADD 2\nADD 3\nACCEPT 2\n",
"output": "2\n",
"typ... |
taco | verifiable_code | https://www.codechef.com/problems/ARRPAL | Solve the following coding problem using the programming language python:
Chef has an array A of size N. He can perform the following operation on A:
Select an i (1 ≤ i ≤ N) and for all 1 ≤ j ≤ i, set A_{j} := A_{j} + 1 (i.e. add 1 to every element in the prefix of length i).
Chef wants to convert A to a *palindrome*... | ```python
for _ in range(int(input())):
n = int(input())
S = [int(x) for x in input().split()]
dif = S[-1] - S[0]
ans = True
for i in range(int(n / 2)):
if S[-i - 1] - S[i] > dif or S[-i - 1] - S[i] < 0:
print(-1)
ans = False
break
dif = S[-i - 1] - S[i]
if ans:
print(S[-1] - S[0])
``` | vfc_144916 | {
"difficulty": "medium",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/ARRPAL",
"time_limit": "1 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n4\n4 2 2 4\n5\n5 4 3 2 1\n4\n1 2 3 4\n",
"output": "0\n-1\n3\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Alice and Bob are playing a game of coins. N coins are placed on the table in a row.
The game begins with Alice and afterwards they alternate the moves.
A valid move is defined as follows:
You pick one coin or two adjacent coins and remove t... | ```python
print('Alice')
print('Alice')
print('Alice')
print('Alice')
print('Alice')
print('Alice')
print('Alice')
print('Alice')
print('Alice')
print('Alice')
print('Alice')
print('Alice')
print('Alice')
print('Alice')
print('Alice')
print('Alice')
print('Alice')
print('Alice')
print('Alice')
print('Alice')
print('Ali... | vfc_144920 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "100\n90287615\n75096686\n621537351\n337906787\n932379178\n576368174\n614524887\n381393352\n683734903\n357312092\n45953951\n11885544\n659581459\n649281842\n360919237\n468202152\n348705142\n433071763\n766393082\n957639054\n492279795\... | |
taco | verifiable_code | https://www.codechef.com/problems/GROUPASSGN | Solve the following coding problem using the programming language python:
Chef's professor is planning to give his class a group assignment. There are 2N students in the class, with distinct roll numbers ranging from 1 to 2N. Chef's roll number is X.
The professor decided to create N groups of 2 students each. The gr... | ```python
t = int(input())
for l in range(t):
(n, x) = map(int, input().split())
print(2 * n + 1 - x)
``` | vfc_144924 | {
"difficulty": "easy",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/GROUPASSGN",
"time_limit": "1 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n2 2\n3 1\n3 4\n",
"output": "3\n6\n3",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://atcoder.jp/contests/abc168/tasks/abc168_a | Solve the following coding problem using the programming language python:
The cat Snuke wants to play a popular Japanese game called ÅtCoder, so Iroha has decided to teach him Japanese.
When counting pencils in Japanese, the counter word "本" follows the number. The pronunciation of this word varies depending on the nu... | ```python
X = input()
if int(X[-1]) in [0, 1, 6, 8]:
print('pon')
elif int(X[-1]) in [3]:
print('bon')
else:
print('hon')
``` | vfc_144928 | {
"difficulty": "easy",
"memory_limit": "1024.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://atcoder.jp/contests/abc168/tasks/abc168_a",
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "16\n",
"output": "pon\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n",
"output": "hon\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "183\n"... |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/sum-of-all-subsets-formed-by-first-n-natural-numbers0603/1 | Solve the following coding problem using the programming language python:
Given a number N, the task is to find the sum of all the elements from all possible subsets of a set formed by first N natural numbers.
Example 1:
Input:
N = 2
Output:
6
Explanation:
Possible subsets are {{1}, {2}, {1, 2}}.
Sum of elements in th... | ```python
class Solution:
def sumOfSubsets(self, N):
a = sum(range(1, N + 1))
b = 2 ** (N - 1)
return a * b
``` | vfc_144932 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/sum-of-all-subsets-formed-by-first-n-natural-numbers0603/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "N = 2",
"output": "6",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "N = 3",
"output": "24",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | Solve the following coding problem using the programming language python:
There are 3^N people dancing in circle. We denote with 0,1,\dots, 3^{N}-1 the positions in the circle, starting from an arbitrary position and going around clockwise. Initially each position in the circle is occupied by one person.
The people a... | ```python
n = int(input())
t = input()
new_pos = [0]
new_w = [0] * len(t)
for i in range(1, n + 1):
ith_bit = [0] * 3 ** i
for k in range(3):
for l in range(3 ** (i - 1)):
ith_bit[k * 3 ** (i - 1) + l] = k
pos = new_pos
w = new_w
q = 0
already = [0] * 3 ** i
new_w = [0] * len(t)
for j in range(len(t)):
m... | vfc_144934 | {
"difficulty": "unknown_difficulty",
"memory_limit": "1024.0 megabytes",
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\nSRRRSSSSR",
"output": "4 6 5 1 3 2 7 0 8 ",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\nRRS",
"output": "1 0 2 ",
"type": "stdin_stdout"
},
{
"fn_name": nul... | |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Watson gives to Sherlock a bag of numbers [1, 2, 3 ... N] and then he removes K numbers A1, A2 ... AK from the bag. He now asks Sherlock to find the P'th smallest number in the bag.
Input
First line contains T, the number of test cases. Each te... | ```python
t = eval(input())
for ____ in range(t):
n, k, p = list(map(int, input().split()))
l = list(map(int, input().split()))
l = sorted(l)
x = 1
if (n - k) < p:
print(-1)
else:
for i,j in enumerate(l):
if p > (j - x):
p = p - j + x
x = j + 1
else:
break
print(x + p - 1)
``` | vfc_144938 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10\n1000 40 125\n13 23 46 54 81 88 93 105 160 172 254 273 296 307 380 387 507 528 604 611 645 663 672 681 718 741 745 747 748 752 772 790 802 857 858 874 893 894 939 968\n1000 500 654\n1 2 4 5 7 8 9 12 16 18 19 22 27 28 29 30 35 36... | |
taco | verifiable_code | https://codeforces.com/problemset/problem/1671/A | Solve the following coding problem using the programming language python:
You are given a string $s$. You have to determine whether it is possible to build the string $s$ out of strings aa, aaa, bb and/or bbb by concatenating them. You can use the strings aa, aaa, bb and/or bbb any number of times and in any order.
F... | ```python
def solve(s):
ans = 'YES'
arr = []
curr = 0
last = s[0]
for i in s:
if last == i:
curr += 1
else:
arr.append(curr)
curr = 1
last = i
arr.append(curr)
for i in arr:
if i < 2:
return 'NO'
return 'YES'
t = int(input())
cases = []
for i in range(t):
cases.append(input())
ans = []
for... | vfc_144942 | {
"difficulty": "easy",
"memory_limit": "512 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1671/A",
"time_limit": "2 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "8\naaaabbb\nbbaaaaabbb\naaaaaa\nabab\na\nb\naaaab\nbbaaa\n",
"output": "YES\nYES\nYES\nNO\nNO\nNO\nNO\nYES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\nababababababababababababababab... |
taco | verifiable_code | https://codeforces.com/problemset/problem/1455/D | Solve the following coding problem using the programming language python:
You are given a sequence $a$ consisting of $n$ integers $a_1, a_2, \dots, a_n$, and an integer $x$. Your task is to make the sequence $a$ sorted (it is considered sorted if the condition $a_1 \le a_2 \le a_3 \le \dots \le a_n$ holds).
To make t... | ```python
for i in range(int(input())):
(n, x) = map(int, input().split())
arr = list(map(int, input().split()))
count = 0
for i in range(n):
if sorted(arr) == arr:
break
if arr[i] > x:
(x, arr[i]) = (arr[i], x)
count += 1
print(count) if sorted(arr) == arr else print(-1)
``` | vfc_144947 | {
"difficulty": "medium_hard",
"memory_limit": "512 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1455/D",
"time_limit": "1.5 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6\n4 1\n2 3 5 4\n5 6\n1 1 3 4 4\n1 10\n2\n2 10\n11 9\n2 10\n12 11\n5 18\n81 324 218 413 324\n",
"output": "3\n0\n0\n-1\n1\n3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n5 15\n5 15 8... |
taco | verifiable_code | Solve the following coding problem using the programming language python:
You are given an array a_0, a_1, ..., a_{N-1} of length N. Process Q queries of the following types.
The type of i-th query is represented by T_i.
* T_i=1: You are given two integers X_i,V_i. Replace the value of A_{X_i} with V_i.
* T_i=2: You... | ```python
class segtree:
sta = -1
func = max
def __init__(self, n):
self.n = n
self.size = 1 << n.bit_length()
self.tree = [self.sta] * (2 * self.size)
def build(self, list):
for (i, x) in enumerate(list, self.size):
self.tree[i] = x
for i in range(self.size - 1, 0, -1):
self.tree[i] = self.func(s... | vfc_144951 | {
"difficulty": "unknown_difficulty",
"memory_limit": "1024.0 megabytes",
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "5.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 5\n1 2 3 2 1\n2 1 5\n3 2 3\n1 3 1\n2 2 4\n3 1 0",
"output": "3\n3\n2\n1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 3\n1 2 3 2 1\n2 1 5\n3 2 3\n1 3 1\n2 2 4\n3 1 0",
"output"... | |
taco | verifiable_code | https://codeforces.com/problemset/problem/1675/F | Solve the following coding problem using the programming language python:
Vlad and Nastya live in a city consisting of $n$ houses and $n-1$ road. From each house, you can get to the other by moving only along the roads. That is, the city is a tree.
Vlad lives in a house with index $x$, and Nastya lives in a house wit... | ```python
def solve(n, k, x, y, a, graph):
a.add(x)
a.add(y)
stack = [(x, 0)]
parent = (n + 1) * [-1]
y_height = None
while stack:
(node, height) = stack.pop()
if node == y:
y_height = height
for child in graph[node]:
if child != parent[node]:
parent[child] = node
stack.append((child, height +... | vfc_144955 | {
"difficulty": "medium_hard",
"memory_limit": "256 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1675/F",
"time_limit": "2 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n\n3 1\n1 3\n2\n1 3\n1 2\n\n6 4\n3 5\n1 6 2 1\n1 3\n3 4\n3 5\n5 6\n5 2\n\n6 2\n3 2\n5 3\n1 3\n3 4\n3 5\n5 6\n5 2\n",
"output": "3\n7\n2\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/triplets-with-sum-with-given-range/1 | Solve the following coding problem using the programming language python:
Given an array Arr[] of N distinct integers and a range from L to R, the task is to count the number of triplets having a sum in the range [L, R].
Example 1:
Input:
N = 4
Arr = {8 , 3, 5, 2}
L = 7, R = 11
Output: 1
Explaination: There is only on... | ```python
class Solution:
def countTriplets(self, Arr, N, L, R):
Arr.sort()
n = len(Arr)
a = 0
b = 0
for i in range(n - 2):
j = i + 1
k = n - 1
while j < k:
if Arr[i] + Arr[j] + Arr[k] <= R:
a += k - j
j += 1
else:
k -= 1
for i in range(n - 2):
j = i + 1
k = n - 1
... | vfc_144959 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/triplets-with-sum-with-given-range/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "N = 4\nArr = {8 , 3, 5, 2}\nL = 7, R = 11",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "N = 5\nArr = {5, 1, 4, 3, 2}\nL = 2, R = 7",
"output": "2",
"type": "stdi... |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/alex-travelling/1 | Solve the following coding problem using the programming language python:
Alex is very fond of traveling. There are n cities, labeled from 1 to n. You are also given flights, a list of travel flights as directed weighted edges flights[i] = (u_{i},v_{i},w_{i}) where u_{i }is the source node, v_{i} is the target node, ... | ```python
import numpy as np
from collections import defaultdict
from collections import deque
from typing import List
class Solution:
def minimumCost(self, flights: List[List[int]], n: int, k: int) -> int:
g = defaultdict(list)
for (s, d, w) in flights:
g[s].append((d, w))
costs = [np.inf] * (n + 1)
cost... | vfc_144962 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/alex-travelling/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "n:4\nk:2\nflights size:3\nflights:[[2,1,1],[2,3,1],[3,4,1]]",
"output": "2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "n:4 \nk:3 \nflights size:3 \nflights:[[2,1,1],[2,3,1],[3,4,1]]",
... |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Hansa is throwing a birthday party. Seeing the extravagant parties thrown by her friends in the past, Hansa too decided to do something unique. Being a Computer Engineer herself, she knew just how to do it. She sent password-protected e-invites ... | ```python
cases = eval(input())
for i in range(cases):
base,string = input().split()
base = (int)(base)
answer = int(string,base)
answer = sum(map(int,str(answer)))
print(answer)
``` | vfc_144963 | {
"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\n20 4600i7952bi9g9a6ij25fdh457h116f082adg4b31b1g5d3hggg6i1cebhbbd89f55b5ab720fa6fb6abe7h54f5j97070hbbf0hc6673ceie7a61g09a0baab47ciadeh9gjcc8j28eef0gjeb58a1410d39a03a93a8bc2heg0g97gc505jd62005fjf0gc63ed30dh08a3254f709a5ac4jbdf21g... | |
taco | verifiable_code | https://codeforces.com/problemset/problem/834/B | Solve the following coding problem using the programming language python:
[Image]
It's the end of July – the time when a festive evening is held at Jelly Castle! Guests from all over the kingdom gather here to discuss new trends in the world of confectionery. Yet some of the things discussed here are not supposed to... | ```python
import os
from io import BytesIO
input = BytesIO(os.read(0, os.fstat(0).st_size)).readline
(n, k) = map(int, input().split())
g = [x - 65 for x in input()]
e = [-1] * 26
for i in range(n):
e[g[i]] = i
curS = 0
met = [0] * 26
for i in range(n):
if not met[g[i]]:
curS += 1
met[g[i]] = 1
if curS > k:
pr... | vfc_144967 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/834/B",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 1\nAABBB\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 1\nABABB\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
taco | verifiable_code | https://www.codechef.com/problems/STUPMACH | Solve the following coding problem using the programming language python:
Read problem statements in [Hindi],[Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
As usual, I went to work in the morning. Unfortunately, I found out that my manager bought a new machine and I have to learn to operate it.
... | ```python
t = int(input())
for i in range(t):
n = int(input())
l = list(map(int, input().split()))
ans = 0
s = 0
while len(l) > 0:
d = min(l)
ans = ans + (d - s) * len(l)
s = d
l = l[:l.index(d)]
print(ans)
``` | vfc_144971 | {
"difficulty": "medium",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/STUPMACH",
"time_limit": "1 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n3\n2 1 3",
"output": "4",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/next-higher-palindromic-number-using-the-same-set-of-digits5859/1 | Solve the following coding problem using the programming language python:
Given a palindromic number N in the form of string. The task is to find the smallest palindromic number greater than N using the same set of digits as in N.
Example 1:
Input:
N = "35453"
Output:
53435
Explanation: Next higher palindromic
numb... | ```python
class Solution:
def nextPalin(self, N):
n = len(N) // 2
ns = [int(N[n - 1])]
i = n - 2
while i >= 0:
nn = int(N[i])
mns = max(ns)
if nn < mns:
rn = min(nn + 1, mns)
while rn not in ns:
rn += 1
if rn > mns:
rn = mns
ns.remove(rn)
ns.append(nn)
ns.sort()
... | vfc_144975 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/next-higher-palindromic-number-using-the-same-set-of-digits5859/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "N = \"35453\"",
"output": "53435",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "N = \"33\"",
"output": "-1",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Raghu wants to design a converter such that when a user inputs a binary number it gets converted to Octal number & also the correspond alphabet to it.
Example- if a user inputs- 10101101
then the output is 255 BEE
Note : for decimal places the... | ```python
import sys
bin=input();
if "." in bin:
bdot,adot=bin.split(".")
else:
bdot=bin
adot=""
bdot=bdot.lstrip("0")
adot=adot.rstrip("0")
baddz= 3 - (len(bdot)%3)
aaddz= 3 - (len(adot)%3)
if(baddz==3):
baddz=0
if(aaddz==3):
aaddz=0
for i in range(baddz):
bdot='0'+bdot
for i in range(aaddz):
adot=ad... | vfc_144976 | {
"difficulty": "unknown_difficulty",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10011010.001111",
"output": "775.54 GGE ED",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "101101101110.111",
"output": "232.17 BCB AG",
"type": "stdin_stdout"
},
{
... | |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/chocolate-distribution-problem3825/1 | Solve the following coding problem using the programming language python:
Given an array A[ ] of positive integers of size N, where each value represents the number of chocolates in a packet. Each packet can have a variable number of chocolates. There are M students, the task is to distribute chocolate packets among M... | ```python
class Solution:
def findMinDiff(self, arr, n, m):
if m == 0 or n == 0:
return 0
arr.sort()
if n < m:
return -1
min_diff = arr[n - 1] - arr[0]
for i in range(len(arr) - m + 1):
min_diff = min(min_diff, arr[i + m - 1] - arr[i])
return min_diff
``` | vfc_144980 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/chocolate-distribution-problem3825/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "N = 8, M = 5\nA = {3, 4, 1, 9, 56, 7, 9, 12}",
"output": "6",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "N = 7, M = 3\nA = {7, 3, 2, 4, 9, 12, 56}",
"output": "2",
"type": "st... |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/circular-linked-list-traversal/1 | Solve the following coding problem using the programming language python:
Given a circular linked list, your task is to complete the method printList() that prints the linked list.
Input:
The printList function takes a single argument as input the reference pointer to the head of the linked list.
There are multiple te... | ```python
class Node:
def __init__(self, data):
self.data = data
self.next = None
class CircularLinkedList:
def __init__(self):
self.head = None
def push(self, data):
ptr1 = Node(data)
ptr1.data = data
temp = self.head
ptr1.next = self.head
if self.head is not None:
while temp.next != self.hea... | vfc_144981 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/circular-linked-list-traversal/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\r\n7\r\n374 363 171 497 282 306 426\r\n2\r\n162 231",
"output": "426 306 282 497 171 363 374\n231 162",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Our hacker, Little Stuart lately has been fascinated by ancient puzzles. One day going through some really old books he finds something scribbled on the corner of a page. Now Little Stuart believes that the scribbled text is more mysterious than... | ```python
n = int(input())
i=0
result = []
while i < n:
pattern=input()
text=input()
reversetext =text[::-1]
if pattern in text or pattern in reversetext:
result.append('YES')
else:
result.append('NO')
i=i+1
for te in result:
print(te)
``` | vfc_144982 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "100\nphqghumeaylnlfdxfircvscxggbwkfnqduxwfnfozvsrtkjprepggxrpnrvystmwcysyycqpevikeffmznimkkasvwsrenzkycxf\nxtlsgypsfadpooefxzbcoejuvpvaboygpoeylfpbnpljvrvipyamyehwqnqrqpmxujjloovaowuxwhmsncbxcoksfzkvatxdknlyjyhfixjswnkkufnuxxzrzbmn... | |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/maximum-xor-of-two-numbers-in-an-array/1 | Solve the following coding problem using the programming language python:
Given an array of non-negative integers of size N. Find the maximum possible XOR between two numbers present in the array.
Example 1:
Input:
Arr = {25, 10, 2, 8, 5, 3}
Output: 28
Explanation:
The maximum result is 5 ^ 25 = 28.
Example 2:
Input ... | ```python
from math import log
class Solution:
def max_xor(self, arr, n):
try:
l = int(log(max(arr), 2))
except:
l = 1
(mask, res) = (0, 0)
for i in range(l, -1, -1):
mask |= 1 << i
S = set((mask & num for num in arr))
temp = res | 1 << i
for num in S:
if num ^ temp in S:
res = tem... | vfc_144986 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/maximum-xor-of-two-numbers-in-an-array/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "Arr = {25, 10, 2, 8, 5, 3}",
"output": "28",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "Arr = {1, 2, 3, 4, 5, 6, 7}",
"output": "7",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/count-the-characters-in-each-word-in-a-given-sentence3451/1 | Solve the following coding problem using the programming language python:
Given a string containing multiple words, count the characters in each word and display them.
Example 1:
Input:
S = "the quick brown fox"
Output: 3 5 5 3
Explanation: "the" has 3 characters
"quick" has 5 characters
"brown" has 5 characters
"fox"... | ```python
class Solution:
def countChars(self, s):
return [len(i) for i in s.split()]
``` | vfc_144987 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/count-the-characters-in-each-word-in-a-given-sentence3451/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "S = \"the quick brown fox\"",
"output": "3 5 5 3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "S = \"geeks for geeks\"",
"output": "5 3 5",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/176/A | Solve the following coding problem using the programming language python:
To get money for a new aeonic blaster, ranger Qwerty decided to engage in trade for a while. He wants to buy some number of items (or probably not to buy anything at all) on one of the planets, and then sell the bought items on another planet. N... | ```python
(n, m, k) = [int(s) for s in input().split()]
BuyingPrice = []
SellingPrice = []
Number_of_items = []
for i in range(n):
input()
x = []
y = []
z = []
for j in range(m):
(a, b, c) = [int(s) for s in input().split()]
x.append(a)
y.append(b)
z.append(c)
BuyingPrice.append(x)
SellingPrice.append(y)... | vfc_144989 | {
"difficulty": "easy",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/176/A",
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 2 1\nQwe\n900 800 1\n5 1 1\nEwq\n1000 999 0\n11 10 0\n",
"output": "99\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 2 11\nMars\n15 10 4\n7 6 3\nSnickers\n20 17 2\n10 8 0\nBounty\n21... |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Steve Jobs' ghost has come down to BITS Pilani Hyderabad Campus, since he has heard a lot about the coding culture here. Hoping to recruit talented people to work on top-secret Apple software, he keeps a strict coding test.
Apple is currently w... | ```python
'''
# Read input from stdin and provide input before running code
name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
w = input()
leastLen = 10000000
n = eval(input())
temp = w
while n:
n -= 1
a = input()
if len(a) <= leastLen and a[:len(w)] == w:
if len(a) == len(w):
temp = a
brea... | vfc_144993 | {
"difficulty": "unknown_difficulty",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "find\n4\nfind\nfindfirstof\nfindit\nfand",
"output": "dzwzyji",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "find\n4\nfondfind\nfondfirstof\nfondit\nfand",
"output": "wmblbphwdjjskzml... | |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/maximum-frequency-1662528911/1 | Solve the following coding problem using the programming language python:
Given an interger array arr[] of size n and an interger k.In one operation, you can choose an index i where 0<i Return the maximum frequency of an element after using atmost k Increment operations.
Example 1:
Input:
n=3
arr[] = {2,2,4},k=4
Out... | ```python
class Solution:
def maxFrequency(self, arr, n, k):
arr.sort()
left = 0
(res, total) = (0, 0)
for right in range(len(arr)):
total += arr[right]
while arr[right] * (right - left + 1) > total + k:
total -= arr[left]
left += 1
res = max(res, right - left + 1)
return res
``` | vfc_144997 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/maximum-frequency-1662528911/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "\r\nn=3\r\narr[] = {2,2,4},k=4\r\n",
"output": " 3\r\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "\r\nn=4\r\narr[] = {7,7,7,7},k=5\r\n",
"output": " 4\r\n",
"type": "stdin_s... |
taco | verifiable_code | https://www.codechef.com/problems/GOTHAM | Solve the following coding problem using the programming language python:
Gotham city is in danger. All the people from Gotham were airlifted and they are going to be dropped at different districts of a new safe city.
There are $N$ districts located at position $(1, 2, \ldots, N)$ in a straight line in this newly bui... | ```python
n = int(input())
ls = list(map(int, input().split()))
q = int(input())
red = [0] * n
for x in range(n - 1):
red[x] = x + 1
red[-1] = -1
for _ in range(q):
lk = list(map(int, input().split()))
pos = lk[0]
peo = lk[1]
dis = 0
tmp = pos
i = pos - 1
todo = []
while i < n:
if peo >= ls[i]:
dis += ls[... | vfc_144998 | {
"difficulty": "hard",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/GOTHAM",
"time_limit": "1 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n5 5 6 1\n2\n2 11\n2 3\n",
"output": "6\n2\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://www.hackerrank.com/challenges/synchronous-shopping/problem | Solve the following coding problem using the programming language python:
Bitville is a seaside city that has a number of shopping centers connected by bidirectional roads, each of which has a travel time associated with it. Each of the shopping centers may have a fishmonger who sells one or more kinds of fish. Two ... | ```python
from heapq import *
from itertools import *
from sys import stderr
def main():
(nvert, nedge, setsize) = readints()
vertexhas = []
for _ in range(nvert):
(nelts, *elts) = readints()
assert nelts == len(elts)
vertexhas.append(sum((1 << elt - 1 for elt in elts)))
edgelist = [readints() for _ in range... | vfc_145002 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.hackerrank.com/challenges/synchronous-shopping/problem",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 5 5\n1 1\n1 2\n1 3\n1 4\n1 5\n1 2 10\n1 3 10\n2 4 10\n3 5 10\n4 5 10\n",
"output": "30\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Solve the mystery
HINT : Digital Display
Input :
First line has an integer T.
Next T lines has an integer N in each line. It is guaranteed that N never starts with 0 unless value is equal to zero.
Output :
Print the output for each test case i... | ```python
arr=[6,2,5,5,4,5,6,3,7,6]
for _ in range(eval(input())):
a=list(input())
temp=0
for item in a:
temp=temp+arr[int(item)]
print(temp)
``` | vfc_145006 | {
"difficulty": "unknown_difficulty",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "50\n67535629\n270936\n62618\n92023759\n289\n36129319\n7\n4503610\n32061\n54\n65693745\n5474430\n86884314\n20689266\n9504871\n27\n26106\n59\n90917\n11\n9776\n36\n639481\n93908\n50963\n561\n59\n4\n10304\n44763\n7596\n1\n857418\n9753\... | |
taco | verifiable_code | https://codeforces.com/problemset/problem/724/B | Solve the following coding problem using the programming language python:
You are given a table consisting of n rows and m columns.
Numbers in each row form a permutation of integers from 1 to m.
You are allowed to pick two elements in one row and swap them, but no more than once for each row. Also, no more than onc... | ```python
def get_perms(perm):
perms = {tuple(perm)}
for i in range(len(perm)):
for j in range(i + 1, len(perm)):
perm_copy = list(perm)
(perm_copy[i], perm_copy[j]) = (perm_copy[j], perm_copy[i])
perms.add(tuple(perm_copy))
return perms
(n, m) = list(map(int, input().split(' ')))
good_perms = get_perms([... | vfc_145011 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/724/B",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 4\n1 3 2 4\n1 3 4 2\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 4\n1 2 3 4\n2 3 4 1\n3 4 1 2\n4 1 2 3\n",
"output": "NO\n",
"type": "stdin_stdout"
... |
taco | verifiable_code | https://codeforces.com/problemset/problem/1175/F | Solve the following coding problem using the programming language python:
You have an array $a_1, a_2, \dots, a_n$.
Let's call some subarray $a_l, a_{l + 1}, \dots , a_r$ of this array a subpermutation if it contains all integers from $1$ to $r-l+1$ exactly once. For example, array $a = [2, 2, 1, 3, 2, 3, 1]$ contai... | ```python
import math
mod = int(1000000007)
i = lambda : map(int, input().split())
n = int(input())
a = [int(x) for x in input().split()]
t = [[0] * 21 for i in range(300005)]
for i in range(n):
t[i][0] = a[i]
def build(n):
for j in range(1, 20):
for i in range(n):
if i + (1 << j) - 1 > n - 1:
break
t[i]... | vfc_145017 | {
"difficulty": "very_hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1175/F",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "8\n2 4 1 3 4 2 1 2\n",
"output": "7\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n1 1 2 1 2\n",
"output": "6\n",
"type": "stdin_stdout"
},
{
"fn_name": null,... |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/number-of-palindromic-strings2706/1 | Solve the following coding problem using the programming language python:
Given two integers N and K, the task is to find the count of palindromic strings of length lesser than or equal to N, with first K characters of lowercase English language, such that each character in a string doesn’t appear more than twice.
Not... | ```python
def rec(N, K, dp):
if N == 0:
return 1
if K == 0:
return 0
if N == 1:
return K
dp[N][K] = rec(N - 2, K - 1, dp) * K
return dp[N][K]
class Solution:
def palindromicStrings(self, N, K):
mod = int(1000000000.0 + 7)
dp = [[0 for i in range(K + 1)] for j in range(N + 1)]
c = 0
for i in range(... | vfc_145021 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/number-of-palindromic-strings2706/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "N = 3, K = 2",
"output": "6",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "N = 4, K = 3",
"output": "18",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://www.codechef.com/problems/PLAYSTR | Solve the following coding problem using the programming language python:
Chef usually likes to play cricket, but now, he is bored of playing it too much, so he is trying new games with strings. Chef's friend Dustin gave him binary strings $S$ and $R$, each with length $N$, and told him to make them identical. However... | ```python
for i in range(int(input())):
a = int(input())
b = input()
c = input()
d = b.count('0')
e = c.count('0')
if d == e:
print('YES')
else:
print('NO')
``` | vfc_145022 | {
"difficulty": "easy",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/PLAYSTR",
"time_limit": "1 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n5\n11000\n01001\n3\n110\n001\n",
"output": "YES\nNO\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/stack-using-two-queues/1 | Solve the following coding problem using the programming language python:
Implement a Stack using two queues q1 and q2.
Example 1:
Input:
push(2)
push(3)
pop()
push(4)
pop()
Output: 3 4
Explanation:
push(2) the stack will be {2}
push(3) the stack will be {2 3}
pop() poped element will be 3 the
stack will be... | ```python
def push(x):
global queue_1
global queue_2
queue_1.append(x)
while queue_2:
val = queue_2.pop(0)
queue_1.append(val)
(queue_1, queue_2) = (queue_2, queue_1)
def pop():
global queue_1
global queue_2
if not queue_2:
return -1
return queue_2.pop(0)
``` | vfc_145026 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/stack-using-two-queues/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": "push",
"input": "push(2)\npush(3)\npop()\npush(4)\npop()",
"output": "3 4",
"type": "function_call"
},
{
"fn_name": "push",
"input": "push(2)\npop()\npop()\npush(3)",
"output": "2 -1",
"type": "function... |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/minimum-notes-required2535/1 | Solve the following coding problem using the programming language python:
An employee's wallet can contain no more than M notes or coins. A boss pays his salary by the minimum notes possible. However the employee may have to leave out some money. Find how much money he has to lose if his original salary is N.
Note: Th... | ```python
class Solution:
def getLoss(self, n, m):
notes = [1000, 500, 100, 50, 20, 10, 5, 2, 1]
count = 0
i = 0
while count < m and n > 0:
if n >= notes[i]:
n = n - notes[i]
count += 1
else:
i += 1
return n
``` | vfc_145027 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/minimum-notes-required2535/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "N = 1712, M = 4",
"output": "12",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "N = 1023, M = 2",
"output": "3",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/sid-and-his-prime-money5736/1 | Solve the following coding problem using the programming language python:
Sid is a superior salesperson. So he gets a task from his boss. The task is that he will be given some number of products say k (All the products are same) and he has to travel N cities [1...N] to sell them. The main objective of the task is tha... | ```python
primes = [2, 3]
class Solution:
def primeMoney(self, arr, n):
maxi = max(arr)
i = primes[-1] + 2
while maxi >= i:
flag = True
for item in primes:
if i % item == 0:
flag = False
break
if flag:
primes.append(i)
i += 2
setti = set(primes)
count = 0
summa = 0
last = ... | vfc_145028 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/sid-and-his-prime-money5736/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "N = 9\nA[] = {4, 2, 3, 5, 1, 6, 7, 8, 9}",
"output": "5 7",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "N = 10\nA[] = {2, 3, 5, 7, 4, 1, 6, 5, 4, 8}",
"output": "4 17",
"type":... |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Ricky has N different balls and John has R different bags. Their teacher Ms.Samara wants them to distribute these N balls into R bags such that each bag gets at least one ball.
Can you find the number of ways of doing so ?
Input:
The one and o... | ```python
'''
# Read input from stdin and provide input before running code
name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
#print 'Hello World!'
from math import factorial
n,k=list(map(int,input().split()))
if n>=k:
f=factorial(n-1)/(factorial(n-k)*factorial(k-1))
print(f%10000007)
else:
print(... | vfc_145029 | {
"difficulty": "unknown_difficulty",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "43 42",
"output": "-1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "8 2",
"output": "42",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "11 23",
... | |
taco | verifiable_code | https://www.hackerrank.com/challenges/game-of-two-stacks/problem | Solve the following coding problem using the programming language python:
Alexa has two stacks of non-negative integers, stack $a[n]$ and stack $b[m]$ where index $0$ denotes the top of the stack. Alexa challenges Nick to play the following game:
In each move, Nick can remove one integer from the top of either stack ... | ```python
import sys
g = int(input().strip())
for a0 in range(g):
(n, m, x) = input().strip().split(' ')
(n, m, x) = [int(n), int(m), int(x)]
a = list(map(int, input().strip().split(' ')))
b = list(map(int, input().strip().split(' ')))
i = 0
while i < len(a) and x >= a[i]:
x -= a[i]
i += 1
ans = i
j = 0
fo... | vfc_145034 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.hackerrank.com/challenges/game-of-two-stacks/problem",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n5 4 10\n4 2 4 6 1\n2 1 8 5\n",
"output": "4\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://www.codechef.com/problems/DOUBLEDDIST | Solve the following coding problem using the programming language python:
You are given N integers \{A_{1}, A_{2}, \ldots, A_{N}\}. Determine whether they can be reordered such that each pair of consecutive differences differ by a factor of 2.
Formally, determine whether there exists a rearrangement of the given inte... | ```python
for _ in range(int(input())):
n = int(input())
a = sorted(list(map(int, input().split())))
l = [a[i + 1] - a[i] for i in range(n - 1)]
c = 0
for i in range(len(l) - 1):
if l[i] == 2 * l[i + 1] or l[i] // 2 == l[i + 1] or 2 * l[i] == l[i + 1]:
c += 1
else:
break
if len(l) - 1 == c:
print('Yes... | vfc_145038 | {
"difficulty": "easy",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/DOUBLEDDIST",
"time_limit": "1 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n3\n5 2 4\n5\n2 1 16 8 4\n5\n97 98 100 96 88\n6\n16 19 18 21 24 22",
"output": "Yes\nYes\nNo\nYes\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://www.hackerrank.com/challenges/text-alignment/problem | Solve the following coding problem using the programming language python:
In Python, a string of text can be aligned left, right and center.
.ljust(width)
This method returns a left aligned string of length width.
>>> width = 20
>>> print 'HackerRank'.ljust(width,'-')
HackerRank----------
.center(width)
This me... | ```python
thickness = int(input())
c = 'H'
for i in range(thickness):
print((c * i).rjust(thickness - 1) + c + (c * i).ljust(thickness - 1))
for i in range(thickness + 1):
print((c * thickness).center(thickness * 2) + (c * thickness).center(thickness * 6))
for i in range((thickness + 2) // 2):
print((c * thickness *... | vfc_145042 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.hackerrank.com/challenges/text-alignment/problem",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n",
"output": " H \n HHH \n HHHHH \n HHHHHHH \nHHHHHHHHH\n HHHHH HHHHH \n HHHHH HHHHH \n HHHHH HHHHH \n HHHHH HHHHH... |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Example
Input
4 4
1 2 3
1 3 3
2 3 3
2 4 3
Output
1 3
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code. | ```python
(N, M) = map(int, input().split())
E0 = []
for i in range(M):
(S, D, C) = map(int, input().split())
E0.append((C, S - 1, D - 1))
E0.sort()
(*parent,) = range(N)
def root(x):
if x == parent[x]:
return x
y = parent[x] = root(parent[x])
return y
def unite(x, y):
px = root(x)
py = root(y)
if px < py:
... | vfc_145046 | {
"difficulty": "unknown_difficulty",
"memory_limit": "268.435456 megabytes",
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "3.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 4\n1 2 3\n1 3 3\n2 3 3\n2 4 6",
"output": "1 6\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 4\n1 2 4\n1 3 3\n2 3 3\n2 4 6",
"output": "3 12\n",
"type": "stdin_stdout"
... | |
taco | verifiable_code | https://codeforces.com/problemset/problem/450/D | Solve the following coding problem using the programming language python:
Jzzhu is the president of country A. There are n cities numbered from 1 to n in his country. City 1 is the capital of A. Also there are m roads connecting the cities. One can go from city ui to vi (and vise versa) using the i-th road, the length... | ```python
import sys
input = sys.stdin.readline
import heapq
(n, m, k) = map(int, input().split())
adj = [[] for _ in range(n + 5)]
for _ in range(m):
(u, v, w) = map(int, input().split())
adj[u].append((v, w))
adj[v].append((u, w))
train = [-1 for _ in range(n + 5)]
ans = 0
dist = [int(1000000000000000.0) for _ in ... | vfc_145050 | {
"difficulty": "hard",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/450/D",
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 5 2\n1 2 100\n2 3 100\n3 4 100\n4 5 20\n2 5 5\n5 50\n4 1\n",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 1 5\n1 2 4\n2 3\n2 5\n2 4\n2 4\n2 5\n",
"output": "4",
... |
taco | verifiable_code | https://codeforces.com/problemset/problem/544/D | Solve the following coding problem using the programming language python:
In some country there are exactly n cities and m bidirectional roads connecting the cities. Cities are numbered with integers from 1 to n. If cities a and b are connected by a road, then in an hour you can go along this road either from city a t... | ```python
from itertools import combinations_with_replacement
from collections import deque
(n, m) = map(int, input().split())
G = [[] for i in range(n)]
for i in range(m):
(x, y) = map(int, input().split())
x -= 1
y -= 1
G[x].append(y)
G[y].append(x)
def BFS(s):
dist = [-1 for i in range(n)]
dist[s] = 0
Q = d... | vfc_145054 | {
"difficulty": "hard",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/544/D",
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 1\n1 2\n1 1 0\n1 2 0\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 0\n1 1 0\n1 1 0\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_na... |
taco | verifiable_code | https://www.codechef.com/problems/EXUNB | Solve the following coding problem using the programming language python:
A tennis tournament is about to take place with $N$ players participating in it.
Every player plays with every other player exactly once and there are no ties. That is, every match has a winner and a loser.
With Naman's birthday approaching, he... | ```python
from math import comb
a = int(input())
for i in range(a):
N = int(input())
matche = comb(N, 2)
win = matche / N
ans = []
if win != int(win):
print('NO')
continue
print('YES')
for k in range(N):
list = []
for j in range(N):
list.append(0)
ans.append(list)
list = []
for k in range(N):
t... | vfc_145058 | {
"difficulty": "medium",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/EXUNB",
"time_limit": "1 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3\n2\n",
"output": "YES\n010\n001\n100\nNO\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Given a set of $N$ axis-aligned rectangular seals, find the number of overlapped seals on the region which has the maximum number of overlapped seals.
Constraints
* $ 1 \leq N \leq 100000 $
* $ 0 \leq x1_i < x2_i \leq 1000 $
* $ 0 \leq y1_i < ... | ```python
from itertools import accumulate
import sys
n = int(input())
ys = [0] * 1001
rects = [None] * 2 * n
i = 0
for line in sys.stdin:
(x1, y1, x2, y2) = [int(j) for j in line.split()]
rects[i] = (x2, -1, y1, y2)
rects[i + n] = (x1, 1, y1, y2)
i += 1
rects.sort(key=lambda x: x[0])
max_overlap = 0
for (x, t, y1,... | vfc_145062 | {
"difficulty": "unknown_difficulty",
"memory_limit": "134.217728 megabytes",
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "1.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n0 0 2 2\n2 0 4 4",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n0 0 1 2\n0 0 2 2\n0 0 2 2",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn... | |
taco | verifiable_code | https://codeforces.com/problemset/problem/1616/D | Solve the following coding problem using the programming language python:
You are given an array of integers $a_1, a_2, \ldots, a_n$ and an integer $x$.
You need to select the maximum number of elements in the array, such that for every subsegment $a_l, a_{l + 1}, \ldots, a_r$ containing strictly more than one elemen... | ```python
for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
x = int(input())
a = [c - x for c in a]
begin = True
unchosen = 0
sum = 0
for i in range(n):
if begin:
sum = a[i]
begin = False
else:
sum += a[i]
if sum < 0:
begin = True
unchosen += 1
else:
... | vfc_145066 | {
"difficulty": "hard",
"memory_limit": "256 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1616/D",
"time_limit": "1.5 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n5\n1 2 3 4 5\n2\n10\n2 4 2 4 2 4 2 4 2 4\n3\n3\n-10 -5 -10\n-8\n3\n9 9 -3\n5\n",
"output": "4\n8\n2\n2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n10\n5 -9 -1 6 -6 5 -6 -8 5 3\n0... |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/faithful-numbers0014/1 | Solve the following coding problem using the programming language python:
A number is called faithful if you can write it as the sum of distinct powers of 7.
e.g., 2457 = 7 + 7^{2} + 7^{4 . }If we order all the faithful numbers, we get the sequence 1 = 7^{0}, 7 = 7^{1}, 8 = 7^{0} + 7^{1}, 49 = 7^{2}, 50 = 7^{0} + 7^... | ```python
class Solution:
def nthFaithfulNum(self, N):
ans = 0
power = 0
while N:
if N & 1:
ans = ans + pow(7, power)
power = power + 1
N = N // 2
return ans
``` | vfc_145071 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/faithful-numbers0014/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "N = 3",
"output": "8",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "N = 7",
"output": "57",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | Solve the following coding problem using the programming language python:
There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on blac... | ```python
from collections import deque
y = [-1, 0, 1, 0]
x = [0, -1, 0, 1]
def main():
(h, w) = (0, 0)
c = []
def check(i, j):
return 0 <= i and i < h and (0 <= j) and (j < w)
def bfs(a, b):
res = 0
d = deque()
d.append([a, b])
f = [[False] * w for _ in range(h)]
while len(d):
(i, j) = d.popleft(... | vfc_145072 | {
"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": "6 9\n....#.\n.....#\n......\n......\n......\n......\n......\n@...#\n.#..#.\n11 9\n.#.........\n.#.#######.\n.#.#.....#.\n.#.#.###.#.\n.#.#..@#.#.\n.#.#####.#.\n.#.......#.\n.#########.\n...........\n11 6\n..#..#..#..\n..#..#..#..\n... | |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/second-largest3735/1 | Solve the following coding problem using the programming language python:
Given an array Arr of size N, print second largest distinct element from an array.
Example 1:
Input:
N = 6
Arr[] = {12, 35, 1, 10, 34, 1}
Output: 34
Explanation: The largest element of the
array is 35 and the second largest element
is 34.
Exam... | ```python
class Solution:
def print2largest(self, arr, n):
if n < 2:
return -1
(largest, second_largest) = (float('-inf'), float('-inf'))
for i in range(n):
if arr[i] > largest:
second_largest = largest
largest = arr[i]
elif arr[i] > second_largest and arr[i] != largest:
second_largest = ar... | vfc_145076 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/second-largest3735/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "N = 6\nArr[] = {12, 35, 1, 10, 34, 1}",
"output": "34",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "N = 3\nArr[] = {10, 5, 10}",
"output": "5",
"type": "stdin_stdout"
}
]... |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Problem Statement
Mr. Takatsuki, who is planning to participate in the Aizu training camp, has a poor house and always tries to save as much paper as possible. She decided to play a ghost leg with other participants to decide the team for the A... | ```python
from itertools import permutations
(N, M) = map(int, input().split())
k = [int(input()) - 1 for i in range(M)]
g = [i for i in range(N)]
for i in range(N):
for j in k:
if g[i] == j:
g[i] = j + 1
elif g[i] == j + 1:
g[i] = j
s = 10
for K in permutations(k):
G = [i for i in range(N)]
for i in range... | vfc_145077 | {
"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": "6 4\n4\n3\n1\n2",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 3\n2\n2\n4",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... | |
taco | verifiable_code | https://codeforces.com/problemset/problem/418/C | Solve the following coding problem using the programming language python:
While resting on the ship after the "Russian Code Cup" a boy named Misha invented an interesting game. He promised to give his quadrocopter to whoever will be the first one to make a rectangular table of size n × m, consisting of positive intege... | ```python
class InputHandlerObject(object):
inputs = []
def getInput(self, n=0):
res = ''
inputs = self.inputs
if not inputs:
inputs.extend(input().split(' '))
if n == 0:
res = inputs[:]
inputs[:] = []
while n > len(inputs):
inputs.extend(input().split(' '))
if n > 0:
res = inputs[:n]
i... | vfc_145081 | {
"difficulty": "very_hard",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/418/C",
"time_limit": "1.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 23\n",
"output": "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 12 \n\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 12 \n\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 12 \n\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 12 \n\n"... |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/maximum-consecutive-ones/1 | Solve the following coding problem using the programming language python:
You are given array nums of n length and an integer k .return the maximum number of consecutive 1's in the array if you can flip at most k 0's.
Example:
Input:
n = 11
nums = [1,1,1,0,0,0,1,1,1,1,0]
k = 2
Output:
6
Explanation:
You can flip 2 0 a... | ```python
class Solution:
def longestOnes(self, n, arr, k):
(left, right) = (0, 0)
zero_count = 0
maxlen = 0
while right < n:
if arr[right] == 1:
right += 1
elif zero_count == k:
zero_count -= 1 - arr[left]
left += 1
else:
zero_count += 1
right += 1
maxlen = max(maxlen, right -... | vfc_145086 | {
"difficulty": "medium",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/maximum-consecutive-ones/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "n = 11\r\nnums = [1,1,1,0,0,0,1,1,1,1,0]\r\nk = 2",
"output": "6",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/475/A | Solve the following coding problem using the programming language python:
The final round of Bayan Programming Contest will be held in Tehran, and the participants will be carried around with a yellow bus. The bus has 34 passenger seats: 4 seats in the last row and 3 seats in remaining rows. [Image]
The event coord... | ```python
k = int(input())
output = ['+------------------------+', '|#.#.#.#.#.#.#.#.#.#.#.|D|)', '|#.#.#.#.#.#.#.#.#.#.#.|.|', '|#.......................|', '|#.#.#.#.#.#.#.#.#.#.#.|.|)', '+------------------------+']
ls = [1, 2, 4, 1, 2, 4, 1, 2, 4, 1, 2, 4, 1, 2, 4, 1, 2, 4, 1, 2, 4, 1, 2, 4, 1, 2, 4, 1, 2, 4, 1, 2,... | vfc_145087 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/475/A",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "9\n",
"output": "+------------------------+\n|O.O.O.#.#.#.#.#.#.#.#.|D|)\n|O.O.O.#.#.#.#.#.#.#.#.|.|\n|O.......................|\n|O.O.#.#.#.#.#.#.#.#.#.|.|)\n+------------------------+\n",
"type": "stdin_stdout"
},... |
taco | verifiable_code | https://codeforces.com/problemset/problem/1506/F | Solve the following coding problem using the programming language python:
Consider an infinite triangle made up of layers. Let's number the layers, starting from one, from the top of the triangle (from top to bottom). The $k$-th layer of the triangle contains $k$ points, numbered from left to right. Each point of an i... | ```python
import os
import math
true = True
false = False
from collections import defaultdict, deque, Counter
from functools import reduce
from heapq import *
is_dev = 'vscode' in os.environ
if is_dev:
inF = open('in.txt', 'r')
outF = open('out.txt', 'w')
def ins():
return list(map(int, input_().split(' ')))
def i... | vfc_145091 | {
"difficulty": "hard",
"memory_limit": "256 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1506/F",
"time_limit": "2 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n3\n1 4 2\n1 3 1\n2\n2 4\n2 3\n2\n1 1000000000\n1 1000000000\n4\n3 10 5 8\n2 5 2 4\n",
"output": "0\n1\n999999999\n2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n3\n1 4 2\n1 3 1\n2... |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Takahashi Lake has a perimeter of L. On the circumference of the lake, there is a residence of the lake's owner, Takahashi. Each point on the circumference of the lake has a coordinate between 0 and L (including 0 but not L), which is the distan... | ```python
(l, n) = [int(item) for item in input().split()]
right = []
left = []
for i in range(n):
a = int(input())
right.append(a)
left.append(l - a)
left.reverse()
rsum = [0] * (n + 1)
lsum = [0] * (n + 1)
for i in range(n):
rsum[i + 1] += rsum[i] + right[i]
lsum[i + 1] += lsum[i] + left[i]
ans = max(right[-1], ... | vfc_145095 | {
"difficulty": "unknown_difficulty",
"memory_limit": "1024.0 megabytes",
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "314159265 7\n21662711\n77271666\n89022761\n156626166\n160332356\n166902656\n453863319",
"output": "1204124749\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6 6\n1\n2\n3\n6\n7\n9",
... | |
taco | verifiable_code | https://codeforces.com/problemset/problem/1143/F | Solve the following coding problem using the programming language python:
Recently Vasya learned that, given two points with different x coordinates, you can draw through them exactly one parabola with equation of type y = x^2 + bx + c, where b and c are reals. Let's call such a parabola an U-shaped one.
Vasya drew s... | ```python
import sys
def cross(o, a, b):
return (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0])
N = int(input())
A = [None] * N
for i in range(N):
(x, y) = map(int, sys.stdin.readline().split())
A[i] = (x, y - x * x)
A.sort()
upper = []
for p in reversed(A):
while len(upper) >= 2 and cross(upper[-2],... | vfc_145099 | {
"difficulty": "very_hard",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1143/F",
"time_limit": "1.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n-751115 -925948\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n-751115 -1566406\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name"... |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/the-and-gate1231/1 | Solve the following coding problem using the programming language python:
Given N bits to an AND - Gate find the output that will be produced.
AND - Gate Table:
1 & 1 = 1
1 & 0 = 0
0 & 1 = 0
0 & 0 = 0
Example 1:
Input:
N = 4
arr: 1 1 1 0
Output:
0
Explanation:
1 & 1 = 1
1 & 1 = 1
1 & 0 = 0
hence output is 0
Example... | ```python
class Solution:
def andGate(self, arr, N):
if 0 in arr:
return 0
return 1
``` | vfc_145103 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/the-and-gate1231/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "N = 4\narr:1 1 1 0",
"output": "0",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "N = 4\narr:0 0 1 0",
"output": "0",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/1430/E | Solve the following coding problem using the programming language python:
You are given a string $s$. You have to reverse it — that is, the first letter should become equal to the last letter before the reversal, the second letter should become equal to the second-to-last letter before the reversal — and so on. For ex... | ```python
def mergeSort(arr, n):
temp_arr = [0] * n
return _mergeSort(arr, temp_arr, 0, n - 1)
def _mergeSort(arr, temp_arr, left, right):
inv_count = 0
if left < right:
mid = (left + right) // 2
inv_count += _mergeSort(arr, temp_arr, left, mid)
inv_count += _mergeSort(arr, temp_arr, mid + 1, right)
inv_co... | vfc_145104 | {
"difficulty": "hard",
"memory_limit": "256 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1430/E",
"time_limit": "2 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\naaaza\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6\ncbaabc\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input... |
taco | verifiable_code | https://atcoder.jp/contests/abc119/tasks/abc119_b | Solve the following coding problem using the programming language python:
Takahashi received otoshidama (New Year's money gifts) from N of his relatives.
You are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either JPY or BTC, and x_i and u_i represent the content of t... | ```python
n = int(input())
btc = 380000.0
a = 0
for _ in range(n):
(x, u) = input().split()
if u == 'JPY':
a += int(x)
elif u == 'BTC':
a += float(x) * btc
print(a)
``` | vfc_145110 | {
"difficulty": "easy",
"memory_limit": "1024.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://atcoder.jp/contests/abc119/tasks/abc119_b",
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n10000 JPY\n0.10000000 BTC\n",
"output": "48000.0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n100000000 JPY\n100.00000000 BTC\n0.00000001 BTC\n",
"output": "138000000.0038\n... |
taco | verifiable_code | https://codeforces.com/problemset/problem/551/A | Solve the following coding problem using the programming language python:
Professor GukiZ likes programming contests. He especially likes to rate his students on the contests he prepares. Now, he has decided to prepare a new contest.
In total, n students will attend, and before the start, every one of them has some ... | ```python
(n, x) = (int(input()), list(map(int, input().split(' '))))
tmp = sorted(x, reverse=True)
for i in x:
print(tmp.index(i) + 1)
``` | vfc_145114 | {
"difficulty": "easy",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/551/A",
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "8\n153 100 87 14 10 8 6 5\n",
"output": "1 2 3 4 5 6 7 8 ",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "70\n11 54 37 62 1 46 13 17 38 47 28 15 63 5 61 34 49 66 32 59 3 41 58 28 23 62 41 64... |
taco | verifiable_code | https://www.codechef.com/problems/TOOLS | Solve the following coding problem using the programming language python:
Like any good boss, the Chef has delegated all cooking jobs to his employees so he can take care of other tasks. Occasionally, one of the cooks needs a tool that is out of reach. In some of these cases, the cook cannot leave their workstation to... | ```python
def dist(pos1: list, pos2: list) -> int:
return abs(pos1[0] - pos2[0]) + abs(pos1[1] - pos2[1])
def list2bin(n: int, lst: list) -> str:
num = 0
for x in lst:
num += 1 << x
return f'{num:08b}'
def pos2str(pos: list) -> str:
return '--'.join(map(str, pos))
def min_chef(chefs: list, tools: list, htools... | vfc_145118 | {
"difficulty": "medium_hard",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/TOOLS",
"time_limit": "0.710216 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n2\n1 0 0 1\n0 0 1 1\n3\n0 3 0 1\n0 4 0 2\n0 5 0 3\n3\n0 1 0 2\n0 1 0 2\n0 1 0 2",
"output": "4\n10\n6",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | Solve the following coding problem using the programming language python:
In the final of CODE FESTIVAL in some year, there are N participants. The height and power of Participant i is H_i and P_i, respectively.
Ringo is hosting a game of stacking zabuton (cushions).
The participants will line up in a row in some or... | ```python
N = int(input())
men = []
for _ in range(N):
(H, P) = map(int, input().split())
men.append((H, P, H + P))
men.sort(key=lambda x: x[2])
maxH = max(men)[0]
inf = maxH + 1
dp = [[-1] * (N + 1) for _ in range(N + 1)]
dp[0][0] = 0
for i in range(1, N + 1):
(h, p, a) = men[i - 1]
for j in range(1, N + 1):
if ... | vfc_145122 | {
"difficulty": "unknown_difficulty",
"memory_limit": "256.0 megabytes",
"memory_limit_bytes": null,
"problem_url": null,
"time_limit": "2.0 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n2 4\n3 1\n4 2",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\n1 3\n8 4\n8 3\n10 1\n6 4\n2 3\n4 2\n9 2\n8 3\n0 1",
"output": "5\n",
"type": "stdin_stdout"
... | |
taco | verifiable_code | https://codeforces.com/problemset/problem/804/E | Solve the following coding problem using the programming language python:
Seyyed and MoJaK are friends of Sajjad. Sajjad likes a permutation. Seyyed wants to change the permutation in a way that Sajjad won't like it. Seyyed thinks more swaps yield more probability to do that, so he makes MoJaK to perform a swap betwee... | ```python
n = int(input())
p = lambda a, b: print(a + 1, b + 1)
if n % 4 > 1:
print('NO')
else:
print('YES')
for i in range(n % 4, n, 4):
for x in range(2):
for j in range(i):
p(j, i + 2 * x)
p(i + 2 * x, i + 2 * x + 1)
for j in range(i, 0, -1):
p(j - 1, i + 2 * x + 1)
p(i, i + 3)
p(i + 1, i +... | vfc_145126 | {
"difficulty": "very_hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/804/E",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n",
... |
taco | verifiable_code | Solve the following coding problem using the programming language python:
Write a program which reads the two dices constructed in the same way as Dice I, and determines whether these two dices are identical. You can roll a dice in the same way as Dice I, and if all integers observed from the six directions are the sa... | ```python
roll_dict = dict(E=(3, 1, 0, 5, 4, 2), W=(2, 1, 5, 0, 4, 3), S=(4, 0, 2, 3, 5, 1), N=(1, 5, 2, 3, 0, 4))
dice1 = list(map(int, input().split()))
dice2 = list(map(int, input().split()))
dices = []
dices.append(dice1)
judge = False
for i in 'EWSN':
dice = dices[0]
new_dice = []
for j in range(6):
new_dice.... | vfc_145132 | {
"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": "1 2 3 2 5 6\n6 5 4 3 2 1",
"output": "No\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 2 3 2 5 6\n6 1 4 3 2 1",
"output": "No\n",
"type": "stdin_stdout"
},
{
... | |
taco | verifiable_code | https://www.codechef.com/IC32016/problems/HBB | Solve the following coding problem using the programming language python:
Humpy, the little elephant, has his birthday coming up. He invited all his cousins but doesn’t know how many of them are really coming as some of them are having exams coming up. He will only get to know how many of them are coming on the day of... | ```python
from sys import stdin, stdout
n = int(stdin.readline())
while n:
n -= 1
(k, l, e) = map(int, stdin.readline().strip().split(' '))
a = map(int, stdin.readline().strip().split(' '))
x = float(l) / float(e + sum(a))
if x - int(x):
stdout.write('NO\n')
else:
stdout.write('YES\n')
``` | vfc_145136 | {
"difficulty": "unknown_difficulty",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/IC32016/problems/HBB",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n4 10 2\n2 2 3 1\n4 12 3\n6 5 7 3\n",
"output": "YES\nNO\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://atcoder.jp/contests/abc174/tasks/abc174_b | Solve the following coding problem using the programming language python:
We have N points in the two-dimensional plane. The coordinates of the i-th point are (X_i,Y_i).
Among them, we are looking for the points such that the distance from the origin is at most D. How many such points are there?
We remind you that the... | ```python
def main():
(N, D) = [int(n) for n in input().split(' ')]
cnt = 0
for i in range(N):
(X, Y) = [int(x) for x in input().split(' ')]
if X ** 2 + Y ** 2 <= D ** 2:
cnt += 1
print(cnt)
main()
``` | vfc_145140 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://atcoder.jp/contests/abc174/tasks/abc174_b",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 5\n0 5\n-2 4\n3 4\n4 -4\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "12 3\n1 1\n1 1\n1 1\n1 1\n1 2\n1 3\n2 1\n2 2\n2 3\n3 1\n3 2\n3 3\n",
"output": "7\n",
... |
taco | verifiable_code | https://www.codechef.com/problems/RRTREE | Solve the following coding problem using the programming language python:
You are given a tree that is built in a following way: initially there is single vertex 1. All the other vertices are added one by one, from vertex 2 to vertex N, by connecting it to one of those that have been added before. You are to find the ... | ```python
def update(M, level, u, v):
level[u] = level[v] + 1
M[u][0] = v
for j in range(1, 18):
if M[u][j - 1]:
M[u][j] = M[M[u][j - 1]][j - 1]
def LCA(M, level, u, v):
if u == v:
return u
if level[u] < level[v]:
(u, v) = (v, u)
for i in range(17, -1, -1):
if M[u][i] and level[M[u][i]] >= level[v]:
... | vfc_145144 | {
"difficulty": "very_hard",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/RRTREE",
"time_limit": "2 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3\n1\n1\n5\n1\n2\n3\n3",
"output": "1\n2\n1\n2\n3\n3",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/641/D | Solve the following coding problem using the programming language python:
Little Artyom decided to study probability theory. He found a book with a lot of nice exercises and now wants you to help him with one of them.
Consider two dices. When thrown each dice shows some integer from 1 to n inclusive. For each dice th... | ```python
def tle():
k = 0
while k >= 0:
k += 1
def quad(a, b, c):
disc = b ** 2 - 4 * a * c
if disc < 0:
disc = 0
disc = disc ** 0.5
return ((-b + disc) / 2 / a, (-b - disc) / 2 / a)
x = int(input())
y = list(map(float, input().strip().split(' ')))
z = list(map(float, input().strip().split(' ')))
py = [0, y... | vfc_145148 | {
"difficulty": "very_hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/641/D",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n0.25 0.75\n0.75 0.25\n",
"output": "0.5 0.5 \n0.5 0.5 \n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n0.125 0.25 0.625\n0.625 0.25 0.125\n",
"output": "0.25 0.25 0.5 \n0.5 0.2... |
taco | verifiable_code | https://codeforces.com/problemset/problem/1374/E1 | Solve the following coding problem using the programming language python:
Easy and hard versions are actually different problems, so read statements of both problems completely and carefully.
Summer vacation has started so Alice and Bob want to play and joy, but... Their mom doesn't think so. She says that they have ... | ```python
(n, k) = map(int, input().split())
a = []
b = []
both = []
for _ in range(n):
(x, y, z) = map(int, input().split())
if y == 1 and z == 1:
both.append(x)
elif y == 1:
a.append(x)
elif z == 1:
b.append(x)
a.sort()
b.sort()
for i in range(min(len(a), len(b))):
both.append(a[i] + b[i])
both.sort()
if l... | vfc_145152 | {
"difficulty": "medium_hard",
"memory_limit": "256 megabytes",
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1374/E1",
"time_limit": "2 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "8 4\n7 1 1\n2 1 1\n4 0 1\n8 1 1\n1 0 1\n1 1 1\n1 0 1\n3 0 0\n",
"output": "18\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 2\n6 0 0\n9 0 0\n1 0 1\n2 1 1\n5 1 0\n",
"output": "8\... |
taco | verifiable_code | https://www.codechef.com/problems/MISREP | Solve the following coding problem using the programming language python:
You are given an array A consisting of N integers.
In one operation, you can:
Choose any two indices i and j (i \neq j);
Subtract min(A_{i} , A_{j}) from both A_{i} and A_{j}. Note that min(A_{i} , A_{j}) denotes the minimum of A_{i} and A_{j}.... | ```python
for _ in range(int(input())):
n = int(input())
a = [int(x) for x in input().split()]
assert len(a) == n
assert all((x > 0 for x in a))
sm = sum(a)
if sm % 2 != 0:
print(-1)
continue
ps_sm = {0: []}
for (i, x) in enumerate(a):
ps_sm_new = ps_sm.copy()
for (v, indices) in ps_sm.items():
if v ... | vfc_145156 | {
"difficulty": "very_hard",
"memory_limit": "50000 bytes",
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/MISREP",
"time_limit": "1 seconds"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n2\n1 1 \n3 \n1 3 1\n4\n1 3 1 3\n",
"output": "1\n1 2\n-1\n2\n1 3\n2 4",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://www.codechef.com/AARA2018/problems/ARMBH4 | Solve the following coding problem using the programming language python:
Ted$Ted$ loves prime numbers. One day he is playing a game called legendary$legendary$ with his girlfriend Robin$Robin$. Ted$Ted$ writes a number N$N$ on a table and the number is in the form of :
N = P1A1 * P2A2 * ……….. * PnAn
Ted$Ted$ asks Ro... | ```python
d = 10 ** 9 + 7
t = int(input())
while t:
t -= 1
n = int(input())
p = list(map(int, input().strip().split()))
a = list(map(int, input().strip().split()))
b = list(map(int, input().strip().split()))
ans = 1
for i in range(n):
c = a[i] - b[i] + 1
tmp = pow(p[i], b[i], d) * ((pow(p[i], c, d) - 1 + d) ... | vfc_145160 | {
"difficulty": "unknown_difficulty",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/AARA2018/problems/ARMBH4",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n3\n2 3 5\n2 1 2\n1 1 1\n",
"output": "540\n",
"type": "stdin_stdout"
}
]
} |
taco | verifiable_code | https://codeforces.com/problemset/problem/828/B | Solve the following coding problem using the programming language python:
Polycarp has a checkered sheet of paper of size n × m. Polycarp painted some of cells with black, the others remained white. Inspired by Malevich's "Black Square", Polycarp wants to paint minimum possible number of white cells with black so that... | ```python
def min_squares(canvas, length, width):
def find_top():
for i in range(length):
for j in range(width):
if canvas[i][j] == 'B':
return i
return -1
def find_left():
for j in range(width):
for i in range(length):
if canvas[i][j] == 'B':
return j
def find_bottom():
for i in r... | vfc_145168 | {
"difficulty": "easy",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/828/B",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 4\nWWWW\nWWWB\nWWWB\nWWBB\nWWWW\n",
"output": "5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 2\nBB\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_n... |
taco | verifiable_code | https://practice.geeksforgeeks.org/problems/7645a18a9015b17f754b7a7e1c7d70825dde6acb/1 | Solve the following coding problem using the programming language python:
There is a one-dimensional garden of length N. In each position of the N length garden, a sprinkler has been installed. Given an array a[]such that a[i] describes the coverage limit of the i^{th} sprinkler. A sprinkler can cover the range from t... | ```python
class Solution:
def minSprinkler(self, arr, N):
coverages = [-1] * N
for (i, a) in enumerate(arr):
min_coverage = max(0, i - a)
max_coverage = min(i + a, N - 1)
coverages[min_coverage] = max(coverages[min_coverage], max_coverage)
needed_sprinklers_count = 0
current_coverage = -1
next_max_... | vfc_145172 | {
"difficulty": "medium_hard",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://practice.geeksforgeeks.org/problems/7645a18a9015b17f754b7a7e1c7d70825dde6acb/1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "a[] = {1, 2, 1}",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "a[] = {2, 1, 1, 2, 1}",
"output": "2",
"type": "stdin_stdout"
}
]
} |
Subsets and Splits
Random Hard Python Problems
Retrieves a random sample of 10 hard difficulty questions along with their answers and problem IDs, providing basic filtering but limited analytical value.