source stringclasses 4
values | task_type stringclasses 1
value | in_source_id stringlengths 0 138 | problem stringlengths 219 13.2k | gold_standard_solution stringlengths 0 413k | problem_id stringlengths 5 10 | metadata dict | verification_info dict |
|---|---|---|---|---|---|---|---|
code_contests | verifiable_code | 360_B. Levko and Array | Solve the following coding problem using the programming language python:
Levko has an array that consists of integers: a1, a2, ... , an. But he doesn’t like this array at all.
Levko thinks that the beauty of the array a directly depends on value c(a), which can be calculated by the formula:
<image> The less value ... | vfc_36441 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 2\n4 7 4 7 4\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6 3\n1 2 3 7 8 9\n",
"output": "1\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 383_E. Vowels | Solve the following coding problem using the programming language python:
Iahubina is tired of so many complicated languages, so she decided to invent a new, simple language. She already made a dictionary consisting of n 3-words. A 3-word is a sequence of exactly 3 lowercase letters of the first 24 letters of the Engl... | vfc_36445 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 4, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\nabc\naaa\nada\nbcd\ndef\n",
"output": "0\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 404_D. Minesweeper 1D | Solve the following coding problem using the programming language python:
Game "Minesweeper 1D" is played on a line of squares, the line's height is 1 square, the line's width is n squares. Some of the squares contain bombs. If a square doesn't contain a bomb, then it contains a number from 0 to 2 — the total number o... | ```python
Mod=1000000007
s=input()
n=len(s)
a,b,c,d=1,0,0,0
for i in range(0,n):
if s[i]=='*':
t=0,a+b+d,0,0
elif s[i]=='?':
t=a+b+c,a+b+d,0,0
elif s[i]=='0':
t=0,0,a+c,0
elif s[i]=='1':
t=0,0,b,a+c
else:
t=0,0,0,b+d
a,b,c,d=map(lambda a:a%Mod,t)
print((a+... | vfc_36449 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "?01???\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "**12\n... |
code_contests | verifiable_code | 431_E. Chemistry Experiment | Solve the following coding problem using the programming language python:
One day two students, Grisha and Diana, found themselves in the university chemistry lab. In the lab the students found n test tubes with mercury numbered from 1 to n and decided to conduct an experiment.
The experiment consists of q steps. On ... | vfc_36453 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 4, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 5\n1 3 0 1\n2 3\n2 1\n1 3 2\n2 3\n2 4\n",
"output": "1.6666666669\n1.0000000014\n2.3333333345\n2.6666666672\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 3\n1 2 0\n2 2\n1 2 1\n2 3\n"... | |
code_contests | verifiable_code | 454_B. Little Pony and Sort by Shift | Solve the following coding problem using the programming language python:
One day, Twilight Sparkle is interested in how to sort a sequence of integers a1, a2, ..., an in non-decreasing order. Being a young unicorn, the only operation she can perform is a unit shift. That is, she can move the last element of the seque... | ```python
def us_num(nums):
where = None
for idx, (a, na) in enumerate(zip(nums[:-1], nums[1:])):
if a > na:
if where is None:
where = idx
else:
return -1
if where is None:
return 0
elif nums[-1] > nums[0]:
return -1
return len(nums) - 1 - where
n = int(input())
nums =... | vfc_36457 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 3 2\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n1 2\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input":... |
code_contests | verifiable_code | 476_E. Dreamoon and Strings | Solve the following coding problem using the programming language python:
Dreamoon has a string s and a pattern string p. He first removes exactly x characters from s obtaining string s' as a result. Then he calculates <image> that is defined as the maximal number of non-overlapping substrings equal to p that can be f... | ```python
s, p = input(), input()
n, m = len(s) + 1, len(p)
d = [[0] * n for t in range(n)]
for x in range(1, n):
i, j = x, m
while i and j:
j -= s[i - 1] == p[j - 1]
i -= 1
if not j:
for y in range(i + 1): d[x][y + x - i - m] = d[i][y] + 1
for y in range(x): d[x][y] = max(d[x][y... | vfc_36461 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "axbaxxb\nab\n",
"output": "0 1 1 2 1 1 0 0 \n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 4_A. Watermelon | Solve the following coding problem using the programming language python:
One hot summer day Pete and his friend Billy decided to buy a watermelon. They chose the biggest and the ripest one, in their opinion. After that the watermelon was weighed, and the scales showed w kilos. They rushed home, dying of thirst, and d... | ```python
x=int(input())
y=x-2
if y%2==0 and y!=0:
print("YES")
else :
print("NO")
``` | vfc_36465 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 64000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "8\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n",
"output": "NO\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 524_F. And Yet Another Bracket Sequence | Solve the following coding problem using the programming language python:
Polycarpus has a finite sequence of opening and closing brackets. In order not to fall asleep in a lecture, Polycarpus is having fun with his sequence. He is able to perform two operations:
* adding any bracket in any position (in the beginni... | vfc_36469 | {
"difficulty": "12",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 5, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "()(())\n",
"output": "(())()\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "()(\n",
"output": "(())\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input... | |
code_contests | verifiable_code | 550_A. Two Substrings | Solve the following coding problem using the programming language python:
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
Input
The only line of input contains a string s of length between 1 and 105 co... | ```python
a = input()
b = a
f1=0
f2=0
if(a.find('AB')!=-1):
a = a.replace('AB', 'C', 1)
if(a.find('BA')!=-1):
f1=1
if(b.find('BA')!=-1):
b = b.replace('BA', 'C', 1)
if(b.find('AB')!=-1):
f2=1
if(f1==0 and f2==0):
print("NO")
else:
print("YES")
``` | vfc_36473 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "ABA\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "AXBYBXA\n",
"output": "NO\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 577_B. Modulo Sum | Solve the following coding problem using the programming language python:
You are given a sequence of numbers a1, a2, ..., an, and a number m.
Check if it is possible to choose a non-empty subsequence aij such that the sum of numbers in this subsequence is divisible by m.
Input
The first line contains two numbers, ... | ```python
n,x=map(int,input().split())
a=set()
for i in input().split():
i=int(i)
b=set()
for j in a: b.add((i+j)%x)
a|=b
a.add(i%x)
if 0 in a:
print("YES")
break
else:
print("NO")
``` | vfc_36477 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 6\n3 1 1 3\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 6\n5\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"i... |
code_contests | verifiable_code | 599_E. Sandy and Nuts | Solve the following coding problem using the programming language python:
Rooted tree is a connected graph without any simple cycles with one vertex selected as a root. In this problem the vertex number 1 will always serve as a root.
Lowest common ancestor of two vertices u and v is the farthest from the root vertex ... | vfc_36481 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 0 1\n3 4 2\n",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 1 0\n1 2\n",
"output": "2",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 620_D. Professor GukiZ and Two Arrays | Solve the following coding problem using the programming language python:
Professor GukiZ has two arrays of integers, a and b. Professor wants to make the sum of the elements in the array a sa as close as possible to the sum of the elements in the array b sb. So he wants to minimize the value v = |sa - sb|.
In one op... | ```python
from bisect import bisect_left
n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
sum_a, sum_b = sum(a), sum(b)
delta = sum_b - sum_a
ans = abs(delta)
ans_swap = []
for i in range(n):
for j in range(m):
if abs((sum_a - a[i] + b[j]) - (sum_b ... | vfc_36485 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n1 2 3 4 5\n4\n1 2 3 4\n",
"output": "1\n1\n3 1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n1 2 3 4 5\n1\n15\n",
"output": "0\n0\n",
"type": "stdin_stdout"
},
... |
code_contests | verifiable_code | 641_C. Little Artem and Dance | Solve the following coding problem using the programming language python:
Little Artem is fond of dancing. Most of all dances Artem likes rueda — Cuban dance that is danced by pairs of boys and girls forming a circle and dancing together.
More detailed, there are n pairs of boys and girls standing in a circle. Initia... | ```python
import io, os, sys
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
n, q = map(int, input().split())
pos = [i for i in range(n)]
cnt, temp, flag = 0, [0, 0], 0
for _ in range(q):
p = list(map(int, input().split()))
if p[0] == 1:
x = (n + p[1]) % n
cnt = cnt + x
... | vfc_36489 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 3\n1 1\n2\n1 -2\n",
"output": "1 2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 2\n2\n1 3\n",
"output": "1 4 3 2\n",
"type": "stdin_stdout"
},
{
"fn_name":... |
code_contests | verifiable_code | 66_A. Petya and Java | Solve the following coding problem using the programming language python:
Little Petya has recently started attending a programming club. Naturally he is facing the problem of choosing a programming language. After long considerations he realized that Java is the best choice. The main argument in favor of choosing Jav... | ```python
n= int(input())
if(n<=127):
print("byte")
elif(n<=32767):
print("short")
elif(n<=2147483647):
print("int")
elif(n<=9223372036854775807):
print("long")
else:
print("BigInteger")
``` | vfc_36493 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "123456789101112131415161718192021222324\n",
"output": "BigInteger\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "127\n",
"output": "byte\n",
"type": "stdin_stdout"
},
... |
code_contests | verifiable_code | 690_F1. Tree of Life (easy) | Solve the following coding problem using the programming language python:
Heidi has finally found the mythical Tree of Life – a legendary combinatorial structure which is said to contain a prophecy crucially needed to defeat the undead armies.
On the surface, the Tree of Life is just a regular undirected tree well-kn... | ```python
n = int(input())
a = [0]*(n+1)
for _ in range(n-1):
x, y = input().split(' ')
x, y = [int(x), int(y)]
a[x] += 1
a[y] += 1
too = 0
for x in a:
too += (x * (x-1))//2
print(too)
``` | vfc_36497 | {
"difficulty": "12",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n1 2\n1 3\n1 4\n",
"output": "3\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 715_C. Digit Tree | Solve the following coding problem using the programming language python:
ZS the Coder has a large tree. It can be represented as an undirected connected graph of n vertices numbered from 0 to n - 1 and n - 1 edges between them. There is a single nonzero digit written on each edge.
One day, ZS the Coder was bored and... | vfc_36501 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6 7\n0 1 2\n4 2 4\n2 0 1\n3 0 9\n2 5 7\n",
"output": "7\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 11\n1 2 3\n2 0 3\n3 0 3\n4 3 3\n",
"output": "8\n",
"type": "stdin_std... | |
code_contests | verifiable_code | 735_E. Ostap and Tree | Solve the following coding problem using the programming language python:
Ostap already settled down in Rio de Janiero suburb and started to grow a tree in his garden. Recall that a tree is a connected undirected acyclic graph.
Ostap's tree now has n vertices. He wants to paint some vertices of the tree black such t... | ```python
def main():
n, k = map(int, input().split())
cnt = [[[0] * 21 for _ in (0, 1)] for _ in range(n + 1)]
edges, mod = [[] for _ in range(n + 1)], 1000000007
for _ in range(n - 1):
u, v = map(int, input().split())
edges[u].append(v)
edges[v].append(u)
def dfs(u, f):
... | vfc_36505 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "7 2\n1 2\n2 3\n1 4\n4 5\n1 6\n6 7\n",
"output": "91\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 1\n1 2\n2 3\n3 4\n",
"output": "9\n",
"type": "stdin_stdout"
},
{
... |
code_contests | verifiable_code | 75_E. Ship's Shortest Path | Solve the following coding problem using the programming language python:
You have got a new job, and it's very interesting, you are a ship captain. Your first task is to move your ship from one point to another point, and for sure you want to move it at the minimum cost.
And it's well known that the shortest distanc... | vfc_36509 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "-1 0 2 0\n4\n0 0 1 0 1 1 0 1\n",
"output": "3.0000000100\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 7 6 7\n4\n4 2 4 12 3 12 3 2\n",
"output": "5.9999999800\n",
"type": "... | |
code_contests | verifiable_code | 780_D. Innokenty and a Football League | Solve the following coding problem using the programming language python:
Innokenty is a president of a new football league in Byteland. The first task he should do is to assign short names to all clubs to be shown on TV next to the score. Of course, the short names should be distinct, and Innokenty wants that all sho... | ```python
from collections import defaultdict
names = int(input())
inp = [input().split() for x in range(names)]
choice = []
res = defaultdict(lambda: [])
for x, word in enumerate(inp):
choice.append(False)
res[word[0][:3]].append(x)
while True:
changes = []
for key in res.keys():
if len(res[ke... | vfc_36513 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\nABC DEF\nABC EFG\nABD OOO\n",
"output": "YES\nABD\nABE\nABO\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 804_A. Find Amir | Solve the following coding problem using the programming language python:
A few years ago Sajjad left his school and register to another one due to security reasons. Now he wishes to find Amir, one of his schoolmates and good friends.
There are n schools numerated from 1 to n. One can travel between each pair of them... | ```python
n = int(input())
print(int((n + 1) / 2) - 1)
``` | vfc_36517 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10\n",
"output": "4\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 850_B. Arpa and a list of numbers | Solve the following coding problem using the programming language python:
Arpa has found a list containing n numbers. He calls a list bad if and only if it is not empty and gcd (see notes section for more information) of numbers in the list is 1.
Arpa can perform two types of operations:
* Choose a number and dele... | vfc_36525 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10 6 2\n100 49 71 73 66 96 8 60 41 63\n",
"output": "10\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 873_D. Merge Sort | Solve the following coding problem using the programming language python:
Merge sort is a well-known sorting algorithm. The main function that sorts the elements of array a with indices from [l, r) can be implemented as follows:
1. If the segment [l, r) is already sorted in non-descending order (that is, for any i ... | ```python
def fun(arr,l,r,cnt,k,flag):
if cnt[0]==k:
flag[0]+=1
return
if l==r-1:
return
m=(l+r)//2
arr[m],arr[m-1]=arr[m-1],arr[m]
if flag[0]==0:
cnt[0]+=2
fun(arr,l,m,cnt,k,flag)
if flag[0]==0:
fun(arr,m,r,cnt,k,flag)
n,k=list(map(i... | vfc_36529 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 3\n",
"output": "3 1 2 \n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 899_C. Dividing the numbers | Solve the following coding problem using the programming language python:
Petya has n integers: 1, 2, 3, ..., n. He wants to split these integers in two non-empty groups in such a way that the absolute difference of sums of integers in each group is as small as possible.
Help Petya to split the integers. Each of n i... | ```python
n = int(input())
if n == 3:
print(0)
print(2, 1, 2)
quit()
start = 1
if n % 2 != 0:
start = 2
end = n // 2
if end % 2 != 0:
end -= 1
a = [k for k in range(start, n + 1)]
b = a[::-1]
# print(a)
# print(b)
c = []
d = []
step = True
for k in range(end):
if step:
c.append(a[... | vfc_36533 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n",
"output": "1\n1 1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n",
"output": "0\n2 4 1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3... |
code_contests | verifiable_code | 91_D. Grocer's Problem | Solve the following coding problem using the programming language python:
Yesterday was a fair in a supermarket's grocery section. There were n jars with spices on the fair. Before the event the jars were numbered from 1 to n from the left to the right. After the event the jars were moved and the grocer had to sort th... | vfc_36537 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6\n3 5 6 1 2 4\n",
"output": "2\n4\n1 3 6 4\n3 6 4 1\n2\n2 5\n5 2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "14\n9 13 11 3 10 7 12 14 1 5 4 6 8 2\n",
"output": "3\n4\n2 13 8 14\... | |
code_contests | verifiable_code | 948_B. Primal Sport | Solve the following coding problem using the programming language python:
Alice and Bob begin their day with a quick game. They first choose a starting number X0 ≥ 3 and try to reach one million by the process described below.
Alice goes first and then they take alternating turns. In the i-th turn, the player whose ... | ```python
import math,sys,bisect,heapq
from collections import defaultdict,Counter,deque
from itertools import groupby,accumulate
#sys.setrecursionlimit(200000000)
int1 = lambda x: int(x) - 1
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda: map(int,input().split())
alele = lambda: li... | vfc_36541 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 500000000}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "8192\n",
"output": "8191\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "20\n",
"output": "15\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "14\... |
code_contests | verifiable_code | 976_B. Lara Croft and the New Game | Solve the following coding problem using the programming language python:
You might have heard about the next game in Lara Croft series coming out this year. You also might have watched its trailer. Though you definitely missed the main idea about its plot, so let me lift the veil of secrecy.
Lara is going to explore... | ```python
import sys
n,m,k=map(int,input().split())
if(k<n):
print(k+1,1)
sys.exit()
k-=n
x=n-(k)//(m-1)
if(x%2==0):
y=k%(m-1)+2
else:
y=m-k%(m-1)
print(x,y)
``` | vfc_36545 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 3 0\n",
"output": "1 1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 3 7\n",
"output": "3 2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": ... |
code_contests | verifiable_code | 995_F. Cowmpany Cowmpensation | Solve the following coding problem using the programming language python:
Allen, having graduated from the MOO Institute of Techcowlogy (MIT), has started a startup! Allen is the president of his startup. He also hires n-1 other employees, each of which is assigned a direct superior. If u is a superior of v and v is a... | vfc_36549 | {
"difficulty": "12",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 5\n1\n",
"output": "15\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 2\n1\n1\n",
"output": "5\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | balanced-strings | Solve the following coding problem using the programming language python:
Balance strings, by definition, are the strings that contain all the characters of the alphabet, from a to z, equal no of times.
eg- abcdefghijklmnopqrstuvwxyz is a balanced string, aabb is not.
Input:
First line contains number of test cases T... | ```python
from collections import Counter
i=0
N=input()
while i<N:
st=raw_input()
d=Counter([j for j in st])
if len(d)==26 and len(set(d.values()))==1:
print 'Yes'
else:
print 'No'
i+=1
``` | vfc_36553 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\ncodemyca\nabcdefghijklmnopqrstuvwxyz\n\nSAMPLE",
"output": "No\nYes\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\ncodemyba\nabcdefghijklmnopqrstuvwxyz\n\nSAMPLE",
"output": "... |
code_contests | verifiable_code | circle-intersection | Solve the following coding problem using the programming language python:
Tom is solving an IQ quiz in which he is stuck in a question which says that there are two circles whose center coordinates and radius are given. Now Tom has to find whether the two circles overlap, do not overlap or are tangential with each oth... | ```python
import math
def centredist(x1, y1, x2, y2):
return math.sqrt(((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2)));
x1, y1, r1 = map(int, raw_input().split());
x2, y2, r2 = map(int, raw_input().split());
d = centredist(x1, y1, x2, y2);
if(d == (r1 + r2)): print "T";
elif(d < (r1 + r2)): print "Y";
else: print "... | vfc_36557 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "100 60 52 \n200 90 45\n\nSAMPLE",
"output": "N",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "25 35 5\n25 45 5",
"output": "T",
"type": "stdin_stdout"
},
{
"fn_nam... |
code_contests | verifiable_code | emma-and-the-prime-sum | Solve the following coding problem using the programming language python:
Emma is fond of prime numbers. Emma’s teacher gave her an interesting problem to solve.
The problem is as follows:
The teacher gave Emma 2 positive integers x and y(x ≤ y).
She asked Emma to find the sum of all the prime numbers between x and ... | ```python
def mysieve(n):
for i in xrange(2, n):
if i * i <= n and not prime[i]:
for j in xrange(i * i, n, i):
prime[j] = 1
def comp():
for i in xrange(2, n):
if not prime[i]:
pre[i] = pre[i-1] + i
else:
pre[i] = pre[i - 1]
n = 1000... | vfc_36561 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 10\n2 6\n5 10\n\nSAMPLE",
"output": "17\n10\n12",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1000\n870 978\n946 984\n767 801\n456 840\n112 402\n665 818\n610 676\n773 942\n177 295\n28... |
code_contests | verifiable_code | hello-brother | Solve the following coding problem using the programming language python:
Dean is watching movie while his younger brother Sam comes and says that he is having difficulty in solving a problem given for homework by his math teacher. Now his older brother Dean who is good in programming asks him to tell the question. Sa... | ```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!'
n,m=map(int,raw_input().split())
l=[int(i) for i in raw_input().split()]
if m in l:
print "1"
else:
print"0"
``` | vfc_36565 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 20\n10 20 30 40 50\n\nSAMPLE",
"output": "1\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | lucky-sequence | Solve the following coding problem using the programming language python:
Lets call a string which is composed of only 4 and 7 a Lucky String. For example,
47, 444, 44744 are all Lucky Strings of length 2, 3 and 5 respectively, while 45, 767 are not Lucky Strings. Now, consider a sorted list of all the Lucky Strings ... | ```python
def count(n):
i=0
n+=1
while(n!=0):
n/=2
i+=1
return i-1
k=int(raw_input())
while(k>0):
a=""
k-=1
n=int(raw_input())
c=count(n)
lb=(2**c)-1
ub=lb*2
while(lb<ub):
mid=(lb+ub)/2
if(n>mid):
a+="7"
lb=mid+1
else:
a+="4"
ub=mid
print a
``` | vfc_36569 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1\n5\n11\n\nSAMPLE",
"output": "4\n74\n744",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | navi-and-beer-1 | Solve the following coding problem using the programming language python:
Navi is at the Beer Bar where he has ordered N beers. After seeing his love with the beers, Bar's Manager has decided to make as much money as they can by asking Navi to pay K * i^3 Rupees for the i^th beer. But Navi has only M Rupees in his pu... | ```python
'''
# Read input from stdin and provide input before running code
name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
t = input()
while(t>0):
n,k,m = map(int,raw_input().split())
sum = (n*(n+1))/2
sum*=sum
sum*=k
if(sum>m): print sum-m
else: print 0
t-=1
``` | vfc_36573 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n2 2 10\n\nSAMPLE",
"output": "8\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n2 3 10\n\nSAMPLE",
"output": "17\n",
"type": "stdin_stdout"
},
{
"fn_name": ... |
code_contests | verifiable_code | problem-of-bilocation | Solve the following coding problem using the programming language python:
Anurag is posed with a very serious problem. He will be in London during the summers from days [ a,b ] for an internship. But he also wants to attend the ACM-ICPC World Finals with his team to be held in Thailand during [ c,d ] days. The opening... | ```python
t=input()
while t:
t-=1
a,b,c,d,S = map(int, raw_input().split())
if c<=a or (a+S)>c:
print 'STAY IN LONDON'
elif (b+S)<c:
# print (b-a+1)
print b
else:
x = c-S
if a<=x<=b:
# print (x-a+1)
print x
else:
print 'STAY IN LONDON'
``` | vfc_36577 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1 14 15 20 2\n13 14 15 20 3\n\nSAMPLE",
"output": "13\nSTAY IN LONDON\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n1 14 15 20 2\n13 14 29 20 3\n\nSAMPLE",
"output": "13\n14\... |
code_contests | verifiable_code | sharmas-area-logic-2 | Solve the following coding problem using the programming language python:
Harry has been tracking Draco Malfoy throughtout the year on the
Marauder's Map. But suddenly one day, Harry could not locate Draco on the map. Now he decides to search the entire map. But since the
Marauder's map is of the entire Hogwarts scho... | ```python
from sys import stdin
def area():
for t in xrange(input()):
n = input()
a = []
b = []
for j in xrange(n):
x,y = map(int,raw_input().split())
a.append(x)
b.append(y)
t1 = min(a)
t2 = max(a)
t3 = min(b)
t4 = ... | vfc_36581 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2\n1 1\n3 3\n3\n1 1\n2 2\n2 3\n\nSAMPLE",
"output": "4\n2",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | the-best-internet-browser-3 | Solve the following coding problem using the programming language python:
In the race for the best Internet browser, there's now a new contender for it, this browser is called the: "The Semantic Mind-Reader!" After its promo on the world wide web, everyone's been desperately waiting for the browser to be released. And... | ```python
t=input()
vovels=['a','e','i','o','u']
for i in range(0,t):
inputstr=raw_input()
inputlen=len(inputstr)
reqstr=inputstr[4:inputlen-3]
reqlist=list(reqstr)
count=0
for i in range(0,len(reqlist)):
if(reqlist[i] in vovels):
c... | vfc_36585 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\nwww.google.com\nwww.hackerearth.com\n\nSAMPLE",
"output": "7/14\n11/19\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100\nwww.oazqupphakywpbqyfajsmgwcfcxuaaarpxhsyiljjzehrmifcxaldbffn... |
code_contests | verifiable_code | xenny-and-counting | Solve the following coding problem using the programming language python:
Xynazog was playing a game. He needed to score k points and he could play at most N moves and at least 1 move. In each move, he could get [0,k] points. Note: the number of points gained is always an integer.
Xynazog's friend PowerShell challeng... | ```python
import math
t=input()
while t>0:
n,k=map(int,raw_input().split())
print math.factorial(k+n-1)/(math.factorial(k)*math.factorial(n-1))
t=t-1
``` | vfc_36589 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n2 2\n\nSAMPLE",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10000\n17 16\n16 2\n6 17\n16 17\n15 18\n10 6\n15 14\n10 17\n11 1\n7 3\n12 18\n9 8\n15 3\n12 5\n14 18\n3 8\n1... |
code_contests | verifiable_code | p00068 Enclose Pins with a Rubber Band | Solve the following coding problem using the programming language python:
Hit n nails one by one at the coordinates P1 (x1, y1), P2 (x2, y2), P3 (x3, y3), ..., Pn (xn, yn) on the flat plate, and put them on the rubber band ring. Surround it with a single rubber band so that all the nails fit inside. At this time, the ... | ```python
# AOJ 0068 Enclose Pins with a Rubber Band
# Python3 2018.6.22 bal4u
def cross(a, b):
return a.real*b.imag - a.imag*b.real
# 凸包 入力: 座標リスト リターン:凸包を構成する座標リスト
def convex_hull(p):
pp = sorted(p, key=lambda x:(x.imag,x.real)) # y座標を優先して昇順、同じならx座標で昇順
n = len(pp)
ans, j = [0]*(n+1), 0
for i in range(n):
w... | vfc_36633 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n1.0,0.0\n0.0,1.0\n2.0,1.0\n1.0,2.0\n9\n-509.94,892.63\n567.62,639.99\n-859.32,-64.84\n-445.99,383.69\n667.54,430.49\n551.12,828.21\n-940.2,-877.2\n-361.62,-970\n-125.42,-178.48\n0",
"output": "0\n3",
"type": "stdin_s... |
code_contests | verifiable_code | p00714 Water Tank | Solve the following coding problem using the programming language python:
Mr. Denjiro is a science teacher. Today he has just received a specially ordered water tank that will certainly be useful for his innovative experiments on water flow.
<image>
---
Figure 1: The water tank
The size of the tank is 100cm (Width) ... | ```python
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
N = int(readline())
W = [(0, 50)]
for i in range(N):
b, h = map(int, readline().split())
W.append((b, h))
W.append((100, 50))
M = int(readline())
S = [0]*(N+1)
Q = []
for i in range(... | vfc_36649 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n5\n15 40\n35 20\n50 45\n70 30\n80 10\n3\n20 3\n60 2\n65 2\n6\n40 4100\n25 7500\n10 18000\n90 7000\n25 15000\n25 22000\n5\n15 40\n35 20\n50 45\n70 30\n80 10\n2\n60 4\n75 1\n3\n60 6000\n75 6000\n85 6000",
"output": "0.666667... |
code_contests | verifiable_code | p00854 And Then There Was One | Solve the following coding problem using the programming language python:
Let’s play a stone removing game.
Initially, n stones are arranged on a circle and numbered 1, ... , n clockwise (Figure 1). You are also given two numbers k and m. From this state, remove stones one by one following the rules explained below, ... | ```python
while True :
n, k, m = map(int, input().split())
if n == 0 and k == 0 and m == 0 :
break
stone = []
for i in range(n) :
stone.append(i+1)
i = m-1
while True :
del stone[i]
if len(stone) == 1 :
break
i += k-1
if i... | vfc_36653 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 8, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "8 5 3\n100 9999 98\n10000 10000 10000\n0 0 0",
"output": "1\n93\n2019",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "12 5 3\n100 9999 98\n10000 10000 10000\n0 0 0",
"output": "11\n93\... |
code_contests | verifiable_code | p01255 Webby Subway | Solve the following coding problem using the programming language python:
You are an officer of the Department of Land and Transport in Oykot City. The department has a plan to build a subway network in the city central of Oykot.
In the plan, n subway lines are built, and each line has two or more stations. Because o... | vfc_36665 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 8, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2\n0 0\n10 0\n2\n0 10\n10 10\n2\n2\n0 0\n10 10\n2\n0 10\n10 0\n3\n2\n0 0\n10 10\n2\n0 10\n10 0\n2\n1 0\n1 10\n0",
"output": "1\n2\n3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n2\n... | |
code_contests | verifiable_code | p01570 Usoperanto | Solve the following coding problem using the programming language python:
Usoperanto is an artificial spoken language designed and regulated by Usoperanto Academy. The academy is now in study to establish Strict Usoperanto, a variation of the language intended for formal documents.
In Usoperanto, each word can modify... | vfc_36673 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 262144000,
"problem_url": null,
"time_limit": "{'seconds': 8, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n3 -1\n4 0\n5 0",
"output": "4",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | p01732 Trodden Cable | Solve the following coding problem using the programming language python:
Nathan O. Davis is running a company. His company owns a web service which has a lot of users. So his office is full of servers, routers and messy LAN cables.
He is now very puzzling over the messy cables, because they are causing many kinds of... | vfc_36677 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 268435456,
"problem_url": null,
"time_limit": "{'seconds': 5, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 3 1\n1 1 3 3\n0 0\n1 RRDDLLUU",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 3 0\n1 1 3 3\n0 0\n1 RRDDLLUU",
"output": "0\n",
"type": "stdin_stdout"
},
... | |
code_contests | verifiable_code | p01870 Relay | Solve the following coding problem using the programming language python:
Problem statement
There is a village called Biwako, which consists of $ N $ islets floating on the lake. Biwako Village has a simple bridge with $ N-1 $ books. The islands are numbered from $ 0 $ to $ N-1 $, and the bridges are numbered from $ ... | vfc_36681 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 536870912,
"problem_url": null,
"time_limit": "{'seconds': 4, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n0 1\n0 2\n0 3\n0 4",
"output": "9",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n0 1\n0 2\n0 3\n0 6",
"output": "11\n",
"type": "stdin_stdout"
},
{
"fn_name"... | |
code_contests | verifiable_code | p02007 Prefix Suffix Search | Solve the following coding problem using the programming language python:
As an English learner, sometimes you cannot remember the entire spelling of English words perfectly, but you can only remember their prefixes and suffixes. For example, you may want to use a word which begins with 'appr' and ends with 'iate', bu... | ```python
from bisect import bisect
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def construct(N, S, base, MOD):
L = 26
root = [0, 0, N-1, [None]*L]
nds = [root]
for i, s in enumerate(S):
node = root
for c in s:
h, a, b, nt = node
if nt[c] is... | vfc_36685 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 536870912,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "7 4\nconnected\ndisconnected\ngraph\ndirected\ndiameter\ndistance\nminor\nc ed\ndi ed\ndis ed\ndis e",
"output": "1\n2\n1\n1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6 7\nappreciate\n... |
code_contests | verifiable_code | p02292 Counter-Clockwise | Solve the following coding problem using the programming language python:
<image>
For given three points p0, p1, p2, print
COUNTER_CLOCKWISE
if p0, p1, p2 make a counterclockwise turn (1),
CLOCKWISE
if p0, p1, p2 make a clockwise turn (2),
ONLINE_BACK
if p2 is on a line p2, p0, p1 in this order (3),
ONL... | ```python
x0,y0,x1,y1 = map(int, input().split())
p0=complex(x0,y0)
p1=complex(x1,y1)
q = int(input())
CCW = {1: 'COUNTER_CLOCKWISE',
-1: 'CLOCKWISE',
2: 'ONLINE_BACK',
-2: 'ONLINE_FRONT',
0: 'ON_SEGMENT',}
def dot(a, b):
return a.real * b.real + a.imag * b.imag
def cross(a, b):
retur... | vfc_36693 | {
"difficulty": "0",
"memory_limit": null,
"memory_limit_bytes": 134217728,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "0 0 2 0\n3\n-1 0\n0 0\n3 0",
"output": "ONLINE_BACK\nON_SEGMENT\nONLINE_FRONT",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | anuthm | Solve the following coding problem using the programming language python:
Problem description
As a holiday gift, Tojo received a probability problem. The problem read as follows
Consider an N by M grid. Rows are numbered 1 to N, from top to bottom. Columns are numbered 1 to M, from left to right. You are initially at ... | ```python
t=int(raw_input())
while(t>0):
t-=1
n,m=[int(i) for i in raw_input().split()]
print ("%.6f" % (n+m-1))
``` | vfc_36701 | {
"difficulty": "2",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2 2\n1 6",
"output": "3.000000\n6.000000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n1 2\n1 6",
"output": "2.0\n6.0\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | chrl2 | Solve the following coding problem using the programming language python:
Chef likes playing with strings. The most interesting game are named "CHEF in string". The move of the game consists of the following: Chef takes a subsequence of string's letters that form the word "CHEF" and then he removes that symbols. The g... | ```python
chef = raw_input()
def find_index(chef, index):
c1,h1,e1,f1 = index
c = chef.find('C', c1+1)
if c<0:
return None
h = chef.find('H', max(c+1, h1+1))
if h<0:
return None
e = chef.find('E', max(h+1, e1+1))
if e<0:
return None
f = chef.find('F', max(e+1, f1... | vfc_36705 | {
"difficulty": "1",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "CHEFCHEFFFF",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "CHHHEEEFFCC",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"inpu... |
code_contests | verifiable_code | error | Solve the following coding problem using the programming language python:
Lots of geeky customers visit our chef's restaurant everyday. So, when asked to fill the feedback form, these customers represent the feedback using a binary string (i.e a string that contains only characters '0' and '1'.
Now since chef is not ... | ```python
# your code goes here
t=int(raw_input())
while t>0:
s=str(raw_input())
f1=s.find('010')
f2=s.find('101')
if f1>-1 and f2>-1:
print "Good"
elif (f1 > -1 and f2== -1) or (f1==-1 and f2 > -1):
print "Good"
else:
print "Bad"
t=t-1
``` | vfc_36709 | {
"difficulty": "2",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n11111110\n10101010101010",
"output": "Bad\nGood\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n11101110\n10101010101010",
"output": "Good\nGood\n",
"type": "stdin_stdout... |
code_contests | verifiable_code | ksum | Solve the following coding problem using the programming language python:
Chef likes arrays a lot. Today, he found an array A consisting of N positive integers.
Let L denote the sorted (in non-increasing order) list of size N*(N+1)/2 containing the sums of all possible contiguous subarrays of A. Chef is interested in ... | ```python
import math
import heapq
def parseIntList(str):
return [long(x) for x in str.split()]
def printBS(li):
if len(li) is 0:
print
else:
for i in range(len(li)-1):
print li[i],
print li[-1]
n,k=parseIntList(raw_input())
li=parseIntList(raw_input())
s=0
for i in range(n):
s+=li[i]
hp=[[-s,1,n]]
res=[]
... | vfc_36713 | {
"difficulty": "2",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 3\n10 2 7",
"output": "19 12 10",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | stablemp | Solve the following coding problem using the programming language python:
There are given n men and n women.
Each woman ranks all men in order of her preference
(her first choice, her second choice, and so on).
Similarly, each man sorts all women according to
his preference. The goal is to arrange n
marriages in such ... | ```python
from sys import stdin
from cStringIO import StringIO
def main():
inp = iter(StringIO(stdin.read())).next
t = int(inp())
for _ in xrange(t):
n = int(inp())
w = {}
m = {}
freem = set([`i+1` for i in xrange(n)])
freew = set([`i+1` for i in xrange(n)])
... | vfc_36721 | {
"difficulty": "3",
"memory_limit": null,
"memory_limit_bytes": 0,
"problem_url": null,
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n4\n1 4 3 1 2\n2 2 1 3 4\n3 1 3 4 2\n4 4 3 1 2\n1 3 2 4 1\n2 2 3 1 4\n3 3 1 2 4\n4 3 2 4 1\n7\n1 3 4 2 1 6 7 5\n2 6 4 2 3 5 1 7\n3 6 3 5 7 2 4 1\n4 1 6 3 2 4 7 5\n5 1 6 5 3 4 7 2\n6 1 7 3 4 5 6 2\n7 5 6 2 4 3 7 1\n1 4 5 3 7 2 6 1... |
code_contests | verifiable_code | 1007_C. Guess two numbers | Solve the following coding problem using the programming language python:
This is an interactive problem.
Vasya and Vitya play a game. Vasya thought of two integers a and b from 1 to n and Vitya tries to guess them. Each round he tells Vasya two numbers x and y from 1 to n. If both x=a and y=b then Vitya wins. Else V... | vfc_36725 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n3\n3\n2\n1\n0",
"output": "4 3\n3 4\n3 3\n1 5\n2 4",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 1030_C. Vasya and Golden Ticket | Solve the following coding problem using the programming language python:
Recently Vasya found a golden ticket — a sequence which consists of n digits a_1a_2... a_n. Vasya considers a ticket to be lucky if it can be divided into two or more non-intersecting segments with equal sums. For example, ticket 350178 is lucky... | ```python
n = int(input())
s = input()
arr = list()
arr.append(int(s[0]))
summ = arr[0]
bigflg = False
for i in range(1,len(s)):
arr.append(int(s[i]))
summ+=arr[i]
for i in range(2,len(s)+1):
if summ % i == 0:
amount = summ / i
sm = 0
flg = True
for j in range(len(arr)):
... | vfc_36729 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n1248\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n73452\n",
"output": "YES\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1053_A. Vasya and Triangle | Solve the following coding problem using the programming language python:
Vasya has got three integers n, m and k. He'd like to find three integer points (x_1, y_1), (x_2, y_2), (x_3, y_3), such that 0 ≤ x_1, x_2, x_3 ≤ n, 0 ≤ y_1, y_2, y_3 ≤ m and the area of the triangle formed by these points is equal to nm/k.
Hel... | ```python
from math import gcd
def tfit(n, m, No, Mo):
if (n < m) != (No < Mo):
n, m = m, n
if n > No or m > Mo:
return -1, -1
return n, m
def sv():
N, M, K = map(int, input().split())
No = N
Mo = M
x = gcd(N, K)
N //= x
K //= x
x = gcd(M, K)
M //= x
K //= x
if K > 2:
print('NO')
return
elif K == ... | vfc_36733 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 4 7\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 3 3\n",
"output": "YES\n0 0\n4 0\n0 2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
code_contests | verifiable_code | 1075_B. Taxi drivers and Lyft | Solve the following coding problem using the programming language python:
Palo Alto is an unusual city because it is an endless coordinate line. It is also known for the office of Lyft Level 5.
Lyft has become so popular so that it is now used by all m taxi drivers in the city, who every day transport the rest of the... | ```python
n, m = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
t = [int(i) for i in input().split()]
ti = [k for k in range(n + m) if t[k] == 1]
pi = [k for k in range(n + m) if t[k] == 0]
tc = [0] * (m + n)
tc[ti[0]] += ti[0]
tc[ti[m-1]] += m + n - 1 - ti[m-1]
for i in range(m-1):
ti1 = t... | vfc_36737 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1 4\n2 4 6 10 15\n1 1 1 1 0\n",
"output": "0 0 0 1\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1096_C. Polygon for the Angle | Solve the following coding problem using the programming language python:
You are given an angle ang.
The Jury asks You to find such regular n-gon (regular polygon with n vertices) that it has three vertices a, b and c (they can be non-consecutive) with \angle{abc} = ang or report that there is no such n-gon.
<imag... | ```python
import math
t=int(input())
for e in range(t):
n=int(input())
g=math.gcd(n,180)
p=n//g
q=180//g
if n==180 or n==0: print(-1)
else:
if p==q-1: print(2*q)
else: print(q)
``` | vfc_36741 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n54\n50\n2\n178\n",
"output": "10\n18\n90\n180\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n179\n",
"output": "360\n",
"type": "stdin_stdout"
},
{
"fn_nam... |
code_contests | verifiable_code | 1117_D. Magic Gems | Solve the following coding problem using the programming language python:
Reziba has many magic gems. Each magic gem can be split into M normal gems. The amount of space each magic (and normal) gem takes is 1 unit. A normal gem cannot be split.
Reziba wants to choose a set of magic gems and split some of them, so the... | ```python
import sys
MOD = 10**9+7
def mult(A,B):
n = len(A)
C = []
for x in range(n):
c = [0]*n
for z in range(n):
b = B[x][z]
a = A[z]
for y in range(n):
c[y] += a[y]*b
for y in range(n):
c[y]%=MOD
C.append(c... | vfc_36745 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 2\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 2\n",
"output": "5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1000000... |
code_contests | verifiable_code | 1143_F. U2 | 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[... | vfc_36749 | {
"difficulty": "12",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n-1 0\n0 2\n1 0\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n1 0\n1 -1\n0 -1\n-1 0\n-1 -1\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
... |
code_contests | verifiable_code | 1163_E. Magical Permutation | Solve the following coding problem using the programming language python:
Kuro has just learned about permutations and he is really excited to create a new permutation type. He has chosen n distinct positive integers and put all of them in a set S. Now he defines a magical permutation to be:
* A permutation of inte... | ```python
def size(k):
return int(math.log2(k))
def v2(k):
if k%2==1:
return 0
else:
return 1+v2(k//2)
n=int(input())
s=list(map(int,input().split()))
import math
s.sort()
used=[]
use=0
found={0:1}
good=0
for guy in s:
big=size(guy)
if guy not in found:
used.append(guy)
... | vfc_36753 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n1\n",
"output": "1\n0 1 ",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n20\n",
"output": "0 \n0",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input":... |
code_contests | verifiable_code | 1184_B1. The Doctor Meets Vader (Easy) | Solve the following coding problem using the programming language python:
Heidi and Doctor Who hopped out of the TARDIS and found themselves at EPFL in 2018. They were surrounded by stormtroopers and Darth Vader was approaching. Miraculously, they managed to escape to a nearby rebel base but the Doctor was very confus... | ```python
def bs(num):
low=0
high=b-1
while low<high:
mid=(low+high)//2
if bases[mid][0]<=num:low=mid+1
else:high=mid-1
if bases[low][0]<=num:return low
else:return low-1
n,b=map(int,input().split())
ar=list(map(int,input().split()))
bases=[];summ=0
for i in range(b):
bases.appen... | vfc_36757 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 4, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 4\n1 3 5 2 4\n0 1\n4 2\n2 8\n9 4\n",
"output": "1 9 11 9 11 ",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 1\n789675559\n140424908 1264\n",
"output": "1264 ",
"type": "stdi... |
code_contests | verifiable_code | 1202_A. You Are Given Two Binary Strings... | Solve the following coding problem using the programming language python:
You are given two binary strings x and y, which are binary representations of some two integers (let's denote these integers as f(x) and f(y)). You can choose any integer k ≥ 0, calculate the expression s_k = f(x) + f(y) ⋅ 2^k and write the bina... | ```python
for _ in range(int(input())):
x=input()[::-1]
y=input()[::-1]
posy=y.index('1')
posx=x.index('1',posy)
print(posx-posy)
``` | vfc_36761 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n1010\n11\n10001\n110\n1\n1\n1010101010101\n11110000\n",
"output": "1\n3\n0\n0\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1219_F. Guarding warehouses | Solve the following coding problem using the programming language python:
Bob Bubblestrong just got a new job as security guard. Bob is now responsible for safety of a collection of warehouses, each containing the most valuable Bubble Cup assets - the high-quality bubbles. His task is to detect thieves inside the ware... | vfc_36765 | {
"difficulty": "12",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n4 1 1 1 3 3 3 3 1\n4 4 3 6 2 6 0 4 0\n6 -5 3 -4 4 -3 4 -2 3 -3 2 -4 2\n3 0 -1 1 -3 -1 -3\n4 1 -4 1 -6 -1 -6 -1 -4\n",
"output": "13.333333333333\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"i... | |
code_contests | verifiable_code | 1244_A. Pens and Pencils | Solve the following coding problem using the programming language python:
Tomorrow is a difficult day for Polycarp: he has to attend a lectures and b practical classes at the university! Since Polycarp is a diligent student, he is going to attend all of them.
While preparing for the university, Polycarp wonders wheth... | ```python
import math
t=eval(input())
while t>0:
a,b,c,d,k=map(int,input().split())
x=math.ceil(a/c)
y=k-x
flag=0
if y*d<b or y<0:
flag=1
if flag==1:
print(-1)
else:
print(x,y)
t-=1
``` | vfc_36769 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n7 5 4 5 8\n7 5 4 5 2\n20 53 45 26 4\n",
"output": "2 1\n-1\n1 3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n53 36 13 3 18\n",
"output": "5 12\n",
"type": "stdin_stdou... |
code_contests | verifiable_code | 1263_E. Editor | Solve the following coding problem using the programming language python:
The development of a text editor is a hard problem. You need to implement an extra module for brackets coloring in text.
Your editor consists of a line with infinite length and cursor, which points to the current character. Please note that it ... | ```python
'''input
11
(R)R(R)Ra)c
'''
# MODIFIED SEGMENT TREE (MIN = MINIMUM PREFIX SUM instead of MINIMUM ELEMENT IN PREFIX)
class SegmentTree:
def __init__(self, n, arr=[]):
self.n = n
self.tsum = [0] * (2 * n)
self.tmin = [0] * (2 * n)
self.tmax = [0] * (2 * n)
if arr:
... | vfc_36773 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "11\n(R)R(R)Ra)c\n",
"output": "-1 -1 1 1 -1 -1 1 1 1 -1 1 ",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "11\n(RaRbR)L)L(\n",
"output": "-1 -1 -1 -1 -1 -1 1 1 -1 -1 2 ",
"type":... |
code_contests | verifiable_code | 1285_A. Mezo Playing Zoma | Solve the following coding problem using the programming language python:
Today, Mezo is playing a game. Zoma, a character in that game, is initially at position x = 0. Mezo starts sending n commands to Zoma. There are two possible commands:
* 'L' (Left) sets the position x: =x - 1;
* 'R' (Right) sets the positi... | ```python
def func(n):
x = input()
ans = 0
l_counter = x.count('L')
r_counter = x.count('R')
y = 0 - l_counter
z = 0 + r_counter
for i in range(y,z+1):
ans += 1
print(ans)
n = int(input())
func(n)
``` | vfc_36777 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\nLRLR\n",
"output": "5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "12\nLLLLLLLLLLLL\n",
"output": "13\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1304_C. Air Conditioner | Solve the following coding problem using the programming language python:
Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it.
Gildong tries so hard to satisfy the customers that he even memorized all customers' preferred temperature ... | ```python
for tc in range(int(input())):
n,m=map(int, input().split())
a=b=m
m=0
fl=1
for tccc in range(n):
t,l,h=map(int, input().split())
a-=(t-m)
b+=(t-m)
m=t
if a<l:
a=l
if b>h:
b=h
if a>b:
fl=0
prin... | vfc_36781 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n3 0\n5 1 2\n7 3 5\n10 -1 0\n2 12\n5 7 10\n10 16 20\n3 -100\n100 0 0\n100 -50 50\n200 100 100\n1 100\n99 -100 0\n",
"output": "YES\nNO\nYES\nNO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"inp... |
code_contests | verifiable_code | 1348_D. Phoenix and Science | Solve the following coding problem using the programming language python:
Phoenix has decided to become a scientist! He is currently investigating the growth of bacteria.
Initially, on day 1, there is one bacterium with mass 1.
Every day, some number of bacteria will split (possibly zero or all). When a bacterium of... | ```python
import sys
stdin = sys.stdin
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
def solve():
n = ni()
da = n.bit_length() - 1
print(da)
n -= da + 1
f = [... | vfc_36789 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n9\n11\n2\n",
"output": "3\n1 0 2\n3\n1 2 0\n1\n0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n9\n11\n2\n",
"output": "3\n1 0 2\n3\n1 2 0\n1\n0\n",
"type": "stdin_stdou... |
code_contests | verifiable_code | 1369_B. AccurateLee | Solve the following coding problem using the programming language python:
Lee was cleaning his house for the party when he found a messy string under the carpets. Now he'd like to make it clean accurately and in a stylish way...
The string s he found is a binary string of length n (i. e. string consists only of 0-s a... | ```python
for _ in range(int(input())):
n=int(input())
s=input()
stack=[]
for i in range(n-1,-1,-1):
num=s[i]
#print(num)
if num=='0':
stack.append(num)
else:
if len(stack)==0:
stack.append(num)
... | vfc_36793 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n10\n0001111111\n4\n0101\n8\n11001101\n10\n1110000000\n1\n1\n",
"output": "0001111111\n001\n01\n0\n1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n10\n0001111111\n4\n0101\n8\n110011... |
code_contests | verifiable_code | 1391_A. Suborrays | Solve the following coding problem using the programming language python:
A permutation of length n is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation (2 appears twice in the array) and [1,3,4] is also not a permutat... | ```python
import sys
input = sys.stdin.readline
from collections import *
for _ in range(int(input())):
n = int(input())
print(*[i for i in range(1, n+1)])
``` | vfc_36797 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1\n3\n7\n",
"output": "1\n1 2 3\n1 2 3 4 5 6 7\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n77\n",
"output": "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 ... |
code_contests | verifiable_code | 1413_D. Shurikens | Solve the following coding problem using the programming language python:
Tenten runs a weapon shop for ninjas. Today she is willing to sell n shurikens which cost 1, 2, ..., n ryo (local currency). During a day, Tenten will place the shurikens onto the showcase, which is empty at the beginning of the day. Her job is ... | ```python
import sys, math
import io, os
#data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
from itertools import permutations,combinations
def... | vfc_36801 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n- 1\n+\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n+\n+\n+\n- 2\n- 1\n- 3\n",
"output": "NO\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 1431_G. Number Deletion Game | Solve the following coding problem using the programming language python:
Alice and Bob play a game. They have a set that initially consists of n integers. The game is played in k turns. During each turn, the following events happen:
1. firstly, Alice chooses an integer from the set. She can choose any integer exce... | vfc_36805 | {
"difficulty": "13",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 2\n3 4 1 5 2\n",
"output": "\n4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7 3\n101 108 200 1 201 109 100\n",
"output": "\n283\n",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 152_C. Pocket Book | Solve the following coding problem using the programming language python:
One day little Vasya found mom's pocket book. The book had n names of her friends and unusually enough, each name was exactly m letters long. Let's number the names from 1 to n in the order in which they are written.
As mom wasn't home, Vasya d... | ```python
mod=10**9+7
n,m=map(int,input().split())
mat=[]
for _ in range(n):
s=input()
mat.append(s)
b=ord("A")
s=[False]*255
res=1
for j in range(m):
for i in range(b,b+26):
s[i]=False
for i in range(n):
s[ord(mat[i][j])]=True
r=0
for i in range(b,b+26):
if(s[i]):r+=1
res*=r
print(res%mod)
``` | vfc_36821 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 3\nAAB\nBAA\n",
"output": "4\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 160_E. Buses and People | Solve the following coding problem using the programming language python:
The main Bertown street is represented by a straight line. There are 109 bus stops located on the line. The stops are numbered with integers from 1 to 109 in the order in which they follow on the road. The city has n buses. Every day the i-th bu... | vfc_36825 | {
"difficulty": "11",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1 1\n1 1000000000 1000000000\n1 1000000000 1000000000\n",
"output": "1 ",
"type": "stdin_stdout"
}
]
} | |
code_contests | verifiable_code | 203_C. Photographer | Solve the following coding problem using the programming language python:
Valera's lifelong ambition was to be a photographer, so he bought a new camera. Every day he got more and more clients asking for photos, and one day Valera needed a program that would determine the maximum number of people he can serve.
The ca... | ```python
n, d = map(int, input().split())
d1, d2 = map(int, input().split())
arr = [0] * n
for i in range(n):
a, b = map(int, input().split())
arr[i] = [d1*a + d2*b, i+1]
arr.sort()
res, idx = 0, ''
for i in arr:
if d - i[0] < 0:
break
d -= i[0]
res += 1
idx += str(i[1]) + ' '
print(res... | vfc_36833 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 10\n2 3\n1 4\n2 1\n1 0\n",
"output": "2\n3 2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 6\n6 6\n1 1\n1 0\n1 0\n",
"output": "1\n2\n",
"type": "stdin_stdout"
},
... |
code_contests | verifiable_code | 228_B. Two Tables | Solve the following coding problem using the programming language python:
You've got two rectangular tables with sizes na × ma and nb × mb cells. The tables consist of zeroes and ones. We will consider the rows and columns of both tables indexed starting from 1. Then we will define the element of the first table, loca... | ```python
def mi():
return map(int, input().split())
def mi1():
return map(int, list(input()))
'''
3 2
01
10
00
2 3
001
111
'''
na, ma = mi()
a = [0]*na
for i in range(na):
a[i] = list(mi1())
nb, mb = mi()
b = [0]*nb
for i in range(nb):
b[i] = list(mi1())
ans = -10**10
ax, ay = 0, 0
n, m... | vfc_36837 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 2\n01\n10\n00\n2 3\n001\n111\n",
"output": "0 1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 3\n000\n010\n000\n1 1\n1\n",
"output": "-1 -1\n",
"type": "stdin_stdout"
... |
code_contests | verifiable_code | 277_A. Learning Languages | Solve the following coding problem using the programming language python:
The "BerCorp" company has got n employees. These employees can use m approved official languages for the formal correspondence. The languages are numbered with integers from 1 to m. For each employee we have the list of languages, which he knows... | ```python
from sys import stdin,stdout
input = stdin.readline
def main():
n, m = map(int,input().split())
sets = list(range(n+1+m))
sizes = [1]*(n+1+m)
def get(a):
if sets[a] != a:
sets[a] = get(sets[a])
return sets[a]
def union(a, b):
a = get(a)
b = get... | vfc_36845 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "8 7\n0\n3 1 2 3\n1 1\n2 5 4\n2 6 7\n1 3\n2 7 4\n1 1\n",
"output": "2",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 29_C. Mail Stamps | Solve the following coding problem using the programming language python:
One day Bob got a letter in an envelope. Bob knows that when Berland's post officers send a letter directly from city «A» to city «B», they stamp it with «A B», or «B A». Unfortunately, often it is impossible to send a letter directly from the c... | ```python
n=int(input())
d={}
for i in range(n):
a,b=map(int,input().split())
if a in d:
d[a].append(b)
else:
d[a]=[b]
if b in d:
d[b].append(a)
else:
d[b]=[a]
ans=[]
for el in d:
if len(d[el])==1:
ans.append(el)
root=el
break
cur=r... | vfc_36849 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1 100\n100 2\n",
"output": "1 100 2 \n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 323_A. Black-and-White Cube | Solve the following coding problem using the programming language python:
You are given a cube of size k × k × k, which consists of unit cubes. Two unit cubes are considered neighbouring, if they have common face.
Your task is to paint each of k3 unit cubes one of two colours (black or white), so that the following c... | ```python
k=int(input())
if k%2==1:
print(-1)
else:
for i in range(k):
for j in range(k):
a=''
for l in range(k):
a+='bw'[(i//2+j+l//2)%2]
print(a)
if i<k-1:
print()
``` | vfc_36853 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 0, 'nanos': 500000000}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n",
"output": "bb\nbb\n\nww\nww\n\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"in... |
code_contests | verifiable_code | 415_C. Mashmokh and Numbers | Solve the following coding problem using the programming language python:
It's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh.
In this game Mashmokh writes sequence of n distinct integers on the board. Then Bimokh makes several (possibly zero) moves. On the first move he removes the ... | ```python
n,k=map(int,input().split())
if n//2>k or (k!=0 and n==1):
print(-1)
exit(0)
ans=[0]*n
ans[0]=k-n//2+1
if n>1:
ans[1]=2*ans[0]
for i in range(2,n):
ans[i]=ans[i-1]+1
print(*ans)
``` | vfc_36869 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 3",
"output": "2 4 5 6 7\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 442_A. Borya and Hanabi | Solve the following coding problem using the programming language python:
Have you ever played Hanabi? If not, then you've got to try it out! This problem deals with a simplified version of the game.
Overall, the game has 25 types of cards (5 distinct colors and 5 distinct values). Borya is holding n cards. The game ... | ```python
input()
p = {(1 << 'RGBYW'.index(c)) + (1 << int(k) + 4) for c, k in input().split()}
print(min(bin(t).count('1') for t in range(1024) if len({t & q for q in p}) == len(p)))
# Made By Mostafa_Khaled
``` | vfc_36873 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\nB1 Y1 W1 G1 R1\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\nG4 R4 R3 B3\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null... |
code_contests | verifiable_code | 488_A. Giga Tower | Solve the following coding problem using the programming language python:
Giga Tower is the tallest and deepest building in Cyberland. There are 17 777 777 777 floors, numbered from - 8 888 888 888 to 8 888 888 888. In particular, there is floor 0 between floor - 1 and floor 1. Every day, thousands of tourists come ... | ```python
n = int(input())+1
nword = str(n)
count = 1
while("8" not in nword):
n+=1
nword = str(n)
count += 1
print(count)
``` | vfc_36881 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "18\n",
"output": "10\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "179\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "-1\n",
... |
code_contests | verifiable_code | 536_A. Tavas and Karafs | Solve the following coding problem using the programming language python:
Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs.
<image>
Each Karafs has a positive integer height. Tavas has ... | ```python
#------------------------template--------------------------#
import os
import sys
from math import *
from collections import *
# from fractions import *
# from heapq import*
from bisect import *
from io import BytesIO, IOBase
def vsInput():
sys.stdin = open('input.txt', 'r')
sys.stdout = open('output.... | vfc_36889 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1 5 2\n1 5 10\n2 7 4\n",
"output": "1\n2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 1 4\n1 5 3\n3 3 10\n7 10 2\n6 4 8\n",
"output": "4\n-1\n8\n-1\n",
"type": "stdin_stdo... |
code_contests | verifiable_code | 560_B. Gerald is into Art | Solve the following coding problem using the programming language python:
Gerald bought two very rare paintings at the Sotheby's auction and he now wants to hang them on the wall. For that he bought a special board to attach it to the wall and place the paintings on the board. The board has shape of an a1 × b1 rectang... | ```python
check = lambda ax, ay, bx, by, cx, cy : bx + cx <= ax and max(by, cy) <= ay
inp = lambda : map(int, input().split())
x1, y1 = inp()
x2, y2 = inp()
x3, y3 = inp()
if check(x1, y1, x2, y2, x3, y3) or check(y1, x1, x2, y2, x3, y3) or check(x1, y1, y2, x2, x3, y3) or check(y1, x1, y2, x2, x3, y3) or check(x1, y1,... | vfc_36893 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 2\n1 3\n2 1\n",
"output": "Yes\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 5\n3 3\n3 3\n",
"output": "No\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
code_contests | verifiable_code | 586_D. Phillip and Trains | Solve the following coding problem using the programming language python:
The mobile application store has a new game called "Subway Roller".
The protagonist of the game Philip is located in one end of the tunnel and wants to get out of the other one. The tunnel is a rectangular field consisting of three rows and n c... | ```python
T = int(input())
for t in range(T):
n, k = map(int, input().split(' ')[:2])
s = ["","",""]
for i in range(3):
s[i] = input()
s[0] += '.' * (n*3)
s[1] += '.' * (n*3)
s[2] += '.' * (n*3)
def top():
return [s[0][0] != '.', s[1][0] != '.', s[2][0] != '.']
def sh... | vfc_36897 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n16 4\n...AAAAA........\ns.BBB......CCCCC\n........DDDDD...\n16 4\n...AAAAA........\ns.BBB....CCCCC..\n.......DDDDD....\n",
"output": "YES\nNO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"inpu... |
code_contests | verifiable_code | 62_D. Wormhouse | Solve the following coding problem using the programming language python:
Arnie the Worm has finished eating an apple house yet again and decided to move. He made up his mind on the plan, the way the rooms are located and how they are joined by corridors. He numbered all the rooms from 1 to n. All the corridors are bi... | ```python
from collections import deque
def readint(): return int(raw_input())
def readarray(foo): return [foo(x) for x in raw_input().split()]
def ok(to, s, t):
if s == t:
if len(to[s]) % 2 != 0: return False
else:
if len(to[s]) % 2 == 0: return False
left = 0
for u in xrange(0, len(to)):
l = len(to[u])
... | vfc_36905 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 3\n1 2 3 1\n",
"output": "1 3 2 1 \n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 3\n1 3 2 1\n",
"output": "No solution\n",
"type": "stdin_stdout"
},
{
"fn_n... |
code_contests | verifiable_code | 656_C. Without Text | Solve the following coding problem using the programming language python:
<image>
You can preview the image in better quality by the link: [http://assets.codeforces.com/files/656/without-text.png](//assets.codeforces.com/files/656/without-text.png)
Input
The only line of the input is a string (between 1 and 50 char... | ```python
s = input()
alpha = "abcdefghijklmnopqrstuvwxyz.0123456789"
res = 0
for c in s:
x1 = int('@' < c and '[' > c)
x2 = alpha.index(c.lower()) + 1
x3 = int('`' < c and '{' > c)
x4 = x1 * x2
x5 = x2 * x3
x6 = x4 - x5
res += x6
print(res)
``` | vfc_36909 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 64000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "APRIL.1st\n",
"output": "17\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "Codeforces\n",
"output": "-87\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 67_C. Sequence of Balls | Solve the following coding problem using the programming language python:
You are given a sequence of balls A by your teacher, each labeled with a lowercase Latin letter 'a'-'z'. You don't like the given sequence. You want to change it into a new sequence, B that suits you better. So, you allow yourself four operation... | vfc_36913 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 4 10 3\nab\nba\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 1 1 1\nyoushouldnot\nthoushaltnot\n",
"output": "5\n",
"type": "stdin_stdout"
},
{
... | |
code_contests | verifiable_code | 702_C. Cellular Network | Solve the following coding problem using the programming language python:
You are given n points on the straight line — the positions (x-coordinates) of the cities and m points on the same line — the positions (x-coordinates) of the cellular towers. All towers work in the same way — they provide cellular network for a... | ```python
import bisect
import sys
EPS = sys.float_info.epsilon
LENGTH = 10
matrix = [[] for i in range(LENGTH)]
array = [0] * LENGTH
if __name__ == "__main__":
n, m = map(int, sys.stdin.readline().split())
a = list(map(int, sys.stdin.readline().split()))
b = list(map(int, sys.stdin.readline().split()))... | vfc_36917 | {
"difficulty": "9",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 2\n-2 2 4\n-3 0\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 3\n1 5 10 14 17\n4 11 15\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn... |
code_contests | verifiable_code | 724_D. Dense Subsequence | Solve the following coding problem using the programming language python:
You are given a string s, consisting of lowercase English letters, and the integer m.
One should choose some symbols from the given string so that any contiguous subsegment of length m has at least one selected symbol. Note that here we choose ... | ```python
from collections import Counter
from string import ascii_lowercase as asc
m, s = int(input()), input()
g = Counter(s)
def solve(c):
p = 0
for q in ''.join(x if x >= c else ' ' for x in s).split():
i, j = 0, -1
while j + m < len(q):
j = q.rfind(c, j + 1, j + m + 1)
... | vfc_36921 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\ncbabc\n",
"output": "a",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\nbcabcbaccba\n",
"output": "aaabb",
"type": "stdin_stdout"
},
{
"fn_name": null,
"... |
code_contests | verifiable_code | 746_D. Green and Black Tea | Solve the following coding problem using the programming language python:
Innokentiy likes tea very much and today he wants to drink exactly n cups of tea. He would be happy to drink more but he had exactly n tea bags, a of them are green and b are black.
Innokentiy doesn't like to drink the same tea (green or black)... | ```python
n,k,a,b = [int(i) for i in input().split()]
check = False
if (a>b):
a,b = b,a
check = True
res = ""
cr = 1
cA = True
while (a > 0 or b > 0):
if (a==b):
break
#print(a,b)
if (cr==1):
if a <= b:
u = min(k, b - a)
b -= u
res += u * '1'
... | vfc_36925 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 1 3 2\n",
"output": "GBGBG",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7 2 2 5\n",
"output": "BBGBBGB",
"type": "stdin_stdout"
},
{
"fn_name": null,
"in... |
code_contests | verifiable_code | 769_D. k-Interesting Pairs Of Integers | Solve the following coding problem using the programming language python:
Vasya has the sequence consisting of n integers. Vasya consider the pair of integers x and y k-interesting, if their binary representation differs from each other exactly in k bits. For example, if k = 2, the pair of integers x = 5 and y = 3 is ... | ```python
from collections import defaultdict
n, k = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
A_dict = defaultdict(int)
for i in A:
A_dict[i] += 1
def bitCount(x):
cur = 0
while x > 0:
if x % 2:
cur += 1
x //= 2
return cur
mask = []
for i in ... | vfc_36929 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6 0\n200 100 100 100 200 200\n",
"output": "6\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 1\n0 3 2 1\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_na... |
code_contests | verifiable_code | 793_D. Presents in Bankopolis | Solve the following coding problem using the programming language python:
Bankopolis is an incredible city in which all the n crossroads are located on a straight line and numbered from 1 to n along it. On each crossroad there is a bank office.
The crossroads are connected with m oriented bicycle lanes (the i-th lane... | ```python
import sys
from functools import lru_cache
input = sys.stdin.readline
# sys.setrecursionlimit(2 * 10**6)
def inpl():
return list(map(int, input().split()))
@lru_cache(maxsize=None)
def recur(v, s, e, k):
"""
vから初めて[s, e]の都市をk個まわる最小値は?
"""
if k == 0:
return 0
elif k > e - s ... | vfc_36933 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "7 4\n4\n1 6 2\n6 2 2\n2 4 2\n2 7 1\n",
"output": "6\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 3\n4\n2 1 2\n1 3 2\n3 4 2\n4 1 1\n",
"output": "3\n",
"type": "stdin_stdou... |
code_contests | verifiable_code | 814_A. An abandoned sentiment from past | Solve the following coding problem using the programming language python:
A few years ago, Hitagi encountered a giant crab, who stole the whole of her body weight. Ever since, she tried to avoid contact with others, for fear that this secret might be noticed.
To get rid of the oddity and recover her weight, a special... | ```python
def checker(L):
return all(x<y for x, y in zip(L, L[1:]))
R = lambda: map(int,input().split())
n, k = R()
a = list(R())
b = list(R())
b.sort(reverse=True)
for i in range(n):
if a[i] in b:
exit(print('No'))
if a[i] == 0:
a[i] = b[0]
del b[0]
print('No' if checker(a) else 'Yes')
``` | vfc_36937 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 1, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 2\n11 0 0 14\n5 4\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6 1\n2 3 0 8 9 10\n5\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_... |
code_contests | verifiable_code | 83_A. Magical Array | Solve the following coding problem using the programming language python:
Valery is very interested in magic. Magic attracts him so much that he sees it everywhere. He explains any strange and weird phenomenon through intervention of supernatural forces. But who would have thought that even in a regular array of numbe... | ```python
from collections import defaultdict
n = int(input())
arr = list(map(int,input().split()))
cur = arr[0]
cnt = 1
d = defaultdict(int)
for i in range(1,n):
if arr[i]==cur:
cnt+=1
else:
d[cnt]+=1
cur = arr[i]
cnt = 1
if cnt!=0:
d[cnt]+=1
ans = 0
for i in d:
freq = d[i]
cnt = (i*(i+1))//2
cnt = cnt*f... | vfc_36941 | {
"difficulty": "7",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n-2 -2 -2 0 1\n",
"output": "8\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 85_B. Embassy Queue | Solve the following coding problem using the programming language python:
In an embassy of a well-known kingdom an electronic queue is organised. Every person who comes to the embassy, needs to make the following three actions: show the ID, pay money to the cashier and be fingerprinted. Besides, the actions should be ... | ```python
q = zip(map(int, input().split()), map(int, input().split()))
n = int(input())
c = list(map(int, input().split()))
d = c[:]
for k, t in q:
for i in range(min(k, n)): c[i] += t
for i in range(k, n): c[i] = max(c[i], c[i - k]) + t
print(max(c[i] - d[i] for i in range(n)))
``` | vfc_36945 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 1 1\n5 1 1\n5\n1 2 3 3 5\n",
"output": "13",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 1 1\n1 1 1\n5\n1 1 1 1 1\n",
"output": "7",
"type": "stdin_stdout"
},
{
... |
code_contests | verifiable_code | 886_B. Vlad and Cafes | Solve the following coding problem using the programming language python:
Vlad likes to eat in cafes very much. During his life, he has visited cafes n times. Unfortunately, Vlad started to feel that his last visits are not any different from each other. To fix that Vlad had a small research.
First of all, Vlad assig... | ```python
from sys import stdin as fin
# fin = open("tc173b.in", "r")
n = int(fin.readline())
# n, k = map(int, fin.readline().split())
arr = list(map(int, fin.readline().split()))
# s = fin.readline().rstrip()
s = dict()
for i in range(n):
x = arr[i]
s[x] = (i, x)
# print(tuple(s.items()))
print(min(s.items(... | vfc_36949 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6\n2 1 2 2 4 1\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n1 3 2 1 2\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
... |
code_contests | verifiable_code | 909_B. Segments | Solve the following coding problem using the programming language python:
You are given an integer N. Consider all possible segments on the coordinate axis with endpoints at integer points with coordinates between 0 and N, inclusive; there will be <image> of them.
You want to draw these segments in several layers so ... | ```python
n=int(input())
print(((n//2)+1)*(n-(n//2)))
``` | vfc_36953 | {
"difficulty": "8",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n",
"output": "4\n",
"type": "stdin_stdout"
}
]
} |
code_contests | verifiable_code | 930_D. Game with Tokens | Solve the following coding problem using the programming language python:
Consider the following game for two players. There is one white token and some number of black tokens. Each token is placed on a plane in a point with integer coordinates x and y.
The players take turn making moves, white starts. On each turn, ... | ```python
from sys import stdin
from itertools import repeat
def solve(a):
inf = 1001001001
C = 400010
lmn = [inf] * 400010
lmx = [-inf] * 400010
for x, y in a:
x = (x - 1) / 2 + 100005
if lmn[x] > y:
lmn[x] = y
if lmx[x] < y:
lmx[x] = y
rmn = lmn[... | vfc_36957 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n-2 0\n-1 1\n0 -2\n1 -1\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "16\n2 1\n1 2\n-1 1\n0 1\n0 0\n1 1\n2 -1\n2 0\n1 0\n-1 -1\n1 -1\n2 2\n0 -1\n-1 0\n0 2\n-1 2\n",
... |
code_contests | verifiable_code | 958_D2. Hyperspace Jump (hard) | Solve the following coding problem using the programming language python:
It is now 125 years later, but humanity is still on the run from a humanoid-cyborg race determined to destroy it. Or perhaps we are getting some stories mixed up here... In any case, the fleet is now smaller. However, in a recent upgrade, all th... | vfc_36961 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 256000000,
"problem_url": null,
"time_limit": "{'seconds': 3, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "8 2\n1\n5 0\n1\n0 1\n1\n0 1\n2\n0 6\n0 1\n2\n0 1\n1 0\n2\n-5 -5\n4 3\n2\n1 1\n0 1\n2\n1 0\n1 0\n",
"output": "1 2 2 2 3 3 3 1 \n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 4\n4\n0 -1... | |
code_contests | verifiable_code | 984_D. XOR-pyramid | Solve the following coding problem using the programming language python:
For an array b of length m we define the function f as
f(b) = \begin{cases} b[1] & if m = 1 \\\ f(b[1] ⊕ b[2],b[2] ⊕ b[3],...,b[m-1] ⊕ b[m]) & otherwise, \end{cases}
where ⊕ is [bitwise exclusive OR](https://en.wikipedia.org/wiki/Bitw... | ```python
n = int(input())
a = list(map(int, input().split()))
dp = [[0 for x in range(n+1)] for y in range(n+1)]
for i in range(n):
dp[0][i] = a[i]
for i in range(1, n):
for j in range(0, n - i + 1):
dp[i][j] = dp[i - 1][j + 1] ^ dp[i - 1][j]
for i in range(1, n):
for j in range(0, n - i):
dp[i]... | vfc_36965 | {
"difficulty": "10",
"memory_limit": null,
"memory_limit_bytes": 512000000,
"problem_url": null,
"time_limit": "{'seconds': 2, 'nanos': 0}"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6\n1 2 4 8 16 32\n4\n1 6\n2 5\n3 4\n1 2\n",
"output": "60\n30\n12\n3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n8 4 1\n2\n2 3\n1 2\n",
"output": "5\n12\n",
"type": "std... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.