message stringlengths 2 48.6k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 318 108k | cluster float64 8 8 | __index_level_0__ int64 636 217k |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
Bob is playing with 6-sided dice. A net of such standard cube is shown below.
<image>
He has an unlimited supply of these dice and wants to build a tower by stacking multiple dice on top of each other, while choosing the orientation of eac... | instruction | 0 | 53,177 | 8 | 106,354 |
Tags: constructive algorithms, math
Correct Solution:
```
x=input()
s=input()
l=s.split(" ")
for i in l:
n=int(i)
if(n>14 and (n%14<=6 and n%14>=1)):
print("YES")
else:
print("NO")
``` | output | 1 | 53,177 | 8 | 106,355 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Bob is playing with 6-sided dice. A net of such standard cube is shown below.
<image>
He has an unlimited supply of these dice and wants to build a tower by stacking multiple dice on top of each other, while choosing the orientation of eac... | instruction | 0 | 53,178 | 8 | 106,356 |
Tags: constructive algorithms, math
Correct Solution:
```
n = int(input())
l = list(map(int,input().split()))
for i in l:
q = i//7
w = i%7
if q%2 == 0 and q!=0 and w>0:
print('YES')
else:
print("NO")
``` | output | 1 | 53,178 | 8 | 106,357 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Bob is playing with 6-sided dice. A net of such standard cube is shown below.
<image>
He has an unlimited supply of these dice and wants to build a tower by stacking multiple dice on top of ea... | instruction | 0 | 53,180 | 8 | 106,360 |
Yes | output | 1 | 53,180 | 8 | 106,361 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Bob is playing with 6-sided dice. A net of such standard cube is shown below.
<image>
He has an unlimited supply of these dice and wants to build a tower by stacking multiple dice on top of ea... | instruction | 0 | 53,185 | 8 | 106,370 |
No | output | 1 | 53,185 | 8 | 106,371 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Bob is playing with 6-sided dice. A net of such standard cube is shown below.
<image>
He has an unlimited supply of these dice and wants to build a tower by stacking multiple dice on top of ea... | instruction | 0 | 53,186 | 8 | 106,372 |
No | output | 1 | 53,186 | 8 | 106,373 |
Provide tags and a correct Python 3 solution for this coding contest problem.
DZY loves chemistry, and he enjoys mixing chemicals.
DZY has n chemicals, and m pairs of them will react. He wants to pour these chemicals into a test tube, and he needs to pour them in one by one, in any order.
Let's consider the danger ... | instruction | 0 | 53,422 | 8 | 106,844 |
Tags: dfs and similar, dsu, greedy
Correct Solution:
```
# 445B
__author__ = 'artyom'
read = lambda: map(int, input().split())
n, m = read()
graph = [set() for _ in range(n + 1)]
for __ in range(m):
x, y = read()
graph[x].add(y)
graph[y].add(x)
visited = set()
def dfs(start, counter):
stack = [start]
whi... | output | 1 | 53,422 | 8 | 106,845 |
Provide tags and a correct Python 3 solution for this coding contest problem.
DZY loves chemistry, and he enjoys mixing chemicals.
DZY has n chemicals, and m pairs of them will react. He wants to pour these chemicals into a test tube, and he needs to pour them in one by one, in any order.
Let's consider the danger ... | instruction | 0 | 53,428 | 8 | 106,856 |
Tags: dfs and similar, dsu, greedy
Correct Solution:
```
def read_input():
global n, m, edge
n, m = map(int, input().split())
edge = []
for i in range(m):
u, v = map(int, input().split())
edge.append((u-1, v-1))
def init():
global lab
lab = [-1] * n
def find_set(u):
global... | output | 1 | 53,428 | 8 | 106,857 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya is a school PE teacher. Unlike other PE teachers, Vasya doesn't like it when the students stand in line according to their height. Instead, he demands that the children stand in the follow... | instruction | 0 | 53,478 | 8 | 106,956 |
Yes | output | 1 | 53,478 | 8 | 106,957 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya is a school PE teacher. Unlike other PE teachers, Vasya doesn't like it when the students stand in line according to their height. Instead, he demands that the children stand in the follow... | instruction | 0 | 53,479 | 8 | 106,958 |
Yes | output | 1 | 53,479 | 8 | 106,959 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya is a school PE teacher. Unlike other PE teachers, Vasya doesn't like it when the students stand in line according to their height. Instead, he demands that the children stand in the follow... | instruction | 0 | 53,480 | 8 | 106,960 |
Yes | output | 1 | 53,480 | 8 | 106,961 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya is a school PE teacher. Unlike other PE teachers, Vasya doesn't like it when the students stand in line according to their height. Instead, he demands that the children stand in the follow... | instruction | 0 | 53,481 | 8 | 106,962 |
Yes | output | 1 | 53,481 | 8 | 106,963 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya is a school PE teacher. Unlike other PE teachers, Vasya doesn't like it when the students stand in line according to their height. Instead, he demands that the children stand in the follow... | instruction | 0 | 53,482 | 8 | 106,964 |
No | output | 1 | 53,482 | 8 | 106,965 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya is a school PE teacher. Unlike other PE teachers, Vasya doesn't like it when the students stand in line according to their height. Instead, he demands that the children stand in the follow... | instruction | 0 | 53,483 | 8 | 106,966 |
No | output | 1 | 53,483 | 8 | 106,967 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya is a school PE teacher. Unlike other PE teachers, Vasya doesn't like it when the students stand in line according to their height. Instead, he demands that the children stand in the follow... | instruction | 0 | 53,484 | 8 | 106,968 |
No | output | 1 | 53,484 | 8 | 106,969 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya is a school PE teacher. Unlike other PE teachers, Vasya doesn't like it when the students stand in line according to their height. Instead, he demands that the children stand in the follow... | instruction | 0 | 53,485 | 8 | 106,970 |
No | output | 1 | 53,485 | 8 | 106,971 |
Provide tags and a correct Python 3 solution for this coding contest problem.
King of Berland Berl IV has recently died. Hail Berl V! As a sign of the highest achievements of the deceased king the new king decided to build a mausoleum with Berl IV's body on the main square of the capital.
The mausoleum will be constr... | instruction | 0 | 53,486 | 8 | 106,972 |
Tags: dp
Correct Solution:
```
n,k = map(int,input().split())
n*=2
n+=2
l,le,e = [[] for i in range(n)],[[] for i in range(n)],[0]*n
ok = 1
for i in range(k):
a,c,b = input().split()
a,b = int(a), int(b)
if c=="=":
if a==b:
continue
if (e[a] and e[a]!=b) or (e[b] and e[b]!=a):
... | output | 1 | 53,486 | 8 | 106,973 |
Provide tags and a correct Python 3 solution for this coding contest problem.
King of Berland Berl IV has recently died. Hail Berl V! As a sign of the highest achievements of the deceased king the new king decided to build a mausoleum with Berl IV's body on the main square of the capital.
The mausoleum will be constr... | instruction | 0 | 53,487 | 8 | 106,974 |
Tags: dp
Correct Solution:
```
def check(l, r, a, b):
if a < 0 or b >= 2 * N:
return 0
def val(p):
if p in [a, b]: return '0'
if l <= p and p < r: return '1'
return '-1'
for i in range(K):
x, y = val(A[i]), val(C[i])
if A[i] in [a, b] or C[i] in [a, b]:
... | output | 1 | 53,487 | 8 | 106,975 |
Provide tags and a correct Python 3 solution for this coding contest problem.
King of Berland Berl IV has recently died. Hail Berl V! As a sign of the highest achievements of the deceased king the new king decided to build a mausoleum with Berl IV's body on the main square of the capital.
The mausoleum will be constr... | instruction | 0 | 53,488 | 8 | 106,976 |
Tags: dp
Correct Solution:
```
import sys
#sys.stdin = open('input.txt', 'r')
#sys.stdout = open('output.txt', 'w')
n, k = map(int, input().split())
dp = [[0] * 2 * n for i in range(2 * n)]
require = list()
inf = int(1e5)
order = [inf] * 2 * n
for i in range(k):
require.append(input().split())
require[i][0] = in... | output | 1 | 53,488 | 8 | 106,977 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
King of Berland Berl IV has recently died. Hail Berl V! As a sign of the highest achievements of the deceased king the new king decided to build a mausoleum with Berl IV's body on the main squar... | instruction | 0 | 53,489 | 8 | 106,978 |
No | output | 1 | 53,489 | 8 | 106,979 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
King of Berland Berl IV has recently died. Hail Berl V! As a sign of the highest achievements of the deceased king the new king decided to build a mausoleum with Berl IV's body on the main squar... | instruction | 0 | 53,490 | 8 | 106,980 |
No | output | 1 | 53,490 | 8 | 106,981 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
King of Berland Berl IV has recently died. Hail Berl V! As a sign of the highest achievements of the deceased king the new king decided to build a mausoleum with Berl IV's body on the main squar... | instruction | 0 | 53,491 | 8 | 106,982 |
No | output | 1 | 53,491 | 8 | 106,983 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
King of Berland Berl IV has recently died. Hail Berl V! As a sign of the highest achievements of the deceased king the new king decided to build a mausoleum with Berl IV's body on the main squar... | instruction | 0 | 53,492 | 8 | 106,984 |
No | output | 1 | 53,492 | 8 | 106,985 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Long ago, Vasily built a good fence at his country house. Vasily calls a fence good, if it is a series of n consecutively fastened vertical boards of centimeter width, the height of each in centimeters is a positive integer. The house owner ... | instruction | 0 | 53,511 | 8 | 107,022 |
Tags: combinatorics, dp, number theory
Correct Solution:
```
mod = 10 ** 9 + 7
n = int(input())
h = list(map(lambda x: int(x) - 1, input().split()))
ans = x = 0
for i in range(n):
ans += h[i] + min(h[i], h[i - 1]) * x
if i < n - 1:
x *= min(h[i - 1], h[i], h[i + 1])
x += min(h[i], h[i + 1])
... | output | 1 | 53,511 | 8 | 107,023 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Long ago, Vasily built a good fence at his country house. Vasily calls a fence good, if it is a series of n consecutively fastened vertical boards of centimeter width, the height of each in cent... | instruction | 0 | 53,512 | 8 | 107,024 |
No | output | 1 | 53,512 | 8 | 107,025 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Long ago, Vasily built a good fence at his country house. Vasily calls a fence good, if it is a series of n consecutively fastened vertical boards of centimeter width, the height of each in cent... | instruction | 0 | 53,513 | 8 | 107,026 |
No | output | 1 | 53,513 | 8 | 107,027 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have to restore the wall. The wall consists of N pillars of bricks, the height of the i-th pillar is initially equal to h_{i}, the height is measured in number of bricks. After the restoration all the N pillars should have equal heights.... | instruction | 0 | 54,093 | 8 | 108,186 |
Tags: binary search, greedy, math, sortings, ternary search
Correct Solution:
```
from collections import defaultdict
from random import randint
itl = lambda: list(map(int, input().strip().split()))
class Problem:
def read(self):
# self.N = 100000
# self.A, self.R, self.M = [randint(1, 10000) for... | output | 1 | 54,093 | 8 | 108,187 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have to restore the wall. The wall consists of N pillars of bricks, the height of the i-th pillar is initially equal to h_{i}, the height is measured in number of bricks. After the restoration all the N pillars should have equal heights.... | instruction | 0 | 54,094 | 8 | 108,188 |
Tags: binary search, greedy, math, sortings, ternary search
Correct Solution:
```
# https://codeforces.com/contest/1355/problem/E
import bisect
def func(val):
cost = 0
toAdd,toRemove = 0,0
lessEqual = bisect.bisect_right(arr,val)
greater = n - lessEqual
toAdd = (lessEqual * val) - dp[lessEqual]
... | output | 1 | 54,094 | 8 | 108,189 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have to restore the wall. The wall consists of N pillars of bricks, the height of the i-th pillar is initially equal to h_{i}, the height is measured in number of bricks. After the restoration all the N pillars should have equal heights.... | instruction | 0 | 54,095 | 8 | 108,190 |
Tags: binary search, greedy, math, sortings, ternary search
Correct Solution:
```
import sys
input = sys.stdin.readline
from bisect import *
N, A, R, M = map(int, input().split())
M = min(M, A+R)
h = list(map(int, input().split()))
h.sort()
acc = [0]*(N+1)
for i in range(N):
acc[i+1] = acc[i]+h[i]
S = sum(h)
bs ... | output | 1 | 54,095 | 8 | 108,191 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have to restore the wall. The wall consists of N pillars of bricks, the height of the i-th pillar is initially equal to h_{i}, the height is measured in number of bricks. After the restoration all the N pillars should have equal heights.... | instruction | 0 | 54,096 | 8 | 108,192 |
Tags: binary search, greedy, math, sortings, ternary search
Correct Solution:
```
from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush,heappop
import math
from collections import *
from functools import reduce,cmp_to_key,lru_cache
import io, os
input = io.BytesIO(os.read... | output | 1 | 54,096 | 8 | 108,193 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have to restore the wall. The wall consists of N pillars of bricks, the height of the i-th pillar is initially equal to h_{i}, the height is measured in number of bricks. After the restoration all the N pillars should have equal heights.... | instruction | 0 | 54,097 | 8 | 108,194 |
Tags: binary search, greedy, math, sortings, ternary search
Correct Solution:
```
n,a,r,m=map(int,input().split())
if m>a+r:
m=a+r
h=[int(i) for i in input().split()]
def checker(height):
above,below=0,0
for i in h:
if i>height:
above+=(i-height)
elif i<height:
below+... | output | 1 | 54,097 | 8 | 108,195 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have to restore the wall. The wall consists of N pillars of bricks, the height of the i-th pillar is initially equal to h_{i}, the height is measured in number of bricks. After the restoration all the N pillars should have equal heights.... | instruction | 0 | 54,098 | 8 | 108,196 |
Tags: binary search, greedy, math, sortings, ternary search
Correct Solution:
```
import bisect
N, A, R, M = map(int, input().split())
aa = sorted(map(int, input().split()))
raa = [0]
for a in aa:
raa.append(raa[-1] + a)
ans = 10 ** 15
# a に揃える時のコスト
def calc(a):
i = bisect.bisect_right(aa, a)
add_n = ... | output | 1 | 54,098 | 8 | 108,197 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have to restore the wall. The wall consists of N pillars of bricks, the height of the i-th pillar is initially equal to h_{i}, the height is measured in number of bricks. After the restoration all the N pillars should have equal heights.... | instruction | 0 | 54,099 | 8 | 108,198 |
Tags: binary search, greedy, math, sortings, ternary search
Correct Solution:
```
import sys,bisect
input = sys.stdin.buffer.readline
n,A,R,M = map(int,input().split())
h = list(map(int,input().split()))
h.sort()
b = []
tmp = 0
for e in h:
tmp += e
b.append(tmp)
def f(x):
k = bisect.bisect_left(h,x)
... | output | 1 | 54,099 | 8 | 108,199 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have to restore the wall. The wall consists of N pillars of bricks, the height of the i-th pillar is initially equal to h_{i}, the height is measured in number of bricks. After the restoration all the N pillars should have equal heights.... | instruction | 0 | 54,100 | 8 | 108,200 |
Tags: binary search, greedy, math, sortings, ternary search
Correct Solution:
```
#!/usr/bin/env python3
import io
import os
from bisect import bisect
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
def get_str():
return input().decode().strip()
def rint():
return map(int, input().split())
def oint... | output | 1 | 54,100 | 8 | 108,201 |
Provide tags and a correct Python 2 solution for this coding contest problem.
You have to restore the wall. The wall consists of N pillars of bricks, the height of the i-th pillar is initially equal to h_{i}, the height is measured in number of bricks. After the restoration all the N pillars should have equal heights.... | instruction | 0 | 54,101 | 8 | 108,202 |
Tags: binary search, greedy, math, sortings, ternary search
Correct Solution:
```
""" Python 3 compatibility tools. """
from __future__ import division, print_function
import itertools
import sys
if sys.version_info[0] < 3:
input = raw_input
range = xrange
filter = itertools.ifilter
map = itertools.imap
zip... | output | 1 | 54,101 | 8 | 108,203 |
Provide tags and a correct Python 2 solution for this coding contest problem.
You have to restore the wall. The wall consists of N pillars of bricks, the height of the i-th pillar is initially equal to h_{i}, the height is measured in number of bricks. After the restoration all the N pillars should have equal heights.... | instruction | 0 | 54,102 | 8 | 108,204 |
Tags: binary search, greedy, math, sortings, ternary search
Correct Solution:
```
""" Python 3 compatibility tools. """
from __future__ import division, print_function
import itertools
import sys
if sys.version_info[0] < 3:
input = raw_input
range = xrange
filter = itertools.ifilter
map = itertools.imap
zip... | output | 1 | 54,102 | 8 | 108,205 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have to restore the wall. The wall consists of N pillars of bricks, the height of the i-th pillar is initially equal to h_{i}, the height is measured in number of bricks. After the restorati... | instruction | 0 | 54,103 | 8 | 108,206 |
Yes | output | 1 | 54,103 | 8 | 108,207 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have to restore the wall. The wall consists of N pillars of bricks, the height of the i-th pillar is initially equal to h_{i}, the height is measured in number of bricks. After the restorati... | instruction | 0 | 54,104 | 8 | 108,208 |
Yes | output | 1 | 54,104 | 8 | 108,209 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have to restore the wall. The wall consists of N pillars of bricks, the height of the i-th pillar is initially equal to h_{i}, the height is measured in number of bricks. After the restorati... | instruction | 0 | 54,105 | 8 | 108,210 |
Yes | output | 1 | 54,105 | 8 | 108,211 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have to restore the wall. The wall consists of N pillars of bricks, the height of the i-th pillar is initially equal to h_{i}, the height is measured in number of bricks. After the restorati... | instruction | 0 | 54,106 | 8 | 108,212 |
Yes | output | 1 | 54,106 | 8 | 108,213 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have to restore the wall. The wall consists of N pillars of bricks, the height of the i-th pillar is initially equal to h_{i}, the height is measured in number of bricks. After the restorati... | instruction | 0 | 54,107 | 8 | 108,214 |
No | output | 1 | 54,107 | 8 | 108,215 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have to restore the wall. The wall consists of N pillars of bricks, the height of the i-th pillar is initially equal to h_{i}, the height is measured in number of bricks. After the restorati... | instruction | 0 | 54,108 | 8 | 108,216 |
No | output | 1 | 54,108 | 8 | 108,217 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have to restore the wall. The wall consists of N pillars of bricks, the height of the i-th pillar is initially equal to h_{i}, the height is measured in number of bricks. After the restorati... | instruction | 0 | 54,109 | 8 | 108,218 |
No | output | 1 | 54,109 | 8 | 108,219 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have to restore the wall. The wall consists of N pillars of bricks, the height of the i-th pillar is initially equal to h_{i}, the height is measured in number of bricks. After the restorati... | instruction | 0 | 54,110 | 8 | 108,220 |
No | output | 1 | 54,110 | 8 | 108,221 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev got hold of lots of wooden cubes somewhere. They started making cube towers by placing the cubes one on top of the other. They defined m... | instruction | 0 | 54,340 | 8 | 108,680 |
Tags: string suffix structures, strings
Correct Solution:
```
def KMPSearch(pat, txt):
ans=0
M = len(pat)
N = len(txt)
lps = [0]*M
j = 0
computeLPSArray(pat, M, lps)
i = 0
while i < N:
if pat[j] == txt[i]:
i += 1
j += 1
if j == M:
an... | output | 1 | 54,340 | 8 | 108,681 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev got hold of lots of wooden cubes somewhere. They started making cube towers by placing the cubes one on top of the other. They defined m... | instruction | 0 | 54,341 | 8 | 108,682 |
Tags: string suffix structures, strings
Correct Solution:
```
# Legends Always Come Up with Solution
# Author: Manvir Singh
import os
import sys
from io import BytesIO, IOBase
from bisect import *
def pie(s): # pie function of KMP algorithm ; pi[i] tell that ending at i what is the maximum length of the suffix th... | output | 1 | 54,341 | 8 | 108,683 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev got hold of lots of wooden cubes somewhere. They started making cube towers by placing the cubes one on top of the other. They defined m... | instruction | 0 | 54,342 | 8 | 108,684 |
Tags: string suffix structures, strings
Correct Solution:
```
# -*- coding:utf-8 -*-
"""
created by shuangquan.huang at 2/11/20
"""
import collections
import time
import os
import sys
import bisect
import heapq
from typing import List
def solve_prefix(N, W, A, B):
# https://cp-algorithms.com/string/prefix-fu... | output | 1 | 54,342 | 8 | 108,685 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev got hold of lots of wooden cubes somewhere. They started making cube towers by placing the cubes one on top of the other. They defined m... | instruction | 0 | 54,343 | 8 | 108,686 |
Tags: string suffix structures, strings
Correct Solution:
```
n, k = map(int, input().split())
a = tuple(map(int, input().split()))
b = tuple(map(int, input().split()))
if k == 1:
print(n)
elif k > n:
print(0)
else:
p = int(1e16 + 7)
q = int(499)
h1 = 0
hs = [0] * (n + 1)
pw = [1] * (n + 1)... | output | 1 | 54,343 | 8 | 108,687 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev got hold of lots of wooden cubes somewhere. They started making cube towers by placing the cubes one on top of the other. They defined m... | instruction | 0 | 54,344 | 8 | 108,688 |
Tags: string suffix structures, strings
Correct Solution:
```
import os
import sys
from io import BytesIO, IOBase
from collections import Counter
import math as mt
import inspect, re
def varname(p): # prints name of the variable
for line in inspect.getframeinfo(inspect.currentframe().f_back)[3]:
m = re.s... | output | 1 | 54,344 | 8 | 108,689 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev got hold of lots of wooden cubes somewhere. They started making cube towers by placing the cubes one on top of the other. They defined m... | instruction | 0 | 54,345 | 8 | 108,690 |
Tags: string suffix structures, strings
Correct Solution:
```
# by the authority of GOD author: manhar singh sachdev #
import os,sys
from io import BytesIO,IOBase
def calprefix(pat):
n = len(pat)
pi = [0]*n
for i in range(1,n):
j = pi[i-1]
while j and pat[i] != pat[j]:
j = pi... | output | 1 | 54,345 | 8 | 108,691 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev got hold of lots of wooden cubes somewhere. They started making cube towers by placing the cubes one on top of the other. They defined m... | instruction | 0 | 54,346 | 8 | 108,692 |
Tags: string suffix structures, strings
Correct Solution:
```
"""
Codeforces Contest 269 Div 2 Problem D
Author : chaotic_iak
Language: Python 3.3.4
"""
def main():
n,w = read()
if w == 1: return n
a = read()
b = read()
c,d = [],[]
for i in range(n-1):
c.append(a[i+1]-a[i])
for i ... | output | 1 | 54,346 | 8 | 108,693 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.