description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | import sys
input = sys.stdin.buffer.readline
T = int(input())
for _ in range(T):
n, ls = int(input()), list(map(int, input().split()))
last, dis = [0] * (n + 1), [0] * (n + 1)
for i, u in enumerate(ls):
i += 1
dis[u] = max(dis[u], i - last[u])
last[u] = i
for u in range(n + 1):
... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR NUMBER ASSI... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | for _ in range(int(input())):
n = int(input())
l = list(map(int, input().split()))
l1 = [0] * (n + 1)
dis = [-1] + [-1] * n
ans = [-1] * (n + 1)
count = 0
tt = 0
for i in range(n):
if l[i] != l[0] and l1[l[i]] == 0:
dis[l[i]] = max(dis[l[i]], i - l1[l[i]] + 1)
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMB... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | import sys
input = sys.stdin.readline
def solve_slow(A, n):
ans = [(-1) for _ in range(n)]
for k in range(n):
common = set(A[: k + 1])
for i in range(n - k):
common &= set(A[i : i + k + 1])
if common:
ans = [(-1) for _ in range(n)]
for k in range(n):
... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR ... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | t = int(input())
for _ in range(t):
n = int(input())
a = list(map(int, input().split()))
d = {}
for i in range(n):
x = a[i]
if not x in d:
d[x] = i, i + 1
else:
j, r = d[x]
d[x] = i, max(i - j, r)
nl = []
for x in d.keys():
i, r... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VA... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | import sys
input = sys.stdin.readline
def main():
n = int(input())
alst = list(map(int, input().split()))
bef = [(-1) for _ in range(n)]
max_d = [(-1) for _ in range(n)]
for i, a in enumerate(alst):
max_d[a - 1] = max(max_d[a - 1], i - bef[a - 1])
bef[a - 1] = i
for i in range... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP V... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | import sys
mod = 1000000007
eps = 10**-9
def main():
import sys
input = sys.stdin.buffer.readline
for _ in range(int(input())):
N = int(input())
A = list(map(int, input().split()))
idx = [[-1] for _ in range(N + 1)]
for i, a in enumerate(A):
idx[a].append(i)
... | IMPORT ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FUNC_DEF IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR VAR FUNC_... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | def calc(lst, n):
if not lst:
return n + 1
else:
k = 0
prev = -1
for ele in lst:
k = max(k, ele - prev)
prev = ele
k = max(k, n - prev)
return k
t = int(input())
for _ in range(t):
n = int(input())
a = list(map(int, input().split(... | FUNC_DEF IF VAR RETURN BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FU... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
ls = [[] for i in range(n + 5)]
for i in range(n):
ls[a[i]].append(i)
ans = [-1] * n
mx = n
for i in range(1, n + 1):
n1 = len(ls[i])
if n1 > 0:
cnt = ls[i][0]
f... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR FOR VA... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | def amazing_numbers(n, arr):
occur_lis = [[] for i in range(n + 1)]
for index in range(n):
a = arr[index]
occur_lis[a].append(index + 1)
f = [(0) for i in range(n + 1)]
for i in range(1, n + 1):
lis = occur_lis[i]
if lis != []:
m = max(lis[0], n - lis[-1] + 1)... | FUNC_DEF ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR IF VAR LIST ASSIGN VAR FUNC_CALL VAR VAR NUMBER BIN_O... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | t = int(input())
INF = 10**18
for _ in range(t):
n = int(input())
A = list(map(int, input().split()))
if n == 1:
print(A[0])
continue
d = {}
max_ = {}
f = {}
for i, a in enumerate(A):
if a in d:
max_[a] = max(i - d[a], max_[a])
d[a] = i
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR VAR FUNC_CALL VAR... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | def solve():
n = int(input())
arr = [int(v) for v in input().split()]
distmp = {}
lastidx = {}
inf = n * 10
ans = [inf] + [inf] * n
for i in range(n):
if arr[i] in lastidx:
distmp[arr[i]] = max(distmp[arr[i]], i - lastidx[arr[i]])
else:
distmp[arr[i]] ... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST VAR BIN_OP LIST VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR VAR VA... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | t = int(input())
for p in range(t):
n = int(input())
b = list(map(int, input().split()))
ind = []
for j in range(n + 1):
ind.append([-1])
for j in range(n):
ind[b[j]].append(j)
ord = []
j = 1
while j <= n:
if len(ind[j]) < 2:
pass
else:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR LIST NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIG... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | for _ in range(int(input())):
n = int(input())
arr = list(map(int, input().split()))
arr = [0] + arr
d = dict()
dp = [0] * (n + 1)
dp1 = [0] * (n + 1)
ans = [-1] * (n + 1)
for j in range(1, n + 1):
i = arr[j]
dp[i] = max(dp[i], j - dp1[i])
dp1[i] = j
for x in ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VA... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | import sys
input = sys.stdin.readline
for nt in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
minn = {}
maxx = {}
prev = {}
for i in range(n):
prev[a[i]] = 0
maxx[a[i]] = 0
for i in range(1, n + 1):
diff = i - prev[a[i - 1]]
maxx[a... | IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CAL... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | t = int(input())
for _ in range(t):
n = int(input())
A = list(map(int, input().split()))
setA = set(A)
if len(setA) == 1:
print(*([A[0]] * n))
continue
last_pos = [-1] * (n + 1)
max_dis = [0] * (n + 1)
for i, a in enumerate(A):
max_dis[a] = max(max_dis[a], i - last_po... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP LIST VAR NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBE... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
res = [-1] * (n + 1)
b = [[] for i in range(n + 1)]
for i in range(n):
b[a[i]].append(i + 1)
p = n
for i in range(1, n + 1):
if b[i] == []:
continue
m = 0
m = b[i][0... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR ... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | t = int(input())
for z in range(t):
n = int(input())
a = list(map(int, input().split()))
a.insert(0, -1)
rast = dict()
last = dict()
for i in range(1, n + 1):
x = a[i]
ll = last.get(x, -1)
if ll == -1:
last[x] = i
rast[x] = i
else:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
last = [(-1) for i in range(n + 1)]
gap = [(0) for i in range(n + 1)]
for i in range(n):
gap[a[i]] = max(gap[a[i]], i - last[a[i]])
last[a[i]] = i
for i in range(1, n + 1):
gap[i] = max(gap... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL V... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
b = [10**6] * n
mn = dict()
for i in range(n):
if a[i] in mn:
mn[a[i]].append(i)
else:
mn[a[i]] = [i, -1, n]
for i in mn:
c = 0
mn[i].sort()
for j in... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST BIN_OP NUMBER NUMBER VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR VAR ... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | for x in range(int(input())):
n = int(input())
m = list(map(int, input().split()))
d = {}
ind = {}
for i in range(n):
if m[i] in d:
d[m[i]] = max(d[m[i]], i - ind[m[i]])
ind[m[i]] = i
else:
ind[m[i]] = i
d[m[i]] = i + 1
for i in ran... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | def solve(n):
s = list(map(int, input().split()))
ind = [[] for _ in range(n + 1)]
for i in range(n):
ind[s[i]].append(i)
ans = [1000000] * (n + 1)
for i in range(1, n + 1):
k = 0
length = len(ind[i])
if length == 0:
continue
for j in range(length ... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL V... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | import sys
input = sys.stdin.readline
INF = 10**18
t = int(input())
for _ in range(t):
n = int(input())
arr = list(map(int, input().split()))
tmp = [[-1] for _ in range(n + 1)]
for i in range(n):
tmp[arr[i]].append(i)
mins = [INF] * (n + 1)
for i in range(1, n + 1):
if tmp[i][-1... | IMPORT ASSIGN VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | import sys
def input():
return sys.stdin.readline().strip()
def list2d(a, b, c):
return [[c for j in range(b)] for i in range(a)]
def list3d(a, b, c, d):
return [[[d for k in range(c)] for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e):
return [
[[[e for l in range(d)] for k... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF NUMBER... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | for t in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
x = 300005
f1 = {}
f2 = {}
ans = [x] * n
for i in range(n):
f1[a[i]] = -1
f2[a[i]] = 0
for i in range(n):
f2[a[i]] = max(f2[a[i]], i - f1[a[i]])
f1[a[i]] = i
for i in ra... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR BIN_OP LIST VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER FOR V... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | gans = []
for _ in range(int(input())):
n = int(input())
u = list(map(int, input().split()))
d = dict()
w = []
v = []
ind = 0
for i in range(n):
if u[i] not in d.keys():
d[u[i]] = ind
w.append([])
w[ind].append(i)
ind += 1
v... | ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | import sys
input = sys.stdin.readline
for _ in range(int(input())):
n = int(input())
ar = list(map(int, input().split()))
dic = {}
for i in range(n):
if ar[i] in dic:
dic[ar[i]].append(i)
else:
dic[ar[i]] = [-1, i]
for i in dic:
dic[i].append(n)
a... | IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR VAR LIST NUMBER VAR FOR VAR VAR EXPR FU... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | import sys
input = sys.stdin.readline
t = int(input())
for case in range(t):
n = int(input())
a = [int(x) for x in input().split(" ")]
b = sorted(a)
dict = {}
for i, x in enumerate(a):
if x in dict.keys():
dict[x] += [i]
else:
dict[x] = [i]
c = [[k, [-1] ... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR VAR FUNC_CALL VAR VAR IF VAR FUNC_CALL VAR VAR VAR LIST VAR ASSIGN VAR VAR LI... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | import sys
input = iter(sys.stdin.read().splitlines()).__next__
t = int(input())
for _ in range(t):
n = int(input())
a = list(map(int, input().split()))
occurrences = [[-1] for _ in range(n + 1)]
for i, a_i in enumerate(a):
occurrences[a_i].append(i)
subsegment_lengths = []
for val, occ... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR EXPR... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | t = int(input())
ans = [[] for i in range(t)]
for i in range(t):
n = int(input())
list_a = [*map(int, input().split())]
dict_a = {value_a: [] for value_a in set(list_a)}
for j in range(n):
value = list_a[j]
dict_a[value].append(j)
ans_dict_a = {
value_a: max(
[*ma... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | from sys import stdin
input = stdin.readline
q = int(input())
for _ in range(q):
n = int(input())
l = list(map(int, input().split()))
for i in range(n):
l[i] -= 1
miej = [[-1] for i in range(n)]
for i in range(n):
miej[l[i]].append(i)
for i in range(n):
miej[i].append(n)... | ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR LIST NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | t = int(input())
for i in range(t):
n = int(input())
a = [int(x) for x in input().split()]
dct = {}
for i in a:
dct[i] = -1, 0
now = 0
for i in a:
dct[i] = [now, max(dct[i][1], now - dct[i][0])]
now += 1
for i in dct:
dct[i] = max(dct[i][1], n - dct[i][0])
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR VAR LIST VAR FUNC_CALL VAR VAR VAR NUMBER BIN_OP VAR VAR VAR ... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | def solve():
n = int(input().strip())
a = list(map(int, input().strip().split()))
last_occur = [(-1) for i in range(n + 1)]
max_dist = [(0) for i in range(n + 1)]
max_dist[0] = n
for i in range(n):
elem = a[i]
dist = i - last_occur[elem] - 1
max_dist[elem] = max(dist, max... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | t = int(input())
for case in range(t):
n = int(input())
a = [(int(x) - 1) for x in input().split()]
last_occ = [(-1) for _ in range(n)]
max_dist = [float("-inf") for _ in range(n)]
for i, x in enumerate(a):
max_dist[x] = max(max_dist[x], i - last_occ[x])
last_occ[x] = i
for x in ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_C... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | import sys
input = sys.stdin.readline
tests = int(input())
for case in range(tests):
n = int(input())
ans = [1000000001] * n
a = list(map(int, input().split()))
k = dict()
for i in range(n):
if a[i] not in k:
k[a[i]] = [i]
else:
k[a[i]].append(i)
z = dict... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR LIST VAR... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | t = int(input())
for i in range(t):
n = int(input())
l = list(map(int, input().split()))
d = {}
for j in range(n):
if l[j] not in d:
d[l[j]] = [j]
else:
d[l[j]].append(j)
d1 = {}
for j in d:
d[j].sort()
m = d[j][0] + 1
for k in rang... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR LIST VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR DICT FOR VAR VAR EXPR ... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | import sys
input = sys.stdin.readline
for _ in range(int(input())):
n = int(input())
l = list(map(int, input().split()))
d = {}
for i in range(len(l)):
x = l[i]
if x in d:
d[x].append(i + 1)
else:
d[x] = [0]
d[x].append(i + 1)
ans = [(10**... | IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | import sys
def main():
n = int(sys.stdin.readline().strip())
q = list(map(int, sys.stdin.readline().split()))
clovar, p, x = {}, [], 1000000000.0
for i in range(n):
if q[i] in clovar:
clovar[q[i]].append(i)
else:
clovar[q[i]] = [i]
for o in clovar:
t... | IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR DICT LIST NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR VAR LIST VAR FOR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL ... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | t = int(input())
for j in range(t):
n = int(input())
l = list(map(int, input().split()))
ans = [(-1) for j in range(n + 3)]
d = {}
la = l[-1]
f = l[0]
for j in range(n):
if l[j] not in d:
d[l[j]] = []
if f != l[j]:
d[l[j]].append(-1)
d[... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR DICT ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VA... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | import sys
def minp():
return sys.stdin.readline().strip()
def mint():
return int(minp())
def mints():
return map(int, minp().split())
def solve():
p = dict()
b = dict()
i = 0
n = mint()
for x in mints():
if x in p:
b[x] = max(b[x], i - p[x])
else:
... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | T = int(input())
for _ in range(T):
n = int(input())
a = [(int(x) - 1) for x in input().split()]
prev = [(-1) for _ in range(n)]
val = [(1) for _ in range(n)]
for i, x in enumerate(a):
delta = i - prev[x]
val[x] = max(val[x], delta)
prev[x] = i
for i in range(n):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIG... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | t = int(input())
for _ in range(t):
n = int(input())
a = [0] + list(map(int, input().split()))
period = [(0) for i in range(n + 1)]
first = [(-1) for i in range(n + 1)]
last = [(-1) for i in range(n + 1)]
for i in range(1, len(a)):
b = a[i]
if first[b] == -1:
first[b]... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR ... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | for _ in range(int(input())):
n = int(input())
arr = list(map(int, input().split()))
di = dict()
di2 = dict()
for i in range(n):
if arr[i] not in di:
di2[arr[i]] = 0
di[arr[i]] = -1
di2[arr[i]] = max(di2[arr[i]], i - di[arr[i]])
di[arr[i]] = i
for ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR VAR FU... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | for j in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
d = [[-1, -1]] * (n + 1)
for i in range(n):
y = a[i]
s = max(d[y][1], i - d[y][0])
d[y] = [i, s]
for i in range(n + 1):
d[i][1] = max(d[i][1], n - d[i][0])
y = [i for i in range(1, ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST LIST NUMBER NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER BIN_OP VAR VAR VAR ... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | import sys
input = sys.stdin.buffer.readline
def prog():
for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
locs = [[-1] for u in range(n + 1)]
for i in range(n):
locs[a[i]].append(i)
for i in range(1, n + 1):
locs[i]... | IMPORT ASSIGN VAR VAR FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR FOR VAR FUNC_CALL... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | import sys
readline = sys.stdin.readline
T = int(readline())
Ans = [None] * T
INF = 10**9 + 7
for qu in range(T):
N = int(readline())
A = list(map(int, readline().split()))
table = [-1] * (N + 1)
pre = [-1] * (N + 1)
for i in range(N):
a = A[i]
table[a] = max(table[a], i - pre[a])
... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NONE VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER A... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | def solve(n, a):
maxD = [1] * (n + 1)
lastP = [-1] * (n + 1)
for i in range(n):
d = i - lastP[a[i]]
maxD[a[i]] = max(maxD[a[i]], d)
lastP[a[i]] = i
res = [-1] * n
k = n
for v in range(1, n + 1):
if lastP[v] == -1:
continue
minK = max(maxD[v], n... | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_O... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | import sys
input = sys.stdin.readline
def inp():
return int(input())
def inlt():
return list(map(int, input().split()))
test_cases = inp()
max_poss = 3123456
def solve():
n = inp()
arr = inlt()
max_dist = {}
last_ind = {}
for ind, num in enumerate(arr):
dist = ind - last_ind... | IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP ... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | MAXN = 300005
t = int(input())
for _ in range(t):
n = int(input())
a = map(int, input().split())
lst = [0] * (n + 5)
ai_sep = [-1] * (n + 5)
for i, ai in enumerate(a, 1):
ai_sep[ai] = ai_sep[ai] if ai_sep[ai] > i - lst[ai] else i - lst[ai]
lst[ai] = i
sep_ai = [MAXN] * (n + 5)
... | ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR V... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | t = input()
t = int(t)
def solve(n, arr):
ans = [float("inf") for _ in range(n)]
pos = {}
dist = {}
for i in range(n):
pos[arr[i]] = 0
dist[arr[i]] = 0
for i in range(n):
dis = i + 1 - pos[arr[i]]
dist[arr[i]] = max(dis, dist[arr[i]])
pos[arr[i]] = i + 1
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING VAR FUNC_CALL VAR VAR ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR VAR VAR ASSIGN VAR VAR VAR ... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | import sys
input = sys.stdin.readline
for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split(" ")))
l = [-1] * n
u = [-1] * n
k = [-1] * n
for x in range(n):
i = a[x] - 1
l[i] = max(l[i], x - u[i])
u[i] = x
m = n
i = [x for x in range(n) i... | IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN ... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | t = int(input())
for _ in range(t):
n = int(input())
a = list(map(int, input().split()))
dic = {}
for i in range(n):
temp = dic.get(a[i], 0)
if temp == 0:
dic[a[i]] = [i + 1, 0, n - i]
else:
dic[a[i]] = [temp[0], max(temp[1], temp[2] - (n - i)), n - i]
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR VAR LIST BIN_OP VAR NUMBER NUMBER BIN_... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | for anynumber in range(int(input())):
n = int(input())
l = list(map(int, input().split()))
d = {}
for index, i in enumerate(l):
if i not in d.keys():
d[i] = [index + 1, index]
else:
d[i] = [max(index - d[i][1], d[i][0]), index]
for i in d.keys():
d[i] ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR VAR FUNC_CALL VAR VAR IF VAR FUNC_CALL VAR ASSIGN VAR VAR LIST BIN_OP VAR NUMBER VAR ASSIGN VAR VAR LIST FUNC_CALL VAR BIN_OP VAR VAR VAR NU... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | for tc in range(int(input())):
n = int(input())
s = list(map(int, input().split()))
prev = [(-1) for i in range(n + 1)]
maxGap = [(-1) for i in range(n + 1)]
for i in range(len(s)):
if i - prev[s[i]] > maxGap[s[i]]:
maxGap[s[i]] = i - prev[s[i]]
prev[s[i]] = i
for i i... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR VA... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | def read_line():
return list(map(int, input().split()))
def A(d, i, x):
if x not in d:
d[x] = [-1, i]
return
d[x][0] = max(i - d[x][1], d[x][0])
d[x][1] = i
T = int(input())
for _ in range(T):
n = int(input())
l = read_line()
d = {}
s = {}
for x in l:
if x... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR VAR ASSIGN VAR VAR LIST NUMBER VAR RETURN ASSIGN VAR VAR NUMBER FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL V... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | t = int(input())
for _ in range(t):
n = int(input())
arr = [int(x) for x in input().split()]
dict = {}
for i in range(n):
if arr[i] in dict:
dict[arr[i]].append(i)
else:
dict[arr[i]] = [-1, i]
for i in dict:
dict[i].append(n)
out = [(-1) for x in r... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR VAR LIST NUMBER VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR V... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | for _ in range(int(input())):
n = int(input())
lis = list(map(int, input().split()))
d = {}
for i in range(n):
if lis[i] not in d:
d[lis[i]] = []
d[lis[i]].append(i)
else:
d[lis[i]].append(i)
for i in d:
d[i].append(n)
ans = [1000000000... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR LIST EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR FOR VAR VAR EXPR FUNC... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | from sys import stdin
t = int(stdin.readline())
for case in range(t):
n = int(stdin.readline())
array = list(map(int, stdin.readline().split()))
dict1 = {}
dict2 = {}
ans = [-1] * n
for i in range(n):
if array[i] not in dict2:
dict2[array[i]] = i
dict1[array[i]] ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR ... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
ind = [[0] for i in range(n + 1)]
maxi = int(100000000.0)
ans = [maxi] * (n + 1)
for i in range(n):
ind[a[i]].append(i + 1)
for i in range(n + 1):
ind[i].append(n + 1)
for i in range(1, n +... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR EX... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | for _ in range(int(input())):
n = int(input())
l = [int(x) for x in input().split()]
d = {}
for i in range(n):
if l[i] not in d:
d[l[i]] = [i + 1]
else:
temp = d[l[i]]
temp.append(i + 1)
d[l[i]] = temp
for i in d:
d[i].append(n ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR LIST BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | def main():
n = int(input())
a = list(map(int, input().split()))
p = [(-1) for _ in range(n)]
f = [(0) for _ in range(n)]
for i in range(n):
element = a[i] - 1
f[element] = max(f[element], i - p[element])
p[element] = i
ans = [(-1) for _ in range(n + 1)]
for x in rang... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | import sys
input = lambda: sys.stdin.readline().rstrip()
T = int(input())
for _ in range(T):
N = int(input())
A = [(int(a) - 1) for a in input().split()]
X = [-1] * N
Y = [0] * N
for i, a in enumerate(A):
Y[a] = max(Y[a], i - X[a] - 1)
X[a] = i
for i in range(N):
Y[i] = ... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR VAR FUNC_CALL VAR VAR ASSIG... |
You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.
Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ e... | import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
n = int(input())
l = list(map(int, input().split()))
last = [-1] * (n + 1)
best = [1] * (n + 1)
for i in range(n):
v = l[i]
diff = i - last[v]
best[v] = max(best[v], diff)
last[v] = i
for v... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIG... |
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person.
Person A will NOT friend request person B (B != A) if any of the following conditions are true:
age[B] <= 0.5 * age[A] + 7
age[B] > age[A]
age[B] > 100 && age[A] < 100
Otherwise, A will friend request B.
... | class Solution:
def numFriendRequests(self, ages: List[int]) -> int:
n = len(ages)
if n < 2:
return 0
ages.sort()
mins = [0] * n
pairs = [0] * n
mins[0] = ages[0] / 2 + 7
for i in range(1, n):
mins[i] = (ages[i] - ages[i - 1]) / 2 + mi... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER RETURN NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR ... |
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person.
Person A will NOT friend request person B (B != A) if any of the following conditions are true:
age[B] <= 0.5 * age[A] + 7
age[B] > age[A]
age[B] > 100 && age[A] < 100
Otherwise, A will friend request B.
... | class Solution:
def numFriendRequests(self, ages: List[int]) -> int:
ageIdx = defaultdict(list)
for i, age in enumerate(ages):
ageIdx[age].append(i)
count = 0
for age in ageIdx:
lowerBound = int(1 / 2 * age) + 7 + 1
upperBound = age
fo... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR BIN_OP BIN_OP NUMBER NUMBER VAR NUMBER NUMBER ASSIGN VAR VAR FOR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF VAR VAR IF VAR... |
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person.
Person A will NOT friend request person B (B != A) if any of the following conditions are true:
age[B] <= 0.5 * age[A] + 7
age[B] > age[A]
age[B] > 100 && age[A] < 100
Otherwise, A will friend request B.
... | class Solution:
def numFriendRequests(self, ages: List[int]) -> int:
count = Counter(ages)
ans = 0
for i in count:
for j in count:
if not (j <= i * 0.5 + 7 or j > i):
ans += count[i] * count[j]
if j == i:
... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR FOR VAR VAR IF VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR VAR VAR BIN_OP VAR VAR VAR VAR IF VAR VAR VAR VAR VAR RETURN VAR VAR |
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person.
Person A will NOT friend request person B (B != A) if any of the following conditions are true:
age[B] <= 0.5 * age[A] + 7
age[B] > age[A]
age[B] > 100 && age[A] < 100
Otherwise, A will friend request B.
... | class Solution:
def numFriendRequests(self, ages: List[int]) -> int:
count = 0
counter = [0] * 121
for i in ages:
counter[i] += 1
for a in range(1, 121):
for b in range(1, 121):
if b > a:
continue
if b <= 0.... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR VAR IF VAR BIN_OP BIN_OP NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER VAR BIN_OP VAR VAR VAR VAR IF VAR VAR VAR VAR VAR RETURN VAR VAR |
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person.
Person A will NOT friend request person B (B != A) if any of the following conditions are true:
age[B] <= 0.5 * age[A] + 7
age[B] > age[A]
age[B] > 100 && age[A] < 100
Otherwise, A will friend request B.
... | class Solution:
def numFriendRequests(self, ages: List[int]) -> int:
dp = [0] * 121
for i in ages:
dp[i] += 1
ans = 0
mp = {}
for i in range(15, 121):
p = 0
if dp[i] > 0:
if i % 2 == 0:
Min = int(i / 2 +... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER IF VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR... |
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person.
Person A will NOT friend request person B (B != A) if any of the following conditions are true:
age[B] <= 0.5 * age[A] + 7
age[B] > age[A]
age[B] > 100 && age[A] < 100
Otherwise, A will friend request B.
... | class Solution:
def numFriendRequests(self, ages: List[int]) -> int:
age_dic = {age: ages.count(age) for age in range(1, 121)}
pairs = 0
for A in range(1, 121):
for B in range(1, 121):
if B <= 0.5 * A + 7:
continue
elif B > A:
... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR BIN_OP BIN_OP NUMBER VAR NUMBER IF VAR VAR IF VAR NUMBER VAR NUMBER VAR BIN_OP VAR VAR VAR VAR IF VAR VAR VAR VAR VAR RETURN VAR VA... |
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person.
Person A will NOT friend request person B (B != A) if any of the following conditions are true:
age[B] <= 0.5 * age[A] + 7
age[B] > age[A]
age[B] > 100 && age[A] < 100
Otherwise, A will friend request B.
... | class Solution:
def check(self, a, b):
if b <= 0.5 * a + 7:
return False
if b > a:
return False
if b > 100 and a < 100:
return False
return True
def numFriendRequests(self, ages: List[int]) -> int:
cnt = 0
c = [(0) for x in ra... | CLASS_DEF FUNC_DEF IF VAR BIN_OP BIN_OP NUMBER VAR NUMBER RETURN NUMBER IF VAR VAR RETURN NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUN... |
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person.
Person A will NOT friend request person B (B != A) if any of the following conditions are true:
age[B] <= 0.5 * age[A] + 7
age[B] > age[A]
age[B] > 100 && age[A] < 100
Otherwise, A will friend request B.
... | class Solution:
def B_search(self, nums, target):
low, high = 0, len(nums) - 1
while low < high:
mid = low + (high - low) // 2
if nums[mid] < target:
low = mid + 1
else:
high = mid
return high
def numFriendRequests(sel... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR RETURN VAR FUNC_DEF VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL ... |
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person.
Person A will NOT friend request person B (B != A) if any of the following conditions are true:
age[B] <= 0.5 * age[A] + 7
age[B] > age[A]
age[B] > 100 && age[A] < 100
Otherwise, A will friend request B.
... | class Solution:
def numFriendRequests(self, ages: List[int]) -> int:
def request(a, b):
return not (b <= 0.5 * a + 7 or b > a or b > 100 and a < 100)
c = collections.Counter(ages)
return sum(request(a, b) * c[a] * (c[b] - (a == b)) for a in c for b in c) | CLASS_DEF FUNC_DEF VAR VAR FUNC_DEF RETURN VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR VAR |
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person.
Person A will NOT friend request person B (B != A) if any of the following conditions are true:
age[B] <= 0.5 * age[A] + 7
age[B] > age[A]
age[B] > 100 && age[A] < 100
Otherwise, A will friend request B.
... | class Solution:
def numFriendRequests(self, ages: List[int]) -> int:
counter = Counter(ages)
ages = list(counter.keys())
res = 0
for a in ages:
for b in ages:
if b <= 0.5 * a + 7:
continue
if b > a:
... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR FOR VAR VAR IF VAR BIN_OP BIN_OP NUMBER VAR NUMBER IF VAR VAR IF VAR NUMBER VAR NUMBER IF VAR VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR VAR VAR RETURN VAR VAR |
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person.
Person A will NOT friend request person B (B != A) if any of the following conditions are true:
age[B] <= 0.5 * age[A] + 7
age[B] > age[A]
age[B] > 100 && age[A] < 100
Otherwise, A will friend request B.
... | class Solution:
def numFriendRequests(self, ages: List[int]) -> int:
d = {}
ans = 0
for age in ages:
if age not in d:
d[age] = 1
else:
d[age] += 1
print(d)
for ageA, countA in list(d.items()):
for ageB, coun... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR IF BIN_OP BIN_OP VAR NUMBER NUMBER VAR IF VAR VAR IF VAR NUMB... |
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person.
Person A will NOT friend request person B (B != A) if any of the following conditions are true:
age[B] <= 0.5 * age[A] + 7
age[B] > age[A]
age[B] > 100 && age[A] < 100
Otherwise, A will friend request B.
... | class Solution:
def numFriendRequests(self, ages: List[int]) -> int:
def friendRequests(age_a, age_b):
if age_b <= 0.5 * age_a + 7 or age_b > age_a:
return False
return True
age_groups = collections.Counter(ages)
total_requests = 0
for age_a... | CLASS_DEF FUNC_DEF VAR VAR FUNC_DEF IF VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR IF VAR VAR VAR VAR RETURN VAR VAR |
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person.
Person A will NOT friend request person B (B != A) if any of the following conditions are true:
age[B] <= 0.5 * age[A] + 7
age[B] > age[A]
age[B] > 100 && age[A] < 100
Otherwise, A will friend request B.
... | class Solution:
def numFriendRequests(self, ages: List[int]) -> int:
count = [0] * 121
s = [0] * 121
for a in ages:
count[a] += 1
for i in range(1, 121):
s[i] = s[i - 1] + count[i]
res = 0
for i in range(15, 121):
edge = i // 2 + 7... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN ... |
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person.
Person A will NOT friend request person B (B != A) if any of the following conditions are true:
age[B] <= 0.5 * age[A] + 7
age[B] > age[A]
age[B] > 100 && age[A] < 100
Otherwise, A will friend request B.
... | class Solution:
def numFriendRequests(self, ages: List[int]) -> int:
ages.sort()
res = 0
i = 0
while i < len(ages):
if ages[i] <= 14:
i += 1
else:
break
if i == len(ages):
return 0
leftmost = i
... | CLASS_DEF FUNC_DEF VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR NUMBER IF VAR FUNC_CALL VAR VAR RETURN NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER... |
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person.
Person A will NOT friend request person B (B != A) if any of the following conditions are true:
age[B] <= 0.5 * age[A] + 7
age[B] > age[A]
age[B] > 100 && age[A] < 100
Otherwise, A will friend request B.
... | class Solution:
def numFriendRequests(self, ages: List[int]) -> int:
ages = sorted(ages)
print(ages)
def bound(a):
low = a // 2 + 8
hi = a
return min(low, a), hi
def getlow(v):
lo, hi = 0, len(ages)
while lo < hi:
... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR RETURN FUNC_CALL VAR VAR VAR VAR FUNC_DEF ASSIGN VAR VAR NUMBER FUNC_CALL VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR VAR ASSIGN V... |
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person.
Person A will NOT friend request person B (B != A) if any of the following conditions are true:
age[B] <= 0.5 * age[A] + 7
age[B] > age[A]
age[B] > 100 && age[A] < 100
Otherwise, A will friend request B.
... | class Solution:
def numFriendRequests(self, ages: List[int]) -> int:
def invert(a):
return -1 * a
ages.sort(key=invert)
age_request_map = collections.defaultdict(int)
num_requests = 0
for age in ages:
if age <= 14:
break
... | CLASS_DEF FUNC_DEF VAR VAR FUNC_DEF RETURN BIN_OP NUMBER VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR NUMBER RETURN... |
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person.
Person A will NOT friend request person B (B != A) if any of the following conditions are true:
age[B] <= 0.5 * age[A] + 7
age[B] > age[A]
age[B] > 100 && age[A] < 100
Otherwise, A will friend request B.
... | class Solution:
def numFriendRequests(self, ages: List[int]) -> int:
counts = Counter(ages)
requests = 0
conditions = [
lambda ageA, ageB: 0.5 * ageA + 7 >= ageB,
lambda ageA, ageB: ageA < ageB,
]
def canSendRequest(ageA, ageB):
return no... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST BIN_OP BIN_OP NUMBER VAR NUMBER VAR VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR FOR VAR VAR FUNC_CALL VAR FOR VAR VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR VAR IF VAR VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR B... |
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person.
Person A will NOT friend request person B (B != A) if any of the following conditions are true:
age[B] <= 0.5 * age[A] + 7
age[B] > age[A]
age[B] > 100 && age[A] < 100
Otherwise, A will friend request B.
... | class Solution:
def numFriendRequests(self, ages: List[int]) -> int:
count = collections.Counter(ages)
ans = 0
for A, countA in count.items():
for B, countB in count.items():
if B <= 0.5 * A + 7:
continue
elif B > A:
... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR FOR VAR VAR FUNC_CALL VAR IF VAR BIN_OP BIN_OP NUMBER VAR NUMBER IF VAR VAR IF VAR NUMBER VAR NUMBER VAR BIN_OP VAR VAR IF VAR VAR VAR VAR RETURN VAR VAR |
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person.
Person A will NOT friend request person B (B != A) if any of the following conditions are true:
age[B] <= 0.5 * age[A] + 7
age[B] > age[A]
age[B] > 100 && age[A] < 100
Otherwise, A will friend request B.
... | class Solution:
def numFriendRequests(self, ages: List[int]) -> int:
age_library = {}
for age in ages:
age_library[age] = age_library.get(age, 0) + 1
res = 0
for A, numA in list(age_library.items()):
for B, numB in list(age_library.items()):
i... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR VAR VAR NUMBER VAR NUMBER VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR... |
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person.
Person A will NOT friend request person B (B != A) if any of the following conditions are true:
age[B] <= 0.5 * age[A] + 7
age[B] > age[A]
age[B] > 100 && age[A] < 100
Otherwise, A will friend request B.
... | class Solution:
def numFriendRequests(self, ages: List[int]) -> int:
counter = [0] * 121
res = 0
for a in ages:
if a <= 14:
continue
counter[a] += 1
for i in range(15, 121):
for j in range(i + 1):
if j <= 0.5 * i + ... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR BIN_OP VAR VAR VAR VAR IF VAR VAR VAR VAR VAR RETURN VAR VAR |
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person.
Person A will NOT friend request person B (B != A) if any of the following conditions are true:
age[B] <= 0.5 * age[A] + 7
age[B] > age[A]
age[B] > 100 && age[A] < 100
Otherwise, A will friend request B.
... | class Solution:
def numFriendRequests(self, ages: List[int]) -> int:
ageCounts = Counter(ages)
numRequests = 0
for a in range(1, 121):
if ageCounts[a] > 0:
exclLowerBound = 0.5 * a + 7
lowerBound = ceil(exclLowerBound)
if lowerBoun... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR IF VAR VAR VAR BIN_OP VAR VAR BIN_OP VAR ... |
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person.
Person A will NOT friend request person B (B != A) if any of the following conditions are true:
age[B] <= 0.5 * age[A] + 7
age[B] > age[A]
age[B] > 100 && age[A] < 100
Otherwise, A will friend request B.
... | class Solution:
def numFriendRequests(self, ages: List[int]) -> int:
sum = 0
counts = collections.Counter(ages)
ages = sorted(counts.keys())
for A in range(0, len(ages)):
for B in range(0, len(ages)):
condition1 = ages[B] <= 0.5 * ages[A] + 7
... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR VAR BIN_OP BIN_OP NUMBER VAR VAR NUMBER ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER VAR V... |
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person.
Person A will NOT friend request person B (B != A) if any of the following conditions are true:
age[B] <= 0.5 * age[A] + 7
age[B] > age[A]
age[B] > 100 && age[A] < 100
Otherwise, A will friend request B.
... | class Solution:
def numFriendRequests(self, ages: List[int]) -> int:
def req(A, B):
if B <= 0.5 * A + 7 or B > A or B > 100 and A < 100:
return False
return True
cnt = Counter(ages)
ans = 0
for i in cnt:
if cnt[i] > 1 and req(i, ... | CLASS_DEF FUNC_DEF VAR VAR FUNC_DEF IF VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR VAR VAR NUMBER VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR NUMBER FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR NUMBER FOR VAR VAR IF VAR VAR FUNC_CALL VAR VAR VAR VA... |
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person.
Person A will NOT friend request person B (B != A) if any of the following conditions are true:
age[B] <= 0.5 * age[A] + 7
age[B] > age[A]
age[B] > 100 && age[A] < 100
Otherwise, A will friend request B.
... | class Solution:
def numFriendRequests(self, ages: List[int]) -> int:
counts = [0] * 121
for age in ages:
counts[age] += 1
SUM = 0
sums = []
for c in counts:
SUM += c
sums.append(SUM)
res = 0
for age in range(15, 121):
... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR... |
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person.
Person A will NOT friend request person B (B != A) if any of the following conditions are true:
age[B] <= 0.5 * age[A] + 7
age[B] > age[A]
age[B] > 100 && age[A] < 100
Otherwise, A will friend request B.
... | class Solution:
def numFriendRequests(self, ages: List[int]) -> int:
a = sorted(ages)
i, j, k = 0, 0, 0
ans = 0
for i in range(1, len(a)):
if a[i] <= 14:
continue
lb = a[i] * 0.5 + 7
while a[j] <= lb:
j += 1
... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER WHILE VAR VAR VAR VAR NUMBER VAR BIN_OP VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR VAR BIN_OP V... |
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person.
Person A will NOT friend request person B (B != A) if any of the following conditions are true:
age[B] <= 0.5 * age[A] + 7
age[B] > age[A]
age[B] > 100 && age[A] < 100
Otherwise, A will friend request B.
... | class Solution:
def numFriendRequests(self, ages: List[int]) -> int:
age_count = Counter(ages)
distinct_ages = set(age_count.keys())
total_req = 0
for a_age in distinct_ages:
a_frn_req = 0
for b_age in distinct_ages:
if b_age > a_age or a_age ... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER VAR VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR BIN_OP VAR VAR VAR VAR IF VAR VAR VAR VAR VAR VAR VAR RETURN VAR VAR |
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person.
Person A will NOT friend request person B (B != A) if any of the following conditions are true:
age[B] <= 0.5 * age[A] + 7
age[B] > age[A]
age[B] > 100 && age[A] < 100
Otherwise, A will friend request B.
... | class Solution:
def numFriendRequests(self, ages: List[int]) -> int:
if ages == []:
return 0
ages.sort()
res = 0
for i in range(len(ages) - 1, -1, -1):
if ages[i] < 15:
break
age = ages[i]
left = self.binary_search_left... | CLASS_DEF FUNC_DEF VAR VAR IF VAR LIST RETURN NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR... |
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person.
Person A will NOT friend request person B (B != A) if any of the following conditions are true:
age[B] <= 0.5 * age[A] + 7
age[B] > age[A]
age[B] > 100 && age[A] < 100
Otherwise, A will friend request B.
... | class Solution:
def numFriendRequests(self, ages: List[int]) -> int:
age_cnt = [0] * 121
for age in ages:
age_cnt[age] += 1
res = 0
for ageA, cntA in enumerate(age_cnt):
for ageB, cntB in enumerate(age_cnt):
if ageB <= 0.5 * ageA + 7 or ageB >... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR IF VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR VAR VAR NUMBER VAR NUMBER VAR BIN_OP VAR VAR IF VAR VAR VAR VAR RETURN VAR VAR |
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person.
Person A will NOT friend request person B (B != A) if any of the following conditions are true:
age[B] <= 0.5 * age[A] + 7
age[B] > age[A]
age[B] > 100 && age[A] < 100
Otherwise, A will friend request B.
... | class Solution:
def numFriendRequests(self, ages: List[int]) -> int:
ages.sort()
ans, i, j = 0, 0, 0
while i < len(ages):
val = ages[i]
while j < i and ages[j] <= 0.5 * val + 7:
j += 1
cnt, num_equal = i - j, 0
while i < len(ag... | CLASS_DEF FUNC_DEF VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR WHILE VAR VAR VAR VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP VAR N... |
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person.
Person A will NOT friend request person B (B != A) if any of the following conditions are true:
age[B] <= 0.5 * age[A] + 7
age[B] > age[A]
age[B] > 100 && age[A] < 100
Otherwise, A will friend request B.
... | class Solution:
def numFriendRequests(self, ages: List[int]) -> int:
ages = sorted(ages)
count, temp_count = 0, 0
for i in range(len(ages) - 1, -1, -1):
if i + 1 < len(ages) and ages[i + 1] == ages[i]:
count += temp_count
continue
temp... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR VAR ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR NUMBER WHI... |
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person.
Person A will NOT friend request person B (B != A) if any of the following conditions are true:
age[B] <= 0.5 * age[A] + 7
age[B] > age[A]
age[B] > 100 && age[A] < 100
Otherwise, A will friend request B.
... | class Solution:
def numFriendRequests(self, ages: List[int]) -> int:
cnt = collections.Counter(ages)
ans = 0
for age in ages:
cnt[age] -= 1
left, right = age // 2 + 8, age
ans += sum(cnt[age] for age in range(left, right + 1))
cnt[age] += 1
... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR NUMBER RETURN VAR VAR |
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person.
Person A will NOT friend request person B (B != A) if any of the following conditions are true:
age[B] <= 0.5 * age[A] + 7
age[B] > age[A]
age[B] > 100 && age[A] < 100
Otherwise, A will friend request B.
... | class Solution:
def numFriendRequests(self, ages: List[int]) -> int:
count = [0] * 121
max_age = 0
for age in ages:
count[age] += 1
max_age = max(max_age, age)
ans = 0
for ageA, countA in enumerate(count[: max_age + 2]):
for ageB, countB i... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER NUMBER VAR IF VAR VAR IF VAR NUMBER ... |
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person.
Person A will NOT friend request person B (B != A) if any of the following conditions are true:
age[B] <= 0.5 * age[A] + 7
age[B] > age[A]
age[B] > 100 && age[A] < 100
Otherwise, A will friend request B.
... | class Solution:
def numFriendRequests(self, ages: List[int]) -> int:
if not ages:
return 0
agesToCount = [0] * 121
for age in ages:
agesToCount[age] += 1
result = 0
for ageA in range(1, 121):
for ageB in range(1, 121):
if a... | CLASS_DEF FUNC_DEF VAR VAR IF VAR RETURN NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR VAR VAR BIN_OP BIN_OP NUMBER VAR NUMBER IF VAR VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR ... |
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person.
Person A will NOT friend request person B (B != A) if any of the following conditions are true:
age[B] <= 0.5 * age[A] + 7
age[B] > age[A]
age[B] > 100 && age[A] < 100
Otherwise, A will friend request B.
... | class Solution:
def numFriendRequests(self, ages: List[int]) -> int:
buckets = [0] * 121
for age in ages:
buckets[age] += 1
ans = 0
for i in range(1, 121):
if buckets[i] <= 0:
continue
for j in range(1, 121):
if buc... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR VAR NUMBER IF VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR VAR VAR NUMBER VAR NUMBER VAR BIN_OP VAR VAR VAR VAR IF VAR ... |
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person.
Person A will NOT friend request person B (B != A) if any of the following conditions are true:
age[B] <= 0.5 * age[A] + 7
age[B] > age[A]
age[B] > 100 && age[A] < 100
Otherwise, A will friend request B.
... | class Solution:
def numFriendRequests(self, ages: List[int]) -> int:
def wantToRequest(A, B):
return not (B <= 0.5 * A + 7 or B > A)
count = Counter(ages)
ans = 0
ages = [*sorted(count.keys())]
for i, a in enumerate(ages):
for j in range(0, i + 1):
... | CLASS_DEF FUNC_DEF VAR VAR FUNC_DEF RETURN VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FUNC_CALL VAR FUNC_CALL VAR FOR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR IF FUNC_CALL VAR VAR VAR VAR VAR VAR BIN_OP VA... |
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person.
Person A will NOT friend request person B (B != A) if any of the following conditions are true:
age[B] <= 0.5 * age[A] + 7
age[B] > age[A]
age[B] > 100 && age[A] < 100
Otherwise, A will friend request B.
... | class Solution:
def numFriendRequests(self, ages: List[int]) -> int:
count = [0] * 121
for a in ages:
count[a] += 1
for i, val in enumerate(count):
count[i] = count[i - 1] + val
total = 0
for a in ages:
ageMin = floor(0.5 * a + 8)
... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN... |
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person.
Person A will NOT friend request person B (B != A) if any of the following conditions are true:
age[B] <= 0.5 * age[A] + 7
age[B] > age[A]
age[B] > 100 && age[A] < 100
Otherwise, A will friend request B.
... | class Solution:
def numFriendRequests(self, ages: List[int]) -> int:
if not ages:
return 0
freq = Counter(ages)
def can_request(a, b):
return not (b <= 0.5 * a + 7 or b > a or b > 100 and a < 100)
ans = 0
for a1 in range(1, 121):
for a2 ... | CLASS_DEF FUNC_DEF VAR VAR IF VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF RETURN VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF FUNC_CALL VAR VAR VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR BIN_OP VAR ... |
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person.
Person A will NOT friend request person B (B != A) if any of the following conditions are true:
age[B] <= 0.5 * age[A] + 7
age[B] > age[A]
age[B] > 100 && age[A] < 100
Otherwise, A will friend request B.
... | class Solution:
def firstLTE(self, lowerBound, ages, endIndex):
if endIndex < 0:
return 0
l = 0
r = endIndex
while l < r:
m = (l + r) // 2
if ages[m] <= lowerBound:
l = m + 1
else:
r = m
if l <= ... | CLASS_DEF FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR IF VAR VAR VAR VAR VAR RETURN VAR RETURN BIN_OP VAR NUMBER FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR VA... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.