message stringlengths 2 65.1k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 0 108k | cluster float64 14 14 | __index_level_0__ int64 0 217k |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
In this problem you will have to help Berland army with organizing their command delivery system.
There are n officers in Berland army. The first officer is the commander of the army, and he does not have any superiors. Every other officer ... | instruction | 0 | 0 | 14 | 0 |
Tags: dfs and similar, graphs, trees
Correct Solution:
```
#####################################
import atexit, io, sys, collections, math, heapq, fractions,copy, os, functools
import sys
import random
import collections
from io import BytesIO, IOBase
##################################### python 3 START
BUFSIZE... | output | 1 | 0 | 14 | 1 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In this problem you will have to help Berland army with organizing their command delivery system.
There are n officers in Berland army. The first officer is the commander of the army, and he does not have any superiors. Every other officer ... | instruction | 0 | 1 | 14 | 2 |
Tags: dfs and similar, graphs, trees
Correct Solution:
```
from collections import deque
len = len
t = 0
def porder():
global adjList, order, span, t
stack = deque()
stack.append(0)
while len(stack):
cur = stack.pop()
if cur in span.keys():
span[cur].append(t)
else:
... | output | 1 | 1 | 14 | 3 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In this problem you will have to help Berland army with organizing their command delivery system.
There are n officers in Berland army. The first officer is the commander of the army, and he does not have any superiors. Every other officer ... | instruction | 0 | 2 | 14 | 4 |
Tags: dfs and similar, graphs, trees
Correct Solution:
```
len = len
def dfs(root, tree, path, pos, size):
index = {}
stack = [root]
while len(stack) >0:
vertex = stack[-1]
if vertex not in index:
path.append(vertex)
pos[vertex] = len(path)-1
index[vertex]... | output | 1 | 2 | 14 | 5 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In this problem you will have to help Berland army with organizing their command delivery system.
There are n officers in Berland army. The first officer is the commander of the army, and he does not have any superiors. Every other officer ... | instruction | 0 | 3 | 14 | 6 |
Tags: dfs and similar, graphs, trees
Correct Solution:
```
# itne me hi thakk gaye?
n, q = map(int, input().split())
parent = [-1] + [int(x) -1 for x in input().split()]
# parent = [i-1 for i in parent]
start = [0 for i in range(n)]
end = [1 for i in range(n)]
size = [1 for i in range(n)]
path = [0 for i in range(n)]
f... | output | 1 | 3 | 14 | 7 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In this problem you will have to help Berland army with organizing their command delivery system.
There are n officers in Berland army. The first officer is the commander of the army, and he does not have any superiors. Every other officer ... | instruction | 0 | 4 | 14 | 8 |
Tags: dfs and similar, graphs, trees
Correct Solution:
```
n,q = [int(x) for x in input().split()]
L = [int(x)-1 for x in input().split()]
G = []
for i in range(n):
G.append([])
for i in range(n-1):
G[L[i]].append((i+1,L[i]))
G[i+1].append((L[i],i+1))
L = [-1]+L
G[0].reverse()
for t in range(1,n):
... | output | 1 | 4 | 14 | 9 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In this problem you will have to help Berland army with organizing their command delivery system.
There are n officers in Berland army. The first officer is the commander of the army, and he does not have any superiors. Every other officer ... | instruction | 0 | 5 | 14 | 10 |
Tags: dfs and similar, graphs, trees
Correct Solution:
```
def dfs(dp,node,edges,order):
visited = set()
stack = [node]
while stack:
curr = stack[-1]
if curr not in visited:
visited.add(curr)
order.append(curr)
count = 0
for kid in edges[c... | output | 1 | 5 | 14 | 11 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In this problem you will have to help Berland army with organizing their command delivery system.
There are n officers in Berland army. The first officer is the commander of the army, and he does not have any superiors. Every other officer ... | instruction | 0 | 6 | 14 | 12 |
Tags: dfs and similar, graphs, trees
Correct Solution:
```
import sys,os,io
from sys import stdin
from collections import defaultdict
# sys.setrecursionlimit(200010)
def ii():
return int(input())
def li():
return list(map(int,input().split()))
from types import GeneratorType
def bootstrap(to, stack=[]):
# ... | output | 1 | 6 | 14 | 13 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In this problem you will have to help Berland army with organizing their command delivery system.
There are n officers in Berland army. The first officer is the commander of the army, and he does not have any superiors. Every other officer ... | instruction | 0 | 7 | 14 | 14 |
Tags: dfs and similar, graphs, trees
Correct Solution:
```
import sys
readline = sys.stdin.readline
def getpar(Edge, p):
N = len(Edge)
par = [0]*N
par[0] = -1
par[p] -1
stack = [p]
visited = set([p])
while stack:
vn = stack.pop()
for vf in Edge[vn]:
if vf in vis... | output | 1 | 7 | 14 | 15 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In this problem you will have to help Berland army with organizing their command delivery system.
There are n officers in Berland army. The first officer is the commander of the army, and he do... | instruction | 0 | 8 | 14 | 16 |
Yes | output | 1 | 8 | 14 | 17 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In this problem you will have to help Berland army with organizing their command delivery system.
There are n officers in Berland army. The first officer is the commander of the army, and he do... | instruction | 0 | 9 | 14 | 18 |
Yes | output | 1 | 9 | 14 | 19 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In this problem you will have to help Berland army with organizing their command delivery system.
There are n officers in Berland army. The first officer is the commander of the army, and he do... | instruction | 0 | 10 | 14 | 20 |
Yes | output | 1 | 10 | 14 | 21 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In this problem you will have to help Berland army with organizing their command delivery system.
There are n officers in Berland army. The first officer is the commander of the army, and he do... | instruction | 0 | 11 | 14 | 22 |
Yes | output | 1 | 11 | 14 | 23 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In this problem you will have to help Berland army with organizing their command delivery system.
There are n officers in Berland army. The first officer is the commander of the army, and he do... | instruction | 0 | 12 | 14 | 24 |
No | output | 1 | 12 | 14 | 25 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In this problem you will have to help Berland army with organizing their command delivery system.
There are n officers in Berland army. The first officer is the commander of the army, and he do... | instruction | 0 | 13 | 14 | 26 |
No | output | 1 | 13 | 14 | 27 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In this problem you will have to help Berland army with organizing their command delivery system.
There are n officers in Berland army. The first officer is the commander of the army, and he do... | instruction | 0 | 14 | 14 | 28 |
No | output | 1 | 14 | 14 | 29 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In this problem you will have to help Berland army with organizing their command delivery system.
There are n officers in Berland army. The first officer is the commander of the army, and he do... | instruction | 0 | 15 | 14 | 30 |
No | output | 1 | 15 | 14 | 31 |
Provide tags and a correct Python 3 solution for this coding contest problem.
This problem is same as the previous one, but has larger constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invit... | instruction | 0 | 81 | 14 | 162 |
Tags: data structures, implementation
Correct Solution:
```
from collections import Counter
n = int(input())
us = [int(t) for t in input().split(' ')]
uc = Counter()
uc.update(us)
ucc = Counter()
ucc.update(v for k, v in uc.items())
i = n
while True:
# print(ucc)
if len(ucc) <= 2:
good = ucc[1] ==... | output | 1 | 81 | 14 | 163 |
Provide tags and a correct Python 3 solution for this coding contest problem.
This problem is same as the previous one, but has larger constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invit... | instruction | 0 | 82 | 14 | 164 |
Tags: data structures, implementation
Correct Solution:
```
n=int(input())
l=list(map(int,input().split()))
count=[0]*(pow(10,5)+2)
num=[0]*(pow(10,5)+1)
mx=0
s=0
for i in range(n):
v=l[i]
count[num[v]]-=1
num[v]+=1
mx=max(mx,num[v])
count[num[v]]+=1
f=0
if count[1]==(i+1):
f=1
e... | output | 1 | 82 | 14 | 165 |
Provide tags and a correct Python 3 solution for this coding contest problem.
This problem is same as the previous one, but has larger constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invit... | instruction | 0 | 83 | 14 | 166 |
Tags: data structures, implementation
Correct Solution:
```
n = int(input())
l = list(map(int,input().split()))
m =[0 for i in range(10**5+5)]
wyn = 0
duz=[0 for i in range(10**5+5)]
ile=[0 for i in range(10**5+5)]
zajete = 0
praw = []
jedynki = 0
mini = 100000000000
maksi = -100000000000000000
for i in range(n):
if m... | output | 1 | 83 | 14 | 167 |
Provide tags and a correct Python 3 solution for this coding contest problem.
This problem is same as the previous one, but has larger constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invit... | instruction | 0 | 84 | 14 | 168 |
Tags: data structures, implementation
Correct Solution:
```
from sys import stdin
def main():
n = int(stdin.readline())
ar = list(map(int, stdin.readline().split()))
c = [0] * (10 ** 5 + 1)
f = [0] * (10 ** 5 + 1)
ans = 1
c[ar[0]] += 1
f[c[ar[0]]] += 1
df = 1
dn = 1
for i in ra... | output | 1 | 84 | 14 | 169 |
Provide tags and a correct Python 3 solution for this coding contest problem.
This problem is same as the previous one, but has larger constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invit... | instruction | 0 | 85 | 14 | 170 |
Tags: data structures, implementation
Correct Solution:
```
from collections import Counter
N = 10**5 + 10
n = int(input().lstrip())
colors = list(map(int, input().lstrip().split()))
cnt = Counter()
f = Counter()
mx = 0
for i, color in enumerate(colors):
i += 1
cnt[f[color]] -= 1
f[color] += 1
cnt[f[... | output | 1 | 85 | 14 | 171 |
Provide tags and a correct Python 3 solution for this coding contest problem.
This problem is same as the previous one, but has larger constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invit... | instruction | 0 | 86 | 14 | 172 |
Tags: data structures, implementation
Correct Solution:
```
import sys
input=sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
b={}
c={}
d=[]
for i in range(n):
b[a[i]]=b.get(a[i],0)+1
c[b[a[i]]]=c.get(b[a[i]],0)+1
if c[b[a[i]]]*b[a[i]]==i+1:
if i+2<=n:
d.append(i+2)
... | output | 1 | 86 | 14 | 173 |
Provide tags and a correct Python 3 solution for this coding contest problem.
This problem is same as the previous one, but has larger constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invit... | instruction | 0 | 87 | 14 | 174 |
Tags: data structures, implementation
Correct Solution:
```
N = int(input())
arr = [int(x) for x in input().split()]
cnt = dict()
brr = set()
crr = [0 for _ in range(100001)]
for i in range(1, N + 1):
cnt[i] = set()
answer = 1
for i in range(N):
u = arr[i]
crr[u] += 1
if crr[u] > 1:
cnt[crr[u] -... | output | 1 | 87 | 14 | 175 |
Provide tags and a correct Python 3 solution for this coding contest problem.
This problem is same as the previous one, but has larger constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invit... | instruction | 0 | 88 | 14 | 176 |
Tags: data structures, implementation
Correct Solution:
```
n = int(input())
l = list(map(int,input().split()))
d = {}
g = {}
mi = 10**18
ma = 0
ans = 0
s = set()
for i in range(n):
x = l[i]
s.add(x)
if x in d:
g[d[x]] -= 1
if g[d[x]] == 0:
del g[d[x]]
if d[x] == mi:
... | output | 1 | 88 | 14 | 177 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This problem is same as the previous one, but has larger constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However... | instruction | 0 | 89 | 14 | 178 |
Yes | output | 1 | 89 | 14 | 179 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This problem is same as the previous one, but has larger constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However... | instruction | 0 | 90 | 14 | 180 |
Yes | output | 1 | 90 | 14 | 181 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This problem is same as the previous one, but has larger constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However... | instruction | 0 | 91 | 14 | 182 |
Yes | output | 1 | 91 | 14 | 183 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This problem is same as the previous one, but has larger constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However... | instruction | 0 | 92 | 14 | 184 |
Yes | output | 1 | 92 | 14 | 185 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This problem is same as the previous one, but has larger constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However... | instruction | 0 | 93 | 14 | 186 |
No | output | 1 | 93 | 14 | 187 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This problem is same as the previous one, but has larger constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However... | instruction | 0 | 94 | 14 | 188 |
No | output | 1 | 94 | 14 | 189 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This problem is same as the previous one, but has larger constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However... | instruction | 0 | 95 | 14 | 190 |
No | output | 1 | 95 | 14 | 191 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This problem is same as the previous one, but has larger constraints.
Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However... | instruction | 0 | 96 | 14 | 192 |
No | output | 1 | 96 | 14 | 193 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Filled with optimism, Hyunuk will host a conference about how great this new year will be!
The conference will have n lectures. Hyunuk has two candidate venues a and b. For each of the n lectures, the speaker specified two time intervals [s... | instruction | 0 | 161 | 14 | 322 |
Tags: binary search, data structures, hashing, sortings
Correct Solution:
```
import sys
input = lambda: sys.stdin.readline().rstrip()
ke = 133333333
pp = 1000000000001003
def rand():
global ke
ke = ke ** 2 % pp
return ((ke >> 10) % (1<<15)) + (1<<15)
N = int(input())
W = [rand() for _ in range(N)]
A ... | output | 1 | 161 | 14 | 323 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Filled with optimism, Hyunuk will host a conference about how great this new year will be!
The conference will have n lectures. Hyunuk has two candidate venues a and b. For each of the n lectures, the speaker specified two time intervals [s... | instruction | 0 | 162 | 14 | 324 |
Tags: binary search, data structures, hashing, sortings
Correct Solution:
```
MOD = 10**18+13
import sys
readline = sys.stdin.readline
from random import randrange
def compress(L):
L2 = list(set(L))
L2.sort()
C = {v : k for k, v in enumerate(L2, 1)}
return L2, C
N = int(readline())
T = set(... | output | 1 | 162 | 14 | 325 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Filled with optimism, Hyunuk will host a conference about how great this new year will be!
The conference will have n lectures. Hyunuk has two candidate venues a and b. For each of the n lectures, the speaker specified two time intervals [s... | instruction | 0 | 163 | 14 | 326 |
Tags: binary search, data structures, hashing, sortings
Correct Solution:
```
import sys
input = lambda: sys.stdin.readline().rstrip()
N = int(input())
W = [(i+12345)**2 % 998244353 for i in range(N)]
AL, AR, BL, BR = [], [], [], []
for i in range(N):
a, b, c, d = map(int, input().split())
AL.append(a)
A... | output | 1 | 163 | 14 | 327 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Filled with optimism, Hyunuk will host a conference about how great this new year will be!
The conference will have n lectures. Hyunuk has two candidate venues a and b. For each of the n lectures, the speaker specified two time intervals [s... | instruction | 0 | 164 | 14 | 328 |
Tags: binary search, data structures, hashing, sortings
Correct Solution:
```
import sys
input = sys.stdin.readline
import heapq
n=int(input())
C=[tuple(map(int,input().split())) for i in range(n)]
CA=[]
CB=[]
for ind,(a,b,c,d) in enumerate(C):
CA.append((a,0,ind))
CA.append((b,1,ind))
CB.append((c,0,i... | output | 1 | 164 | 14 | 329 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Filled with optimism, Hyunuk will host a conference about how great this new year will be!
The conference will have n lectures. Hyunuk has two candidate venues a and b. For each of the n lectures, the speaker specified two time intervals [s... | instruction | 0 | 165 | 14 | 330 |
Tags: binary search, data structures, hashing, sortings
Correct Solution:
```
MOD = 10**18+13
import sys
readline = sys.stdin.readline
from random import randrange
def compress(L):
L2 = list(set(L))
L2.sort()
C = {v : k for k, v in enumerate(L2, 1)}
return L2, C
N = int(readline())
T = set(... | output | 1 | 165 | 14 | 331 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Filled with optimism, Hyunuk will host a conference about how great this new year will be!
The conference will have n lectures. Hyunuk has two candidate venues a and b. For each of the n lectures, the speaker specified two time intervals [s... | instruction | 0 | 166 | 14 | 332 |
Tags: binary search, data structures, hashing, sortings
Correct Solution:
```
from operator import itemgetter
import sys
import bisect
input = sys.stdin.readline
class BIT():
"""区間加算、区間取得クエリをそれぞれO(logN)で答える
add: 区間[l, r)にvalを加える
get_sum: 区間[l, r)の和を求める
l, rは0-indexed
"""
def __init__(self, n):... | output | 1 | 166 | 14 | 333 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Filled with optimism, Hyunuk will host a conference about how great this new year will be!
The conference will have n lectures. Hyunuk has two candidate venues a and b. For each of the n lectures, the speaker specified two time intervals [s... | instruction | 0 | 167 | 14 | 334 |
Tags: binary search, data structures, hashing, sortings
Correct Solution:
```
import sys
input = lambda: sys.stdin.readline().rstrip()
N = int(input())
W = [(i+1000007)**3 % 998244353 for i in range(N)]
AL, AR, BL, BR = [], [], [], []
for i in range(N):
a, b, c, d = map(int, input().split())
AL.append(a)
A... | output | 1 | 167 | 14 | 335 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Filled with optimism, Hyunuk will host a conference about how great this new year will be!
The conference will have n lectures. Hyunuk has two candidate venues a and b. For each of the n lectures, the speaker specified two time intervals [s... | instruction | 0 | 168 | 14 | 336 |
Tags: binary search, data structures, hashing, sortings
Correct Solution:
```
import sys
input = lambda: sys.stdin.readline().rstrip()
from bisect import bisect_right as br
ke = 1333333333
pp = 1000000000001003
def rand():
global ke
ke = ke ** 2 % pp
return ((ke >> 10) % (1<<15)) + (1<<15)
N = int(input(... | output | 1 | 168 | 14 | 337 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Filled with optimism, Hyunuk will host a conference about how great this new year will be!
The conference will have n lectures. Hyunuk has two candidate venues a and b. For each of the n lectur... | instruction | 0 | 169 | 14 | 338 |
Yes | output | 1 | 169 | 14 | 339 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Filled with optimism, Hyunuk will host a conference about how great this new year will be!
The conference will have n lectures. Hyunuk has two candidate venues a and b. For each of the n lectur... | instruction | 0 | 170 | 14 | 340 |
Yes | output | 1 | 170 | 14 | 341 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Filled with optimism, Hyunuk will host a conference about how great this new year will be!
The conference will have n lectures. Hyunuk has two candidate venues a and b. For each of the n lectur... | instruction | 0 | 171 | 14 | 342 |
Yes | output | 1 | 171 | 14 | 343 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Filled with optimism, Hyunuk will host a conference about how great this new year will be!
The conference will have n lectures. Hyunuk has two candidate venues a and b. For each of the n lectur... | instruction | 0 | 172 | 14 | 344 |
No | output | 1 | 172 | 14 | 345 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Filled with optimism, Hyunuk will host a conference about how great this new year will be!
The conference will have n lectures. Hyunuk has two candidate venues a and b. For each of the n lectur... | instruction | 0 | 173 | 14 | 346 |
No | output | 1 | 173 | 14 | 347 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Filled with optimism, Hyunuk will host a conference about how great this new year will be!
The conference will have n lectures. Hyunuk has two candidate venues a and b. For each of the n lectur... | instruction | 0 | 174 | 14 | 348 |
No | output | 1 | 174 | 14 | 349 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Filled with optimism, Hyunuk will host a conference about how great this new year will be!
The conference will have n lectures. Hyunuk has two candidate venues a and b. For each of the n lectur... | instruction | 0 | 175 | 14 | 350 |
No | output | 1 | 175 | 14 | 351 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exce... | instruction | 0 | 270 | 14 | 540 |
Tags: binary search, combinatorics, two pointers
Correct Solution:
```
######### ## ## ## #### ##### ## # ## # ##
# # # # # # # # # # # # # # # # # # #
# # # # ### # # # # # # # # # # # #
# ##### # # # # ### # # # # # # # # ####... | output | 1 | 270 | 14 | 541 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exce... | instruction | 0 | 271 | 14 | 542 |
Tags: binary search, combinatorics, two pointers
Correct Solution:
```
nd=input().split()
n=int(nd[0])
d=int(nd[1])
x=input().split()
for i in range(n):
x[i]=int(x[i])
s=0
j=0
for i in range(n):
while j < n and x[j]-x[i] <= d:
j+=1
k=j-i-1
s+=(k*(k-1))//2
print(s)
``` | output | 1 | 271 | 14 | 543 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exce... | instruction | 0 | 272 | 14 | 544 |
Tags: binary search, combinatorics, two pointers
Correct Solution:
```
def main():
n, d = map(int, input().split())
X = [int(x) for x in input().split()]
cnt = 0
for i in range(n):
l = i
r = n - 1
j = -1
while(l <= r):
m = l + (r - l) // 2
if X[m] ... | output | 1 | 272 | 14 | 545 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.