description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Polycarp often uses his smartphone. He has already installed $n$ applications on it. Application with number $i$ takes up $a_i$ units of memory.
Polycarp wants to free at least $m$ units of memory (by removing some applications).
Of course, some applications are more important to Polycarp than others. He came up with... | for _ in range(int(input())):
n, m = map(int, input().split())
a = list(map(int, input().split()))
c = list(map(int, input().split()))
o, t, s = [], [], 0
for i in range(n):
s += a[i]
if c[i] == 1:
o.append(a[i])
else:
t.append(a[i])
if s < m:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR LIST LIST NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR IF VA... |
Polycarp often uses his smartphone. He has already installed $n$ applications on it. Application with number $i$ takes up $a_i$ units of memory.
Polycarp wants to free at least $m$ units of memory (by removing some applications).
Of course, some applications are more important to Polycarp than others. He came up with... | import sys
input = lambda: sys.stdin.readline().rstrip()
T = int(input())
for _ in range(T):
N, M = map(int, input().split())
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]
X = []
Y = []
for a, b in zip(A, B):
if b == 1:
X.append(a)
else:... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VA... |
Polycarp often uses his smartphone. He has already installed $n$ applications on it. Application with number $i$ takes up $a_i$ units of memory.
Polycarp wants to free at least $m$ units of memory (by removing some applications).
Of course, some applications are more important to Polycarp than others. He came up with... | t = int(input())
for _ in range(t):
n, m = map(int, input().split())
mem = list(map(int, input().split()))
imp = list(map(int, input().split()))
one = []
two = []
for mi, pi in zip(mem, imp):
if pi == 1:
one.append(mi)
else:
two.append(mi)
one.sort(rev... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR VA... |
Polycarp often uses his smartphone. He has already installed $n$ applications on it. Application with number $i$ takes up $a_i$ units of memory.
Polycarp wants to free at least $m$ units of memory (by removing some applications).
Of course, some applications are more important to Polycarp than others. He came up with... | def main():
for _ in range(int(input())):
n, m = map(int, input().split())
d = {"1": [], "2": []}
for a, b in zip(map(int, input().split()), input().split()):
d[b].append(a)
if sum(map(sum, d.values())) < m:
print(-1)
continue
i, j, k, best... | FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT STRING STRING LIST LIST FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL ... |
Polycarp often uses his smartphone. He has already installed $n$ applications on it. Application with number $i$ takes up $a_i$ units of memory.
Polycarp wants to free at least $m$ units of memory (by removing some applications).
Of course, some applications are more important to Polycarp than others. He came up with... | for _ in range(int(input())):
n, m = map(int, input().split())
memoryCost = list(map(int, input().split()))
convPoints = list(map(int, input().split()))
cost1 = list()
cost2 = list()
for mem, conv in zip(memoryCost, convPoints):
if conv == 1:
cost1.append(mem)
else:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL 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 VAR FUNC_CALL VAR VAR... |
Polycarp often uses his smartphone. He has already installed $n$ applications on it. Application with number $i$ takes up $a_i$ units of memory.
Polycarp wants to free at least $m$ units of memory (by removing some applications).
Of course, some applications are more important to Polycarp than others. He came up with... | def find():
n, m = map(int, input().split())
mem = tuple(input().split())
val = tuple(input().split())
a = []
b = []
for i in range(n):
a.append(int(mem[i])) if int(val[i]) == 1 else b.append(int(mem[i]))
a.sort(reverse=True)
b.sort(reverse=True)
sumA = 0
sumB = sum(b)
... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR ... |
Polycarp often uses his smartphone. He has already installed $n$ applications on it. Application with number $i$ takes up $a_i$ units of memory.
Polycarp wants to free at least $m$ units of memory (by removing some applications).
Of course, some applications are more important to Polycarp than others. He came up with... | t = int(input())
for _ in range(t):
n, g = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if g > sum(a):
print(-1)
continue
p1, p2 = [], []
for i in range(n):
if b[i] == 1:
p1.append(a[i])
else:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VA... |
Polycarp often uses his smartphone. He has already installed $n$ applications on it. Application with number $i$ takes up $a_i$ units of memory.
Polycarp wants to free at least $m$ units of memory (by removing some applications).
Of course, some applications are more important to Polycarp than others. He came up with... | cases = int(input())
for i in range(cases):
n, m = map(int, input().split())
twos = []
ones = []
mem = list(map(int, input().split()))
conv = list(map(int, input().split()))
for i in range(n):
if conv[i] == 2:
twos.append(mem[i])
else:
ones.append(mem[i])
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR... |
Polycarp often uses his smartphone. He has already installed $n$ applications on it. Application with number $i$ takes up $a_i$ units of memory.
Polycarp wants to free at least $m$ units of memory (by removing some applications).
Of course, some applications are more important to Polycarp than others. He came up with... | t = int(input())
for _ in range(t):
n, m = map(int, input().split())
release = [int(i) for i in input().split()]
cost = [int(i) for i in input().split()]
one_cost = [release[i] for i in range(n) if cost[i] == 1]
two_cost = [release[i] for i in range(n) if cost[i] == 2]
one_cost.sort(reverse=True... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR FUNC_... |
Polycarp often uses his smartphone. He has already installed $n$ applications on it. Application with number $i$ takes up $a_i$ units of memory.
Polycarp wants to free at least $m$ units of memory (by removing some applications).
Of course, some applications are more important to Polycarp than others. He came up with... | for i in range(int(input())):
n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
one = []
two = []
l1 = l2 = 0
for j in range(n):
if b[j] == 1:
one.append(a[j])
l1 += 1
else:
two.append(... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR... |
Polycarp often uses his smartphone. He has already installed $n$ applications on it. Application with number $i$ takes up $a_i$ units of memory.
Polycarp wants to free at least $m$ units of memory (by removing some applications).
Of course, some applications are more important to Polycarp than others. He came up with... | for _ in range(int(input())):
n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
arrA = []
arrB = []
for i in range(n):
if b[i] == 1:
arrA.append(a[i])
else:
arrB.append(a[i])
arrA.sort(reverse=True... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXP... |
Polycarp often uses his smartphone. He has already installed $n$ applications on it. Application with number $i$ takes up $a_i$ units of memory.
Polycarp wants to free at least $m$ units of memory (by removing some applications).
Of course, some applications are more important to Polycarp than others. He came up with... | def solve(a, b, m):
s = 0
while m > 0 and a and b:
if a[-1] >= m:
m -= a.pop()
s += 1
break
elif len(a) == 1 or b[-1] > a[-1] + a[-2]:
m -= b.pop()
s += 2
else:
s += 1
m -= a.pop()
while m > 0 and a:
... | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR VAR IF VAR NUMBER VAR VAR FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR WHILE VAR NUMBER VAR VAR NUMBER VAR FUNC_CALL VAR WHILE VAR NUMBER VAR VAR NUMBER VAR FUNC_CALL... |
Polycarp often uses his smartphone. He has already installed $n$ applications on it. Application with number $i$ takes up $a_i$ units of memory.
Polycarp wants to free at least $m$ units of memory (by removing some applications).
Of course, some applications are more important to Polycarp than others. He came up with... | import sys
t = int(input())
for _ in range(0, t, 1):
n, m = map(int, input().split())
one, two, x, ok, mini = [], [], 0, False, 2 * n + 10
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]
for i in range(0, n, 1):
if B[i] == 1:
one.append(A[i])
... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR LIST LIST NUMBER NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC... |
Polycarp often uses his smartphone. He has already installed $n$ applications on it. Application with number $i$ takes up $a_i$ units of memory.
Polycarp wants to free at least $m$ units of memory (by removing some applications).
Of course, some applications are more important to Polycarp than others. He came up with... | def find_convenience_lost(n):
memory = list(map(int, input().split()))[1]
memory_per_app, weight = list(map(int, input().split())), list(
map(int, input().split())
)
ones = list(
reversed(sorted([a for i, a in enumerate(memory_per_app) if weight[i] == 1]))
)
twos = list(
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR F... |
Polycarp often uses his smartphone. He has already installed $n$ applications on it. Application with number $i$ takes up $a_i$ units of memory.
Polycarp wants to free at least $m$ units of memory (by removing some applications).
Of course, some applications are more important to Polycarp than others. He came up with... | import sys
def main():
t = int(input())
allAns = []
for _ in range(t):
n, m = readIntArr()
oneConvenientPt = []
twoConvenientPts = []
a = readIntArr()
b = readIntArr()
for i in range(n):
if b[i] == 1:
oneConvenientPt.append(a[i])
... | IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL... |
Polycarp often uses his smartphone. He has already installed $n$ applications on it. Application with number $i$ takes up $a_i$ units of memory.
Polycarp wants to free at least $m$ units of memory (by removing some applications).
Of course, some applications are more important to Polycarp than others. He came up with... | tests = int(input())
while tests > 0:
apps, clean = list(map(int, input().split()))
storage = list(map(int, input().split()))
conv = list(map(int, input().split()))
if sum(storage) < clean:
print(-1)
tests -= 1
continue
arr1 = list()
arr2 = list()
for i in range(apps)... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER VAR NUMB... |
Polycarp often uses his smartphone. He has already installed $n$ applications on it. Application with number $i$ takes up $a_i$ units of memory.
Polycarp wants to free at least $m$ units of memory (by removing some applications).
Of course, some applications are more important to Polycarp than others. He came up with... | def solve():
n, m = map(int, input().split())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
one = []
two = []
for i in range(n):
a, b = A[i], B[i]
if b == 1:
one.append(a)
else:
two.append(a)
one = [0] + sorted(one... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL... |
Polycarp often uses his smartphone. He has already installed $n$ applications on it. Application with number $i$ takes up $a_i$ units of memory.
Polycarp wants to free at least $m$ units of memory (by removing some applications).
Of course, some applications are more important to Polycarp than others. He came up with... | import sys
input = sys.stdin.readline
for _ in range(int(input())):
n, m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
E = sorted(filter(lambda i: B[i] == 1, range(n)), key=A.__getitem__, reverse=True)
F = sorted(filter(lambda i: B[i] == 2, rang... | IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER FUN... |
While performing complex market analysis William encountered the following problem:
For a given array $a$ of size $n$ and a natural number $e$, calculate the number of pairs of natural numbers $(i, k)$ which satisfy the following conditions:
$1 \le i, k$
$i + e \cdot k \le n$.
Product $a_i \cdot a_{i + e} \cdot a_{... | n = 10**6
prime = [(True) for i in range(n + 1)]
prime[1] = False
p = 2
while p <= 1000:
if prime[p]:
for i in range(p * p, n + 1, p):
prime[i] = False
p += 1
t = int(input())
for _ in range(t):
n, e = map(int, input().split())
arr = list(map(int, input().split()))
ans = 0
fo... | ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN... |
While performing complex market analysis William encountered the following problem:
For a given array $a$ of size $n$ and a natural number $e$, calculate the number of pairs of natural numbers $(i, k)$ which satisfy the following conditions:
$1 \le i, k$
$i + e \cdot k \le n$.
Product $a_i \cdot a_{i + e} \cdot a_{... | p = [(1) for i in range(10**6 + 1)]
p[0] = 0
p[1] = 0
for i in range(2, len(p)):
if p[i] == 1:
for j in range(i * 2, len(p), i):
if j % i == 0:
p[j] = 0
t = int(input())
for test in range(t):
n, e = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
b... | ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ... |
While performing complex market analysis William encountered the following problem:
For a given array $a$ of size $n$ and a natural number $e$, calculate the number of pairs of natural numbers $(i, k)$ which satisfy the following conditions:
$1 \le i, k$
$i + e \cdot k \le n$.
Product $a_i \cdot a_{i + e} \cdot a_{... | from sys import stdin
p = 2
isprime = [True] * (10**6 + 1)
isprime[0] = isprime[1] = False
while p * p <= 10**6:
if isprime[p]:
for i in range(p * p, 10**6 + 1, p):
isprime[i] = False
p += 1
for _ in range(int(stdin.readline())):
n, e = map(int, stdin.readline().split())
arr = list(... | ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER VAR NUMBER NUMBER WHILE BIN_OP VAR VAR BIN_OP NUMBER NUMBER IF VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER VAR ASSIGN VAR VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUN... |
While performing complex market analysis William encountered the following problem:
For a given array $a$ of size $n$ and a natural number $e$, calculate the number of pairs of natural numbers $(i, k)$ which satisfy the following conditions:
$1 \le i, k$
$i + e \cdot k \le n$.
Product $a_i \cdot a_{i + e} \cdot a_{... | def soe(n):
s = set()
prime = [(True) for i in range(n + 1)]
p = 2
while p * p <= n:
if prime[p] == True:
for i in range(p * p, n + 1, p):
prime[i] = False
p += 1
for p in range(2, n + 1):
if prime[p]:
s.add(p)
return s
s = soe(10... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VA... |
While performing complex market analysis William encountered the following problem:
For a given array $a$ of size $n$ and a natural number $e$, calculate the number of pairs of natural numbers $(i, k)$ which satisfy the following conditions:
$1 \le i, k$
$i + e \cdot k \le n$.
Product $a_i \cdot a_{i + e} \cdot a_{... | primes = []
d = list(range(10**6 + 1))
for i in range(2, 10**6 + 1):
if d[i] == i:
primes.append(i)
for j in primes:
if i * j > 10**6:
break
if j > d[i]:
break
d[i * j] = j
for _ in " " * int(input()):
n, e = map(int, input().split())
a = [int(x) f... | ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER IF VAR VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR VAR IF BIN_OP VAR VAR BIN_OP NUMBER NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR FOR VAR BIN_OP STRING FUNC_CALL ... |
While performing complex market analysis William encountered the following problem:
For a given array $a$ of size $n$ and a natural number $e$, calculate the number of pairs of natural numbers $(i, k)$ which satisfy the following conditions:
$1 \le i, k$
$i + e \cdot k \le n$.
Product $a_i \cdot a_{i + e} \cdot a_{... | from sys import stdin
input = stdin.readline
n = 10**6
prime = [(True) for i in range(n + 1)]
prime[1] = False
p = 2
while p * p <= n:
if prime[p] == True:
for i in range(p * p, n + 1, p):
prime[i] = False
p += 1
for _ in range(int(input())):
n, b = map(int, input().split())
li = li... | ASSIGN VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_... |
While performing complex market analysis William encountered the following problem:
For a given array $a$ of size $n$ and a natural number $e$, calculate the number of pairs of natural numbers $(i, k)$ which satisfy the following conditions:
$1 \le i, k$
$i + e \cdot k \le n$.
Product $a_i \cdot a_{i + e} \cdot a_{... | import sys
def fprime():
taille = 10**6 + 1
primes = [(True) for x in range(taille)]
primes[0] = False
primes[1] = False
for i in range(2, taille):
if primes[i]:
j = 2 * i
while j < taille:
primes[j] = False
j += i
return primes
... | IMPORT FUNC_DEF ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR ASSIGN VAR BIN_OP NUMBER VAR WHILE VAR VAR ASSIGN VAR VAR NUMBER VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR VAR ASSIGN VAR FUNC_... |
While performing complex market analysis William encountered the following problem:
For a given array $a$ of size $n$ and a natural number $e$, calculate the number of pairs of natural numbers $(i, k)$ which satisfy the following conditions:
$1 \le i, k$
$i + e \cdot k \le n$.
Product $a_i \cdot a_{i + e} \cdot a_{... | import sys
isPrime = [True] * int(1000000.0 + 2)
def solve():
inp = sys.stdin.readline
n, e = map(int, inp().split())
a = list(map(int, inp().split()))
w = [True] * n
r = 0
for i in range(n):
if w[i]:
j = 0
z = i
last = -1
last1 = -1
... | IMPORT ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR BIN_OP NUMBER NUMBER FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL 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 NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR ... |
While performing complex market analysis William encountered the following problem:
For a given array $a$ of size $n$ and a natural number $e$, calculate the number of pairs of natural numbers $(i, k)$ which satisfy the following conditions:
$1 \le i, k$
$i + e \cdot k \le n$.
Product $a_i \cdot a_{i + e} \cdot a_{... | isPrime = [(1) for j in range(1000003)]
def sieve(isPrime):
maxN = 1000002
isPrime[0], isPrime[1] = 0, 0
i = 2
while i * i <= maxN:
if isPrime[i]:
for j in range(i * i, maxN + 1, i):
isPrime[j] = 0
i += 1
sieve(isPrime)
for i in range(int(input())):
n,... | ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR IF VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FU... |
While performing complex market analysis William encountered the following problem:
For a given array $a$ of size $n$ and a natural number $e$, calculate the number of pairs of natural numbers $(i, k)$ which satisfy the following conditions:
$1 \le i, k$
$i + e \cdot k \le n$.
Product $a_i \cdot a_{i + e} \cdot a_{... | import sys
input = sys.stdin.readline
n = 10**6
is_prime = [(True) for i in range(n + 1)]
is_prime[1] = False
p = 2
while p * p <= n:
if is_prime[p]:
for i in range(p * p, n + 1, p):
is_prime[i] = False
p += 1
t = int(input())
for _ in range(t):
n, e = map(int, input().split())
a = ... | IMPORT ASSIGN VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR IF VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FO... |
While performing complex market analysis William encountered the following problem:
For a given array $a$ of size $n$ and a natural number $e$, calculate the number of pairs of natural numbers $(i, k)$ which satisfy the following conditions:
$1 \le i, k$
$i + e \cdot k \le n$.
Product $a_i \cdot a_{i + e} \cdot a_{... | def SieveOfEratosthenes(n):
li = [1] * (n + 1)
p = 2
while p * p <= n:
if li[p] == 1:
for i in range(p**2, n + 1, p):
li[i] = 0
p += 1
li[0] = 0
li[1] = 0
return li
li = SieveOfEratosthenes(10**6 + 1)
t = int(input())
for i in range(t):
n, e = ma... | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER ... |
While performing complex market analysis William encountered the following problem:
For a given array $a$ of size $n$ and a natural number $e$, calculate the number of pairs of natural numbers $(i, k)$ which satisfy the following conditions:
$1 \le i, k$
$i + e \cdot k \le n$.
Product $a_i \cdot a_{i + e} \cdot a_{... | max = 10**6 + 1
allPrime = [True] * max
allPrime[0] = allPrime[1] = False
for i in range(2, max):
if allPrime[i]:
for j in range(i, max, i):
if j != i:
allPrime[j] = False
test = int(input())
for t in range(test):
n, e = map(int, input().split())
array = list(map(int, inp... | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR... |
While performing complex market analysis William encountered the following problem:
For a given array $a$ of size $n$ and a natural number $e$, calculate the number of pairs of natural numbers $(i, k)$ which satisfy the following conditions:
$1 \le i, k$
$i + e \cdot k \le n$.
Product $a_i \cdot a_{i + e} \cdot a_{... | prime = [(1) for i in range(1000002)]
p = 2
prime[0], prime[1] = 0, 0
while p * p <= 1000001:
if prime[p]:
for i in range(p * p, 1000002, p):
prime[i] = 0
p += 1
for _ in range(int(input())):
n, e = map(int, input().split())
arr = list(map(int, input().split()))
ans = 0
for i... | ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER NUMBER NUMBER WHILE BIN_OP VAR VAR NUMBER IF VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR ASSIGN VAR VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUN... |
While performing complex market analysis William encountered the following problem:
For a given array $a$ of size $n$ and a natural number $e$, calculate the number of pairs of natural numbers $(i, k)$ which satisfy the following conditions:
$1 \le i, k$
$i + e \cdot k \le n$.
Product $a_i \cdot a_{i + e} \cdot a_{... | def SieveOfEratosthenes(n):
prime = [(True) for i in range(n + 1)]
p = 2
while p * p <= n:
if prime[p] == True:
for i in range(p * p, n + 1, p):
prime[i] = False
p += 1
m = {}
for p in range(2, n):
if prime[p]:
m[p] = 1
return m
h... | FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR ASSIGN VAR VAR NUMBER RETURN VAR ASSIGN VAR ... |
Alice and Bob are playing a game. They are given an array $A$ of length $N$. The array consists of integers. They are building a sequence together. In the beginning, the sequence is empty. In one turn a player can remove a number from the left or right side of the array and append it to the sequence. The rule is that t... | length = int(input())
arr = input().split(" ")
arr = list(map(int, arr))
leftMax = 1
rightMax = 1
for i in range(length - 1):
if arr[i] < arr[i + 1]:
leftMax += 1
else:
break
for i in range(length - 1):
if arr[-(i + 1)] < arr[-(i + 2)]:
rightMax += 1
else:
break
if leftMa... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR BIN... |
Alice and Bob are playing a game. They are given an array $A$ of length $N$. The array consists of integers. They are building a sequence together. In the beginning, the sequence is empty. In one turn a player can remove a number from the left or right side of the array and append it to the sequence. The rule is that t... | n = int(input())
vetor = list(map(lambda x: int(x), input().split(" ")))
right = True
left = True
for i in range(0, n - 1):
if vetor[i + 1] <= vetor[i]:
break
left = not left
for j in range(n - 1, -1, -1):
if vetor[j - 1] <= vetor[j]:
break
right = not right
if right or left:
print("... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR B... |
Alice and Bob are playing a game. They are given an array $A$ of length $N$. The array consists of integers. They are building a sequence together. In the beginning, the sequence is empty. In one turn a player can remove a number from the left or right side of the array and append it to the sequence. The rule is that t... | n = int(input())
num = [int(i) for i in input().split()]
l, r = 0, n - 1
while l + 1 < n and num[l] < num[l + 1]:
l += 1
while r >= 0 and num[r] < num[r - 1]:
r -= 1
l = l + 1
r = n - r
if l % 2 or r % 2:
print("Alice")
else:
print("Bob") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER WHILE BIN_OP VAR NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER WHILE VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF... |
Alice and Bob are playing a game. They are given an array $A$ of length $N$. The array consists of integers. They are building a sequence together. In the beginning, the sequence is empty. In one turn a player can remove a number from the left or right side of the array and append it to the sequence. The rule is that t... | n = int(input())
arr = list(map(int, input().split()))
prenum = 1
while prenum < n and arr[prenum] > arr[prenum - 1]:
prenum += 1
surnum = n - 2
while surnum >= 0 and arr[surnum] > arr[surnum + 1]:
surnum -= 1
front = 0
rear = n - 1
result = 0
while front <= prenum and rear >= surnum:
if front == prenum or ... | 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 WHILE VAR VAR VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN ... |
Alice and Bob are playing a game. They are given an array $A$ of length $N$. The array consists of integers. They are building a sequence together. In the beginning, the sequence is empty. In one turn a player can remove a number from the left or right side of the array and append it to the sequence. The rule is that t... | length = int(input())
arr = input().split(" ")
arr = list(map(int, arr))
go = True
currentHigh = -1
player = 1
leftMax = 1
rightMax = 1
for i in range(length - 1):
if arr[i] < arr[i + 1]:
leftMax += 1
else:
break
for i in range(length - 1):
if arr[-(i + 1)] < arr[-(i + 2)]:
rightMax ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL ... |
Alice and Bob are playing a game. They are given an array $A$ of length $N$. The array consists of integers. They are building a sequence together. In the beginning, the sequence is empty. In one turn a player can remove a number from the left or right side of the array and append it to the sequence. The rule is that t... | from sys import stdin
eg = False
inp = []
it0 = 0
it1 = 0
new = []
it = 0
max1 = -1
max2 = -1
va = 0
for line in stdin:
if va == 1:
inp = [x for x in line.strip().split()]
va += 1
l = len(inp)
def only_one_end(it, lr):
global inp
global l
if lr:
n1 = int(inp[l - it - 1])
n... | ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF IF VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP B... |
Alice and Bob are playing a game. They are given an array $A$ of length $N$. The array consists of integers. They are building a sequence together. In the beginning, the sequence is empty. In one turn a player can remove a number from the left or right side of the array and append it to the sequence. The rule is that t... | n = int(input())
a = list(map(int, input().split()))
Left = 0
Right = n - 1
while Left != n - 1 and a[Left + 1] > a[Left]:
Left += 1
while Right != 0 and a[Right - 1] > a[Right]:
Right -= 1
if (Left + 1) % 2 or (n - Right) % 2:
print("Alice")
else:
print("Bob") | 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 BIN_OP VAR NUMBER WHILE VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER NUMBER BIN_O... |
Alice and Bob are playing a game. They are given an array $A$ of length $N$. The array consists of integers. They are building a sequence together. In the beginning, the sequence is empty. In one turn a player can remove a number from the left or right side of the array and append it to the sequence. The rule is that t... | arraySize = int(input())
left, right = 0, arraySize - 1
array = list(map(int, input().split()))
while left + 1 < arraySize and array[left] < array[left + 1]:
left += 1
while right > 0 and array[right] < array[right - 1]:
right -= 1
left += 1
right = arraySize - right
if left % 2 or right % 2:
print("Alice")... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR WHILE BIN_OP VAR NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER WHILE VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF BIN_OP ... |
At the first holiday in spring, the town Shortriver traditionally conducts a flower festival. Townsfolk wear traditional wreaths during these festivals. Each wreath contains exactly k flowers.
The work material for the wreaths for all n citizens of Shortriver is cut from the longest flowered liana that grew in the tow... | def main():
m, k, n, s = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
b_dict = {}
for x in b:
b_dict.setdefault(x, 0)
b_dict[x] += 1
left = 0
right = 0
max_cut = m - n * k
condition_not_met = len(b_dict)
a_dict ... | FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASS... |
At the first holiday in spring, the town Shortriver traditionally conducts a flower festival. Townsfolk wear traditional wreaths during these festivals. Each wreath contains exactly k flowers.
The work material for the wreaths for all n citizens of Shortriver is cut from the longest flowered liana that grew in the tow... | m, k, n, s = map(int, input().split())
ls = list(map(int, input().split()))
seq = map(int, input().split())
dseq = {}
for se in seq:
if se not in dseq:
dseq[se] = 0
dseq[se] += 1
maxwindowsize = m - k * n + k
dcurr = {}
nrusefull = 0
for i in range(maxwindowsize - k):
if ls[i] not in dcurr:
... | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR ... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | import sys
input = sys.stdin.readline
for __ in range(int(input())):
s = input().split()[1]
n = len(s) + 1
amin = []
i = 0
t = n
while i < n - 1:
c = s[i]
if c == ">":
amin.append(t)
t -= 1
i += 1
else:
j = i + 1
... | IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR IF VAR STRING EXPR FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER ASSIGN V... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | from sys import stdin, stdout
t = int(stdin.readline().strip())
for _ in range(t):
n, comp = stdin.readline().split()
n = int(n)
clist = []
last, cnt = None, 0
lt = 0
for i in range(len(comp)):
if comp[i] == "<":
lt += 1
if last:
if comp[i] != last:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR VAR NONE NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VA... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | a = int(input())
for i in range(a):
n, s = map(str, input().split())
n = int(n)
ans = []
flag = 1
glag = 1
for i in range(len(s)):
if i == 0:
if s[i] == "<":
ans.append(-flag * n)
ans.append(ans[-1] + 1)
else:
ans.ap... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_C... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | def makeRepeat(s):
repeat = [[s[0], 0]]
for ch in s:
if ch == repeat[-1][0]:
repeat[-1][1] += 1
else:
repeat.append([ch, 1])
return repeat
def solve(N, S):
assert len(S) == N - 1
curr = 0
repeat = makeRepeat(S)
longest = list(range(1, N + 1))
sho... | FUNC_DEF ASSIGN VAR LIST LIST VAR NUMBER NUMBER FOR VAR VAR IF VAR VAR NUMBER NUMBER VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR LIST VAR NUMBER RETURN VAR FUNC_DEF FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN V... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | def print_arr(arr):
for a in arr:
print(a, end=" ")
print()
def solve_max(n, s):
div = s.count(">") + 1
l, r = div - 1, div + 1
ans = [div]
for c in s:
if c == "<":
ans.append(r)
r += 1
else:
ans.append(l)
l -= 1
print... | FUNC_DEF FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR STRING NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST VAR FOR VAR VAR IF VAR STRING EXPR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR FUNC_DE... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
N, s = input().split()
N = int(N)
s = s.strip()
ts = []
t = 0
for c in s:
if c == "<":
t += 1
else:
ts.append(t)
t = 0
ts.append(t)
c = 0
rs = []
while t... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIG... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | import sys
input = sys.stdin.readline
def compress(array):
array2 = sorted(set(array))
memo = {value: index for index, value in enumerate(array2)}
for i in range(len(array)):
array[i] = memo[array[i]] + 1
return array
t = int(input())
base = 10**6
for _ in range(t):
n, b = list(map(str,... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR V... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | import sys
import time
def reverse_items(seq, reverse_start, reverse_end):
while reverse_start < reverse_end:
tmp = seq[reverse_start]
seq[reverse_start] = seq[reverse_end]
seq[reverse_end] = tmp
reverse_start += 1
reverse_end -= 1
def output_shortest_and_longest(max_numb... | IMPORT IMPORT FUNC_DEF WHILE VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR NUMBER VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NONE ASSIGN VAR NONE ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | for nt in range(int(input())):
n, s = input().split()
n = int(n)
a = [i for i in range(n, 0, -1)]
i = 0
c = []
while i < n:
if i < n - 1 and s[i] == "<":
start = i
while start < n - 1 and s[start] == "<":
start += 1
c.append((i, start))... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR VAR IF VAR BIN_OP VAR NUMBER VAR VAR STRING ASSIGN VAR VAR WHILE VAR BIN_OP VAR NUMBER VAR VAR STRING VAR N... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | import sys
input = sys.stdin.readline
Q = int(input())
Query = []
for _ in range(Q):
N, S = map(str, input().rstrip().split())
Query.append((int(N), list(S)))
for N, S in Query:
L = []
for i, s in enumerate(S):
if s == "<":
L.append(i)
L.append(N - 1)
Ls = set(L)
Longans... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR VAR VAR ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR IF VAR STRING EXPR FUNC_CALL VAR ... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | t = int(input())
for _ in range(t):
n, s = input().split()
n = int(n)
s = "<" + s + ">"
up = [1]
dw = []
for i in range(1, n + 1):
if s[i - 1 : i + 1] == "<<":
up[-1] += 1
elif s[i - 1 : i + 1] == ">>":
dw[-1] += 1
elif s[i - 1 : i + 1] == "<>":
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP STRING VAR STRING ASSIGN VAR LIST NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER STRING VAR NUMB... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | for _ in range(int(input())):
n, s = input().split()
n = int(n)
mn = [0] * n
mx = [0] * n
s_i = [0] * n
if s[-1] == ">":
s_i[-2] = 1
else:
s_i[-2] = -1
for i in range(len(s) - 2, -1, -1):
if s[i] == ">":
if i + 1 < len(s) and s_i[i + 1] > 0:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR IF VAR NUMBER STRING ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP ... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | from sys import stdin
for case in range(int(stdin.readline())):
n, s = stdin.readline().strip().split()
n = int(n)
parts = []
ind = 0
while ind < n - 1:
cur = s[ind]
l = 0
while s[ind] == cur:
ind += 1
l += 1
if ind == len(s):
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR FUNC_CALL VAR VAR IF VAR STRING EXPR FUNC_CALL... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
n, s = input().rstrip().split()
n = int(n)
last = 0
num = n
ans1 = [0] * n
for i in range(n):
if i == n - 1 or s[i] == ">":
for j in range(last, i + 1)[::-1]:
ans1[j] = num
... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER VAR VAR STRING FOR VAR FUNC_CALL VAR ... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | for t in range(int(input())):
n, s = [i for i in input().split()]
n = int(n)
s1 = ""
s2 = ""
for i in range(n - 1):
if s[i] == "<":
s1 += "0"
s2 += "1"
else:
s1 += "1"
s2 += "0"
s2 = s2[::-1]
res1 = []
res2 = []
temp1 = ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR STRING VAR STRING VAR STRING VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST AS... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | import sys
input = lambda: sys.stdin.readline().strip()
for _ in range(int(input())):
n, s = input().split()
n = int(n)
lts = [-1, *(i for i in range(len(s)) if s[i] == ">"), n - 1]
cur = n + 1
for i in range(1, len(lts)):
diff = lts[i] - lts[i - 1]
print(*range(cur - diff, cur), en... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR STRING BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_C... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | def calmin(xs):
n = len(xs) + 1
ans = [-1] * n
high = n
i = xs.find("<")
while 0 <= i < n - 1:
j = xs.find(">", i)
if j == -1:
j = n - 1
diff = j - i
begin = high - diff + 1
for i in range(i, j):
ans[i + 1] = begin
begin += ... | FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR STRING WHILE NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER FOR VAR... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | def getInput():
line = input().split()
return int(line[0]), line[1]
def sLIS(n, s):
ans = list(range(n, 0, -1))
rev = []
i = 0
while i < n - 1:
if s[i] == "<":
j = i + 1
while j < n - 1 and s[j] == "<":
j += 1
rev.append((i, j))
... | FUNC_DEF ASSIGN VAR FUNC_CALL FUNC_CALL VAR RETURN FUNC_CALL VAR VAR NUMBER VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR BIN_OP VAR NUMBER VAR VAR STRING VAR NUMBER EXPR... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | t = int(input())
while t:
n, s = input().split()
n = int(n)
a = []
temp = n
ls = []
for i in range(n - 1):
if s[i] == ">":
a.append(temp)
temp -= 1
if len(ls):
j = len(ls) - 1
while j >= 0:
a.append(l... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING EXPR FUNC_CALL VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | import sys
input = sys.stdin.readline
q = int(input())
for i in range(q):
n, s = input().split()
n = int(n)
direct = [0]
for i in range(1, n - 1):
if s[i] != s[i - 1]:
direct.append(i)
if s[-1] == ">":
direct.append(n - 1)
l = len(direct)
if l == 1:
print... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER STRING EXPR FUNC_CALL VAR... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
n, s = input().split()
n = int(n)
inc, dec = [[0]], [[0]]
for i in range(n - 1):
if s[i] == ">":
inc.append([])
else:
dec.append([])
inc[-1].append(i + 1)
dec[-1].append(i +... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR LIST LIST NUMBER LIST LIST NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING EXPR FUNC_CALL VAR LIST EXPR FUNC_CALL VAR LIST EXPR FUNC_... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | t = int(input())
for loop in range(t):
n, s = input().split()
n = int(n)
s = list(s)
lisUP = []
lisDO = []
now = 1
d = s[0]
for i in range(n - 1):
if d == s[i]:
now += 1
else:
if d == "<":
lisUP.append(now)
else:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR NUMBER IF VAR STRING EXPR F... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | import sys
input = lambda: sys.stdin.readline().rstrip()
for _ in range(int(input())):
n, m = map(str, input().split())
n = int(n)
l = []
g = []
buf = [n]
li = n - 1
gi = 2
for i in m:
if i == ">":
while buf:
l.append(buf.pop())
l.append(l... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING WHILE VAR EXPR FU... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | import sys
t = int(input())
g = sys.stdin.readlines()
for i in range(t):
n, s = g[i].split()
n = int(n)
n -= 1
j = 0
big = []
small = []
while j < n:
count = 1
while j < n and s[j] == ">":
count += 1
j += 1
big.append(count)
j += 1
... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST WHILE VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER VAR NUMBER EXPR FUNC_CALL VA... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | t = int(input())
for _ in range(t):
n, s = input().split()
s = s + "<"
n = int(n)
ans1 = [(-1) for i in range(n)]
time = 0
now1 = n
key = 0
for i in range(n):
if i == n - 1:
for j in range(n - 1, key - 1, -1):
ans1[j] = now1
now1 -= 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER FOR VAR FUNC_CAL... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | n = int(input())
for i in range(0, n):
lis = input()
a, b = lis.split()
curr = int(a)
pos = 0
arr = [1] * curr
while curr > 0 and pos < int(a) - 1:
if b[pos] == ">":
arr[pos] = curr
curr -= 1
pos += 1
else:
cal = pos
dif... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR WHILE VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING ASSIGN VAR VAR VAR VAR NUMBER VAR NUMBER A... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | import sys
def main():
t = int(input())
allans = []
for _ in range(t):
n, s = input().split()
n = int(n)
s = s + "$"
seq = []
prev = None
l = 0
for c in s:
if c != prev:
if l > 0:
seq.append([prev == "<... | IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR LIST ASSIGN VAR NONE ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR LIST VAR STRING VAR ... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | t = int(input())
for _ in range(t):
n, s = map(str, input().split())
small = [(0) for i in range(int(n))]
big = [(0) for i in range(int(n))]
n = int(n)
ma = n
p = s
s = " " + s
for i in range(n - 1, -1, -1):
if s[i] == "<" or i == 0:
big[i] = ma
ma -= 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP STRING VAR FO... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | t = int(input())
for test_case in range(t):
n, pattern = input().split()
n = int(n)
ans = [0] * n
num, last = n, 0
for i in range(n):
if i == n - 1 or pattern[i] == ">":
for j in range(i, last - 1, -1):
ans[j] = num
num -= 1
last = i + ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER VAR VAR STRING FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | import sys
inp = sys.stdin.readline
input = lambda: inp().strip()
flush = sys.stdout.flush
def iin():
return int(input())
def lin():
return list(map(int, input().split()))
def main():
T = iin()
while T:
T -= 1
n, s = input().split()
n = int(n)
ansmx, ansmn = [0] * ... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR 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 FUNC_DEF ASSIGN VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VA... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | import sys
t = int(sys.stdin.readline())
for _ in range(t):
n, s = sys.stdin.readline().split()
n = int(n)
num, last = n, 0
ans = [(-1) for _ in range(n)]
for i in range(n):
if i == n - 1 or s[i] == ">":
for j in range(i, last - 1, -1):
ans[j] = num
... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER VAR VAR STRING FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMB... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | Q = int(input())
total = []
for _ in range(Q):
n, s = input().split()
n = int(n)
seq = []
curlen = 1
for i in range(len(s)):
if s[i] == "<":
curlen += 1
else:
seq.append(curlen)
curlen = 1
seq.append(curlen)
curr = n
ans = []
for sq... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR ASSI... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | import sys
def main():
import sys
input = sys.stdin.readline
for _ in range(int(input())):
line = list(input().split())
N = int(line[0])
S = line[1]
inc_num = S.count("<")
ans = [0] * N
inc = N
dec = N - inc_num
for i in range(N - 1):
... | IMPORT FUNC_DEF IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL ... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | tc = int(input())
def remap(s):
sorted_s = sorted(s)
num2idx = {num: i for i, num in enumerate(sorted_s, 1)}
return [num2idx[num] for num in s]
def get_min(s):
n = len(s)
res = [0]
min_so_far = 0
for i, sign in enumerate(s):
if sign == "<":
res.append(res[-1] + 1)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR NUMBER RETURN VAR VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER E... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | t = int(input())
for i in range(t):
a = input().split()
n = int(a[0])
s = a[1] + ">"
ans = []
c = []
now = n
for j in range(n):
if s[j] == "<":
c.append(now)
now -= 1
elif len(c) > 0:
c.append(now)
now -= 1
ans += c[... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR NU... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | for tc in range(int(input())):
n, s = input().split(" ")
n = int(n)
inc = [-1] * n
dec = [-1] * n
cnti = 1
for i in range(len(s)):
if s[i] == "<":
inc[i] = cnti
cnti += 1
lcnt = n
for i in range(n):
if inc[i] == -1:
inc[i] = lcnt
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR VAR FOR VA... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | for _ in range(int(input())):
n, s = map(str, input().split())
n = int(n)
cnt = {"<": 0, ">": 0}
for i in range(n - 1):
cnt[s[i]] += 1
big = n - cnt["<"] + 1
small = big - 2
ans1 = [big - 1]
for i in range(n - 1):
if s[i] == "<":
ans1.append(big)
b... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT STRING STRING NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR STRING NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIG... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | for _ in range(int(input())):
n, s = map(str, input().split())
n = int(n)
mn = [0] * n
mx = [0] * n
for i in range(n):
mn[i] = n - i
mx[i] = i + 1
j = 0
i = 0
while i < n - 1:
while j < n - 1 and s[i] == s[j]:
j += 1
if s[i] == "<":
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VA... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | line = input()
q = int(line)
for _ in range(q):
line = input()
n, s = [x for x in line.split()]
n = int(n)
minseq = [n]
potential = 0
maxseq = [1]
minel = 1
maxel = 1
for x in s:
if x == "<":
maxseq.append(maxel + 1)
maxel += 1
potential +=... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING EXPR FUNC_CALL VAR BIN_OP ... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | import itertools
def countstrs(s):
return [(k, len(list(g))) for k, g in itertools.groupby(s)]
def countstrs_withIndex(s):
d = countstrs(s)
r = []
ind = 0
for i in range(len(d)):
r.append((d[i][0], d[i][1], ind))
ind += d[i][1]
return r
q = int(input())
for _ in range(q):
... | IMPORT FUNC_DEF RETURN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER VAR VAR NUMBER VAR VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR F... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | cases = int(input())
for _ in range(cases):
l, s = input().split()
l = int(l)
seq = []
i = 0
prev = l
start_i = 0
while i <= len(s):
start_i = i
while i < len(s) and s[i] == "<":
i += 1
for n in range(prev - (i - start_i), prev + 1):
seq.append... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR VAR WHILE VAR FUNC_CALL VAR VAR VAR VAR STRING VAR NUMBER FOR VAR FUNC_CALL VAR B... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | from sys import gettrace, stdin
if not gettrace():
def input():
return next(stdin)[:-1]
def main():
def solve():
nt, ss = input().split()
n = int(nt)
tt = []
for s in ss[::-1]:
if s == ">":
tt.append("<")
else:
... | IF FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR NUMBER FUNC_DEF FUNC_DEF ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR VAR NUMBER IF VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING VAR EXPR FUNC_CALL VAR FUNC_CALL ... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | def main():
T = int(input())
for t in range(T):
n, a = input().split()
n = int(n)
ans1 = [0] * n
l = 0
while l < n - 1:
if a[l] == "<":
r = l
while r < n - 1 and a[r] == "<":
r += 1
x = n - r
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR VAR STRING ASSIGN VAR VAR WHILE VAR BIN_OP VAR NUMBER VAR VAR STRING VAR NUMBER ASSIGN VAR ... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | t = int(input())
for _ in range(t):
n, s = input().split()
n = int(n)
s = list(s)
ans1 = [(n - i) for i in range(n)]
i = 0
while i < n - 1:
j = i
while j < n - 1 and s[j] == "<":
j += 1
for k in range((j - i) // 2 + 1):
ans1[i + k], ans1[j - k] = a... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER ASSIGN VAR VAR WHILE VAR BIN_OP VAR NUMBER VAR VAR STRING VAR NU... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | import sys
from itertools import groupby
reader = (line.rstrip() for line in sys.stdin)
input = reader.__next__
t = int(input())
for _ in range(t):
n, s = input().split()
n = int(n)
good = [0] + list(range(1, n + 1))
bad = [0] + list(reversed(range(1, n + 1)))
l = 1
for k, g in groupby(s):
... | IMPORT ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | from sys import stdin
input = stdin.readline
q = int(input())
def maxmozodprawej(s, n):
res = []
ind = 0
maksi = n
while True:
if ind >= n - 1:
break
if s[ind] == 1:
res.append(maksi)
maksi -= 1
ind += 1
if ind >= n - 1:
... | ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE NUMBER IF VAR BIN_OP VAR NUMBER IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR BIN_OP VAR NUMBER VAR BIN... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | for _ in range(int(input())):
n, s = input().split()
n = int(n)
tmp = []
ans = []
for i, x in enumerate(s):
tmp.append(n - i)
if x == ">":
ans += tmp[::-1]
tmp = []
tmp.append(1)
ans += tmp[::-1]
print(" ".join([str(x) for x in ans]))
i = 1
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR IF VAR STRING VAR VAR NUMBER ASSIGN VAR LIST EXPR FUNC_CALL VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR F... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
n, S = input().split()
n = int(n)
max_ans = [0] * n
i = j = 0
cur = 1
for s in S + "<":
if s == ">":
j += 1
elif s == "<":
for k in range(j, i - 1, -1):
max_ans[k] =... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR BIN_OP VAR STRING IF VAR STRING VAR NUMBER IF VAR STRING FOR VAR FUNC_CALL VAR VAR ... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | import itertools
import sys
input = iter(sys.stdin.readlines()).__next__
t = int(input())
outputs = []
for _ in range(t):
line = input().split()
n = int(line[0])
s = line[1]
out1 = []
out2 = []
j = n
i = 1
for k, g in itertools.groupby(s):
g_len = len(list(g))
if k == "<... | IMPORT IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VA... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | import sys
def reverse(arr, i, j):
while i < j:
temp = arr[i]
arr[i] = arr[j]
arr[j] = temp
i += 1
j -= 1
return None
def main():
t = int(input())
allans = []
for _ in range(t):
n, s = input().split()
n = int(n)
minLIS = list(range(... | IMPORT FUNC_DEF WHILE VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR NUMBER VAR NUMBER RETURN NONE FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VA... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | T = int(input())
for _ in range(0, T):
tt = input().split()
n = int(tt[0])
s = str(tt[1])
mx = []
vismx = [0] * (n + 1)
mn = []
vismn = [0] * (n + 1)
L = []
c = 1
for i in range(1, len(s)):
if s[i] != s[i - 1]:
L.append((s[i - 1], c))
c = 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR LI... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | def max_nvp(rel):
n = len(rel) + 1
seq = [0] * n
lower, higher = 1, n
for i in range(len(rel)):
if "<" == rel[i]:
seq[i] = lower
lower += 1
elif ">" == rel[i]:
seq[i] = higher
higher -= 1
seq[-1] = lower
return " ".join(map(str, seq... | FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR NUMBER VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF STRING VAR VAR ASSIGN VAR VAR VAR VAR NUMBER IF STRING VAR VAR ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER VAR RETURN FUNC_CALL STRING FUNC_CALL VAR VAR VAR FUNC... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | def solve1(n, comps):
ans = []
rng = iter(list(range(1, n + 1)))
for comp in [(len(comp) + 1) for comp in comps.split(">")][::-1]:
ans.append([ansi for _, ansi in zip(list(range(comp)), rng)])
fin_ans = []
ans.reverse()
for ansi in ans:
fin_ans.extend(ansi)
return fin_ans
d... | FUNC_DEF ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR FOR VAR VAR EXPR FUNC_CALL VA... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | import sys
def reverse(s):
return s[::-1]
def main():
N = int(sys.stdin.readline().strip())
for _ in range(N):
n, s = sys.stdin.readline().strip().split()
n = int(n)
a0 = [0] * n
cnt0 = 1
for i in list(range(n - 1))[::-1]:
if s[i] == ">":
... | IMPORT FUNC_DEF RETURN VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR ... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | import sys
Q = int(sys.stdin.readline().strip())
for q in range(0, Q):
n, s = sys.stdin.readline().strip().split()
n = int(n)
U = [1]
D = [1]
for i in range(0, n - 1):
if s[i] == "<":
U[-1] = U[-1] + 1
D.append(1)
else:
D[-1] = D[-1] + 1
... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER NUMBER... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | import sys
import time
class Node:
def __init__(self):
self.val: int = None
self.next: Node = None
class NodeLink:
def __init__(self):
self.head = Node()
self.tail = self.head
self.size = 0
def append(self, node: Node, val):
new_node = Node()
ne... | IMPORT IMPORT CLASS_DEF FUNC_DEF VAR VAR NONE VAR VAR NONE CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FUNC_DEF VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR IF VAR VAR ASSIGN VAR VAR FUNC_DEF ASSIGN VAR VAR ASSIGN VAR LIST WHILE VAR NONE EXPR FUNC_CALL VAR F... |
Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to mak... | from sys import stderr, stdin
def rl():
return [int(w) for w in stdin.readline().split()]
def p1(n, s, le):
r = []
b = i = 0
while i < n:
try:
ni = s.index(le, i) + 1
except ValueError:
ni = n
r += list(range(ni, i, -1))
i = ni
return r
(... | FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR LIST ASSIGN VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN ... |
Vasya has two arrays $A$ and $B$ of lengths $n$ and $m$, respectively.
He can perform the following operation arbitrary number of times (possibly zero): he takes some consecutive subsegment of the array and replaces it with a single element, equal to the sum of all elements on this subsegment. For example, from the ar... | def main():
length1 = int(input())
store = input().split()
arr1 = []
for x in range(length1):
arr1.append(int(store[x]))
length2 = int(input())
store = input().split()
arr2 = []
for x in range(length2):
arr2.append(int(store[x]))
pos1 = 0
pos2 = 0
tot1 = 0
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR V... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.