description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | n, v = map(int, input().split())
T = 3010
a = [[] for i in range(T)]
for i in range(n):
x, y = map(int, input().split())
a[x].append([y, 1])
ans = 0
for i in range(T):
a[i] = a[i][::-1]
j = 0
cur = v
while j < len(a[i]):
if a[i][j][0] > cur:
ans += cur
if a[i][j][... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR LIST VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR ... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | frukti_po_dnyam = {}
n, resurs = map(int, input().split(" "))
for i in range(n):
den, chislo_fruktov = map(int, input().split(" "))
if den in frukti_po_dnyam:
frukti_po_dnyam[den] += chislo_fruktov
else:
frukti_po_dnyam[den] = chislo_fruktov
if den + 1 not in frukti_po_dnyam:
fru... | ASSIGN VAR DICT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR IF BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER NUMBER FUNC_DEF ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBE... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | n, v = map(int, input().split())
g = [(0) for x in range(3002)]
for i in range(n):
a, b = map(int, input().split())
g[a] += b
r = 0
for i in range(1, 3002):
c = v
r += min(c, max(g[i - 1], 0))
c -= max(g[i - 1], 0)
if c > 0:
r += min(c, g[i])
g[i] = max(g[i] - c, 0)
print(r) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBE... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | def read(mode=2):
inputs = input().strip()
if mode == 0:
return inputs
if mode == 1:
return inputs.split()
if mode == 2:
return [int(x) for x in inputs.split()]
def write(s="\n"):
if isinstance(s, list):
s = " ".join(s)
s = str(s)
print(s, end="")
n, v = r... | FUNC_DEF NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER RETURN VAR IF VAR NUMBER RETURN FUNC_CALL VAR IF VAR NUMBER RETURN FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_DEF STRING IF FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR STRING ASSIGN VAR VAR FUNC_... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | n, v = map(int, input().split())
N = [(0) for i in range(3002)]
for i in range(n):
x, y = map(int, input().split())
N[x] += y
cost = 0
cur = 0
for i in range(3002):
if N[i] + cur > v:
cost += v
if cur > v:
cur = N[i]
else:
cur = N[i] - (v - cur)
else:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR VAR VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR ... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | def main():
R = lambda: map(int, input().split())
n, v = R()
mlist = [0] * 3003
for i in range(n):
a, b = R()
mlist[a] += b
mlist2 = mlist[:]
ans = 0
for i in range(1, 3002):
tmp = min(v, mlist[i])
ans += tmp
mlist[i + 1] += min(mlist[i] - tmp, mlist2[... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR BIN_OP ... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | n, v = map(int, input().split())
arr = [0] * 3002
for _ in range(n):
a, b = map(int, input().split())
arr[a] += b
x = v
ans = 0
prev = 0
for i in range(1, 3002):
x = max(x - prev, 0)
ans += v - x
if arr[i] <= x:
ans += arr[i]
prev = 0
else:
ans += x
prev = arr[i] ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR NUMB... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | l = lambda: map(int, input().split())
n, v = l()
t = {}
for _ in " " * n:
x, y = l()
t[x] = t.get(x, 0) + y
s = 0
for i in range(min(t), max(t) + 2):
us = v
x = min(us, t.get(i - 1, 0))
s += x
us -= x
t[i - 1] = t.get(i - 1, 0) - x
x = min(us, t.get(i, 0))
s += x
t[i] = t.get(i, ... | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR BIN_OP STRING VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR ... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | n, m = map(int, input().split())
d = {}
for i in range(n):
a, b = map(int, input().split())
d[a] = d.get(a, 0) + b
d = {x: d[x] for x in sorted(d)}
p = -1
r = 0
out = 0
for x in d:
if x - p > 1:
r = 0
p = x
f = min(d[x], m * 2 - r)
r = max(min(m, d[x] - m + r), 0)
out += f
print(out) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | n, V = map(int, input().split())
A = []
max_no_of_days = 0
for _ in range(n):
a, b = map(int, input().split())
A.append([a, b])
max_no_of_days = max(max_no_of_days, a)
A.sort()
Fruits = [0] * (max_no_of_days + 2)
for i in A:
Fruits[i[0]] += i[1]
S = 0
for i in range(1, max_no_of_days + 2):
v = V
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER 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 ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR VAR VA... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | n, v = list(map(int, input().split()))
trees = {}
days = set()
for i in range(n):
a, b = list(map(int, input().split()))
if a not in trees:
trees[a] = b
else:
trees[a] += b
days.add(a)
max_days = max(days)
total = 0
for a in range(1, max_days + 1):
prev_collected = 0
if a - 1 in ... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | n, v = map(int, input().split())
a = [0] * 3002
ans = 0
for i in range(n):
y, x = map(int, input().split())
a[y] += x
for i in range(1, 3002):
usable = v
z = min(usable, a[i - 1])
ans += z
usable -= z
a[i - 1] -= z
z = min(usable, a[i])
ans += z
usable -= z
a[i] -= z
print(an... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | DEBUG = False
n, v = [int(x) for x in input().split()]
fruits = []
for i in range(n):
aa, bb = [int(x) for x in input().split()]
fruits.append([aa, bb])
fruits.sort()
day, t_harvested, tot, curr = 0, 0, 0, []
def remove_old():
while fruits != [] and fruits[0][0] < day - 1:
t = fruits.pop(0)
... | ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR 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 EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER LIST FUNC_DEF WHILE VAR LIST VAR NUMBER NUM... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | n, v = map(int, input().split())
s, t = 0, [0] * 3002
for i in range(n):
a, b = map(int, input().split())
t[a] += b
for d in range(1, 3002):
ds = min(t[d - 1], v)
s += ds
ds = min(t[d], v - ds)
t[d] -= ds
s += ds
print(s) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR VAR ASSIGN VAR FUNC_CALL VAR ... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | total_plucked = 0
n, v = list(map(int, input().split()))
fruits = [0] * 3002
plucked = [0] * 30002
for _ in range(n):
a, b = list(map(int, input().split()))
fruits[a] = fruits[a] + b
for i in range(1, 3002):
plucked[i] = fruits[i - 1] if fruits[i - 1] <= v else v
if plucked[i] < v:
pluck = fruit... | ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR FOR VAR FUNC_CALL VAR NUMB... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | n, v = map(int, input().split())
f = [0] * 3005
for i in range(n):
a, b = map(int, input().split())
f[a] += b
day = 1
down = 0
collect = 0
while day <= 3001:
curr = f[day]
if curr + down <= v:
collect += curr + down
curr = 0
else:
collect += v
if down < v:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR VAR VAR IF BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR ... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | n, v = map(int, input().split())
f = list()
for i in range(n):
f.append(list(map(int, input().split())))
f.sort()
sum = 0
today = 0
tomor = 0
day = 0
rest = 0
for tree in f:
if tree[0] > day + 1:
sum += min(tomor, v)
tomor = tree[1]
sum += min(tomor, v)
rest = v - min(tomor, v)
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER BI... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | n, v = map(int, input().split(" "))
result, day, trees = 0, 1, {}
for i in range(n):
days, fruits = map(int, input().split(" "))
if days in trees:
trees[days] += fruits
else:
trees[days] = fruits
while day <= 3001:
to_collect = v
if day - 1 in trees:
x = trees[day - 1]
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR NUMBER NUMBER DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR WHILE VAR NUMBER ASSIGN VAR VAR IF BIN_OP VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR NUM... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | n, v = map(int, input().split(" "))
a, b = [], []
for i in range(n):
x, y = map(int, input().split(" "))
a.append(x)
b.append(y)
fi = max(a)
li = []
for i in range(fi + 3):
li.append([0, 0])
for i in range(n):
li[a[i]][1] += b[i]
ans = 0
for i in range(fi + 2):
if li[i][0] <= v:
ans += l... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | import itertools as it
import sys
class pair:
x, y = 0, 0
array = [pair() for _ in range(4000)]
n, v = map(int, input().split())
for _ in range(n):
a, b = map(int, input().split())
array[a].y += b
array[a + 1].x += b
ans = 0
for i in range(1, 3500):
tmp = v
ans += min(tmp, array[i].x)
tm... | IMPORT IMPORT CLASS_DEF ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER 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 VAR VAR VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | import sys
f = sys.stdin
n, v = map(int, f.readline().strip().split())
p = [0] * 3002
for i in range(n):
a, b = map(int, f.readline().strip().split())
p[a] += b
S = 0
for k in range(1, len(p)):
dv = min(v, p[k - 1])
S += dv
p[k - 1] -= dv
dv = min(v - dv, p[k])
S += dv
p[k] -= dv
print(... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | n, v = map(int, input().split())
trees = [0] * 3002
for i in range(n):
a, b = map(int, input().split())
trees[a] += b
ans = 0
prev = 0
for i in range(1, len(trees)):
available = min(v, prev + trees[i])
ans += available
if prev >= v:
prev = trees[i]
else:
prev = max(0, trees[i] - ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR ... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | n, v = map(int, input().split())
trees = [list(map(int, input().split())) for i in range(n)]
trees.sort()
mergedTrees = []
treeIndex = 0
currentDay = trees[treeIndex][0]
while treeIndex < len(trees):
nbFruits = 0
while treeIndex < len(trees) and trees[treeIndex][0] == currentDay:
nbFruits += trees[treeI... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR VAR VAR NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR VAR NUMBER VAR VA... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | import sys
sys.setrecursionlimit(100000)
n, v = [int(x) for x in sys.stdin.readline().strip().split()]
arr = [0] * 3002
k = [0]
for i in range(n):
a, b = [int(x) for x in sys.stdin.readline().strip().split()]
if arr[a] == 0:
k.append(a)
arr[a] += b
k.sort()
count = 0
for i in k[1:]:
if arr[i + ... | IMPORT EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR EXPR F... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | n, v = map(int, input().split())
lst = [0] * 4001
for _ in range(n):
a, b = map(int, input().split())
lst[a] += b
b = lst[:]
t = 0
for day in range(4000):
x = min(v, b[day])
t += x
b[day + 1] += min(b[day] - x, lst[day])
print(t) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR BIN_OP VAR NUMBER FU... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | def main():
n, m = map(int, input().split())
a = []
b = []
for _ in range(n):
a1, b1 = map(int, input().split())
a.append(a1)
b.append(b1)
prev = 0
tv = 0
ans = 0
for i in range(1, 3002):
curr = 0
for j in range(n):
if a[j] == i:
... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL 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 VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASS... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | total, limit = map(int, input().split())
l = [int(0)] * 3002
due = [int(0)] * 3002
ans = int(0)
for i in range(total):
day, mango = map(int, input().split())
l[day - 1] += mango
for i in range(3002):
tut = limit
if due[i] <= tut:
ans += due[i]
tut -= due[i]
else:
ans += tut
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VA... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | n, v = map(int, input().split())
a = []
for x in range(n):
p = list(map(int, input().split()))
a.append((p[0], p[1]))
a.sort()
arr = [0] * 4000
for x in range(n):
arr[a[x][0]] += a[x][1]
tmp = max(0, arr[a[x][0]] - v)
arr[a[x][0]] -= tmp
arr[a[x][0] + 1] += tmp
arr[a[x][0] + 1] = min(arr[a[x... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER VAR VAR NUMB... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | n, v = map(int, input().split())
apples = [0] * 3002
for i in range(n):
a, b = map(int, input().split())
apples[a] += b
count = 0
for i in range(1, 3002):
leftover = apples[i - 1]
collectable = min(v, apples[i] + leftover)
count += collectable
apples[i] = apples[i] + min(0, leftover - collectabl... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | n, v = map(int, input().rstrip().split())
li = [0] * 3002
t = 0
for i in range(n):
a, b = map(int, input().rstrip().split())
li[a] += b
for i in range(1, 3002):
x = min(v, li[i - 1])
y = min(li[i], v - x)
li[i - 1] -= x
li[i] -= y
t += x + y
print(t) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER ASSIGN... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | n, v = map(int, input().split())
l = []
for j in range(3001):
l += [0]
for k in range(n):
x, y = map(int, input().split())
l[x - 1] += y
sum = 0
for kl in range(3001):
if kl == 0:
if v <= l[kl]:
sum += v
l[kl] -= v
else:
sum += l[kl]
l[kl] ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR LIST NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR NUMBER IF VAR VAR VAR VAR VAR VAR VAR V... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | def read_integer_pair():
line = input()
pair = line.split(" ")
assert len(pair) == 2
return int(pair[0]), int(pair[1])
n, v = read_integer_pair()
trees = {}
for i in range(n):
a, b = read_integer_pair()
if a in trees:
trees[a] += b
else:
trees[a] = b
trees = list(trees.item... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING FUNC_CALL VAR VAR NUMBER RETURN FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR IF VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | n, k = map(int, input().split(" "))
dict = {}
max = []
for i in range(n):
a, b = map(int, input().split(" "))
if a in dict:
dict[a] += b
else:
dict[a] = b
for i in dict.copy():
if i + 1 not in dict:
dict[i + 1] = 0
def summa_fruit(dict):
k = dict.values()
sum = 0
fo... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR DICT ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER NUMBER FUNC_DEF ... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | n, v = map(int, input().split())
t = []
for i in range(n):
t.append(list(map(int, input().split())))
t.sort()
c = 0
a = 0
for d in range(3002):
l = 0
while c < n and t[c][0] < d - 1:
c += 1
while l < v and c < n and t[c][0] <= d:
if t[c][0] == d or t[c][0] == d - 1:
if t[c][1... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR NUMBER BIN_OP VAR NUMB... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | n, v = map(int, input().split())
inp = []
for i in range(n):
x, y = map(int, input().split())
e = [x, y]
inp.append(e)
inp = sorted(inp)
b = []
a = []
for e in inp:
a.append(e[0])
b.append(e[1])
cur = 0
day = 1
ans = 0
while day <= a[-1] + 1:
while day > a[cur] + 1 and cur + 1 < len(a):
... | 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 ASSIGN VAR LIST VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | n, v = map(int, input().split())
d = [0] * 3001
for _ in range(n):
a, b = map(int, input().split())
d[a - 1] += b
sum = min(v, d[0])
d[0] = max(0, d[0] - v)
for i in range(1, 3001):
sum += min(v, d[i - 1] + d[i])
d[i] = max(0, d[i] - max(0, v - d[i - 1]))
print(sum) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR FOR VAR FUNC_CAL... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | n, v = [int(c) for c in input().split()]
m = [[0, 0] for i in range(3003)]
for i in range(n):
a, b = [int(c) for c in input().split()]
m[a][1] += b
m[a + 1][0] += b
res = 0
for i in range(1, 3002):
if v <= m[i][0]:
res += v
else:
from_future = v - m[i][0]
got_fr = min(from_fu... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR NUMBER VAR VAR BIN_OP VAR NUMBER NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR VAR ... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | import sys
def minp():
return sys.stdin.readline().strip()
A = [0] * 3005
n, v = map(int, minp().split())
for i in range(n):
a, b = map(int, minp().split())
A[a] += b
r = 0
for i in range(1, len(A) - 1):
z = min(v, A[i - 1])
A[i - 1] -= z
w = min(v - z, A[i])
A[i] -= w
r += z + w
pri... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER 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 VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIG... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | def a():
n, v = list(map(int, input().split(" ")))
d = []
for i in range(n):
d.append(list(map(int, input().split(" "))))
d.sort()
cur = 0
nex = 0
k = 0
r = 0
for i in range(d[-1][0] + 2):
nex = 0
p = v
if k != n:
while d[k][0] < i:
... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING 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 STRING EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL ... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | [n, v] = input().split()
v1 = []
for i in range(3002):
v1.append(0)
v = int(v)
maxx = 0
for i in range(int(n)):
[a, b] = input().split()
v1[int(a)] += int(b)
maxx = max(int(a), maxx)
res = 0
for i in range(1, maxx + 2):
delt = min(v, v1[i] + v1[i - 1])
res += delt
d = v1[i - 1] - delt
v1... | ASSIGN LIST VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN LIST VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | N = 3005
n, v = map(int, input().split())
ripe = [0] * N
for i in range(n):
a, b = map(int, input().split())
ripe[a] += b
t = 0
ans = 0
for i in range(N):
if ripe[i] + t <= v:
ans += ripe[i] + t
t = 0
else:
ans += min(t, v)
ans += min(max(0, v - t), ripe[i])
t = m... | ASSIGN VAR NUMBER 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 VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR VAR BIN_OP VAR VAR VAR ASSIG... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | n, v = [int(i) for i in input().split()]
d = {}
for i in range(n):
a, b = [int(i) for i in input().split()]
if a in d:
d[a] += b
else:
d[a] = b
set_tree = sorted(d)
set_tree = list(range(1, max(set_tree) + 2))
set_tree.append(0)
d[0] = 0
S = 0
for i in set_tree:
if i in d:
None
... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FU... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | n, v = map(int, input().split())
li = []
for i in range(n):
tp = [int(x) for x in input().split()]
li.append(tp)
li.sort(key=lambda x: x[0])
d = {}
end = {}
distinct = set()
for i in range(n):
if d.get(li[i][0], -1) == -1:
d[li[i][0]] = i
if i < n - 1 and li[i][0] != li[i + 1][0]:
end[li... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR NUM... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | n, v = map(int, input().split())
w = []
q = [v for i in range(3003)]
for i in range(n):
w.append(list(map(int, input().split())))
w = sorted(w, reverse=True)
s = 0
for i in w:
a = i[0]
b = i[1]
if q[a + 1] >= b:
q[a + 1] -= b
s += b
b = 0
else:
b -= q[a + 1]
s... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUM... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | n, v = map(int, input().split())
d = {}
for i in range(n):
a, b = map(int, input().split())
if a in d:
d[a] += b
else:
d[a] = b
mi = min(d.keys())
ma = max(d.keys())
c = 0
for i in range(mi, ma + 3):
quota = v
if i - 1 in d:
if quota > d[i - 1]:
c += d[i - 1]
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | R = lambda: list(map(int, input().split()))
n, v = R()
M = 3005
x = [0] * M
for i in range(n):
a, b = R()
x[a - 1] += b
y = [0] * M
s = 0
for i in range(M):
a = min(v, y[i])
b = min(v - a, x[i])
s += a + b
if i < M - 1:
y[i + 1] = x[i] - b
print(s) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FU... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | n, v = map(int, input().split())
l = []
for i in range(n):
l += [list(map(int, input().split()))]
l.sort()
r = [0] * (3000 + 2)
t = 0
for i in range(n):
if r[l[i][0]] + l[i][1] <= v:
r[l[i][0]] += l[i][1]
elif r[l[i][0]] + r[l[i][0] + 1] + l[i][1] <= 2 * v:
t = r[l[i][0]]
r[l[i][0]] ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR VAR LIST FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR NUMBER VAR VAR NUMBE... |
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on day a_{i} and day a_{i} + 1 (all fruits that are not collected in the... | n, v = [int(x) for x in input().split(" ")]
a_dict = {}
m = 0
p = 0
for tree in range(n):
a, b = [int(x) for x in input().split(" ")]
m = max(a, m)
if a in a_dict.keys():
a_dict[a] += b
else:
a_dict[a] = b
for day in range(m + 2):
if day not in a_dict.keys():
a_dict[day] = 0
... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR... |
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In... | def main():
n = int(input())
s, t = str(input()), str(input())
p = [([0] * 26) for _ in range(26)]
dist = 0
for i in range(n):
if s[i] != t[i]:
j = ord(s[i]) - ord("a")
k = ord(t[i]) - ord("a")
p[j][k] = i + 1
dist += 1
for i in range(26):
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_... |
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In... | n = input()
s1, s2 = input(), input()
l2, l3 = [], []
l1 = [
[l2.append((s1[x] + s2[x], x)), l3.append((s2[x] + s1[x], x))]
for x in range(len(s1))
if s1[x] != s2[x]
]
d1, d2 = dict(l2), dict(l3)
ins = set(d1.keys()) & set(d2.keys())
if ins:
e = ins.pop()
print(len(l1) - 2)
print(d1[e] + 1, d2[e... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR LIST LIST ASSIGN VAR LIST FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CAL... |
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In... | import sys
n = int(input())
a = input()
b = input()
l = 0
c = [[(0) for j in range(26)] for i in range(26)]
for i in range(n):
if a[i] != b[i]:
l += 1
c[ord(a[i]) - ord("a")][ord(b[i]) - ord("a")] = i + 1
for i in range(26):
for j in range(26):
if i == j or c[i][j] == 0 or c[j][i] == 0:... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING BIN_OP FUNC_CALL VAR ... |
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In... | n = int(input())
s = input()
t = input()
a = []
x = y = -2
h = 0
for i in range(26):
a.append([])
for j in range(26):
a[i].append(-1)
for i in range(n):
if s[i] != t[i]:
h += 1
a[ord(s[i]) - ord("a")][ord(t[i]) - ord("a")] = i
if a[ord(t[i]) - ord("a")][ord(s[i]) - ord("a")] ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER ASSIGN ... |
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In... | def main():
n = int(input())
s = input()
t = input()
p = {}
hd = sum(int(x != y) for x, y in zip(s, t))
for i, (x, y) in enumerate(zip(s, t)):
if x != y:
if x in p and y in p[x]:
print(hd - 2)
print(i + 1, p[x][y] + 1)
return
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FOR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR IF VAR VAR IF VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR F... |
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In... | __author__ = "ruckus"
n = int(input())
s = input()
t = input()
dif = {}
hem = 0
for i in range(n):
if s[i] != t[i]:
dif[i] = [s[i], t[i]]
hem += 1
change = []
probed = []
k = 0
for i in dif.keys():
if dif[i] in probed:
continue
probed.append(dif[i])
k += 1
for j in list(dif.k... | ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR LIST VAR VAR VAR VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR IF VAR VAR VAR ... |
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In... | import time
class Profiler(object):
def __enter__(self):
self._startTime = time.time()
def __exit__(self, type, value, traceback):
print("Elapsed time: {:.3f} sec".format(time.time() - self._startTime))
n = int(input())
a = input()
b = input()
indexes = list()
d = {}
f1 = False
f2 = False
... | IMPORT CLASS_DEF VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR FUNC_CALL STRING BIN_OP FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR ... |
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In... | xxx = 0
a1 = []
a2 = []
a = int(input())
x = input()
y = input()
of1 = []
of2 = []
a1 = {}
a2 = {}
for i in "abcdefghijklmnopqrstuvwxyz":
a1[i] = []
a2[i] = []
for i in range(a):
if x[i] != y[i]:
a1[x[i]].append(i + 1)
a2[y[i]].append(i + 1)
else:
xxx += 1
for i in "abcdefghijklm... | ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR STRING ASSIGN VAR VAR LIST ASSIGN VAR VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VA... |
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In... | num = int(input())
a = input()
b = input()
dic = {}
lis = []
ham = 0
swap1 = -1
swap2 = -1
p = False
q = False
for i in range(num):
if a[i] != b[i]:
ham += 1
lis.append(i)
dic[b[i]] = i
for i in lis:
if a[i] in dic:
p = True
swap1 = i + 1
f = dic[a[i]]
swa... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FOR VAR... |
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In... | n = int(input())
s = input()
t = input()
pair2ind = {}
letters_s = [0] * 26
letters_t = [0] * 26
non_common = set()
cnt = 0
for i in range(n):
if s[i] != t[i]:
pair2ind[s[i], t[i]] = i + 1
letters_s[ord(s[i]) - ord("a")] = i + 1
letters_t[ord(t[i]) - ord("a")] = i + 1
non_common.add(... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN V... |
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In... | def solve():
r = 0
d = {}
for i in range(n):
if a[i] != b[i]:
r += 1
d[a[i], b[i]] = i + 1
symbols = [chr(ord("a") + i) for i in range(26)]
for i in symbols:
for j in symbols:
if (i, j) in d and (j, i) in d:
return r - 2, d[i, j], d... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR STRING VAR VAR FUNC_CALL VAR NUMBER FOR VAR VAR FOR VAR VAR IF VAR VAR VAR VAR VAR VAR RETURN BIN_OP VAR NUMBER VAR VAR VAR VAR VA... |
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In... | n = int(input())
s = input()
t = input()
def id(c):
return ord(c) - ord("a")
diff = 0
for i in range(n):
if s[i] != t[i]:
diff += 1
has = [[(0) for i in range(30)] for j in range(30)]
x = [(0) for i in range(30)]
y = [(0) for i in range(30)]
if diff == 0:
print("0\n-1 -1")
elif diff == 1:
pr... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF RETURN BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_... |
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In... | def solve(n, S, T):
st = dict()
ts = dict()
s = dict()
t = dict()
dist = 0
for i, (si, ti) in enumerate(zip(S, T), 1):
if si != ti:
st[si, ti] = i
ts[ti, si] = i
s[si] = i
t[ti] = i
dist += 1
for key, i in st.items():
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR VAR NUMBER FOR VAR VAR FUNC_CALL VAR IF... |
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In... | _, s, t = input(), input(), input()
d = 0
p = [[(-1) for _ in range(26)] for _ in range(26)]
a, b = [(-1) for _ in range(26)], [(-1) for _ in range(26)]
for i in range(len(s)):
if s[i] != t[i]:
cs = ord(s[i]) - 97
ct = ord(t[i]) - 97
d += 1
p[cs][ct] = i + 1
a[cs] = i + 1
... | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER VAR FUNC_CALL VAR NUMBER NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR... |
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In... | n, s, t = int(input()), input(), input()
d = {}
wrongs = []
ansD, ansI, ansJ = 0, -1, -1
for i in range(n):
if s[i] != t[i]:
ansD += 1
wrongs.append(i)
d[t[i]] = i
perfectSwapped = False
swapped = False
for i in wrongs:
if s[i] in d:
swapped = True
ansI = i + 1
j ... | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR LIST ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR ASSIGN V... |
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In... | n = int(input())
a = input()
b = input()
cnt = 0
index1 = -1
index2 = -1
mp = {}
flag1 = True
flag2 = True
l = [chr(ord("a") + i) for i in range(26)]
for i in range(n):
if a[i] != b[i]:
cnt += 1
mp[a[i], b[i]] = i
for i in l:
if flag1:
for j in l:
if flag1:
if... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR STRING VAR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VA... |
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In... | n, s, t, a, error, ans, kappa = int(input()), str(input()), str(input()), {}, 0, -1, 0
for i in range(n):
if s[i] != t[i]:
a[s[i] + t[i]] = i
error += 1
for c1 in "abcdefghijklmnopqrstuvwxyz":
for c2 in "abcdefghijklmnopqrstuvwxyz":
if c1 == c2 or kappa == 2:
continue
... | ASSIGN VAR VAR VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR DICT NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR VAR VAR NUMBER FOR VAR STRING FOR VAR STRING IF VAR VAR VAR NUMBER IF BIN_OP VAR VAR VAR BIN_OP ... |
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In... | n = input()
s1, s2 = input(), input()
l1 = [[x, [s1[x], s2[x]]] for x in range(len(s1)) if s1[x] != s2[x]]
d1, d2 = dict([(y[1][0] + y[1][1], y[0]) for y in l1]), dict(
[(y[1][1] + y[1][0], y[0]) for y in l1]
)
ins = set(d1.keys()) & set(d2.keys())
if ins:
e = ins.pop()
print(len(l1) - 2)
print(d1[e] + ... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST VAR LIST VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER ... |
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In... | n = int(input())
s = input()
t = input()
diff = {}
dis = 0
for i in range(len(s)):
if s[i] != t[i]:
dis += 1
diff[s[i] + t[i]] = i + 1
for d in diff.keys():
if diff.get(d[::-1], 0) > 0:
print(dis - 2)
print(diff[d], diff[d[::-1]])
exit()
for d in diff.keys():
for dd i... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER NUMBER NUMBER EXPR FUNC_C... |
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In... | n = int(input())
s = input()
t = input()
dis = 0
d = [[(False) for i in range(30)] for i in range(30)]
x = [[(0) for i in range(30)] for i in range(30)]
for i in range(n):
if s[i] != t[i]:
dis += 1
d[ord(s[i]) - ord("a")][ord(t[i]) - ord("a")] = True
x[ord(s[i]) - ord("a")][ord(t[i]) - ord("... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP FUN... |
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In... | n = int(input())
s, t = input(), input()
alpha = list("abcdefghijklmnopqrstuvwxyz")
spair, tpair = dict(), dict()
x = [1] * n
k = n
d = 0
u, v = -1, -1
dd = dict()
for i in range(n):
if s[i] == t[i]:
k = k - 1
else:
dd[s[i] + t[i]] = str(i + 1)
for i in alpha:
for j in alpha:
if i + ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR V... |
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In... | n = int(input())
s = input()
t = input()
k, l = 0, 0
state = 0
hd = 0
m = {}
for i in range(n):
if s[i] != t[i]:
hd += 1
cs = s[i]
ct = t[i]
cst = cs + ct
if cst not in m:
m[cst] = i + 1
for pair in m:
r = pair[1] + pair[0]
if r in m:
print(hd - 2)... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR VAR BIN_... |
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In... | n = int(input())
s = input()
t = input()
p = 0
dist = 0
m = [[] for i in range(0, 26)]
sr = []
while p < len(s):
if s[p] != t[p]:
m[ord(s[p]) - ord("a")].append((t[p], p))
dist += 1
p += 1
p = 0
while p < len(s):
if s[p] != t[p]:
flag = False
for i in sr:
if i[0] ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR LIST WHILE VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING VAR VAR VAR VAR... |
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In... | def gao():
n = int(input())
a = input()
b = input()
mp = {}
cnt = 0
for i in range(n):
if a[i] != b[i]:
cnt += 1
mp[a[i], b[i]] = i + 1
l = [chr(ord("a") + i) for i in range(26)]
for i in l:
for j in l:
if (i, j) in mp and (j, i) in mp:... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR STRING VAR VAR FUNC_CALL VAR NUMBER FOR V... |
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In... | n = int(input())
s = list(input())
t = list(input())
d = {}
ans = 0
x, y = -1, -1
for i in range(n):
if s[i] != t[i]:
d[s[i], t[i]] = i
ans += 1
l = [chr(i + 97) for i in range(26)]
for i in l:
for j in l:
if (i, j) in d and (j, i) in d:
ans -= 2
x = d[i, j] + 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_C... |
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In... | diff = []
wrong_t = {}
def distance(n, s, t):
count = 0
for i in range(n):
if s[i] != t[i]:
diff.append(i)
wrong_t[t[i]] = i
count += 1
return count
def minDistance():
m_ben = 0
m_i = -2
m_j = -2
for i in diff:
v = wrong_t[s[i]] if s[i]... | ASSIGN VAR LIST ASSIGN VAR DICT FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR NONE IF VAR NONE ASSIGN VAR NUMBER ASS... |
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In... | alth = "abcdefghijklmnopqrstuvwxyz"
n = int(input())
S = input()
T = input()
heming = 0
first = [-1] * 26
second = [-1] * 26
first_second = [-1] * 676
for i in range(n):
if S[i] != T[i]:
heming += 1
temp = alth.find(S[i])
temp2 = alth.find(T[i])
first[temp] = i
second[temp2] ... | ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR... |
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In... | import sys
n = int(input())
s = input()
t = input()
def ff(ch):
return ord(ch) - ord("a")
def answer(a, b, sc):
print(res + sc)
print(a + 1, b + 1)
return
matrix = [([None] * 26) for _ in range(26)]
res = 0
for i in range(len(s)):
matrix[ff(s[i])][ff(t[i])] = i
if s[i] != t[i]:
re... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF RETURN BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING FUNC_DEF EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER RETURN ASSIGN VAR BIN_OP LIST NONE NUMBER VAR FUNC_CALL VAR NUMB... |
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In... | import sys
n = int(input())
s = input()
t = input()
arr = {}
f = 0
for idx in range(n):
if s[idx] != t[idx]:
f += 1
arr[s[idx] + t[idx]] = idx
for k in arr.keys():
if k[1] + k[0] in arr:
print(f - 2)
print(str(arr[k] + 1) + " " + str(arr[k[1] + k[0]] + 1))
sys.exit(0)
fo... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR VAR VAR FOR VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER E... |
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In... | n = int(input())
s = input()
t = input()
p = [-1, -1]
a = [([-1] * 26) for i in range(26)]
k = 0
for i in range(n):
if t[i] != s[i]:
k += 1
for i in range(n):
if t[i] != s[i]:
if a[ord(t[i]) - 97][ord(s[i]) - 97] != -1:
print(k - 2)
print(a[ord(t[i]) - 97][ord(s[i]) - 97]... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR IF VAR BIN_OP FUNC_C... |
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the In... | YNaXbdBeHKpwfIm = int
YNaXbdBeHKpwfIi = input
YNaXbdBeHKpwfIj = range
YNaXbdBeHKpwfIR = len
YNaXbdBeHKpwfID = print
YNaXbdBeHKpwfIl = exit
YNaXbdBeHKpwfIt = YNaXbdBeHKpwfIm
YNaXbdBeHKpwfIx = YNaXbdBeHKpwfIi
YNaXbdBeHKpwfIz = YNaXbdBeHKpwfIj
YNaXbdBeHKpwfIW = YNaXbdBeHKpwfIR
YNaXbdBeHKpwfIO = YNaXbdBeHKpwfID
YNaXbdBeHKp... | ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR ... |
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N.
You want to maximize the value of interaction of the arrays. You are allowed to make ... | for _ in range(int(input())):
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
s = 0
for i in range(n):
s += a[i] * b[i]
m = max([abs(i) for i in b])
print(s + k * m) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN V... |
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N.
You want to maximize the value of interaction of the arrays. You are allowed to make ... | for _ in range(int(input())):
n, k = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
mul = [(a[x] * b[x]) for x in range(n)]
absb = [abs(x) for x in b]
mx = max(absb)
index = absb.index(mx)
su = sum(mul)
(
print(su + (a[in... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN... |
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N.
You want to maximize the value of interaction of the arrays. You are allowed to make ... | for _ in range(int(input())):
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
interaction = 0
mx = -float("INF")
for item in b:
mx = max(mx, abs(item))
for i in range(n):
interaction += a[i] * b[i]
interaction += mx... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING FOR VAR VAR ASSIGN VAR FUNC_C... |
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N.
You want to maximize the value of interaction of the arrays. You are allowed to make ... | for _ in range(int(input().strip())):
n, k = map(int, input().strip().split())
a = list(map(int, input().strip().split()))
b = list(map(int, input().strip().split()))
ans = 0
ans += sum(x * y for x, y in zip(a, b))
ans += k * max(map(abs, b))
print(ans) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN... |
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N.
You want to maximize the value of interaction of the arrays. You are allowed to make ... | from sys import flags
for _ in range(int(input())):
n, k = [int(a) for a in input().split()]
arr = [int(a) for a in input().split()]
brr = [int(a) for a in input().split()]
val = -float("inf")
for l in brr:
val = max(val, abs(l))
val2 = 0
for l in range(n):
val2 = val2 +... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSI... |
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N.
You want to maximize the value of interaction of the arrays. You are allowed to make ... | def main():
t = int(input())
while t:
t -= 1
n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
ssum = sum([(n1 * n2) for n1, n2 in zip(a, b)])
mmax = max(b)
mmin = min(b)
if abs(mmi... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN... |
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N.
You want to maximize the value of interaction of the arrays. You are allowed to make ... | for __ in range(int(input())):
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
mx, mn = max(b), min(b)
val = mx if abs(mx) > abs(mn) else mn
idx = b.index(val)
if val > 0:
a[idx] += k
else:
a[idx] -= k
s = 0
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR... |
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N.
You want to maximize the value of interaction of the arrays. You are allowed to make ... | for cas in range(int(input())):
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
for i in range(n):
a[i] = a[i] * b[i]
b[i] = abs(b[i])
s = sum(a)
p = max(b)
print(s + k * abs(p)) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR ... |
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N.
You want to maximize the value of interaction of the arrays. You are allowed to make ... | t = int(input())
for i in range(t):
n, k = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
b = list(map(int, input().split(" ")))
c = list(map(lambda x, y: x * y, a, b))
m = max(list(map(lambda x: abs(x), b)))
csum = sum(c)
print(csum + k * m) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_... |
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N.
You want to maximize the value of interaction of the arrays. You are allowed to make ... | T = int(input())
while T:
N, K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
ans = 0
for i in range(len(A)):
ans += A[i] * B[i]
B[i] = abs(B[i])
ans += K * max(B)
print(ans)
T -= 1 | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR ... |
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N.
You want to maximize the value of interaction of the arrays. You are allowed to make ... | t = int(input())
for test in range(t):
n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
s = sum(x * y for x, y in zip(a, b))
mx = 0
pair = 0
for i in range(n):
if abs(b[i]) > abs(mx):
mx = b[i]
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR... |
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N.
You want to maximize the value of interaction of the arrays. You are allowed to make ... | tests = int(input())
for i in range(tests):
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
maximum = -(10**6)
ans = 0
for j in range(n):
ans += a[j] * b[j]
maximum = max(maximum, abs(b[j]))
ans += maximum * k
print... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_C... |
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N.
You want to maximize the value of interaction of the arrays. You are allowed to make ... | T = int(input())
for j in range(T):
in1 = [int(i) for i in input().split()]
N, K = in1[0], in1[1]
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
P = K * max([abs(l) for l in [max(B), min(B)]])
for i in range(0, N):
P += A[i] * B[i]
print(P) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR FUNC_CALL V... |
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N.
You want to maximize the value of interaction of the arrays. You are allowed to make ... | t = int(input())
for _ in range(0, t):
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
sum = 0
for i in range(0, n):
sum += a[i] * b[i]
max = 0
ii = 0
for i in range(0, n):
if max < abs(b[i]):
max = abs(... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR BI... |
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N.
You want to maximize the value of interaction of the arrays. You are allowed to make ... | for t in range(int(input())):
temp = list(map(int, input().split()))
n = temp[0]
k = temp[1]
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
x = abs(b[0])
for i in range(n):
ans += a[i] * b[i]
if abs(b[i]) > x:
x = abs(b[i])
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR 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 FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN ... |
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N.
You want to maximize the value of interaction of the arrays. You are allowed to make ... | def temp(n, k):
a = list(map(int, input().split()))
b = list(map(int, input().split()))
max_i = 0
m1 = abs(b[0])
j = 0
for i in range(n):
if m1 < abs(b[i]):
m1 = abs(b[i])
j = i
max_i += a[i] * b[i]
max_i = max_i + k * abs(b[j])
return max_i
t = ... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VA... |
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N.
You want to maximize the value of interaction of the arrays. You are allowed to make ... | for _ in range(int(input())):
n, k = map(int, input().split(" "))
a = [int(i) for i in input().split(" ")]
b = [int(i) for i in input().split(" ")]
c = 0
final = 0
for i in range(n):
c += a[i] * b[i]
final += a[i] * b[i]
for i in range(n):
p = 1 if b[i] >= 0 else -1
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR V... |
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N.
You want to maximize the value of interaction of the arrays. You are allowed to make ... | for i in range(int(input())):
s = input().split()
s = [int(j) for j in s]
l1 = input().split()
l2 = input().split()
l1 = [int(j) for j in l1]
l2 = [int(j) for j in l2]
mx = abs(l2[0])
k = 0
for j in range(len(l2)):
if abs(l2[j]) > mx:
mx = abs(l2[j])
k... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ... |
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N.
You want to maximize the value of interaction of the arrays. You are allowed to make ... | for _ in range(int(input())):
arr = input().split()
n, k = int(arr[0]), int(arr[1])
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
for i in range(n):
if b[i] < 0:
b[i] *= -1
a[i] *= -1
m = b.index(max(b))
a[m] += k
print(sum([(... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR NUMB... |
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N.
You want to maximize the value of interaction of the arrays. You are allowed to make ... | for _ in range(int(input())):
N, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
min_el = min(B)
max_el = max(B)
ind = 0
if abs(min_el) < max_el:
ind = B.index(max_el)
A[ind] = A[ind] + K
elif min_el == max_el:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF ... |
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N.
You want to maximize the value of interaction of the arrays. You are allowed to make ... | t = int(input())
for _ in range(t):
n, k = map(int, input().split())
ans = 0
a = list(map(int, input().split()))
b = list(map(int, input().split()))
for i in range(n):
ans += a[i] * b[i]
d = ans
for i in range(n):
d = max(d, ans + k * b[i])
d = max(d, ans + -1 * k * b... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR V... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.