description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ... | t = list(input())
p = list(input())
s = input().split()
v = [0] * len(s)
for i in range(len(s)):
v[i] = int(s[i])
l, r = 0, len(t)
while r - l > 1:
m = (l + r) // 2
t1 = t[:]
for i in range(m):
t1[v[i] - 1] = "*"
i, j = 0, 0
while j < len(t1) and i < len(p):
if p[i] == t1[j]:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR NUMBER FUNC_CALL VAR VAR WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN... |
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ... | def ok(n):
mark = set()
global a
for i in range(n):
mark.add(a[i] - 1)
one = 0
two = 0
while one < len(p) and two < len(t):
if two in mark:
two += 1
elif p[one] == t[two]:
one += 1
two += 1
else:
two += 1
return ... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER RETURN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIG... |
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ... | t = input()
p = input()
a = list(map(int, input().split()))
def good(b):
i = 0
l = len(b)
for c in p:
while i < l and b[i] != c:
i += 1
if i == l:
return False
i += 1
return True
def check(x):
tt = list(t)
for p in a[:x]:
tt[p - 1] = ""... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR WHILE VAR VAR VAR VAR VAR VAR NUMBER IF VAR VAR RETURN NUMBER VAR NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VA... |
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ... | def subseq(s, b):
h = iter(b)
return all(any(l == ch for l in h) for ch in s)
t = input()
p = input()
num = [int(x) for x in input().split()]
st = []
l = 0
r = len(num)
ans = r + 1
while l <= r:
mid = (l + r) // 2
st = list(t)
c = num[:mid]
for i in c:
st[i - 1] = ""
if subseq(p, "... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR... |
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ... | import sys
inp = sys.stdin.readline
def input():
return inp().strip()
def iin():
return int(input())
def lin():
return list(map(int, input().split()))
def main():
p, t = input(), input()
a = lin()
n = len(p)
def check(x):
rm = set(a[:x])
p1 = [p[i] for i in range(n)... | IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL 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 VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VA... |
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ... | def check(x):
temp = []
for i in t:
temp.append(i)
for i in range(x):
temp[a[i] - 1] = ""
l = 0
r = 0
c = 0
while r < len(s) and l < len(t):
if s[r] == temp[l]:
r += 1
c += 1
l += 1
return c == len(s)
t = input()
s = input()
a = l... | FUNC_DEF ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER RETURN VAR FUNC_CALL VAR VAR ASSIGN VA... |
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ... | s = input()
t = input()
arr = [(x - 1) for x in map(int, input().split())]
l = 0
r = len(s) - 1
def check(sa, sb):
j = 0
for i in range(len(sb)):
while j < len(sa) and sa[j] != sb[i]:
j += 1
if j == len(sa):
return False
j += 1
return True
while l < r:
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR WHILE VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR NUMBER IF VAR FUNC_... |
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ... | def isSubStr(word, liveTimes, str, time):
p = 0
for i in range(len(word)):
if time < liveTimes[i] and word[i] == str[p]:
p += 1
if p == len(str):
break
return p == len(str)
p, t, perms = input(), input(), input().split()
liveTimes = [(0) for _ in range(len(p))]
for ... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR RETURN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL ... |
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ... | t = list(input())
p = list(input())
lis = list(map(int, input().split()))
pp = len(p)
tt = len(t)
l = 0
r = tt
while l <= r:
mid = l + (r - l) // 2
tep = t[:]
for i in range(mid):
tep[lis[i] - 1] = "#"
j = i = 0
while i < tt and j < pp:
if tep[i] == p[j]:
j += 1
i... | ASSIGN 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 VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR FOR ... |
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ... | P = list(input())
T = list(input())
a = list(map(int, input().split()))
def check(k, p, t, a):
p1 = p.copy()
for i in range(k):
p1[a[i] - 1] = "#"
n, m = len(p1), len(t)
i, j = 0, 0
while i < n and j < m:
if p1[i] == t[j]:
i += 1
j += 1
else:
... | ASSIGN 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 FUNC_DEF ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER STRING ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NU... |
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ... | from sys import stdin
t = input().strip()
p = input().strip()
def possible(pos):
it = 0
ip = 0
while it < len(t) and ip < len(p):
if it in d:
it += 1
continue
if t[it] == p[ip]:
it += 1
ip += 1
else:
it += 1
if ip == ... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER IF VAR FUNC_CALL VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR BIN_OP FUNC_CALL ... |
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ... | def main():
s, w = ["", *input()], input()
l = list(map(int, input().split()))
lo, hi = 0, len(s) - len(w)
while lo < hi:
mid, t = (lo + hi) // 2, s[:]
for i in l[:mid]:
t[i] = ""
try:
i = 1
for c in w:
while c != t[i]:
... | FUNC_DEF ASSIGN VAR VAR LIST STRING FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR WHILE VAR VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR FOR VAR VAR VAR ASSIGN VAR VAR STRING ASSIGN VAR NUMBER FOR VA... |
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ... | t, p = input(), input()
indices = tuple(map(int, input().split()))
n = len(t)
np = len(p)
l = 0
right = n
ans = 0
while n - l > 1:
m = (l + right) // 2
if l == m:
break
tu = list(t)
for i in range(l, m):
tu[indices[i] - 1] = "0"
pos = 0
yes = 0
for i in tu:
if i == p[... | ASSIGN VAR 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 ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL V... |
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ... | s = input()
p = input()
a = list(map(int, input().split()))
a_inds = [0] * (len(s) + 1)
for i in range(len(a)):
a_inds[a[i]] = i
l = -1
r = len(s)
def check_answer(ans):
i = 0
j = 0
while i < len(s) and j < len(p):
if a_inds[i + 1] >= ans and s[i] == p[j]:
j += 1
i += 1
... | ASSIGN VAR FUNC_CALL VAR ASSIGN 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 FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSI... |
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ... | import sys
sys.setrecursionlimit(2**20)
DEBUG = 0
def testRemove(string, target, remove, until):
copy = string.copy()
for i in remove[:until]:
copy[i - 1] = 0
if DEBUG:
print(copy, string)
j = 0
for i in copy:
if i == target[j]:
j += 1
if j == len(target):
... | IMPORT EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR FOR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER NUMBER IF VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR BIN_OP... |
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ... | a = input()
b = input()
p = list(map(int, input().split()))
n = len(p)
h = [0] * n
for i in range(n):
p[i] -= 1
h[p[i]] = i
def check(s1, s2, g):
m1 = len(s1)
m2 = len(s2)
j = 0
i = 0
while j < m1 and i < m2:
if s1[j] == s2[i] and h[i] > g:
j = j + 1
i = i + 1
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VA... |
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ... | s = list(input())
p = list(input())
a = list(map(int, input().strip().split(" ")))
n = len(s)
t = len(p)
l = 0
u = n
def possible(x):
global n, t
memeory = [True] * n
for i in range(0, x):
memeory[a[i] - 1] = False
j = 0
for i in range(n):
if memeory[i] and j < t and s[i] == p[j]:
... | ASSIGN 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 FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NU... |
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ... | def check(index, string, string2, arr):
string1 = list(string)
for i in range(index + 1):
string1[arr[i] - 1] = "-1"
j = 0
for i in range(len(string1)):
if string1[i] == string2[j]:
j += 1
if j == len(string2):
return True
return False
def main():
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FU... |
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ... | s = list(input())
t = list(input())
arr = list(x - 1 for x in map(int, input().split()))
n, m = len(arr), len(t)
def binary_search():
f, e = 0, n
while f <= e:
mid = f + e >> 1
vis = [0] * n
for i in range(mid):
vis[arr[i]] = 1
idx, found = 0, 0
for i in ran... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR VAR NUMBER VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BI... |
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ... | def f(ind):
global t, p, a
g = t.copy()
c = p.copy()
b = []
for i in range(ind + 1):
g[a[i] - 1] = "0"
for i in range(len(g)):
if g[i] != "0":
b.append(g[i])
symbol = 0
for i in range(len(b)):
if b[i] == c[symbol]:
symbol += 1
if sy... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR... |
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ... | s = input()
t = input()
a = list(map(int, input().split()))
def exist(m):
vis = [0] * len(s)
for i in range(m):
vis[a[i] - 1] = 1
j = 0
for i in range(len(s)):
if vis[i] == 0:
if s[i] == t[j]:
j += 1
if j == len(t):
return 1
r... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER IF V... |
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ... | s = input()
t = input()
a = list(map(int, input().split()))
def ok(n):
bad = set()
for i in range(n):
bad.add(a[i] - 1)
pt = 0
ps = 0
while pt < len(t) and ps < len(s):
if ps in bad:
ps += 1
elif t[pt] == s[ps]:
ps += 1
pt += 1
el... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR N... |
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ... | a = input()
b = input()
p = list(map(int, input().split()))
for i in range(len(p)):
p[i] -= 1
def good(m):
pos = 0
a1 = list(a)
for i in range(m):
a1[p[i]] = "#"
for i in range(len(a1)):
if a1[i] == b[pos]:
pos += 1
if pos == len(b):
return T... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ... |
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ... | s = list(input().strip())
t = input().strip()
sq = [int(a) for a in input().strip().split()]
l = len(s)
lt = len(t)
def check(x):
tmp = s.copy()
for i in range(x):
tmp[sq[i] - 1] = "_"
idx = 0
for i in range(l):
if tmp[i] == t[idx]:
idx += 1
if idx == lt:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER STRING ASSIGN VAR ... |
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ... | sed = 257
mod = int(1000000000.0 + 7)
def judge(t, p):
j = 0
for ch in p:
while j < len(t) and t[j] != ch:
j += 1
if j >= len(t):
return False
j += 1
return True
def generate(t, a, n):
res = list(t)
for i in range(n):
res[a[i] - 1] = "#"
... | ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR WHILE VAR FUNC_CALL VAR VAR VAR VAR VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR RETURN NUMBER VAR NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER STRIN... |
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ... | t = list(input())
p = list(input())
def has_sub(temp):
idx = 0
for c in temp:
if c == p[idx]:
idx += 1
if idx == len(p):
return True
return False
arr = list(map(int, input().split()))
left = 0
right = len(arr) - 1
while left < right:
mid = (left + right + 1) /... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUM... |
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ... | def good(t, p, b, k):
j = 0
for i in range(len(t)):
if b[i] >= k and t[i] == p[j]:
j += 1
if j == len(p):
return True
return False
def solve(t, p, a):
b = [0] * len(a)
for i in range(len(a)):
b[a[i] - 1] = i
low = 0
high = len(a)
... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN... |
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ... | import sys
inp = input()
tar = input()
seq = list(map(int, input().split()))
l_inp = len(inp)
l_tar = len(tar)
def check_for_m(m):
banned = set(seq[:m])
ip = 0
for i in range(l_inp):
if not i + 1 in banned:
if inp[i] == tar[ip]:
ip += 1
if ip == l_tar:
... | IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER VAR IF VAR VAR VAR VAR VAR NUMB... |
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ... | def checksub(tmp, t):
j = 0
n = len(tmp)
m = len(t)
for i in range(n):
if t[j] == tmp[i]:
j += 1
if j == m:
return True
return False
def solve(p, t, perms):
l = 0
h = len(p) - 1
ans = 0
while l <= h:
m = int((l + h) / 2)
tmp =... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER IF VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP... |
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ... | t = input()
p = input()
a = [int(v) for v in input().split()]
lt = len(t)
lp = len(p)
def isValid(pos):
flags = [0] * lt
for i in range(pos + 1):
flags[a[i] - 1] = 1
count = 0
for i in range(lt):
if flags[i] == 0 and t[i] == p[count]:
count += 1
if count == lp:
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_C... |
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ... | def is_subsequence(a, b, idx, top):
i = 0
for j, c in enumerate(a):
if c == b[i] and idx[j + 1] > top:
i += 1
if i == len(b):
return True
return False
a = input()
b = input()
r = list(map(int, input().split()))
idx = [(0) for _ in range(len(r) + 1)]
for i in range(l... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR BIN_OP VAR NUMBER VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN 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_O... |
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ... | t = input()
p = input()
ai = list(map(int, input().split()))
n = len(ai)
ti = [[t[i], 1] for i in range(n)]
for i in range(n):
ai[i] -= 1
num2 = 1
def check(num):
global num2
num2 -= 1
for i in range(num):
ti[ai[i]][1] = num2
num3 = 0
for i in ti:
if i[1] == num2:
c... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR V... |
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ... | def func(s1, s2):
n = len(s1)
m = len(s2)
k = 0
for i in range(n):
if s1[i] == s2[k]:
k = k + 1
if k == m:
return True
break
return False
s1 = list(input())
s2 = list(input())
a = list(map(int, input().strip().split(" ")))
high = len(a)
low = 0
b... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR F... |
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ... | def sub(a, s):
pa = 0
ps = 0
while pa < len(a) and ps < len(s):
if a[pa] == s[ps]:
ps += 1
pa += 1
else:
pa += 1
return ps == len(s)
def subword(t, ord_ar, n):
t_copy = []
for i in range(len(ord_ar)):
if ord_ar[i] >= n:
t_... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER RETURN VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_C... |
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ... | def main():
a_string = input()
b_string = input()
moves = [int(x) for x in input().split()]
index_of_move = {}
lenb = len(b_string)
for index, elem in enumerate(moves):
index_of_move[elem] = index + 1
l = 0
r = len(moves) - 1
while l < r:
middle = int((l + r + 1) / 2)... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL ... |
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ... | s, t = input(), input()
ind = list(map(int, input().split()))
def is_substring(text, word, exclude):
wi = 0
for i in range(len(text)):
if wi < len(word) and text[i] == word[wi] and i + 1 not in exclude:
wi += 1
return wi == len(word)
l, r = 0, len(ind)
while l < r:
mid = (l + r) ... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR FUNC_CALL VAR VAR VAR VAR VAR VAR BIN_OP VAR NUMBER VAR VAR NUMBER RETURN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER FUNC_CALL VAR VAR ... |
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ... | def isSubSequence(pat, text, Done):
t = 0
for i in range(len(text)):
if t < len(pat) and text[i] == pat[t] and i + 1 not in Done:
t += 1
return t == len(pat)
s = input()
r = input()
A = list(map(int, input().split()))
n = len(A)
low = 0
high = n
while low < high:
mid = (low + high)... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR FUNC_CALL VAR VAR VAR VAR VAR VAR BIN_OP VAR NUMBER VAR VAR NUMBER RETURN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSI... |
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ... | t = input()
p = input()
a = list(map(int, input().strip().split()))
a = [(x - 1) for x in a]
n = len(t)
m = len(p)
lo = 0
hi = n - 1
while lo < hi:
mid = lo + hi >> 1
temp = list(t)
for x in a[: mid + 1]:
temp[x] = "_"
ptr, curr = 0, 0
while ptr < n and curr < m:
while ptr < n and te... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMB... |
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ... | def is_match(string_long, string_short):
idx_long = 0
for idx, value in enumerate(string_short):
while idx_long < len(string_long) and string_long[idx_long] != value:
idx_long += 1
if idx_long == len(string_long):
return False
idx_long += 1
return idx_long <= ... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR WHILE VAR FUNC_CALL VAR VAR VAR VAR VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR RETURN NUMBER VAR NUMBER RETURN VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP V... |
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.
Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain ... | from sys import stdin
def input():
return stdin.readline()
s = list(input())
t = input()
a = list(map(lambda x: int(x) - 1, input().split()))
n = len(a)
def can(s):
cur = 0
for i, ch in enumerate(s):
if ch == t[cur]:
cur += 1
if cur == len(t):
return True
re... | FUNC_DEF RETURN FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER IF VAR FUNC_CALL VA... |
The only difference between easy and hard versions is constraints.
Ivan plays a computer game that contains some microtransactions to make characters look cooler. Since Ivan wants his character to be really cool, he wants to use some of these microtransactions — and he won't start playing until he gets all of them.
E... | import sys
def main():
n, m = map(int, input().split())
k = [int(x) for x in input().split()]
d = [[] for _ in range(4 * 10**5 + 1)]
for j in range(m):
dj, tj = map(int, input().split())
d[dj - 1].append(tj - 1)
lo, hi = 0, 4 * 10**5 + 1
while lo < hi:
mi = (hi + lo) //... | IMPORT 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 LIST VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_O... |
The only difference between easy and hard versions is constraints.
Ivan plays a computer game that contains some microtransactions to make characters look cooler. Since Ivan wants his character to be really cool, he wants to use some of these microtransactions — and he won't start playing until he gets all of them.
E... | def check(x):
last = [0] * (n + 1)
for i in tmp:
if i[0] > x:
break
else:
last[i[1]] = i[0]
sal = [0] * (x + 1)
for i in range(1, n + 1):
sal[last[i]] += lis[i - 1]
c = 0
for i in range(1, x + 1):
c += 1
if sal[i] >= c:
... | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR ASSIGN VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR NU... |
The only difference between easy and hard versions is constraints.
Ivan plays a computer game that contains some microtransactions to make characters look cooler. Since Ivan wants his character to be really cool, he wants to use some of these microtransactions — and he won't start playing until he gets all of them.
E... | import sys
N, M = [int(x) for x in sys.stdin.readline().rstrip().split()]
K = [int(x) for x in sys.stdin.readline().rstrip().split()]
D = [0] * M
T = [0] * M
for i in range(M):
D[i], T[i] = [int(x) for x in sys.stdin.readline().rstrip().split()]
D[i] -= 1
T[i] -= 1
KS = sum(K)
ok = 2 * KS
ng = KS - 1
while... | IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR VA... |
The only difference between easy and hard versions is constraints.
Ivan plays a computer game that contains some microtransactions to make characters look cooler. Since Ivan wants his character to be really cool, he wants to use some of these microtransactions — and he won't start playing until he gets all of them.
E... | def BinarySearch(my_list, key):
l = 0
r = len(my_list) - 1
while r > l:
mid = (l + r) // 2
if my_list[mid + 1] <= key:
l = mid + 1
else:
r = mid
return l
def weather_can_buy(day, total, req_list, sale_days):
tmp_buy = []
last_day = []
d = day... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR E... |
The only difference between easy and hard versions is constraints.
Ivan plays a computer game that contains some microtransactions to make characters look cooler. Since Ivan wants his character to be really cool, he wants to use some of these microtransactions — and he won't start playing until he gets all of them.
E... | import sys
input = sys.stdin.readline
def check(num):
last = [(0) for i in range(n)]
for i in o:
if i[0] > num:
break
else:
last[i[1] - 1] = i[0]
b = [(0) for i in range(num + 1)]
for i in range(n):
b[last[i]] += a[i]
i = 0
c = 0
d = 0
f... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR VAR IF VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL ... |
The only difference between easy and hard versions is constraints.
Ivan plays a computer game that contains some microtransactions to make characters look cooler. Since Ivan wants his character to be really cool, he wants to use some of these microtransactions — and he won't start playing until he gets all of them.
E... | def check(mid):
l = [(0) for i in range(n)]
for i in b:
if i[0] > mid:
break
l[i[1] - 1] = i[0]
v = [(0) for i in range(mid + 1)]
for i in range(n):
v[l[i]] += a[i]
ct = 0
for i in range(1, mid + 1):
ct += 1
if ct >= v[i]:
ct -= v[i... | FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR VAR IF VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR... |
Read problems statements in Mandarin Chinese and Russian as well.
Mike takes part in programming contests. His favourite topic is dynamic programming(DP). As he said, that he likes problems on DP, because "you spend a lot of time on thinking and a little time on coding".
In this problem you are to solve a version of ... | n = int(input())
W1 = []
W2 = []
m = 0
for i in range(n):
c, w = list(map(int, input().split()))
if c == 1:
W1.append(w)
else:
W2.append(w)
m += c
W1.sort()
W2.sort()
ans = [None for i in range(m + 1)]
cur = 0
w1, w2 = W1[:], W2[:]
for i in range(2, m + 1, 2):
c1, c2 = 0, 0
flag ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NONE VAR FUNC_CAL... |
Read problems statements in Mandarin Chinese and Russian as well.
Mike takes part in programming contests. His favourite topic is dynamic programming(DP). As he said, that he likes problems on DP, because "you spend a lot of time on thinking and a little time on coding".
In this problem you are to solve a version of ... | def printArray(A, start, end):
for i in range(start, end + 1):
print(A[i], end=" ")
print()
n = int(input())
itemsOfWeight1 = []
itemsOfWeight2 = []
m = 0
for i in range(n):
w, c = [int(x) for x in input().split()]
if w == 1:
itemsOfWeight1.append({"weight": w, "cost": c})
else:
... | FUNC_DEF FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR DICT ... |
Read problems statements in Mandarin Chinese and Russian as well.
Mike takes part in programming contests. His favourite topic is dynamic programming(DP). As he said, that he likes problems on DP, because "you spend a lot of time on thinking and a little time on coding".
In this problem you are to solve a version of ... | test = False
N = int(input())
ones = []
twos = []
for i in range(N):
W, C = map(int, input().strip().split(" "))
if test:
print("W, C = ", W, C)
if W == 1:
ones.append(C)
else:
twos.append(C)
max_weight = len(ones) + 2 * len(twos)
if len(ones) >= 1:
ones.append(0)
ones.so... | ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING IF VAR EXPR FUNC_CALL VAR STRING VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VA... |
Read problems statements in Mandarin Chinese and Russian as well.
Mike takes part in programming contests. His favourite topic is dynamic programming(DP). As he said, that he likes problems on DP, because "you spend a lot of time on thinking and a little time on coding".
In this problem you are to solve a version of ... | n = int(input())
total = 0
w1 = []
w2 = []
for _ in range(n):
w, c = map(int, input().split())
if w == 1:
w1.append(c)
else:
w2.append(c)
total += w
w1.sort(reverse=True)
w2.sort(reverse=True)
ans = [0] * (total + 1)
lw1 = len(w1)
lw2 = len(w2)
cur = 0
one, two = 0, 0
for i in range(2, t... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBE... |
Read problems statements in Mandarin Chinese and Russian as well.
Mike takes part in programming contests. His favourite topic is dynamic programming(DP). As he said, that he likes problems on DP, because "you spend a lot of time on thinking and a little time on coding".
In this problem you are to solve a version of ... | n = int(input())
l = []
v = 0
o = []
t = []
for w in range(n):
p, q = [int(e) for e in input().split()]
l.append([q, p])
v += p
if p == 1:
o.append(q)
else:
t.append(q)
o.sort(reverse=True)
t.sort(reverse=True)
i = 1
j = 0
k = 1
s = 0
if len(o) == 0:
o.append(0)
c = o[0]
print(o[... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EX... |
Read problems statements in Mandarin Chinese and Russian as well.
Mike takes part in programming contests. His favourite topic is dynamic programming(DP). As he said, that he likes problems on DP, because "you spend a lot of time on thinking and a little time on coding".
In this problem you are to solve a version of ... | try:
n = int(input())
w1 = []
w2 = []
for i in range(n):
wi, ci = [int(x) for x in input().split()]
if wi == 2:
w2.append(ci)
else:
w1.append(ci)
w1.sort()
w2.sort()
w1o = w1.copy()
w2o = w2.copy()
m = len(w2) * 2 + len(w1)
curr = 0... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN... |
Read problems statements in Mandarin Chinese and Russian as well.
Mike takes part in programming contests. His favourite topic is dynamic programming(DP). As he said, that he likes problems on DP, because "you spend a lot of time on thinking and a little time on coding".
In this problem you are to solve a version of ... | try:
n = int(input())
one = []
two = []
tw = 0
for _ in range(n):
w, c = map(int, input().split())
tw += w
if w == 1:
one.append(c)
else:
two.append(c)
one = sorted(one, reverse=True)
two = sorted(two, reverse=True)
onet = one.copy(... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN V... |
Read problems statements in Mandarin Chinese and Russian as well.
Mike takes part in programming contests. His favourite topic is dynamic programming(DP). As he said, that he likes problems on DP, because "you spend a lot of time on thinking and a little time on coding".
In this problem you are to solve a version of ... | n = int(input())
m = 0
item1 = []
item2 = []
for i in range(n):
w, c = map(int, input().split())
m += w
if w == 1:
item1.append(c)
if w == 2:
item2.append(c)
item1 = sorted(item1, reverse=True)
item2 = sorted(item2, reverse=True)
ans = [0] * (m + 1)
curr = 0
l1 = len(item1)
l2 = len(item... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR N... |
Read problems statements in Mandarin Chinese and Russian as well.
Mike takes part in programming contests. His favourite topic is dynamic programming(DP). As he said, that he likes problems on DP, because "you spend a lot of time on thinking and a little time on coding".
In this problem you are to solve a version of ... | n = int(input())
cost = [[], []]
for i in range(n):
w, c = map(int, input().split())
cost[w - 1].append(c)
cost[0].sort()
cost[1].sort()
l1 = len(cost[0])
l2 = len(cost[1])
m = l1 + 2 * l2
mp1 = [(0) for i in range(m + 1)]
mp2 = [(0) for i in range(m + 1)]
mp1[0] = l1
mp2[0] = l2
dp = [(0) for i in range(m + 1)... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST LIST LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN ... |
Read problems statements in Mandarin Chinese and Russian as well.
Mike takes part in programming contests. His favourite topic is dynamic programming(DP). As he said, that he likes problems on DP, because "you spend a lot of time on thinking and a little time on coding".
In this problem you are to solve a version of ... | num_items = int(input())
costs_weight1 = []
costs_weight2 = []
total_weight = 0
for i in range(num_items):
weight, cost = map(int, input().split())
total_weight += weight
if weight == 1:
costs_weight1.append(cost)
else:
costs_weight2.append(cost)
costs_weight1.sort(reverse=True)
costs_we... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBE... |
Read problems statements in Mandarin Chinese and Russian as well.
Mike takes part in programming contests. His favourite topic is dynamic programming(DP). As he said, that he likes problems on DP, because "you spend a lot of time on thinking and a little time on coding".
In this problem you are to solve a version of ... | n = int(input())
one, two = [], []
W = 0
for _ in range(n):
w, c = map(int, input().split())
if w == 1:
one.append(c)
else:
two.append(c)
W += w
e_one = sorted(one)
e_two = sorted(two)
ans = [0] * W
temp = 0
for w in range(2, W + 1, 2):
cost1, cost2 = 0, 0
if len(e_one) >= 2:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR LIST LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER... |
Read problems statements in Mandarin Chinese and Russian as well.
Mike takes part in programming contests. His favourite topic is dynamic programming(DP). As he said, that he likes problems on DP, because "you spend a lot of time on thinking and a little time on coding".
In this problem you are to solve a version of ... | from sys import stdin
n = int(stdin.readline())
list1 = []
weight = 0
list_one = []
list_two = []
for i in range(n):
w, c = map(int, stdin.readline().split())
if w == 1:
list_one.append(c)
else:
list_two.append(c)
weight += w
list1 = [0] * weight
list_one.sort(reverse=True)
list_two.sor... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR EXPR FUNC_CALL VAR NUMBER EXPR... |
Read problems statements in Mandarin Chinese and Russian as well.
Mike takes part in programming contests. His favourite topic is dynamic programming(DP). As he said, that he likes problems on DP, because "you spend a lot of time on thinking and a little time on coding".
In this problem you are to solve a version of ... | memo = dict()
n = int(input())
s, l1, l2 = 0, [], []
for i in range(n):
w, p = map(int, input().split())
if w == 1:
l1.append(p)
else:
l2.append(p)
s += w
l1 = sorted(l1)
l2 = sorted(l2)
l1 = l1[::-1]
l2 = l2[::-1]
dupl1 = l1[:]
dupl2 = l2[:]
memo[0] = 0
for i in range(2, s + 1, 2):
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER LIST LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR ... |
Read problems statements in Mandarin Chinese and Russian as well.
Mike takes part in programming contests. His favourite topic is dynamic programming(DP). As he said, that he likes problems on DP, because "you spend a lot of time on thinking and a little time on coding".
In this problem you are to solve a version of ... | def solve(oneWP, twoWP, C):
newOneWP = sorted(oneWP, reverse=True)
newTwoWP = sorted(twoWP, reverse=True)
dp = {}
used = {}
for i in range(C):
dp[i] = dp.get(i, 0)
used[i] = 0, 0
if len(newOneWP) > 0:
dp[0] = newOneWP[0]
used[0] = 1, 0
cost2 = 0
cost1 = 0
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIG... |
Read problems statements in Mandarin Chinese and Russian as well.
Mike takes part in programming contests. His favourite topic is dynamic programming(DP). As he said, that he likes problems on DP, because "you spend a lot of time on thinking and a little time on coding".
In this problem you are to solve a version of ... | def answer():
n = len(a) + 2 * len(b)
dp = [[0, 0, 0] for i in range(n + 1)]
if len(a):
dp[1] = [a[-1], 1, 0]
for i in range(2, n + 1):
x1 = dp[i - 1][0]
if dp[i - 1][1] < len(a):
x1 += a[-dp[i - 1][1] - 1]
x2 = dp[i - 2][0]
if dp[i - 2][2] < len(b):
... | FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP NUMBER FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR ASSIGN VAR NUMBER LIST VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER NUMBER IF VAR BIN_OP ... |
Read problems statements in Mandarin Chinese and Russian as well.
Mike takes part in programming contests. His favourite topic is dynamic programming(DP). As he said, that he likes problems on DP, because "you spend a lot of time on thinking and a little time on coding".
In this problem you are to solve a version of ... | n, a, b, MaxW, MaxC = int(input()), list(), list(), 0, 0
for _ in range(n):
w, c = map(int, input().split())
a.append(c) if w == 1 else b.append(c)
MaxW, MaxC = MaxW + w, MaxC + c
a, b, c, x, y = (
sorted(a),
sorted(b),
[0] * (MaxW + 1),
[0] * (MaxW + 1),
[0] * (MaxW + 1),
)
c[MaxW] = Ma... | ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR VAR NUMBER FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VA... |
Read problems statements in Mandarin Chinese and Russian as well.
Mike takes part in programming contests. His favourite topic is dynamic programming(DP). As he said, that he likes problems on DP, because "you spend a lot of time on thinking and a little time on coding".
In this problem you are to solve a version of ... | n = int(input().strip())
values_of_weight = {(1): [], (2): []}
m = 0
for i in range(n):
weight, value = map(int, input().strip().split())
values_of_weight[weight].append(value)
m += weight
values_of_weight[1].sort()
values_of_weight[2].sort()
value_dp = [(0) for i in range(m + 1)]
idx_1 = len(values_of_weig... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT NUMBER NUMBER LIST LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL V... |
Read problems statements in Mandarin Chinese and Russian as well.
Mike takes part in programming contests. His favourite topic is dynamic programming(DP). As he said, that he likes problems on DP, because "you spend a lot of time on thinking and a little time on coding".
In this problem you are to solve a version of ... | x = []
y = []
m = 0
for _ in range(int(input())):
w, c = map(int, input().split())
m += w
if w == 1:
x.append(c)
else:
y.append(c)
if not x:
x.append(0)
x.sort(reverse=True)
y.sort(reverse=True)
xn = len(x)
yn = len(y)
i = 1
j = 0
tKnapSack = x[0]
print(tKnapSack, end=" ")
for k in r... | ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR... |
Read problems statements in Mandarin Chinese and Russian as well.
Mike takes part in programming contests. His favourite topic is dynamic programming(DP). As he said, that he likes problems on DP, because "you spend a lot of time on thinking and a little time on coding".
In this problem you are to solve a version of ... | from sys import stdin
n = int(stdin.readline())
list1 = []
list2 = []
m = 0
sum1 = 0
pop = ()
for i in range(n):
w, c = list(map(int, stdin.readline().split()))
if w == 1:
list1.append((w, c))
m += w
else:
list2.append((w, c))
m += w
list1.sort(reverse=True, key=lambda x: x[... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR NU... |
You've got a robot, its task is destroying bombs on a square plane. Specifically, the square plane contains n bombs, the i-th bomb is at point with coordinates (x_{i}, y_{i}). We know that no two bombs are at the same point and that no bomb is at point with coordinates (0, 0). Initially, the robot is at point with coor... | import sys
def dist(p):
return abs(p[0]) + abs(p[1])
n = int(input())
pts = []
for i in range(n):
pts.append(tuple(map(int, input().split())))
pts.sort(key=dist)
ops = []
def move(s, t, direc):
if s == t:
return
if t > s:
ops.append("1 {} {}".format(t - s, direc[0]))
else:
... | IMPORT FUNC_DEF RETURN BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST FUNC_DEF IF VAR VAR RETURN IF VAR VAR EXPR FU... |
You've got a robot, its task is destroying bombs on a square plane. Specifically, the square plane contains n bombs, the i-th bomb is at point with coordinates (x_{i}, y_{i}). We know that no two bombs are at the same point and that no bomb is at point with coordinates (0, 0). Initially, the robot is at point with coor... | from sys import stdin, stdout
def inp():
return stdin.readline().strip()
def iinp():
return int(inp())
def out(var, end="\n"):
stdout.write(str(var) + "\n")
def mp():
return map(int, inp().split())
n = iinp()
ml = []
for i in range(n):
x, y = mp()
ml.append((x, y))
ml.sort(key=lambda x... | FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR STRING FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR EXPR FUNC_CALL ... |
You've got a robot, its task is destroying bombs on a square plane. Specifically, the square plane contains n bombs, the i-th bomb is at point with coordinates (x_{i}, y_{i}). We know that no two bombs are at the same point and that no bomb is at point with coordinates (0, 0). Initially, the robot is at point with coor... | n = int(input())
d = []
for i in range(n):
x, y = list(map(int, input().split()))
d.append([(x**2 + y**2) ** 0.5, x, y])
d.sort()
ans = []
for i in range(n):
if d[i][1] < 0:
ans.append("1 " + str(-d[i][1]) + " L")
elif d[i][1] > 0:
ans.append("1 " + str(d[i][1]) + " R")
if d[i][2] < ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ... |
You've got a robot, its task is destroying bombs on a square plane. Specifically, the square plane contains n bombs, the i-th bomb is at point with coordinates (x_{i}, y_{i}). We know that no two bombs are at the same point and that no bomb is at point with coordinates (0, 0). Initially, the robot is at point with coor... | def f(i, j):
x, y = str(abs(i)), str(abs(j))
l, r, u, d = " L", " R", " U", " D"
if i < 0:
l, r = r, l
if j < 0:
u, d = d, u
if i:
if j:
return ["1 " + x + r, "1 " + y + u, "2", "1 " + x + l, "1 " + y + d, "3"]
else:
return ["1 " + x + r, "2", ... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR STRING STRING STRING STRING IF VAR NUMBER ASSIGN VAR VAR VAR VAR IF VAR NUMBER ASSIGN VAR VAR VAR VAR IF VAR IF VAR RETURN LIST BIN_OP BIN_OP STRING VAR VAR BIN_OP BIN_OP STRING VAR VAR STRING BIN_OP BIN_OP ST... |
You've got a robot, its task is destroying bombs on a square plane. Specifically, the square plane contains n bombs, the i-th bomb is at point with coordinates (x_{i}, y_{i}). We know that no two bombs are at the same point and that no bomb is at point with coordinates (0, 0). Initially, the robot is at point with coor... | 3
def readln():
return tuple(map(int, input().split()))
(n,) = readln()
ans = []
for x, y in sorted([readln() for _ in range(n)], key=lambda x: abs(x[0]) + abs(x[1])):
if x > 0:
ans.append("1 %d R" % x)
if x < 0:
ans.append("1 %d L" % -x)
if y > 0:
ans.append("1 %d U" % y)
... | EXPR NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP STRING VAR IF VAR NUMBER EXPR FUNC_C... |
You've got a robot, its task is destroying bombs on a square plane. Specifically, the square plane contains n bombs, the i-th bomb is at point with coordinates (x_{i}, y_{i}). We know that no two bombs are at the same point and that no bomb is at point with coordinates (0, 0). Initially, the robot is at point with coor... | from sys import stdin
input = stdin.readline
n = int(input())
seg = [list(map(int, input().split())) for _ in range(n)]
seg = sorted(seg, key=lambda x: abs(x[0]) + abs(x[1]))
res = []
for x, y in seg:
if x > 0:
res.append("1 %d %c" % (x, "R"))
if x < 0:
res.append("1 %d %c" % (-x, "L"))
if ... | ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP STRING VAR STRING I... |
You've got a robot, its task is destroying bombs on a square plane. Specifically, the square plane contains n bombs, the i-th bomb is at point with coordinates (x_{i}, y_{i}). We know that no two bombs are at the same point and that no bomb is at point with coordinates (0, 0). Initially, the robot is at point with coor... | import sys
input = sys.stdin.readline
print = sys.stdout.write
I = lambda: list(map(int, input().split()))
(n,) = I()
l = []
r = []
k = 0
for i in range(n):
x, y = I()
if x < 0:
l.append([x, y])
else:
r.append([x, y])
k = k + 4 if x != 0 and y != 0 else k + 2
k += 2 * n
an = []
l.sort(k... | IMPORT ASSIGN VAR VAR ASSIGN VAR 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 ASSIGN VAR VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR ASSIGN V... |
You've got a robot, its task is destroying bombs on a square plane. Specifically, the square plane contains n bombs, the i-th bomb is at point with coordinates (x_{i}, y_{i}). We know that no two bombs are at the same point and that no bomb is at point with coordinates (0, 0). Initially, the robot is at point with coor... | from sys import stdin, stdout
n = int(stdin.readline())
pos = []
for i in range(n):
x, y = list(map(int, stdin.readline().split()))
pos.append([x, y])
pos = sorted(pos, key=lambda pos: abs(pos[0]) + abs(pos[1]))
moves = []
for p in pos:
x, y = p
xNeg, yNeg = False, False
xPos, yPos = False, False
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR VAR VAR ASS... |
You've got a robot, its task is destroying bombs on a square plane. Specifically, the square plane contains n bombs, the i-th bomb is at point with coordinates (x_{i}, y_{i}). We know that no two bombs are at the same point and that no bomb is at point with coordinates (0, 0). Initially, the robot is at point with coor... | n = int(input())
arr = [
(abs(i) + abs(j), i, j)
for i, j in tuple(map(int, input().split()) for i in range(n))
]
arr.sort()
ans = []
for z, x, y in arr:
X, Y = str(abs(x)), str(abs(y))
l, r, u, d = " L", " R", " U", " D"
if x < 0:
l, r = r, l
if y < 0:
u, d = d, u
if x:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR... |
You've got a robot, its task is destroying bombs on a square plane. Specifically, the square plane contains n bombs, the i-th bomb is at point with coordinates (x_{i}, y_{i}). We know that no two bombs are at the same point and that no bomb is at point with coordinates (0, 0). Initially, the robot is at point with coor... | import sys
testcases = int(input())
def get_ints():
return map(int, sys.stdin.readline().strip().split())
arr = []
count_zero = 0
for testcase in range(testcases):
x, y = get_ints()
arr.append((x, y))
if x == 0:
count_zero += 1
if y == 0:
count_zero += 1
arr.sort(key=lambda x: a... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR ... |
You've got a robot, its task is destroying bombs on a square plane. Specifically, the square plane contains n bombs, the i-th bomb is at point with coordinates (x_{i}, y_{i}). We know that no two bombs are at the same point and that no bomb is at point with coordinates (0, 0). Initially, the robot is at point with coor... | n = int(input())
tot = 0
boombs = []
for _ in range(n):
x, y = map(int, input().split())
tot += 2 + (2 if x == 0 or y == 0 else 4)
boombs.append((abs(x) + abs(y), x, y))
boombs.sort()
moves = "LR", "DU"
print(tot)
for boomb in boombs:
ans = []
_, x, y = map(int, boomb)
if x:
ans.append(f... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR BIN_OP NUMBER VAR NUMBER VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR STRING STR... |
After bracket sequences Arthur took up number theory. He has got a new favorite sequence of length n (a1, a2, ..., an), consisting of integers and integer k, not exceeding n.
This sequence had the following property: if you write out the sums of all its segments consisting of k consecutive elements (a1 + a2 ... + ak, ... | import sys
n, k = map(int, input().split())
a = input().split()
INF = 10**9 + 7
OK = True
for i in range(n):
if a[i] == "?":
a[i] = INF
else:
a[i] = int(a[i])
for i in range(len(a)):
if a[i] == INF:
j = i + k
while j < len(a) and a[j] == INF:
j += k
count... | IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR AS... |
After bracket sequences Arthur took up number theory. He has got a new favorite sequence of length n (a1, a2, ..., an), consisting of integers and integer k, not exceeding n.
This sequence had the following property: if you write out the sums of all its segments consisting of k consecutive elements (a1 + a2 ... + ak, ... | def foo(left, right, number):
left += 1
right -= 1
if right - left + 1 < number:
return 10**10
num = number // 2
if number % 2:
if num <= right and -num >= left:
return -num
else:
if -num >= left and num - 1 <= right:
return -num
if -num + ... | FUNC_DEF VAR NUMBER VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER VAR RETURN BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER IF VAR VAR VAR VAR RETURN VAR IF VAR VAR BIN_OP VAR NUMBER VAR RETURN VAR IF BIN_OP VAR NUMBER VAR VAR VAR RETURN BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETU... |
After bracket sequences Arthur took up number theory. He has got a new favorite sequence of length n (a1, a2, ..., an), consisting of integers and integer k, not exceeding n.
This sequence had the following property: if you write out the sums of all its segments consisting of k consecutive elements (a1 + a2 ... + ak, ... | INF = 10000000001
def fill(s):
s.insert(0, -INF)
s.append(INF)
i = 0
for j in filter(lambda x: s[x] != "?", range(1, len(s))):
d = i - j
s[j] = int(s[j])
if s[i] > s[j] + d:
raise
a = max(min(d // 2, s[j] + d), s[i])
for t in range(i + 1, j):
... | ASSIGN VAR NUMBER FUNC_DEF EXPR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR STRING FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUM... |
After bracket sequences Arthur took up number theory. He has got a new favorite sequence of length n (a1, a2, ..., an), consisting of integers and integer k, not exceeding n.
This sequence had the following property: if you write out the sums of all its segments consisting of k consecutive elements (a1 + a2 ... + ak, ... | n, k = map(int, input().split())
arr = [[-2 * 10**9] for i in range(k)]
for i, j in enumerate(input().split()):
arr[i % k].append(j)
b = True
for i in range(k):
arr[i].append(2 * 10**9)
z, c = 1, 0
while z < len(arr[i]):
while arr[i][z] == "?":
z += 1
arr[i][z] = int(arr[i][z... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST BIN_OP NUMBER BIN_OP NUMBER NUMBER VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP NUMBER BIN_OP NUMBER NUMBER ... |
After bracket sequences Arthur took up number theory. He has got a new favorite sequence of length n (a1, a2, ..., an), consisting of integers and integer k, not exceeding n.
This sequence had the following property: if you write out the sums of all its segments consisting of k consecutive elements (a1 + a2 ... + ak, ... | INF = 1 << 60
Q = 1 << 58
def solve():
ans = [0] * n
for i in range(k):
b = [-INF]
b.extend(a[i:n:k])
m = len(b)
b.append(INF)
lb = -INF
p, q = 1, 0
while p < m:
while b[p] == Q:
p += 1
l = p - q - 1
lb... | ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR NUMBER NUMBER WHILE VAR VAR WHILE VAR VAR VAR VAR ... |
Valera's lifelong ambition was to be a photographer, so he bought a new camera. Every day he got more and more clients asking for photos, and one day Valera needed a program that would determine the maximum number of people he can serve.
The camera's memory is d megabytes. Valera's camera can take photos of high and l... | def readln():
return tuple(map(int, input().split()))
n, d = readln()
a, b = readln()
lst = []
for _ in range(n):
x, y = readln()
lst.append((a * x + b * y, _ + 1))
lst.sort()
ans = []
s = 0
for v, i in lst:
if s + v > d:
break
s += v
ans.append(i)
print(len(ans))
print(*ans) | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR... |
Valera's lifelong ambition was to be a photographer, so he bought a new camera. Every day he got more and more clients asking for photos, and one day Valera needed a program that would determine the maximum number of people he can serve.
The camera's memory is d megabytes. Valera's camera can take photos of high and l... | n, d = map(int, input().split())
a, b = map(int, input().split())
t = [0] * n
for i in range(n):
x, y = map(int, input().split())
t[i] = a * x + b * y, i
t.sort()
j, s = n, 0
for i in range(n):
s += t[i][0]
if s > d:
j = i
break
print(j)
print(" ".join(str(t[i][1] + 1) for i in range(j))... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR... |
Valera's lifelong ambition was to be a photographer, so he bought a new camera. Every day he got more and more clients asking for photos, and one day Valera needed a program that would determine the maximum number of people he can serve.
The camera's memory is d megabytes. Valera's camera can take photos of high and l... | n, d = map(int, input().split())
a, b = map(int, input().split())
people = []
for i in range(1, n + 1):
x, y = map(int, input().split())
people.append((a * x + b * y, i))
people.sort()
pos = 0
while True:
d -= people[pos][0]
if d < 0:
break
pos += 1
if pos == n:
break
print(pos)
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN ... |
Valera's lifelong ambition was to be a photographer, so he bought a new camera. Every day he got more and more clients asking for photos, and one day Valera needed a program that would determine the maximum number of people he can serve.
The camera's memory is d megabytes. Valera's camera can take photos of high and l... | from sys import *
inp = lambda: stdin.readline()
def main():
n, d = map(int, inp().split())
a, b = map(int, inp().split())
l, ans = [], []
for i in range(n):
x, y = map(int, inp().split())
l.append((x * a + y * b, i + 1))
l = sorted(l)
for i in l:
if i[0] <= d:
... | ASSIGN VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP V... |
Valera's lifelong ambition was to be a photographer, so he bought a new camera. Every day he got more and more clients asking for photos, and one day Valera needed a program that would determine the maximum number of people he can serve.
The camera's memory is d megabytes. Valera's camera can take photos of high and l... | R = lambda: list(map(int, input().split()))
n, d = R()
a, b = R()
lst1 = []
lst2 = []
lst3 = []
sum = 0
cnt = 1
for i in range(0, n):
x, y = R()
p = x * a + y * b
lst1.append(p)
lst2.append(i)
iteams = list(zip(lst1, lst2))
iteams.sort()
for i in range(0, n):
sum = sum + iteams[i][0]
if sum <= d... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR E... |
Valera's lifelong ambition was to be a photographer, so he bought a new camera. Every day he got more and more clients asking for photos, and one day Valera needed a program that would determine the maximum number of people he can serve.
The camera's memory is d megabytes. Valera's camera can take photos of high and l... | I = lambda: map(int, input().split())
R = range
n, d = I()
a, b = I()
m = []
v = []
for i in R(n):
x, y = I()
v += [x * a + y * b]
m += [i]
m = sorted(m, key=lambda x: v[x])
for i in R(n):
if v[m[i]] > d:
n = i
break
d -= v[m[i]]
print(n)
for i in R(n):
print(m[i] + 1, end=" ") | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR LIST BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR LIST VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR FOR VAR FUN... |
Valera's lifelong ambition was to be a photographer, so he bought a new camera. Every day he got more and more clients asking for photos, and one day Valera needed a program that would determine the maximum number of people he can serve.
The camera's memory is d megabytes. Valera's camera can take photos of high and l... | n, d = [int(x) for x in input().split()]
a, b = [int(x) for x in input().split()]
arr = []
for _ in range(n):
arr.append([int(x) for x in input().split()] + [_ + 1])
arr.sort(key=lambda x: a * x[0] + b * x[1])
ans = []
for i in arr:
d -= a * i[0] + b * i[1]
if d >= 0:
ans.append(i[2])
else:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR LIST BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VA... |
Valera's lifelong ambition was to be a photographer, so he bought a new camera. Every day he got more and more clients asking for photos, and one day Valera needed a program that would determine the maximum number of people he can serve.
The camera's memory is d megabytes. Valera's camera can take photos of high and l... | from sys import stdin
def arr_inp(n):
if n == 1:
return [int(x) for x in stdin.readline().split()]
elif n == 2:
return [float(x) for x in stdin.readline().split()]
else:
return [str(x) for x in stdin.readline().split()]
def arr_inp_enu(n):
return [[i, arr_inp(1)] for i in ran... | FUNC_DEF IF VAR NUMBER RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN LIST VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FUNC_DEF FOR VAR FUNC_CALL VAR VAR ... |
Valera's lifelong ambition was to be a photographer, so he bought a new camera. Every day he got more and more clients asking for photos, and one day Valera needed a program that would determine the maximum number of people he can serve.
The camera's memory is d megabytes. Valera's camera can take photos of high and l... | n, d = list(map(int, input().split()))
a, b = list(map(int, input().split()))
res = []
for i in range(n):
x, y = list(map(int, input().split()))
res.append((x, y, i + 1))
res.sort(key=lambda x: a * x[0] + b * x[1])
output = []
for x, y, idx in res:
if a * x + b * y <= d:
d -= a * x + b * y
o... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR B... |
Valera's lifelong ambition was to be a photographer, so he bought a new camera. Every day he got more and more clients asking for photos, and one day Valera needed a program that would determine the maximum number of people he can serve.
The camera's memory is d megabytes. Valera's camera can take photos of high and l... | n, d = map(int, input().split())
a, b = map(int, input().split())
s = [None] * n
for i in range(n):
x, y = map(int, input().split())
s[i] = [a * x + b * y, i + 1]
s.sort()
res = []
for i in range(n):
if d - s[i][0] >= 0:
res.append(s[i][1])
d -= s[i][0]
else:
break
print(str(len(... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NONE VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL V... |
Valera's lifelong ambition was to be a photographer, so he bought a new camera. Every day he got more and more clients asking for photos, and one day Valera needed a program that would determine the maximum number of people he can serve.
The camera's memory is d megabytes. Valera's camera can take photos of high and l... | n, d = map(int, input().split())
lis = []
aa = []
m1, m2 = map(int, input().split())
for i in range(n):
a, b = map(int, input().split())
lis.append([m1 * a + m2 * b, i + 1])
lis.sort()
ans = 0
for i in range(n):
if lis[i][0] + ans <= d:
ans += lis[i][0]
aa.append(lis[i][1])
print(len(aa))
pr... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CA... |
Valera's lifelong ambition was to be a photographer, so he bought a new camera. Every day he got more and more clients asking for photos, and one day Valera needed a program that would determine the maximum number of people he can serve.
The camera's memory is d megabytes. Valera's camera can take photos of high and l... | n, d = map(int, input().split())
a, b = map(int, input().split())
req = []
for i in range(n):
x, y = map(int, input().split())
req.append([x, y, i])
ans = []
req.sort(key=lambda x: [x[0] * a + x[1] * b])
for i in range(n):
curr = req[i][0] * a + req[i][1] * b
if d >= curr:
ans.append(req[i][2] +... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR LIST BIN_OP BIN_OP VAR NUMBER VAR BI... |
Valera's lifelong ambition was to be a photographer, so he bought a new camera. Every day he got more and more clients asking for photos, and one day Valera needed a program that would determine the maximum number of people he can serve.
The camera's memory is d megabytes. Valera's camera can take photos of high and l... | n, d = map(int, input().split())
a, b = map(int, input().split())
ans = []
for i in range(n):
x, y = map(int, input().split())
ans.append([x * a + y * b, i + 1])
ans.sort()
nans = []
for i in range(len(ans)):
if d >= ans[i][0]:
nans.append(ans[i][1])
d = d - ans[i][0]
else:
break... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VA... |
Valera's lifelong ambition was to be a photographer, so he bought a new camera. Every day he got more and more clients asking for photos, and one day Valera needed a program that would determine the maximum number of people he can serve.
The camera's memory is d megabytes. Valera's camera can take photos of high and l... | inp = [int(x) for x in input().split()]
n = inp[0]
d = inp[1]
size = [int(x) for x in input().split()]
lowSize = size[0]
highSize = size[1]
sizeByCustomer = []
for i in range(n):
photosCount = [int(x) for x in input().split()]
photosLowCount = photosCount[0]
photosHighCount = photosCount[1]
totalSize = ... | ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMB... |
Valera's lifelong ambition was to be a photographer, so he bought a new camera. Every day he got more and more clients asking for photos, and one day Valera needed a program that would determine the maximum number of people he can serve.
The camera's memory is d megabytes. Valera's camera can take photos of high and l... | lst = list(map(int, input().split()))
n = lst[0]
d = lst[1]
lst = list(map(int, input().split()))
a = lst[0]
b = lst[1]
ans = []
for x in range(0, n):
lst = list(map(int, input().split()))
ans.append([lst[0] * a + lst[1] * b, x + 1])
ans.sort()
sum = 0
i = 0
for s in range(0, n):
i += 1
sum += ans[s][0]... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_C... |
Valera's lifelong ambition was to be a photographer, so he bought a new camera. Every day he got more and more clients asking for photos, and one day Valera needed a program that would determine the maximum number of people he can serve.
The camera's memory is d megabytes. Valera's camera can take photos of high and l... | n, d = [int(i) for i in input().split()]
a, b = [int(i) for i in input().split()]
arr, res = [], []
for j in range(n):
x, y = [int(i) for i in input().split()]
arr.append([x * a + y * b, j])
arr.sort()
sum = 0
for i in range(n):
sum = sum + arr[i][0]
if sum > d:
break
res.append(arr[i][1] + ... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR AS... |
Valera's lifelong ambition was to be a photographer, so he bought a new camera. Every day he got more and more clients asking for photos, and one day Valera needed a program that would determine the maximum number of people he can serve.
The camera's memory is d megabytes. Valera's camera can take photos of high and l... | n, d = map(int, input().split())
a, b = map(int, input().split())
clients = []
for i in range(n):
x_i, y_i = map(int, input().split())
clients.append({"number": i + 1, "size": x_i * a + y_i * b})
clients = sorted(clients, key=lambda x: x["size"])
sum = 0
cnt = len(clients)
for i in range(len(clients)):
sum ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR DICT STRING STRING BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR FUN... |
Valera's lifelong ambition was to be a photographer, so he bought a new camera. Every day he got more and more clients asking for photos, and one day Valera needed a program that would determine the maximum number of people he can serve.
The camera's memory is d megabytes. Valera's camera can take photos of high and l... | n, d = map(int, input().split())
d1, d2 = map(int, input().split())
datos = []
for i in range(n):
a, b = map(int, input().split())
datos.append((a * d1 + b * d2, i + 1))
datos = sorted(datos)
posiciones = ""
cont = 0
acum = 0
res = []
for x in datos:
if x[0] <= d:
res.append(x[1])
d -= x[0]
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSI... |
Valera's lifelong ambition was to be a photographer, so he bought a new camera. Every day he got more and more clients asking for photos, and one day Valera needed a program that would determine the maximum number of people he can serve.
The camera's memory is d megabytes. Valera's camera can take photos of high and l... | master = []
n, total = map(int, input().split())
a, b = map(int, input().split())
for t in range(1, n + 1):
one, two = map(int, input().split())
one = one * a
two = two * b
summ = one + two
master.append((t, summ))
final = []
master.sort(key=lambda x: x[1])
empty = 0
for t in master:
empty += t[... | ASSIGN VAR LIST ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUN... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.