description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
You are given a sequence of $n$ integers $a_1, a_2, \dots, a_n$. You are also given $x$ integers $1, 2, \dots, x$.
You are asked to insert each of the extra integers into the sequence $a$. Each integer can be inserted at the beginning of the sequence, at the end of the sequence, or between any elements of the sequence... | t = int(input())
while t > 0:
p = input().split()
n, x = int(p[0]), int(p[1])
a = input().split()
for i in range(n):
a[i] = int(a[i])
ma, mi = max(a), min(a)
ans = 0
r = 10**7
s = 10**7
f1 = 0
f2 = 0
for i in range(n):
if a[i] == ma and x > ma and (i == 0 or i... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMB... |
You are given a sequence of $n$ integers $a_1, a_2, \dots, a_n$. You are also given $x$ integers $1, 2, \dots, x$.
You are asked to insert each of the extra integers into the sequence $a$. Each integer can be inserted at the beginning of the sequence, at the end of the sequence, or between any elements of the sequence... | def solve():
n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for i in range(n - 1):
ans += abs(a[i] - a[i + 1])
mn, mx = min(a), max(a)
if mn == 1 and mx >= k:
print(ans)
return
if mn > 1:
res = min(a[0] - 1, a[-1] - 1)
for... | FUNC_DEF 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 NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR VAR E... |
You are given a sequence of $n$ integers $a_1, a_2, \dots, a_n$. You are also given $x$ integers $1, 2, \dots, x$.
You are asked to insert each of the extra integers into the sequence $a$. Each integer can be inserted at the beginning of the sequence, at the end of the sequence, or between any elements of the sequence... | for i in range(int(input())):
n, x = map(int, input().split())
l = list(map(int, input().split()))
m1 = min(l)
m2 = max(l)
m3 = min(l[0], l[-1])
m4 = max(l[0], l[-1])
s = 0
for j in range(n - 1):
s += abs(l[j] - l[j + 1])
if x > m2:
s += m1 - 1
s += x - m2
... | 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 VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR N... |
You are given a sequence of $n$ integers $a_1, a_2, \dots, a_n$. You are also given $x$ integers $1, 2, \dots, x$.
You are asked to insert each of the extra integers into the sequence $a$. Each integer can be inserted at the beginning of the sequence, at the end of the sequence, or between any elements of the sequence... | for g in range(int(input())):
n, e = map(int, input().split())
x = list(map(int, input().split()))
print(
sum(abs(x[i + 1] - x[i]) for i in range(n - 1))
+ min(2 * max(e - max(x), 0), max(e - x[0], 0), max(e - x[-1], 0))
+ min(2 * (min(x) - 1), x[0] - 1, x[-1] - 1)
) | 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 EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VA... |
Vasya has n items lying in a line. The items are consecutively numbered by numbers from 1 to n in such a way that the leftmost item has number 1, the rightmost item has number n. Each item has a weight, the i-th item weights w_{i} kilograms.
Vasya needs to collect all these items, however he won't do it by himself. He... | n, l, r, ql, qr = map(int, input().split())
w = [0] + list(map(int, input().split()))
for i in range(1, n + 1):
w[i] += w[i - 1]
s = w[n]
print(
min(
l * w[i]
+ r * (s - w[i])
+ ql * max(0, 2 * i - n - 1)
+ qr * max(0, n - 2 * i - 1)
for i in range(n + 1)
)
) | ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR ... |
Vasya has n items lying in a line. The items are consecutively numbered by numbers from 1 to n in such a way that the leftmost item has number 1, the rightmost item has number n. Each item has a weight, the i-th item weights w_{i} kilograms.
Vasya needs to collect all these items, however he won't do it by himself. He... | n, l, r, ql, qr = map(int, input().split())
w = list(map(int, input().split()))
answ = 0
first = 0
last = sum(w)
answ = last * r + (len(w) - 1) * qr
for i in range(n):
first += w[i]
last -= w[i]
tmp = first * l + last * r
if i + 1 > n - i - 1:
tmp += ql * (i + 1 - n + i + 1 - 1)
elif i + 1 <... | ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR V... |
Vasya has n items lying in a line. The items are consecutively numbered by numbers from 1 to n in such a way that the leftmost item has number 1, the rightmost item has number n. Each item has a weight, the i-th item weights w_{i} kilograms.
Vasya needs to collect all these items, however he won't do it by himself. He... | n, l, r, Ql, Qr = map(int, input().split())
s, v = [0] * (n + 1), 2 * 10**9
for i, wi in enumerate(map(int, input().split())):
s[i + 1] = s[i] + wi
for lc in range(0, n + 1):
rc = n - lc
c = s[lc] * l + (s[n] - s[lc]) * r
if lc > rc + 1:
c += (lc - rc - 1) * Ql
elif rc > lc + 1:
c +=... | ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER BIN_OP NUMBER BIN_OP NUMBER NUMBER FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER A... |
Vasya has n items lying in a line. The items are consecutively numbered by numbers from 1 to n in such a way that the leftmost item has number 1, the rightmost item has number n. Each item has a weight, the i-th item weights w_{i} kilograms.
Vasya needs to collect all these items, however he won't do it by himself. He... | from itertools import accumulate
from sys import stdin
def arr_sum(arr):
return list(accumulate(arr, lambda x, y: x + y))
rints = lambda: [int(x) for x in stdin.readline().split()]
n, l, r, ql, qr = rints()
w, ans = [0] + rints(), float("inf")
mem = arr_sum(w)
for i in range(n + 1):
s1, s2 = mem[i] - mem[0]... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP... |
Vasya has n items lying in a line. The items are consecutively numbered by numbers from 1 to n in such a way that the leftmost item has number 1, the rightmost item has number n. Each item has a weight, the i-th item weights w_{i} kilograms.
Vasya needs to collect all these items, however he won't do it by himself. He... | n, l, r, ql, qr = list(map(int, input().split()))
w = list(map(int, input().split()))
prefix = [0]
suffix = [sum(w)]
for i in range(n):
prefix.append(prefix[i] + w[i])
suffix.append(suffix[i] - w[i])
m = 10000000000.0
for i in range(n + 1):
res = l * prefix[i] + r * suffix[i]
if i > n - i:
res +... | ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR LIST FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASS... |
Vasya has n items lying in a line. The items are consecutively numbered by numbers from 1 to n in such a way that the leftmost item has number 1, the rightmost item has number n. Each item has a weight, the i-th item weights w_{i} kilograms.
Vasya needs to collect all these items, however he won't do it by himself. He... | n, l, r, ql, qr = map(int, input().split())
arr = [int(i) for i in input().split()]
mini = 10**20
sm = sum(arr)
appaji = 0
curr = 0
for i in range(n + 1):
if i > 0:
curr += arr[i - 1]
now = curr * l + (sm - curr) * r
j = n - i
if i > j:
now += (i - j - 1) * ql
if j > i:
now +... | ASSIGN VAR VAR VAR 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 BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP... |
Vasya has n items lying in a line. The items are consecutively numbered by numbers from 1 to n in such a way that the leftmost item has number 1, the rightmost item has number n. Each item has a weight, the i-th item weights w_{i} kilograms.
Vasya needs to collect all these items, however he won't do it by himself. He... | path = list(map(int, input().split()))
n, L, R, QL, QR = path[0], path[1], path[2], path[3], path[4]
w = list(map(int, input().split()))
sumpref = [0]
for i in range(1, n + 1):
sumpref.append(w[i - 1] + sumpref[i - 1])
answer = QR * (n - 1) + sumpref[n] * R
for i in range(1, n + 1):
energy = L * sumpref[i] + R ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_... |
Vasya has n items lying in a line. The items are consecutively numbered by numbers from 1 to n in such a way that the leftmost item has number 1, the rightmost item has number n. Each item has a weight, the i-th item weights w_{i} kilograms.
Vasya needs to collect all these items, however he won't do it by himself. He... | n, l, r, ql, qr = map(int, input().split())
weights = [int(x) for x in input().split()]
curr_sum = 0
cum_sum = list()
for i in weights:
curr_sum += i
cum_sum.append(curr_sum)
min_cost = r * curr_sum + (n - 1) * qr
for i in range(1, n + 1):
taskl = i
taskr = n - i
cost = l * cum_sum[taskl - 1] + r * ... | ASSIGN VAR VAR VAR 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 NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER... |
Vasya has n items lying in a line. The items are consecutively numbered by numbers from 1 to n in such a way that the leftmost item has number 1, the rightmost item has number n. Each item has a weight, the i-th item weights w_{i} kilograms.
Vasya needs to collect all these items, however he won't do it by himself. He... | n, l, r, ql, qr = list(map(int, input().split()))
w = list(map(int, input().split()))
sum = 0
sums = []
for i in range(n):
sum += w[i]
sums.append(sum)
min = r * sum + qr * (n - 1)
for i in range(n):
ss = l * sums[i] + r * (sum - sums[i])
if i + 1 > n - i - 1 and i - n + i + 1 > 0:
ss += ql * (i... | ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR NUMBER FOR VAR FUNC_... |
Vasya has n items lying in a line. The items are consecutively numbered by numbers from 1 to n in such a way that the leftmost item has number 1, the rightmost item has number n. Each item has a weight, the i-th item weights w_{i} kilograms.
Vasya needs to collect all these items, however he won't do it by himself. He... | def main():
n, l, r, Ql, Qr = list(map(int, input().split()))
ww = list(map(int, input().split()))
work = sum(ww) * r + (n - 1) * Qr
res, penalty = [work], Qr * 2
l -= r
for w in ww[: (n - 1) // 2]:
work += l * w - penalty
res.append(work)
penalty = Ql * 2
work += l * ww[... | FUNC_DEF ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR VAR LIST VAR BIN_OP VAR NUMBER VAR VAR FOR VAR VAR BIN_OP BIN_OP VAR NUMBE... |
Vasya has n items lying in a line. The items are consecutively numbered by numbers from 1 to n in such a way that the leftmost item has number 1, the rightmost item has number n. Each item has a weight, the i-th item weights w_{i} kilograms.
Vasya needs to collect all these items, however he won't do it by himself. He... | num, l, r, ql, qr = list(map(int, input().split()))
ara = [int(i) for i in input().split()]
for i in range(1, num, 1):
ara[i] = ara[i] + ara[i - 1]
ans = 10**11
for i in range(0, num + 1, 1):
tr = num - i
cl = ara[i - 1] if i > 0 else 0
cr = ara[num - 1] - cl
pl = max(0, i - tr - 1)
pr = max(0, ... | ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER AS... |
Vasya has n items lying in a line. The items are consecutively numbered by numbers from 1 to n in such a way that the leftmost item has number 1, the rightmost item has number n. Each item has a weight, the i-th item weights w_{i} kilograms.
Vasya needs to collect all these items, however he won't do it by himself. He... | n, l, r, Ql, Qr = [int(x) for x in input().split(" ")]
w = [int(x) for x in input().split(" ")]
sum = [(0) for x in range(n + 1)]
for i in range(1, n + 1):
sum[i] = sum[i - 1] + w[i - 1]
ans = 2**32
for k in range(0, n + 1):
temp = sum[k] * l + (sum[n] - sum[k]) * r
if 2 * k > n:
temp += (2 * k - n ... | ASSIGN VAR VAR VAR VAR 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 VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VA... |
Vasya has n items lying in a line. The items are consecutively numbered by numbers from 1 to n in such a way that the leftmost item has number 1, the rightmost item has number n. Each item has a weight, the i-th item weights w_{i} kilograms.
Vasya needs to collect all these items, however he won't do it by himself. He... | import sys
input = sys.stdin.readline
for _ in range(1):
n, l, r, ql, qr = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
temp1, temp2 = [], []
curr = 0
for i in arr:
curr += i
temp1.append(curr)
curr = 0
for i in arr[::-1]:
curr += i
... | IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR 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 VAR LIST LIST ASSIGN VAR NUMBER FOR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR NUMBER VAR VAR EXPR FUN... |
Vasya has n items lying in a line. The items are consecutively numbered by numbers from 1 to n in such a way that the leftmost item has number 1, the rightmost item has number n. Each item has a weight, the i-th item weights w_{i} kilograms.
Vasya needs to collect all these items, however he won't do it by himself. He... | import sys
n, l, r, ql, qr = map(int, sys.stdin.readline().strip().split())
w = [int(x) for x in sys.stdin.readline().strip().split()]
s = [0]
for i in range(0, n):
s.append(s[-1] + w[i])
def cost(left):
right = n - left
diff = left - right
bonus = 0
if diff > 0:
bonus = ql * (diff - 1)
... | IMPORT ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR FUNC_DEF ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIG... |
Vasya has n items lying in a line. The items are consecutively numbered by numbers from 1 to n in such a way that the leftmost item has number 1, the rightmost item has number n. Each item has a weight, the i-th item weights w_{i} kilograms.
Vasya needs to collect all these items, however he won't do it by himself. He... | import sys
n, L, r, QL, QR = map(int, sys.stdin.readline().split())
W = list(map(int, sys.stdin.readline().split()))
minn = 10**10
SumsL = [0] * n
SumsR = [0] * n
s = 0
for i in range(n):
s += W[i]
SumsL[i] = s
for i in range(n - 1):
ans = L * SumsL[i] + r * (s - SumsL[i])
if n - (i + 1) > i + 1:
... | IMPORT ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR FO... |
Vasya has n items lying in a line. The items are consecutively numbered by numbers from 1 to n in such a way that the leftmost item has number 1, the rightmost item has number n. Each item has a weight, the i-th item weights w_{i} kilograms.
Vasya needs to collect all these items, however he won't do it by himself. He... | n, l, r, q1, q2 = list(map(int, input().split()))
item = list(map(int, input().split()))
pre = [item[0]] + [(0) for i in range(1, n)]
suf = [(0) for i in range(0, n - 1)] + [item[n - 1], 0]
for i in range(1, n):
pre[i] = pre[i - 1] + item[i]
for i in range(n - 2, -1, -1):
suf[i] = suf[i + 1] + item[i]
ans = 1e2... | ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST VAR NUMBER NUMBER VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER LIST VAR BIN_OP VAR NUMBER NUMBE... |
Vasya has n items lying in a line. The items are consecutively numbered by numbers from 1 to n in such a way that the leftmost item has number 1, the rightmost item has number n. Each item has a weight, the i-th item weights w_{i} kilograms.
Vasya needs to collect all these items, however he won't do it by himself. He... | n, l, r, ql, qr = list(map(int, input().split()))
li = list(map(int, input().split()))
ri = li.copy()
ri.append(0)
list(map(lambda x: 0, ri))
ri[0] = 0
ri[1] = li[0]
for i in range(2, len(li) + 1):
ri[i] = ri[i - 1] + li[i - 1]
minans = 1000000000000000
s1 = 0
for j in range(0, len(li) + 1):
if j < len(li) / 2:... | ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR... |
Vasya has n items lying in a line. The items are consecutively numbered by numbers from 1 to n in such a way that the leftmost item has number 1, the rightmost item has number n. Each item has a weight, the i-th item weights w_{i} kilograms.
Vasya needs to collect all these items, however he won't do it by himself. He... | def solve(lst, l, r, left, right):
left_sum = [0]
right_sum = [0] * (len(lst) + 1)
cum_sum = 0
for i in range(len(lst)):
cum_sum += lst[i]
left_sum.append(cum_sum)
cum_sum = 0
for i in reversed(range(len(lst))):
cum_sum += lst[i]
right_sum[i] = cum_sum
min_cos... | FUNC_DEF ASSIGN VAR LIST NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR STRIN... |
Vasya has n items lying in a line. The items are consecutively numbered by numbers from 1 to n in such a way that the leftmost item has number 1, the rightmost item has number n. Each item has a weight, the i-th item weights w_{i} kilograms.
Vasya needs to collect all these items, however he won't do it by himself. He... | import sys
inf = float("inf")
def get_array():
return list(map(int, sys.stdin.readline().strip().split()))
def get_ints():
return map(int, sys.stdin.readline().strip().split())
def input():
return sys.stdin.readline().strip()
n, l, r, ql, qr = get_ints()
Arr = get_array()
pre = [0] * (n + 1)
for i ... | IMPORT ASSIGN VAR FUNC_CALL VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NU... |
This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $n$ stations, enumerated from $1$ through $n$. The train occupies one stat... | N, M = map(int, input().split())
candies = [[] for _ in [0] * N]
for a, b in (map(int, input().split()) for _ in [0] * M):
candies[a - 1].append(b - 1)
ans = []
for start in range(N):
_candies = [[] for _ in [0] * N]
for i in range(N):
_candies[i] = [
(n % N) for n in sorted(n + N if n <... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR BIN_OP LIST NUMBER VAR FOR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR BIN_OP LIST NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR BIN_OP LIST NUMBER VAR... |
This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $n$ stations, enumerated from $1$ through $n$. The train occupies one stat... | n, m = map(int, input().split())
d = {}
for i in range(n):
d[i] = []
for i in range(m):
a, b = map(int, input().split())
d[a - 1].append(b - 1)
def fn(x, i):
if x >= i:
return x - i
else:
return n - 1 - i + x
for i in range(n):
d[i] = sorted(d[i], key=lambda x: fn(x, i))
md =... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER FUNC_DEF IF VAR VAR RETURN BIN_OP VAR VAR RETURN BIN_OP BIN_OP ... |
This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $n$ stations, enumerated from $1$ through $n$. The train occupies one stat... | import sys
n, m = map(int, input().split())
dist = [n] * n
candy_cnt = [0] * n
for a, b in (map(int, l.split()) for l in sys.stdin):
if a > b:
b += n
if dist[a - 1] > b - a:
dist[a - 1] = b - a
candy_cnt[a - 1] += 1
dist *= 2
candy_cnt *= 2
ans = [0] * n
for i in range(n):
time = 0
... | IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR VAR VAR IF VAR BIN_OP VAR NUMBER BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR BIN_OP VAR NUMBER NUMBER VAR NUM... |
This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $n$ stations, enumerated from $1$ through $n$. The train occupies one stat... | import sys
input = sys.stdin.readline
mii = lambda: list(map(int, input().split()))
n, m = mii()
a = [[] for _ in range(n)]
c = [(123456) for _ in range(n)]
for _ in range(m):
u, v = mii()
u %= n
v %= n
if v < u:
v += n
a[u].append(v)
if c[u] > v:
c[u] = v
ans = []
for i in list... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR IF VAR ... |
This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $n$ stations, enumerated from $1$ through $n$. The train occupies one stat... | from sys import exit, setrecursionlimit
setrecursionlimit(10**6)
inn = lambda: input().strip()
mapp_m1 = lambda: map(lambda x: int(x) - 1, inn().split(" "))
mapp = lambda: map(int, inn().split(" "))
N, M = mapp()
station = [[] for _ in range(N)]
for _ in range(M):
a, b = mapp()
a, b = a - 1, b - 1
station[... | EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSI... |
This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $n$ stations, enumerated from $1$ through $n$. The train occupies one stat... | n, m = list(map(int, input().split()))
a = []
for i in range(m):
a.append(list(map(int, input().split())))
locs = []
for i in range(n + 1):
locs.append([])
for i in range(m):
locs[a[i][0]].append(a[i][1])
ans = [0] * (n + 1)
for i in range(1, n + 1):
mini = 2**n
for j in locs[i]:
if j > i:
... | ASSIGN VAR VAR FUNC_CALL 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 ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR... |
This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $n$ stations, enumerated from $1$ through $n$. The train occupies one stat... | n, m = map(int, input().split())
def dist(a, b):
return (n + b - a) % n
def main():
inp1 = [0] * (n + 1)
inp2 = [n] * (n + 1)
for _ in range(m):
a, b = map(int, input().split())
inp1[a] += 1
inp2[a] = min(inp2[a], dist(a, b))
inp = tuple((r1 - 1) * n + r2 for r1, r2 in zi... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR... |
This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $n$ stations, enumerated from $1$ through $n$. The train occupies one stat... | def distance(fro, to):
nonlocal n
return to - fro if to - fro >= 0 else n + to - fro
n, m = list(map(int, input().split()))
count = [(-1) for i in range(n + 1)]
dis = [n for i in range(n + 1)]
ans = []
for i in range(1, m + 1):
a, b = list(map(int, input().split()))
dis[a] = min(distance(a, b), dis[a]... | FUNC_DEF RETURN BIN_OP VAR VAR NUMBER BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER AS... |
This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $n$ stations, enumerated from $1$ through $n$. The train occupies one stat... | import sys
try:
sys.stdin = open("in.in", "r")
sys.stdout = open("out.out", "w")
except:
pass
n, m = map(int, input().split())
def Len(st, ed):
st += 1
ed += 1
if st <= ed:
return ed - st
else:
return ed + n - st
cnt = [(0) for i in range(n)]
mxlen = [(n + 233) for i in ... | IMPORT ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF VAR NUMBER VAR NUMBER IF VAR VAR RETURN BIN_OP VAR VAR RETURN BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR FUNC_CAL... |
This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $n$ stations, enumerated from $1$ through $n$. The train occupies one stat... | n, m = map(int, input().split())
minima = [float("inf") for i in range(n + 1)]
counted = [(-1) for i in range(n + 1)]
stored = [(0) for i in range(n + 1)]
for i in range(m):
curr, des = map(int, input().split())
curr -= 1
des -= 1
minima[curr] = min(minima[curr], (des - curr) % n)
counted[curr] += 1... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR ... |
This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $n$ stations, enumerated from $1$ through $n$. The train occupies one stat... | (n, m), count, length = list(map(int, input().split())), {}, {}
for _ in range(m):
a, b = list(map(int, input().split()))
count[a] = count[a] + 1 if a in count.keys() else 1
length[a] = (
min(length[a], (b + n - a) % n) if a in length.keys() else (b + n - a) % n
)
for i in range(1, n + 1):
p... | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR DICT DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP BIN... |
This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $n$ stations, enumerated from $1$ through $n$. The train occupies one stat... | n, m = map(int, input().strip().split())
arr = [[] for i in range(n + 1)]
for i in range(m):
u, v = map(int, input().strip().split())
arr[u].append(v)
x = 100000000000000
st = [x] * (n + 1)
for i in range(1, 1 + n):
for j in range(len(arr[i])):
if i <= arr[i][j]:
st[i] = min(st[i], arr[i... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL ... |
This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $n$ stations, enumerated from $1$ through $n$. The train occupies one stat... | N, m = [int(value) for value in input().split()]
candies = []
for _ in range(N):
candies.append([])
for _ in range(m):
start, end = [int(value) for value in input().split()]
candies[start - 1].append(end - 1)
min_distantions = []
for start_pos in range(N):
min_distantion = 0
for shift in range(N):
... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VA... |
This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $n$ stations, enumerated from $1$ through $n$. The train occupies one stat... | def dist(a, b):
return (b - a) % n
n, m = list(map(int, input().split(" ")))
sweets = {i: [] for i in range(n)}
for i in range(m):
s, t = list(map(int, input().split(" ")))
sweets[s - 1].append(t - 1)
t = {i: (-1000000.0) for i in range(n)}
for i in range(n):
sweets[i] = sorted(sweets[i], key=lambda x... | FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER... |
This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $n$ stations, enumerated from $1$ through $n$. The train occupies one stat... | n, m = [int(x) for x in input().split()]
def distance(nrof_stations, a, b):
if a > b:
b += nrof_stations
return b - a
def get_n(stations, start):
max_d = 0
for i, c in enumerate(stations):
if len(c) == 0:
continue
max_d = max(
distance(len(stations), s... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR VAR VAR VAR RETURN BIN_OP VAR VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_C... |
This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $n$ stations, enumerated from $1$ through $n$. The train occupies one stat... | n, m = list(map(int, input().split()))
a = [0] * m
b = [0] * m
t = [[-1]] * n
for i in range(m):
a[i], b[i] = map(int, input().split())
if t[a[i] - 1] == [-1]:
if b[i] > a[i]:
t[a[i] - 1] = [b[i] - a[i]]
if b[i] < a[i]:
t[a[i] - 1] = [n - a[i] + b[i]]
else:
if... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP VAR VAR NUMBER LIST NUMBER IF VAR VAR... |
This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $n$ stations, enumerated from $1$ through $n$. The train occupies one stat... | from sys import stdin
def __starting_point():
from sys import stdin
n, m = list(map(int, stdin.readline().split()))
c = {}
for _ in range(m):
a, b = list(map(int, stdin.readline().split()))
if a - 1 not in c.keys():
c[a - 1] = []
x = b - a + (n if b < a else 0)
... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER LIST ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR NUMBER EXPR F... |
This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $n$ stations, enumerated from $1$ through $n$. The train occupies one stat... | n, m = map(int, input().split())
candies = [[] for _ in range(n)]
for _ in range(m):
src, dst = map(lambda x: int(x) - 1, input().split())
candies[src].append(dst)
def get_ans():
ans = 0
laps = 0
for i in range(n):
if len(candies[i]) > 0:
curr = 0
sz = len(candies[i... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR... |
This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $n$ stations, enumerated from $1$ through $n$. The train occupies one stat... | n, m = [int(i) for i in input().split()]
A = [[int(i) for i in input().split()] for j in range(m)]
INF = 10**9
mi = [INF] * (n + 1)
cnt = [0] * (n + 1)
for a, b in A:
cnt[a] += 1
mi[a] = min(mi[a], (b - a) % n)
ANS = []
for i in range(1, n + 1):
ans = 0
for j in range(1, n + 1):
if cnt[j] == 0:
... | 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 VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP LIST VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL... |
This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $n$ stations, enumerated from $1$ through $n$. The train occupies one stat... | n, m = map(int, input().split())
a = [[] for i in range(5010)]
for i in range(m):
x, y = map(int, input().split())
if y < x:
a[x].append(n - x + y)
else:
a[x].append(y - x)
for i in range(1, n + 1):
a[i].sort()
mx = int(-1000000000.0)
for i in range(1, n + 1):
if len(a[i]):
m... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR N... |
This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $n$ stations, enumerated from $1$ through $n$. The train occupies one stat... | n, m = map(int, input().split())
s2 = [[] for i in range(n)]
for i in range(m):
a, b = map(int, input().split())
a, b = a - 1, b - 1
s2[a].append(b)
for i in range(n):
s2[i].sort()
for j in range(len(s2[i])):
if s2[i][j] > i:
s2[i] = s2[i][j:] + s2[i][:j]
break
for i ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR 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 ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CA... |
This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $n$ stations, enumerated from $1$ through $n$. The train occupies one stat... | def dist(a, b):
return (b - a) % n
n, m = map(int, input().split())
cnd = [(0) for x in range(n + 1)]
mn = [(5000) for x in range(n + 1)]
for i in range(m):
a, b = map(int, input().split())
cnd[a] += 1
mn[a] = min(mn[a], dist(a, b))
for i in range(1, n + 1):
ans = 0
for j in range(1, n + 1):
... | FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR ... |
This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $n$ stations, enumerated from $1$ through $n$. The train occupies one stat... | n, m = map(int, input().split())
d = dict()
for i in range(m):
a, b = map(int, input().split())
a -= 1
b -= 1
if a in d:
d[a].append(b)
else:
d[a] = [b]
for i in d.keys():
d[i].sort()
times = [(0) for i in range(n)]
for i in d.keys():
mi = 9999999
for j in d[i]:
m... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR LIST VAR FOR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC... |
This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $n$ stations, enumerated from $1$ through $n$. The train occupies one stat... | n, m = (int(t) for t in input().split(" "))
candies = [set() for _ in range(n)]
candies_total = [(0) for _ in range(n)]
for _ in range(m):
from_, to = (int(t) - 1 for t in input().split(" "))
candies[from_].add(to)
candies_total[from_] += 1
stations_best = [(0) for _ in range(n)]
for i in range(n):
clos... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMB... |
This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $n$ stations, enumerated from $1$ through $n$. The train occupies one stat... | from sys import stdin
def prog():
n, m = map(int, input().split())
d = {i: [] for i in range(1, n + 1)}
from sys import stdin
for i in range(m):
a, b = map(int, stdin.readline().split())
d[a].append(b)
res = []
for i in range(1, n + 1):
lst = []
for j, x in enu... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST FO... |
This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $n$ stations, enumerated from $1$ through $n$. The train occupies one stat... | def dista(start, n):
return lambda end: n - (start - end) if start > end else end - start
n, m = list(map(int, input().split(" ")))
dicta = [[] for i in range(n + 1)]
for i in range(m):
s, d = list(map(int, input().split(" ")))
dicta[s].append(d)
for i in range(n + 1):
dicta[i].sort(key=dista(i, n))
m... | FUNC_DEF RETURN VAR VAR BIN_OP VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VA... |
This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $n$ stations, enumerated from $1$ through $n$. The train occupies one stat... | n, m = map(int, input().split())
stations = []
for i in range(n):
stations.append([])
for i in range(m):
a, b = map(int, input().split())
stations[a - 1].append((b - a) % n)
maxes = []
for i in range(n):
if len(stations[i]) > 0:
big = min(stations[i])
else:
big = 0
maxes.append(n... | 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 LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF FUNC_C... |
This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $n$ stations, enumerated from $1$ through $n$. The train occupies one stat... | n, m = list(map(int, input().split()))
ms, md = [(n - 1) for i in range(n + 1)], [(-1) for i in range(n + 1)]
def distance(sfrom, sto):
nonlocal n
return sto - sfrom if sto >= sfrom else sto + n - sfrom
for i in range(m):
c, d = list(map(int, input().split()))
md[c] += 1
ms[c] = min(distance(c, ... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_DEF RETURN VAR VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR... |
This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $n$ stations, enumerated from $1$ through $n$. The train occupies one stat... | def distance(b, a, n):
return b - a if b >= a else b + n - a
n, m = map(int, input().split())
dic_last_candy = dict()
dict_node = dict()
s = ""
for i in range(m):
a, b = map(int, input().split())
c = dict_node.get(a, 0)
c += 1
dict_node[a] = c
last_candy = dic_last_candy.get(a, 0)
if last_... | FUNC_DEF RETURN VAR VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER ... |
This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $n$ stations, enumerated from $1$ through $n$. The train occupies one stat... | def solve(candies, start, n):
time = 0
train = {}
while True:
far = 0
for i in candies:
if i[0] == start:
if i[1] < start:
far = max(far, i[1] + n)
else:
far = max(far, i[1])
if far != 0:
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR DICT WHILE NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR IF VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER IF VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR VAR VAR IF VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR VAR NUMB... |
This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $n$ stations, enumerated from $1$ through $n$. The train occupies one stat... | def dist(a, b):
return (b - a) % n
n, m = list(map(int, input().split(" ")))
sweets = {i: [] for i in range(n)}
for i in range(m):
s, t = list(map(int, input().split(" ")))
sweets[s - 1].append(t - 1)
t = {i: (0) for i in range(n)}
for i in range(n):
sweets[i] = sorted(sweets[i], key=lambda x: -dist(i... | FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER... |
This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $n$ stations, enumerated from $1$ through $n$. The train occupies one stat... | n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(m)]
s = [[] for _ in range(n)]
for q in a:
s[q[0] - 1].append(q[1] - 1)
d = []
for q in range(len(s)):
if len(s[q]) == 0:
d.append(0)
else:
p = min(s[q], key=lambda x: (x - q) % n)
d.append((len(s[q]... | 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 ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR... |
This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $n$ stations, enumerated from $1$ through $n$. The train occupies one stat... | MOD = 10**9 + 7
I = lambda: list(map(int, input().split()))
n, m = I()
ans = [(0) for i in range(n)]
l = [[] for i in range(5001)]
for i in range(m):
a, b = I()
a -= 1
b -= 1
l[a].append(b)
for i in range(n):
l[i].sort(key=lambda x: (x - i) % n, reverse=True)
for i in range(n):
res = 0
k = l... | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR V... |
This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $n$ stations, enumerated from $1$ through $n$. The train occupies one stat... | import sys
sys.setrecursionlimit(10**5 + 1)
inf = int(10**20)
max_val = inf
min_val = -inf
RW = lambda: sys.stdin.readline().strip()
RI = lambda: int(RW())
RMI = lambda: [int(x) for x in sys.stdin.readline().strip().split()]
RWI = lambda: [x for x in sys.stdin.readline().strip().split()]
sys.setrecursionlimit(100000)
... | IMPORT EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL FUN... |
This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $n$ stations, enumerated from $1$ through $n$. The train occupies one stat... | N, M = map(int, input().split())
X = [0] * N
Y = [-N] * N
Z = [0] * N
for _ in range(M):
a, b = map(int, input().split())
a -= 1
b -= 1
X[a] += 1
if Y[a] < 0:
Y[a] = (b - a) % N
else:
Y[a] = min((b - a) % N, Y[a])
for i in range(N):
Z[i] = (X[i] - 1) * N + Y[i]
ANS = []
for i... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST VAR 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 NUMBER VAR NUMBER VAR VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_... |
This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $n$ stations, enumerated from $1$ through $n$. The train occupies one stat... | n, m = map(int, input().split())
arr = []
for i in range(m):
x, y = map(int, input().split())
arr.append((x, y))
dict1 = {}
for i in range(1, n + 1):
dict1[i] = []
for i in range(m):
dict1[arr[i][0]].append(arr[i][1])
for i in range(1, n + 1):
dict1[i].sort()
ansarr = []
for i in range(1, n + 1):
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR N... |
This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $n$ stations, enumerated from $1$ through $n$. The train occupies one stat... | import sys
n, m = (int(t) for t in input().split(" "))
candies_total = [(0) for _ in range(n)]
closest_distance = [n for _ in range(n)]
candies = sys.stdin.readlines()
for i in range(m):
from_, to = (int(t) - 1 for t in candies[i].split(" "))
candies_total[from_] += 1
distance = (to + n - from_) % n
if... | IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR STRING VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP B... |
On the way to school, Karen became fixated on the puzzle game on her phone!
<image>
The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.
One move consists of choosing one row or column, and adding 1 to all of the cells in that row or col... | n, m = map(int, input().split())
a = []
for i in range(n):
a.append(list(map(int, input().split())))
s1, s2 = "row", "col"
if n > m:
b = []
for i in range(m):
b.append([])
for j in range(n):
b[i].append(a[j][i])
n, m, s1, s2, a = m, n, s2, s1, b
mi = min(a[0])
r = [mi]
cn = m... | 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 ASSIGN VAR VAR STRING STRING IF VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL... |
On the way to school, Karen became fixated on the puzzle game on her phone!
<image>
The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.
One move consists of choosing one row or column, and adding 1 to all of the cells in that row or col... | n, m = map(int, input().split())
g = list()
moves = list()
m1, m2 = "row", "col"
for _ in range(n):
g.append(list(map(int, input().split())))
if n > m:
g = list(map(list, zip(*g)))
n, m = m, n
m1, m2 = m2, m1
for i in range(n):
while min(g[i]) > 0:
for j in range(m):
g[i][j] -= 1... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR STRING STRING FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR ... |
On the way to school, Karen became fixated on the puzzle game on her phone!
<image>
The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.
One move consists of choosing one row or column, and adding 1 to all of the cells in that row or col... | n, m = map(int, input().split())
M = [list(map(int, input().split())) for i in range(n)]
M1 = [([0] * m) for i in range(n)]
for i in range(n):
for j in range(m):
M1[i][j] = M[i][j]
l = []
l1 = []
c = 0
for i in range(n):
V = min(M[i])
if n > m:
c = 1
break
for j in range(V):
... | 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 ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASS... |
On the way to school, Karen became fixated on the puzzle game on her phone!
<image>
The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.
One move consists of choosing one row or column, and adding 1 to all of the cells in that row or col... | n, m = map(int, input().split())
table = [list(map(int, input().split())) for i in range(n)]
table2 = [list(l) for l in table]
anslst = []
for i in range(n):
minv = min(table[i])
for v in range(minv):
anslst.append("row {}".format(i + 1))
for j in range(m):
table[i][j] -= minv
for j in range... | 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 ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING ... |
On the way to school, Karen became fixated on the puzzle game on her phone!
<image>
The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.
One move consists of choosing one row or column, and adding 1 to all of the cells in that row or col... | n, m = [int(i) for i in input().split(" ")]
g = []
c, f = 0, 0
ans = ""
def row():
global n, m, g, c, ans
for i in range(n):
t = min(g[i])
c += t
ans += "row %d\n" % (i + 1) * t
for j in range(m):
g[i][j] -= t
def col():
global n, m, g, c, ans
for i in ran... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR STRING FUNC_DEF FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR BIN_OP BIN_OP STRING BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR FUNC_DEF FOR VAR FUNC_CA... |
On the way to school, Karen became fixated on the puzzle game on her phone!
<image>
The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.
One move consists of choosing one row or column, and adding 1 to all of the cells in that row or col... | n, m = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(n)]
r = [(a[i][0] - a[0][0]) for i in range(n)]
c = [(a[0][i] - a[0][0]) for i in range(m)]
t = min(r)
r = [(x - t) for x in r]
t = min(c)
c = [(x - t) for x in c]
p = a[0][0] - r[0] - c[0]
if n < m:
r = [(x + p) for x in r]
... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER VAR NUMBER NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR VAR NUMBER NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR FUN... |
On the way to school, Karen became fixated on the puzzle game on her phone!
<image>
The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.
One move consists of choosing one row or column, and adding 1 to all of the cells in that row or col... | n, m = input().split()
n = int(n)
m = int(m)
a = []
for i in range(n):
x = input().split()
x = [int(p) for p in x]
a.append(x)
if n <= m:
ans = ""
step = 0
for i in range(n):
t = 500
for j in range(m):
t = min(t, a[i][j])
ans += ("row" + " " + str(i + 1) + "\n... | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NU... |
On the way to school, Karen became fixated on the puzzle game on her phone!
<image>
The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.
One move consists of choosing one row or column, and adding 1 to all of the cells in that row or col... | n, m = map(int, input().split())
a = []
row = []
col = []
for i in range(n):
a.append(list(map(int, input().split())))
if m > n:
for i in range(n):
row.append(min(a[i]))
for i in range(m):
col.append(a[0][i] - row[0])
else:
for i in range(m):
r = 1000
for j in range(n):
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST 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 IF VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_... |
On the way to school, Karen became fixated on the puzzle game on her phone!
<image>
The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.
One move consists of choosing one row or column, and adding 1 to all of the cells in that row or col... | r, c = map(int, input().split(" "))
arr = []
ops = []
num_ops = 0
for i in range(r):
arr.append(list(map(int, input().split(" "))))
s1, s2 = "row ", "col "
if r > c:
arr1 = []
for i in range(c):
arr1.append([0] * r)
for i in range(r):
for j in range(c):
arr1[j][i] = arr[i][j]... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR STRING STRING IF VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL V... |
On the way to school, Karen became fixated on the puzzle game on her phone!
<image>
The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.
One move consists of choosing one row or column, and adding 1 to all of the cells in that row or col... | read = lambda: map(int, input().split())
def fail():
print(-1)
exit()
n, m = read()
g = [list(read()) for i in range(n)]
a = [(g[i][0] - g[0][0]) for i in range(n)]
b = [(g[0][i] - g[0][0]) for i in range(m)]
for i in range(n):
for j in range(1, m):
if g[i][j] - g[i][0] != b[j]:
fail... | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER VAR NUMBER NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR VAR NUMBER NUMBER... |
On the way to school, Karen became fixated on the puzzle game on her phone!
<image>
The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.
One move consists of choosing one row or column, and adding 1 to all of the cells in that row or col... | import sys
def main():
n, m = list(map(int, sys.stdin.readline().split()))
field = []
for i in range(n):
row = list(map(int, sys.stdin.readline().split()))
field.append(row)
nmoves = 0
moves = []
while True:
minrow = [min(field[i][j] for j in range(m)) for i in range(n)... | IMPORT FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR... |
On the way to school, Karen became fixated on the puzzle game on her phone!
<image>
The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.
One move consists of choosing one row or column, and adding 1 to all of the cells in that row or col... | nm = [int(s) for s in input().split()]
a = []
for i in range(nm[0]):
a.append([int(j) for j in input().split()])
rez = []
def stroka():
global rez
rez_row = []
rez_r = 0
for i in range(nm[0]):
min_row = 501
for j in range(nm[1]):
if a[i][j] < min_row:
mi... | ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER IF VAR... |
On the way to school, Karen became fixated on the puzzle game on her phone!
<image>
The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.
One move consists of choosing one row or column, and adding 1 to all of the cells in that row or col... | n, m = map(int, input().split())
table = list()
table_T = list()
for i in range(n):
table.append(list(map(int, input().split())))
for i in range(m):
a = [table[j][i] for j in range(n)]
table_T.append(a)
OUT = list()
if n <= m:
a = 0
while a < n:
is_0 = False
for i in table[a]:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CA... |
On the way to school, Karen became fixated on the puzzle game on her phone!
<image>
The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.
One move consists of choosing one row or column, and adding 1 to all of the cells in that row or col... | n, m = map(int, input().split())
mat = [list(map(int, input().strip().split())) for _ in range(n)]
def clear_row():
rows = []
for i in range(n):
minx = 501
for j in range(m):
minx = min(minx, mat[i][j])
for j in range(m):
mat[i][j] -= minx
for j in range... | 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 FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR VA... |
Polycarp takes part in a math show. He is given n tasks, each consists of k subtasks, numbered 1 through k. It takes him t_{j} minutes to solve the j-th subtask of any task. Thus, time required to solve a subtask depends only on its index, but not on the task itself. Polycarp can solve subtasks in any order.
By solvin... | def zhadnik(n, k, M, t):
ans = 0
i = 0
while i < k and M >= t[i]:
temp = M // t[i]
if temp <= n:
ans += temp
M -= temp * t[i]
else:
ans += n
M -= n * t[i]
i += 1
return ans
n, k, M = map(int, input().split())
t = list(map(... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL ... |
Polycarp takes part in a math show. He is given n tasks, each consists of k subtasks, numbered 1 through k. It takes him t_{j} minutes to solve the j-th subtask of any task. Thus, time required to solve a subtask depends only on its index, but not on the task itself. Polycarp can solve subtasks in any order.
By solvin... | n, k, m = map(int, input().split())
line = list(map(int, input().split()))
line.sort()
t = sum(line)
ans = 0
for i in range(n + 1):
if m - t * i < 0:
break
mm = m - t * i
ans1 = (k + 1) * i
for j in range(k):
ans1 += min(n - i, mm // line[j])
mm -= min(n - i, mm // line[j]) * lin... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR BI... |
Polycarp takes part in a math show. He is given n tasks, each consists of k subtasks, numbered 1 through k. It takes him t_{j} minutes to solve the j-th subtask of any task. Thus, time required to solve a subtask depends only on its index, but not on the task itself. Polycarp can solve subtasks in any order.
By solvin... | n, k, M = list(map(int, input().strip().split()))
a = list(map(int, input().strip().split()))
a.sort()
rimasto = []
punteggio = []
s = sum(a)
for i in range(n + 1):
if i * s <= M:
rimasto.append(M - i * s)
punteggio.append(i * (k + 1))
for i in range(len(rimasto)):
t = rimasto[i]
task = 0
... | ASSIGN VAR VAR 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 EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR EXPR FUNC_CALL V... |
Polycarp takes part in a math show. He is given n tasks, each consists of k subtasks, numbered 1 through k. It takes him t_{j} minutes to solve the j-th subtask of any task. Thus, time required to solve a subtask depends only on its index, but not on the task itself. Polycarp can solve subtasks in any order.
By solvin... | n, k, M = map(int, input().split())
T = sorted(map(int, input().split()))
sT = sum(T)
def it(p):
score = p * (k + 1)
m = M - p * sT
if m < 0:
return 0
q = n - p
for t in T:
if m > q * t:
m -= q * t
score += q
else:
score += m // t
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR IF VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP VAR VAR FOR VAR VAR IF VAR BIN_... |
Polycarp takes part in a math show. He is given n tasks, each consists of k subtasks, numbered 1 through k. It takes him t_{j} minutes to solve the j-th subtask of any task. Thus, time required to solve a subtask depends only on its index, but not on the task itself. Polycarp can solve subtasks in any order.
By solvin... | n, k, M = map(int, input().split())
time_list = sorted(list(map(int, input().split())))
sum1 = sum(time_list)
tries_list = []
for i in range(n + 1):
m = M
c = 0
for j in range(i):
if m - sum1 >= 0:
m -= sum1
c += k + 1
else:
break
for j in range(k):
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER VAR VAR V... |
Polycarp takes part in a math show. He is given n tasks, each consists of k subtasks, numbered 1 through k. It takes him t_{j} minutes to solve the j-th subtask of any task. Thus, time required to solve a subtask depends only on its index, but not on the task itself. Polycarp can solve subtasks in any order.
By solvin... | n, k, M = map(int, input().split(" "))
t = map(int, input().split(" "))
st_but_long = list(sorted(t))
max_point = 0
for finished_tasks in range(n + 1):
iteration_point = 0
remaining_minutes = M
remaining_minutes -= sum(st_but_long) * finished_tasks
iteration_point += (
(k + 1) * finished_tasks i... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR VAR VAR NUMBER VAR NUMBER... |
Polycarp takes part in a math show. He is given n tasks, each consists of k subtasks, numbered 1 through k. It takes him t_{j} minutes to solve the j-th subtask of any task. Thus, time required to solve a subtask depends only on its index, but not on the task itself. Polycarp can solve subtasks in any order.
By solvin... | def list_input():
return list(map(int, input().split()))
def map_input():
return map(int, input().split())
def map_string():
return input().split()
n, k, m = map_input()
a = list_input()
a.sort()
sm = sum(a)
ans = 0
for i in range(n + 1):
if sm * i > m:
break
m1 = m - sm * i
cnt = ... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_... |
Polycarp takes part in a math show. He is given n tasks, each consists of k subtasks, numbered 1 through k. It takes him t_{j} minutes to solve the j-th subtask of any task. Thus, time required to solve a subtask depends only on its index, but not on the task itself. Polycarp can solve subtasks in any order.
By solvin... | n, k, M = map(int, input().split())
t = sorted(list(map(int, input().split())))
pt = t[:]
for i in range(1, k):
pt[i] += pt[i - 1]
ans, r = 0, k - 1
for i in range(0, n + 1):
if pt[-1] * i > M:
break
m = M - pt[-1] * i
while r != -1 and pt[r] * (n - i) > m:
r -= 1
m -= 0 if r == -1 e... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR... |
Polycarp takes part in a math show. He is given n tasks, each consists of k subtasks, numbered 1 through k. It takes him t_{j} minutes to solve the j-th subtask of any task. Thus, time required to solve a subtask depends only on its index, but not on the task itself. Polycarp can solve subtasks in any order.
By solvin... | n, k, m = [int(x) for x in input().split()]
a = sorted([int(x) for x in input().split()])
et = sum(a)
es = k + 1
ans = []
for i in range(n + 1):
ts = es * i
ht = m - et * i
if ht < 0:
break
for p in a:
s = min(ht // p, n - i)
ht -= s * p
ts += s
ans.append(ts)
ans.sor... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR IF VAR ... |
Polycarp takes part in a math show. He is given n tasks, each consists of k subtasks, numbered 1 through k. It takes him t_{j} minutes to solve the j-th subtask of any task. Thus, time required to solve a subtask depends only on its index, but not on the task itself. Polycarp can solve subtasks in any order.
By solvin... | n, k, M = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
b.sort()
suma = sum(b)
ans = 0
for total in range(n + 1):
m = M - total * suma
if m < 0:
break
r = (k + 1) * total
for x in b:
sol = min(n - total, m // x)
r += sol
m -= sol * x
ans = ma... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR F... |
Polycarp takes part in a math show. He is given n tasks, each consists of k subtasks, numbered 1 through k. It takes him t_{j} minutes to solve the j-th subtask of any task. Thus, time required to solve a subtask depends only on its index, but not on the task itself. Polycarp can solve subtasks in any order.
By solvin... | ins = lambda: map(int, input().split())
n, k, m = ins()
c = list(ins())
c.sort()
s = sum(c)
ans = 0
for i in range(min(n, m // s) + 1):
t, a = m - s * i, i * k + i
for j in range(k):
for l in range(n - i):
if t - c[j] < 0:
break
t -= c[j]
a += 1
... | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR V... |
Polycarp takes part in a math show. He is given n tasks, each consists of k subtasks, numbered 1 through k. It takes him t_{j} minutes to solve the j-th subtask of any task. Thus, time required to solve a subtask depends only on its index, but not on the task itself. Polycarp can solve subtasks in any order.
By solvin... | n, k, m = [int(i) for i in input().split()]
t = sorted([int(i) for i in input().split()])
st = sum(t)
best = -1
for s in range(min(n, m // st) + 1):
score = s * (k + 1)
rm = m - s * st
for j in range(k):
q = min(n - s, rm // t[j])
rm -= q * t[j]
score += q
best = max(best, score)... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP... |
Polycarp takes part in a math show. He is given n tasks, each consists of k subtasks, numbered 1 through k. It takes him t_{j} minutes to solve the j-th subtask of any task. Thus, time required to solve a subtask depends only on its index, but not on the task itself. Polycarp can solve subtasks in any order.
By solvin... | n, k, m = map(int, input().split())
t = list(map(int, input().split()))
t.sort()
s = []
for i in range(min(m // sum(t) + 1, n)):
y = m
x = i * (k + 1)
y -= i * sum(t)
f = n - i
for j in range(k - 1):
x += min(f, y // t[j])
y -= min(f, y // t[j]) * t[j]
x += 2 * min(f, y // t[k - ... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR FUNC... |
Polycarp takes part in a math show. He is given n tasks, each consists of k subtasks, numbered 1 through k. It takes him t_{j} minutes to solve the j-th subtask of any task. Thus, time required to solve a subtask depends only on its index, but not on the task itself. Polycarp can solve subtasks in any order.
By solvin... | n, k, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
s = sum(a)
maximum = 0
i = 0
while i <= n and i * s <= m:
cur = m - s * i
ans = (k + 1) * i
for pos in range(k):
if cur < a[pos]:
break
c = min(n - i, cur // a[pos])
cur -= a[pos] * c
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VA... |
Polycarp takes part in a math show. He is given n tasks, each consists of k subtasks, numbered 1 through k. It takes him t_{j} minutes to solve the j-th subtask of any task. Thus, time required to solve a subtask depends only on its index, but not on the task itself. Polycarp can solve subtasks in any order.
By solvin... | def solve(n, k, M, t):
task_sum = sum(t)
t = sorted(t)
best = 0
for tasks_completed in range(n + 1):
minutes_spent_on_full_tasks = tasks_completed * task_sum
if minutes_spent_on_full_tasks > M:
break
total_points = tasks_completed * k + tasks_completed
remaini... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR VAR VAR VAR VAR VAR ... |
Polycarp takes part in a math show. He is given n tasks, each consists of k subtasks, numbered 1 through k. It takes him t_{j} minutes to solve the j-th subtask of any task. Thus, time required to solve a subtask depends only on its index, but not on the task itself. Polycarp can solve subtasks in any order.
By solvin... | n, k, m = list(map(int, input().split()))
tt = list(map(int, input().split()))
tt.sort()
s = sum(tt)
ans = 0
def check(x, m):
ret = (k + 1) * x
m -= s * x
if m < 0:
return -1
for i in range(k):
if tt[i] * (n - x) <= m:
m -= tt[i] * (n - x)
ret += n - x
e... | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR VAR BIN_OP VAR VAR IF VAR NUMBER RETURN NUMBER FOR VAR FUNC_CAL... |
Polycarp takes part in a math show. He is given n tasks, each consists of k subtasks, numbered 1 through k. It takes him t_{j} minutes to solve the j-th subtask of any task. Thus, time required to solve a subtask depends only on its index, but not on the task itself. Polycarp can solve subtasks in any order.
By solvin... | n, k, m = map(int, input().split())
lst = list(map(int, input().split()))
l = []
s = sum(lst)
lst.sort()
g = n
h = m
for r in range(g + 1):
ans = 0
m = h
n = g - r
if s * r <= m:
ans += (k + 1) * r
m = m - s * r
c = 0
while 1:
if c >= k:
break
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR... |
Polycarp takes part in a math show. He is given n tasks, each consists of k subtasks, numbered 1 through k. It takes him t_{j} minutes to solve the j-th subtask of any task. Thus, time required to solve a subtask depends only on its index, but not on the task itself. Polycarp can solve subtasks in any order.
By solvin... | n, k, M = map(int, input().split())
t = list(map(int, input().split()))
answer = []
for good in range(n + 1):
local_answer = (k + 1) * good
m = M - sum(t) * good
if m < 0:
continue
todo = sorted(t * (n - good), key=lambda x: -x)
while todo and m:
if m < todo[-1]:
break
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP FUNC_CALL VAR VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP... |
Polycarp takes part in a math show. He is given n tasks, each consists of k subtasks, numbered 1 through k. It takes him t_{j} minutes to solve the j-th subtask of any task. Thus, time required to solve a subtask depends only on its index, but not on the task itself. Polycarp can solve subtasks in any order.
By solvin... | [n, k, M] = list(map(int, input().split()))
t = list(map(int, input().split()))
t.sort()
tot = sum(t)
res = 0
for x in range(n + 1):
need = x * tot
if need <= M:
cnt = x * (k + 1)
r = M - need
j = 0
while r > 0 and j < k:
if t[j] * (n - x) <= r:
cnt +=... | ASSIGN LIST VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP V... |
Polycarp takes part in a math show. He is given n tasks, each consists of k subtasks, numbered 1 through k. It takes him t_{j} minutes to solve the j-th subtask of any task. Thus, time required to solve a subtask depends only on its index, but not on the task itself. Polycarp can solve subtasks in any order.
By solvin... | def find_max(n, k, m, ts):
out = 0
ts.sort()
for i in range(n + 1):
cur = 0
time = sum(ts) * i
if time > m:
break
else:
cur += (k + 1) * i
time_left = m - time
cur_subtask = 0
while time_left > 0 and cur_subtask < k:
... | FUNC_DEF ASSIGN VAR NUMBER EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR IF VAR VAR VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR VAR VAR IF V... |
Polycarp takes part in a math show. He is given n tasks, each consists of k subtasks, numbered 1 through k. It takes him t_{j} minutes to solve the j-th subtask of any task. Thus, time required to solve a subtask depends only on its index, but not on the task itself. Polycarp can solve subtasks in any order.
By solvin... | import sys
n, k, m = map(int, input().split())
a = list(map(int, input().split()))
total = sum(a)
if n * total <= m:
print(n * (k + 1))
exit()
ans = 0
for complete in range(n):
if complete * total > m:
break
items = a * (n - complete)
dp = [-1] * (len(items) + 1)
dp[0] = m - complete * ... | IMPORT ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR A... |
Polycarp takes part in a math show. He is given n tasks, each consists of k subtasks, numbered 1 through k. It takes him t_{j} minutes to solve the j-th subtask of any task. Thus, time required to solve a subtask depends only on its index, but not on the task itself. Polycarp can solve subtasks in any order.
By solvin... | def main():
n, k, m = map(int, input().split(" "))
time = list(map(int, input().split(" ")))
time = sorted(time)
ans = 0
for i in range(n + 1):
remain_time = m - i * sum(time)
if remain_time < 0:
break
value = (k + 1) * i
for j in range(k):
for... | FUNC_DEF ASSIGN VAR 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 VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP... |
Polycarp takes part in a math show. He is given n tasks, each consists of k subtasks, numbered 1 through k. It takes him t_{j} minutes to solve the j-th subtask of any task. Thus, time required to solve a subtask depends only on its index, but not on the task itself. Polycarp can solve subtasks in any order.
By solvin... | n, k, m = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
sum_row = 0
for elem in a:
sum_row += elem
max_ans = 0
for i in range(min(n + 1, m // sum_row + 1)):
ans = i * (k + 1)
m1 = m - sum_row * i
for j in range(k):
t = (n - i) * a[j]
if t <= m1:
... | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VA... |
Polycarp takes part in a math show. He is given n tasks, each consists of k subtasks, numbered 1 through k. It takes him t_{j} minutes to solve the j-th subtask of any task. Thus, time required to solve a subtask depends only on its index, but not on the task itself. Polycarp can solve subtasks in any order.
By solvin... | def solve(n, k, M, t):
t.sort()
k = len(t)
T = sum(t)
max_score = 0
for fully_solved in range(min(n, M // T) + 1):
score_1 = fully_solved * (k + 1)
score_2 = 0
remaining_time = M - T * fully_solved
remaining_problems = n - fully_solved
if remaining_problems > ... | FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR N... |
Polycarp takes part in a math show. He is given n tasks, each consists of k subtasks, numbered 1 through k. It takes him t_{j} minutes to solve the j-th subtask of any task. Thus, time required to solve a subtask depends only on its index, but not on the task itself. Polycarp can solve subtasks in any order.
By solvin... | n, k, m = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
p.sort()
ans = 0
for i in range(n + 1):
l = m
for j in range(k):
l -= p[j] * i
if l < 0:
break
cr = i * k + i
for j in range(k):
if l < p[j]:
break
c = min(l // p[j], n - i)
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR FOR VA... |
Polycarp takes part in a math show. He is given n tasks, each consists of k subtasks, numbered 1 through k. It takes him t_{j} minutes to solve the j-th subtask of any task. Thus, time required to solve a subtask depends only on its index, but not on the task itself. Polycarp can solve subtasks in any order.
By solvin... | n, k, m = list(map(int, input().split()))
t = sorted(map(int, input().split()))
res = 0
for i in range(n + 1):
rem = m - i * sum(t)
if rem < 0:
break
r = i * (k + 1)
for j in range(k):
d = min(rem // t[j], n - i)
rem -= d * t[j]
r += d
res = max(res, r)
print(res) | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER FOR VAR FUNC_CA... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.