description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
The only difference between the easy and the hard versions is the maximum value of $k$.
You are given an infinite sequence of form "112123123412345$\dots$" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$ to $1$, the second one — f... | def calc_base(k):
base = k
for i in range(1, k):
base += 9 * i * 10 ** (i - 1)
return base
def global_length(k):
base = calc_base(k)
d = 10**k - 10 ** (k - 1)
if d % 2 == 0:
return d * base + k * (d - 1) * (d // 2)
return d * base + k * (d - 1) // 2 * d
def global_offset(... | FUNC_DEF ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR VAR BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER BIN_OP VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER RETURN BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR... |
The only difference between the easy and the hard versions is the maximum value of $k$.
You are given an infinite sequence of form "112123123412345$\dots$" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$ to $1$, the second one — f... | q = int(input())
for _ in range(q):
k = int(input())
if k == 933939799:
print(7)
else:
d = 1
l = 0
n = 9
a1 = 1
while l + (2 * a1 + (n - 1) * d) * n // 2 < k:
l += (2 * a1 + (n - 1) * d) * n // 2
a1 += n * d + 1
d += 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR BIN_OP BIN_OP VAR NUMBER VAR VAR NUMBER VAR VAR ... |
The only difference between the easy and the hard versions is the maximum value of $k$.
You are given an infinite sequence of form "112123123412345$\dots$" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$ to $1$, the second one — f... | import sys
input = sys.stdin.readline
LIST = [9]
for i in range(1, 20):
LIST.append(LIST[-1] + 9 * 10**i * (i + 1))
SUM = [45]
for i in range(1, 19):
SUM.append(SUM[-1] + (LIST[i - 1] + (i + 1) + LIST[i]) * 9 * 10**i // 2)
def calc(x):
True
SUM = [0] + SUM
LIST = [0] + LIST
LIST2 = [0]
for i in range(1... | IMPORT ASSIGN VAR VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP NUMBER BIN_OP NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR... |
The only difference between the easy and the hard versions is the maximum value of $k$.
You are given an infinite sequence of form "112123123412345$\dots$" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$ to $1$, the second one — f... | dp = [0] * 100001
for i in range(1, 100001):
dp[i] = dp[i - 1] + len(str(i))
for q in range(int(input())):
k = int(input())
a = 1
total_len = 0
while total_len + dp[a] < k:
total_len += dp[a]
a += 1
k -= total_len
i = 1
cnt = 0
while cnt + len(str(i)) < k:
cnt... | ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR N... |
The only difference between the easy and the hard versions is the maximum value of $k$.
You are given an infinite sequence of form "112123123412345$\dots$" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$ to $1$, the second one — f... | def digits_until_block_(n):
result = 0
for bas in range(1, 30):
minimum = int(10 ** (bas - 1))
maximum = int(10**bas - 1)
if n < maximum:
maximum = n
if maximum < minimum:
break
result += sum_between(n - maximum + 1, n - minimum + 1) * bas
retu... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR VAR IF VAR VAR VAR BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER VAR RETURN VAR FUNC_DEF... |
The only difference between the easy and the hard versions is the maximum value of $k$.
You are given an infinite sequence of form "112123123412345$\dots$" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$ to $1$, the second one — f... | import sys
input = sys.stdin.readline
print = sys.stdout.write
for _ in range(int(input())):
k = int(input())
k -= 1
n = 0
m = 0
while k >= m:
k -= m
n += 1
m += len(str(n))
i = 1
while k >= len(str(i)):
k -= len(str(i))
i += 1
print(str(i)[k] + "... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ... |
The only difference between the easy and the hard versions is the maximum value of $k$.
You are given an infinite sequence of form "112123123412345$\dots$" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$ to $1$, the second one — f... | def foo(n):
a = []
s = []
leng = 0
last_leng = 0
for i in range(1, n + 1):
for c in str(i):
last_leng += 1
leng += last_leng
return leng
def small_foo(n):
leng = 0
for i in range(1, n + 1):
leng += len(str(i))
return leng
def bar(n):
total_... | FUNC_DEF ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR NUMBER VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR... |
The only difference between the easy and the hard versions is the maximum value of $k$.
You are given an infinite sequence of form "112123123412345$\dots$" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$ to $1$, the second one — f... | s = ""
for i in range(100000):
s += str(i)
l = []
nn = [9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999]
for i in range(100000):
if i <= 9:
l.append(i * (i + 1) // 2)
else:
l.append(l[-1] + i)
for j in nn:
if j < i:
l[-1] += i - j
... | ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR VA... |
The only difference between the easy and the hard versions is the maximum value of $k$.
You are given an infinite sequence of form "112123123412345$\dots$" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$ to $1$, the second one — f... | d, pre = [0], [0]
i = 1
x, y = 1, 9
while True:
while i <= y:
d.append(d[i - 1] + x)
pre.append(pre[i - 1] + d[i])
if pre[i] > 1000000000.0:
break
i += 1
if i <= y:
break
y = y * 10 + 9
x += 1
for q in range(int(input())):
k = int(input())
l, r... | ASSIGN VAR VAR LIST NUMBER LIST NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER WHILE NUMBER WHILE VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR IF VAR VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER FOR V... |
The only difference between the easy and the hard versions is the maximum value of $k$.
You are given an infinite sequence of form "112123123412345$\dots$" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$ to $1$, the second one — f... | max_d = 18
max_index = [0] * max_d
num_dig_last = [0] * max_d
num_dig_all = [0] * max_d
num_dig_all_until = [0] * max_d
for i in range(max_d):
max_index[i] = 10**i - 1
for i in range(1, max_d):
n = 9 * 10 ** (i - 1)
num_dig_last[i] = num_dig_last[i - 1] + n * i
num_dig_all[i] = (num_dig_last[i - 1] + i ... | ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP BIN_OP NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP NUMBER BIN_OP NUMBER BIN_OP VAR NUMBER ASS... |
The only difference between the easy and the hard versions is the maximum value of $k$.
You are given an infinite sequence of form "112123123412345$\dots$" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$ to $1$, the second one — f... | l = [0]
def count(size):
nums = 10**size - 10 ** (size - 1)
small = l[size - 1] + size
large = l[size - 1] + nums * size
if len(l) <= size:
l.append(large)
return nums * (small + large) // 2
def test(minSize, size, val):
out = minSize * val + size * ((val + 1) * val) // 2
return ... | ASSIGN VAR LIST NUMBER FUNC_DEF ASSIGN VAR BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR RETURN BIN_OP BIN_OP VAR BIN_OP VAR VAR NUMBER FUNC_DEF ASSIGN VAR BIN_OP... |
The only difference between the easy and the hard versions is the maximum value of $k$.
You are given an infinite sequence of form "112123123412345$\dots$" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$ to $1$, the second one — f... | n = int(input())
k_list = []
for i in range(n):
k_list.append(int(input()))
digits = [0]
w = 1
milestone = 10
str_seq = ""
for i in range(1, 100000):
if i == milestone:
w += 1
milestone *= 10
digits.append(digits[i - 1] + w)
str_seq += str(i)
digits_in_sequence = [0]
for i in range(1, 10... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBE... |
The only difference between the easy and the hard versions is the maximum value of $k$.
You are given an infinite sequence of form "112123123412345$\dots$" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$ to $1$, the second one — f... | def init(maxn):
Sum = [0] * maxn
Single = [0] * maxn
for i in range(1, maxn):
lens = 10**i - 10 ** (i - 1)
pre = Single[i - 1]
Single[i] = pre + lens * i
for i in range(1, maxn):
lens = 10**i - 10 ** (i - 1)
pre = Single[i - 1]
Sum[i] = (pre + i + pre + le... | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR... |
The only difference between the easy and the hard versions is the maximum value of $k$.
You are given an infinite sequence of form "112123123412345$\dots$" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$ to $1$, the second one — f... | lis = [0] * 30001
s = ""
for i in range(1, 30000):
s += str(i)
lis[i] = len(s) + lis[i - 1]
for _ in range(int(input())):
k = int(input())
l = 0
r = 30000
while l <= r:
mid = l + (r - l) // 2
if lis[mid] >= k:
r = mid - 1
else:
l = mid + 1
prin... | ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN... |
The only difference between the easy and the hard versions is the maximum value of $k$.
You are given an infinite sequence of form "112123123412345$\dots$" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$ to $1$, the second one — f... | def cached(func):
_cache = {}
def wrapped(*args):
nonlocal _cache
if args not in _cache:
_cache[args] = func(*args)
return _cache[args]
return wrapped
@cached
def num_count_with_len(l):
return 10**l - 10 ** (l - 1) if l > 0 else 0
@cached
def numbers_len_sum(l):... | FUNC_DEF ASSIGN VAR DICT FUNC_DEF IF VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR RETURN VAR VAR RETURN VAR FUNC_DEF RETURN VAR NUMBER BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER VAR FUNC_DEF IF VAR NUMBER RETURN NUMBER RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR FUNC_CALL VAR VAR VAR FUNC_... |
The only difference between the easy and the hard versions is the maximum value of $k$.
You are given an infinite sequence of form "112123123412345$\dots$" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$ to $1$, the second one — f... | def givelen(_______):
tot = 0
while _______:
_______ //= 10
tot += 1
return tot
for _ in range(int(input())):
end = int(input())
l = []
secon = sec = ans = currlen = last = 0
while end > 0:
last += 1
l.append(last)
currlen += givelen(last)
se... | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR NUMBER VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR VAR VAR VAR NUMBER WHILE VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FOR VAR FUNC_CA... |
The only difference between the easy and the hard versions is the maximum value of $k$.
You are given an infinite sequence of form "112123123412345$\dots$" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$ to $1$, the second one — f... | a = int(input())
sp = []
for i in range(a):
sp += [[int(input()), i]]
sp.sort()
w = 1
le = 0
i = 0
w2 = ""
while le <= sp[-1][0]:
w2 = w2 + str(w)
if sp[i][0] <= le + len(w2):
while i < a and sp[i][0] <= le + len(w2):
sp[i] = [sp[i][1], [w2[sp[i][0] - le - 1]]]
i += 1
le ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR VAR LIST LIST FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING WHILE VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER BIN_OP VAR FUNC_... |
The only difference between the easy and the hard versions is the maximum value of $k$.
You are given an infinite sequence of form "112123123412345$\dots$" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$ to $1$, the second one — f... | def num_of_digits(n):
s = 0
for i in range(20):
o = 10**i - 1
if o > n:
break
s += (n - o) * (n - o + 1) // 2
return s
q = int(input(""))
while q:
q -= 1
digit = int(input(""))
l = 0
r = int(10000000000.0)
while r - l > 1:
m = (r + l) // 2
... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER IF VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER... |
The only difference between the easy and the hard versions is the maximum value of $k$.
You are given an infinite sequence of form "112123123412345$\dots$" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$ to $1$, the second one — f... | q = int(input())
a = ""
for i in range(1, 100000):
a += str(i)
b = []
ans = 0
n = 1
i = 1
while ans < 10**9:
ans += n
n += len(str(i + 1))
i += 1
b.append(ans)
while q:
k = int(input())
for i in range(len(b)):
if k > b[i]:
x = 1
else:
if i >= 1:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP NUMBER NUMBER VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR WHILE VAR AS... |
The only difference between the easy and the hard versions is the maximum value of $k$.
You are given an infinite sequence of form "112123123412345$\dots$" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$ to $1$, the second one — f... | q = int(input())
num_cnt = [[0, 0]]
for i in range(1, 22000):
if i < 10:
num_cnt.append([num_cnt[-1][1] + 1, num_cnt[-1][1] + i])
elif i < 100:
num_cnt.append([num_cnt[-1][1] + 1, num_cnt[-1][1] + 9 + (i - 9) * 2])
elif i < 1000:
num_cnt.append([num_cnt[-1][1] + 1, num_cnt[-1][1] + 9... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR LIST BIN_OP VAR NUMBER NUMBER NUMBER BIN_OP VAR NUMBER NUMBER VAR IF VAR NUMBER EXPR FUNC_CALL VAR LIST BIN_OP VAR NUMBER NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER BI... |
The only difference between the easy and the hard versions is the maximum value of $k$.
You are given an infinite sequence of form "112123123412345$\dots$" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$ to $1$, the second one — f... | q = int(input())
def ar(n):
return n * (n + 1) // 2
def sm(a, r, n):
return a * n + (n - 1) * n // 2 * r
def cale(n):
if n == 0:
return 0
return cale(n - 1) + 9 * 10 ** (n - 1) * n
def zaj(n):
poz = 1
while True:
left = 1
right = 9 * 10 ** (poz - 1) + 1
wh... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR FUNC_DEF IF VAR NUMBER RETURN NUMBER RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP NUMBER BIN_OP NUMBER BIN_OP VAR N... |
The only difference between the easy and the hard versions is the maximum value of $k$.
You are given an infinite sequence of form "112123123412345$\dots$" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$ to $1$, the second one — f... | def solve(dp, k):
for i in range(3 * 10**4):
if dp[i] >= k:
index = i
break
total = dp[index - 1]
for i in range(1, index + 1):
total += len(str(i))
if total >= k:
total -= len(str(i))
for j in str(i):
total += 1
... | FUNC_DEF FOR VAR FUNC_CALL VAR BIN_OP NUMBER BIN_OP NUMBER NUMBER IF VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR EXPR FUNC_CAL... |
The only difference between the easy and the hard versions is the maximum value of $k$.
You are given an infinite sequence of form "112123123412345$\dots$" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$ to $1$, the second one — f... | def g(n):
s = str(n)
ans = 0
for i in range(1, len(s)):
ans += i * 9 * 10 ** (i - 1)
return n * len(s) - (len(s) * (10 ** (len(s) - 1) - 1) - ans)
def sum(i, j):
return i * (j - i + 1) + (j - i) * (j - i + 1) // 2
def f(n):
ans = (n + 1) * g(n)
s = str(n)
for i in range(1, le... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR BIN_OP BIN_OP VAR NUMBER BIN_OP NUMBER BIN_OP VAR NUMBER RETURN BIN_OP BIN_OP VAR FUNC_CALL VAR VAR BIN_OP BIN_OP FUNC_CALL VAR VAR BIN_OP BIN_OP NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER VAR FUNC_DEF RETURN B... |
The only difference between the easy and the hard versions is the maximum value of $k$.
You are given an infinite sequence of form "112123123412345$\dots$" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$ to $1$, the second one — f... | q = int(input())
sum = [0] * 20
cnt = [0] * 20
for i in range(1, 20):
ct = 9 * 10 ** (i - 1)
cnt[i] = cnt[i - 1] + i * ct
sum[i] = sum[i - 1] + cnt[i - 1] * ct + i * (1 + ct) * ct // 2
def check(x, k, i):
return cnt[i - 1] * x + i * (1 + x) * x // 2 < k
def check2(x, k):
l = 0
for i in range... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BIN_... |
The only difference between the easy and the hard versions is the maximum value of $k$.
You are given an infinite sequence of form "112123123412345$\dots$" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$ to $1$, the second one — f... | def binary_search(k):
l, r = 0, 10**5
while l <= r:
m = (l + r) // 2
if k <= dp[m]:
r = m - 1
else:
l = m + 1
return l
def binary_search2(b, k):
l, r = 0, len(str(b))
while l <= r:
m = (l + r) // 2
if k <= dp2[m]:
r = m - ... | FUNC_DEF ASSIGN VAR VAR NUMBER BIN_OP NUMBER NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VA... |
The only difference between the easy and the hard versions is the maximum value of $k$.
You are given an infinite sequence of form "112123123412345$\dots$" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$ to $1$, the second one — f... | import sys
input = sys.stdin.buffer.readline
C = [0]
X = [0]
for i in range(50):
A = 10**i * 9
C.append(C[i] + X[i] * A + (i + 1) * A * (A + 1) // 2)
X.append(X[i] + A * (i + 1))
C2 = [0]
X2 = [0]
for i in range(50):
A = 10**i * 9
C2.append(C2[i] + X2[i] * A + A)
X2.append(i + 1)
for t in range... | IMPORT ASSIGN VAR VAR ASSIGN VAR LIST NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR BIN_OP ... |
The only difference between the easy and the hard versions is the maximum value of $k$.
You are given an infinite sequence of form "112123123412345$\dots$" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$ to $1$, the second one — f... | def solveQuad(gotcha, a, d):
D = (2 * a - d) ** 2 + 8 * d * gotcha
val = (-(2 * a - d) + D**0.5) / (2 * d)
return val
def isint(p):
if p == int(p):
return True
def giveChar(index):
a, an, d = 1, 9, 1
total = 0
for i in range(25):
n = 9 * 10**i
an = a + (n - 1)
... | FUNC_DEF ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER BIN_OP BIN_OP NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR RETURN VAR FUNC_DEF IF VAR FUNC_CALL VAR VAR RETURN NUMBER FUNC_DEF ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR V... |
The only difference between the easy and the hard versions is the maximum value of $k$.
You are given an infinite sequence of form "112123123412345$\dots$" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$ to $1$, the second one — f... | def number(n):
ans = 0
l = 0
while n // 10**l > 0:
l += 1
l -= 1
while n > 0:
ans += (l + 1) * (n + 1 - 10**l)
n = 10**l - 1
l -= 1
return ans
a = list()
a.append(0)
for i in range(40000):
a.append(number(i + 1))
s = list()
s.append(0)
for i in range(1, len(... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR BIN_OP NUMBER VAR NUMBER VAR NUMBER VAR NUMBER WHILE VAR NUMBER VAR BIN_OP BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER FOR VA... |
The only difference between the easy and the hard versions is the maximum value of $k$.
You are given an infinite sequence of form "112123123412345$\dots$" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$ to $1$, the second one — f... | def check(num):
if values[num - 1] > n:
return False
return values[num - 1]
s = ""
for i in range(1, 100000):
s += str(i)
values = [1]
prev = 1
for i in range(2, 30000):
values.append(values[-1] + prev + len(str(i)))
prev = prev + len(str(i))
for nt in range(int(input())):
n = int(inpu... | FUNC_DEF IF VAR BIN_OP VAR NUMBER VAR RETURN NUMBER RETURN VAR BIN_OP VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN... |
The only difference between the easy and the hard versions is the maximum value of $k$.
You are given an infinite sequence of form "112123123412345$\dots$" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$ to $1$, the second one — f... | import sys
zz = 1
sys.setrecursionlimit(10**5)
if zz:
input = sys.stdin.readline
else:
sys.stdin = open("input.txt", "r")
sys.stdout = open("all.txt", "w")
di = [[-1, 0], [1, 0], [0, 1], [0, -1]]
def fori(n):
return [fi() for i in range(n)]
def inc(d, c, x=1):
d[c] = d[c] + x if c in d else x
... | IMPORT ASSIGN VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER IF VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR LIST LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF NU... |
The only difference between the easy and the hard versions is the maximum value of $k$.
You are given an infinite sequence of form "112123123412345$\dots$" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$ to $1$, the second one — f... | import sys
def fn(f):
global file
k = f
por = 1
spi = 0
dlc = 0
i = 1
while True:
if i == por:
dlc += 1
por = por * 10
spi += dlc
if k > spi:
k = k - spi
else:
j = 1
por = 1
ndl = 0
... | IMPORT FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER V... |
The only difference between the easy and the hard versions is the maximum value of $k$.
You are given an infinite sequence of form "112123123412345$\dots$" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$ to $1$, the second one — f... | import sys
def input():
return sys.stdin.readline().strip()
def list2d(a, b, c):
return [([c] * b) for i in range(a)]
def list3d(a, b, c, d):
return [[([d] * c) for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e):
return [[[([e] * d) for j in range(c)] for j in range(b)] for i in ran... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN BIN_OP LIST VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN BIN_OP LIST VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN BIN_OP LIST VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF NUMBER RETURN FUNC_CALL ... |
The only difference between the easy and the hard versions is the maximum value of $k$.
You are given an infinite sequence of form "112123123412345$\dots$" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$ to $1$, the second one — f... | def isqrt(x):
if x < 0:
raise ValueError("square root not defined for negative numbers")
n = int(x)
if n == 0:
return 0
a, b = divmod(n.bit_length(), 2)
x = 2 ** (a + b)
while True:
y = (x + n // x) // 2
if y >= x:
return x
x = y
p = [
0,... | FUNC_DEF IF VAR NUMBER FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER RETURN NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP VAR VAR WHILE NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR NUMBER IF VAR VAR RETURN VAR ASSIGN VAR VAR ASSIGN VAR LIST NUMBER NUMBE... |
The only difference between the easy and the hard versions is the maximum value of $k$.
You are given an infinite sequence of form "112123123412345$\dots$" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$ to $1$, the second one — f... | class Num:
cur, digits, di, stored = 0, 0, {}, [0, 0, 0, 0]
def dig(n):
if "1" + "0" * (len(str(n)) - 1) == str(n):
Num.cur += 1
Num.digits += Num.cur
else:
Num.digits += Num.cur
return Num.digits
def work(n):
j = n
start = 1 + Num.stored[0]
Num.cur, Num.digits = ... | CLASS_DEF ASSIGN VAR VAR VAR VAR NUMBER NUMBER DICT LIST NUMBER NUMBER NUMBER NUMBER FUNC_DEF IF BIN_OP STRING BIN_OP STRING BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR VAR NUMBER VAR VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR VAR ASSIGN VAR BIN_OP NUMBER VAR NUMBER ASSIGN VAR VAR VAR NUMBER VAR NUM... |
The only difference between the easy and the hard versions is the maximum value of $k$.
You are given an infinite sequence of form "112123123412345$\dots$" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$ to $1$, the second one — f... | dp, cnt = [0], 1
dp2 = [0]
while dp[-1] <= int(1e18):
ans = dp2[-1] + (10**cnt - 10 ** (cnt - 1)) * cnt
dp2.append(ans)
ans = (
dp[-1]
+ dp2[-2] * (10**cnt - 10 ** (cnt - 1))
+ cnt * (10**cnt - 10 ** (cnt - 1) + 1) * (10**cnt - 10 ** (cnt - 1)) / 2
)
ans = int(ans)
cnt +=... | ASSIGN VAR VAR LIST NUMBER NUMBER ASSIGN VAR LIST NUMBER WHILE VAR NUMBER FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER BIN_OP BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER BIN_OP VAR N... |
The only difference between the easy and the hard versions is the maximum value of $k$.
You are given an infinite sequence of form "112123123412345$\dots$" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$ to $1$, the second one — f... | def sum_first(k):
return (k + 1) * k // 2
def sum_seq_len(k):
res = 0
x = 1
while k >= x:
res += sum_first(k - (x - 1))
x *= 10
return res
def seq_len(k):
res = 0
x = 1
while k >= x:
res += k - (x - 1)
x *= 10
return res
def brut_ssl(k):
res ... | FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR... |
The only difference between the easy and the hard versions is the maximum value of $k$.
You are given an infinite sequence of form "112123123412345$\dots$" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$ to $1$, the second one — f... | import sys
def count_num(num):
i = 0
while num:
num //= 10
i += 1
return i
def find1(num):
for i in range(1, 21837):
if num < list_psum[i]:
return i - 1
list_count = [0] * 21837
list_psum = [0] * 21837
for i in range(1, 21837):
list_count[i] = list_count[i -... | IMPORT FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR VAR VAR RETURN BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER FUNC... |
The only difference between the easy and the hard versions is the maximum value of $k$.
You are given an infinite sequence of form "112123123412345$\dots$" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$ to $1$, the second one — f... | def l(n):
s = 0
for i in range(20):
o = 10**i - 1
if o > n:
break
s += (n - o) * (n - o + 1) // 2
return s
def bs(k):
n = 0
for p in range(63, -1, -1):
if l(n + 2**p) < k:
n += 2**p
return n
def num(n):
if n < 10:
return n
... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER IF VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER VAR VAR VAR BIN_OP... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | t = int(input())
for _ in range(t):
summ = 0
count = 0
sneg = 0
ncount = 0
x = int(input())
f = list(map(int, input().split()))
for d in f:
z = d
if z >= 0:
summ += z
count += 1
else:
sneg += z
ncount += 1
f = sorted... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR VAR ASSIGN VAR VAR IF VAR NUMBER VAR VAR VAR NUMBER VAR VAR VAR NUMBE... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | n = int(input().strip())
for a0 in range(n):
num = int(input().strip())
a = [int(a_temp) for a_temp in input().strip().split(" ")]
a = sorted(a)
a = a[::-1]
sec = []
s = 0
c = 0
sep = 0
for x in a:
if x >= 0:
s = s + x
c = c + 1
else:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER F... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | T = eval(input())
for i in range(T):
X = eval(input())
c = 0
sum1 = 0
A = list(map(eval, input().split()))
A.sort()
j = X - 1
while j >= 0:
if (sum1 + A[j]) * (c + 1) >= sum1 * c:
sum1 = sum1 + A[j]
j = j - 1
c = c + 1
else:
bre... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER IF BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER B... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | for _ in range(int(input().strip())):
n = int(input().strip())
a = list(map(int, input().strip().split()))
c = 0
total = 0
subtotal = 0
a.sort(reverse=True)
for i in a:
if i < 0:
if subtotal * c > (subtotal + i) * (c + 1):
total += subtotal * c + i
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR VAR IF VAR NUMBER IF BIN_OP VAR VAR BIN_OP BIN... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | test = int(input())
SUM = [0]
for i in range(1, 100000 + 1):
SUM.append(0)
while test != 0:
n = int(input())
ar = list(map(int, input().split()))
ar.sort()
for i in range(1, n + 1):
SUM[i] = ar[i - 1] + SUM[i - 1]
ans = SUM[n] * n
for i in range(1, n + 1):
if ans < SUM[i] + (... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR ... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | def binary_search(arr, start, end, key):
if start > end:
return -1
mid = (start + end) // 2
if arr[mid] == key:
return mid
if arr[mid] > key:
return binary_search(arr, start, mid - 1, key)
else:
return binary_search(arr, mid + 1, end, key)
t = int(input())
for i in ... | FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR RETURN VAR IF VAR VAR VAR RETURN FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR RETURN FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | for t in range(int(input())):
n = int(input())
a = map(int, input().split())
total = 0
pos = []
neg = []
for i in a:
if i >= 0:
pos.append(i)
else:
neg.append(i)
neg.sort(reverse=True)
s = sum(pos)
l = len(pos)
for i in neg:
if s + ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR A... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | for _ in range(int(input())):
input()
happiness_array = list(map(int, input().split()))
displeasurables = sorted(filter(lambda x: x < 0, happiness_array), reverse=True)
pleasurables = [x for x in happiness_array if x >= 0]
sum_displeasure = sum(displeasurables)
sum_pleasure = sum(pleasurables)
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR AS... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | def solve(arr: "list[int]") -> "int":
pos = 0
pos_size = 0
neg = 0
neg_li = []
for ele in arr:
if ele >= 0:
pos += ele
pos_size += 1
else:
neg_li.append(ele)
neg += ele
if pos == 0:
return sum(neg_li)
elif neg == 0:
... | FUNC_DEF STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR NUMBER VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR IF VAR NUMBER RETURN FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR VAR RETURN VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FO... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | for z in range(int(input())):
N = int(input())
inputs = list(map(int, input().split()))
inputs.sort(reverse=True)
positive = list(filter(lambda x: x >= 0, inputs))
negative = list(filter(lambda x: x < 0, inputs))
final_negative_list = []
total = sum(positive)
counts = len(positive)
f... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR LIST ASSIGN VAR FUN... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | for t in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
a.sort()
x = s = c = 0
for ai in reversed(a):
if (s + ai) * (c + 1) > s * c:
s += ai
c += 1
else:
x += ai
print(s * c + x) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR VAR VAR NUMBER VAR VAR EXPR FUN... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | t = int(input().strip())
for a0 in range(t):
n = int(input().strip())
arr = list(map(int, input().strip().split(" ")))
arr.sort()
ans = sum(arr) * n
sumArray = [0] * (n + 1)
for i in range(n):
s = ans - sumArray[i]
s = s // n
s -= arr[i]
s = s * (n - 1 if n > 2 el... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR V... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | for t in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
result = 0
if a[0] <= 0:
result = sum(a)
else:
current_max = 0
_sum = 0
i = 0
for x in a:
i += 1
_sum += x
if curren... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR ... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | count = int(input())
for step in range(count):
size = int(input())
dishes = [int(x) for x in input().split()]
dishes.sort(reverse=True)
happiness = 0
counter = 0
negative = 0
top = 0
for mrinal in dishes:
if top <= (happiness + mrinal) * (counter + 1):
top = (happines... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER AS... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | varTest = int(input("\n"))
for j in range(0, varTest):
arraylength = int(input("\n"))
array = list(map(int, input().split()))
array.sort(key=None, reverse=False)
length = int(len(array))
sum = int(0)
startingindex = int(-1)
for i in range(0, length, 1):
if int(array[i]) >= 0:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NONE NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL V... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | import sys
def set_input():
t = int(input())
inp = []
sum = []
for i in range(t):
n = int(input())
inp = list(map(int, input().split()))
sum.append(solve(n, inp))
for i in sum:
print(i)
def solve(n, inp):
neg_sum = 0
pos_sum = 0
neg = []
pos = []
... | IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR NUMBE... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | T = int(input())
for _ in range(T):
n = int(input())
Happiness = list(map(int, input().split()))
Happiness.sort()
Happiness.reverse()
sum1 = 0
ans = 0
found = False
for i in range(n):
sum1 += Happiness[i]
ans1 = sum1 * (i + 1)
if ans1 > ans:
ans = ans1... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP V... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | t = int(input())
for i in range(t):
n = int(input())
array = list(map(int, input().rstrip().split(" ")))
array.sort()
cum_sum = [array[0]]
for j in range(1, n):
cum_sum.append(cum_sum[j - 1] + array[j])
total_sum = cum_sum[n - 1]
prev_sum = total_sum * n
printed = False
for j... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR V... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | tc = int(input())
for t in range(tc):
n = int(input())
happiness = list(map(int, input().strip().split(" ")))
happiness.sort(reverse=True)
totalpos = 0
poslen = 0
negative_list = []
i = 0
while i < n and happiness[i] >= 0:
totalpos += happiness[i]
poslen += 1
i +=... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR NUMBER VAR VAR... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | t = int(input())
while t:
n = int(input())
hpns = [int(x) for x in input().split()]
sumt = sum(hpns)
po_sum = 0
count = 0
neg_sum = 0
neg_count = 0
neg_list = []
for num in hpns:
if num >= 0:
po_sum += num
count += 1
else:
neg_sum +... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR NUMBER VAR VAR VAR NUMBER VAR VAR EXPR ... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | t = int(input())
while t > 0:
t = t - 1
n = int(input())
arr = []
neg = []
pos = []
ans = 0
copy = 0
arr = [int(x) for x in input().split(" ")]
for i in range(n):
if arr[i] < 0:
neg.append(arr[i])
else:
pos.append(arr[i])
copy = ans = sum(p... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | __author__ = ["vjn4006(Vaibhav Nagda)"]
def main():
t = int(input().strip())
for _ in range(t):
n = int(input().strip())
s = sorted(list(map(int, input().strip().split(" "))))
grt_cnt = 0
grt_sum = 0
happiness = 0
smaller = []
for i in s:
if ... | ASSIGN VAR LIST STRING FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR L... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | for _ in range(int(input())):
N = int(input())
A = sorted(list(map(int, input().split())))
s = 0
m = 0
j = 0
z = 1
for i in range(N - 1, -1, -1):
s += A[i]
if z * s > m:
m = z * s
z += 1
else:
j += A[i]
print(m + j) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER VAR VAR VAR IF BIN_OP VA... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | t = int(input())
while t:
t = t - 1
n = int(input())
a = input().split()
a = [int(x) for x in a]
count_negative = sum(x < 0 for x in a)
count_only_neg = sum(x <= 0 for x in a)
if count_only_neg == n:
print(sum(a))
elif count_negative == 0:
print(n * sum(a))
elif count... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR VAR IF VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | T = int(input())
while T > 0:
dishes = int(input())
numbers = list(map(int, input().split()))
happiness = 0
count = 0
total = 0
steps = 0
numbers.sort(reverse=True)
for i in numbers:
if i >= 0:
count = count + i
total = total + 1
elif count + (tota... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN V... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | for _ in range(int(input())):
n = int(input())
A = list(map(int, input().split()))
A = sorted(A)[::-1]
left = 0
summ = sum(A)
right = summ
ans = -float("inf")
for i in range(n):
left += A[i]
right -= A[i]
ans = max(ans, (i + 1) * left + right)
print(ans) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR VAR VAR ... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | t = int(input())
for test in range(t):
n = int(input())
a = list(map(int, input().split()))
a = sorted(a, reverse=True)
ans = 0
curr_sum = 0
for i in range(n):
curr_sum += a[i]
if curr_sum * (i + 1) > ans:
ans = curr_sum * (i + 1)
else:
ans += a[i]... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR IF BIN_OP VAR BIN_OP VAR NUMBER VAR ASS... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | for t in range(int(input())):
n = int(input())
x = list(map(int, input().split(" ")))
x.sort(reverse=True)
s = x[0]
mul = 1
res = 0
for i in range(1, len(x)):
prev = s * mul
s += x[i]
mul += 1
if s * mul < prev and s * mul < prev + x[i]:
res += pre... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | t = int(input())
for i in range(t):
n = int(input())
a = []
a.extend(map(int, input().split()))
a.sort(reverse=True)
c = 0
s = a[0]
while (s + a[c + 1]) * (c + 2) >= s * (c + 1):
s += a[c + 1]
c += 1
if c >= n - 1:
break
s *= c + 1
for i in range(c... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER WHILE BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VA... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | t = int(input())
for i in range(t):
l = int(input())
seq = list(map(int, input().split()))
seq.sort(reverse=True)
counter = 0
negsum = 0
posum = 0
for j in seq:
if j >= 0:
posum += j
counter += 1
elif posum >= (counter + 1) * abs(j):
posum ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR VAR VAR NUMBER IF VAR BIN_OP BIN_OP VAR... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | numTests = int(input())
for test in range(numTests):
numDishes = int(input())
happy = map(int, input().split())
sumPos = 0
countPos = 0
negNums = []
for h in happy:
if h > -1:
sumPos += h
countPos += 1
else:
negNums.append(-h)
negNums.sort(... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR NUMBER VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR LIST WHIL... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | for _ in range(int(input())):
n = int(input())
arr = sorted(map(int, input().split()), reverse=True)
negative_arr = tuple(i for i in arr if i < 0)
positive_arr = tuple(i for i in arr if i >= 0)
temp_len = len(positive_arr)
positive_sum = sum(positive_arr)
ans = positive_sum * temp_len
if... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASS... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | tc = int(input())
while tc:
n = int(input())
no = list(map(int, input().split()))
neg = []
pos = []
ncnt = 0
pcnt = 0
psum = 0
nsum = 0
for x in range(n):
temp = no[x]
if temp < 0:
neg.append(temp)
ncnt = ncnt + 1
nsum = nsum + temp... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF VAR NUMBER EX... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | for i in range(int(input())):
amd = int(input())
array = list(map(int, input().split()))
array.sort()
mke = len(array) - 1
for k in range(len(array)):
if array[k] >= 0:
mke = k
break
total = sum(array) * len(array)
sum1 = sum(array)
r = len(array)
rmd ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP FUNC_CALL V... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | t = int(input())
for i in range(t):
l = int(input())
seq = list(map(int, input().split()))
seq.sort(reverse=True)
lensubset = 0
total = 0
negtotal = 0
posum = 0
for j in range(l):
if seq[j] >= 0:
posum += seq[j]
lensubset += 1
elif posum >= (j + 2)... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | def max_happiness(arr):
pos = []
neg = []
for y in arr:
if y > 0:
pos.append(y)
else:
neg.append(y)
if len(pos) == len(arr):
return sum(pos) * len(pos)
elif len(neg) == len(arr):
return sum(neg)
else:
arr.sort()
arr.reverse(... | FUNC_DEF ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBE... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | for _ in range(int(input())):
size = int(input())
dishes = sorted(list(map(int, input().split())))[::-1]
positivessum, negativessum = 0, 0
positives, negatives = list(), list()
for i in range(size):
if dishes[i] >= 0:
positives.append(dishes[i])
positivessum += dishes... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | t = int(input())
for _ in range(t):
n, sum1, sum2, cnt = int(input()), 0, 0, 0
arr = [int(i) for i in input().split()]
arr.sort(reverse=True)
for i in arr:
if sum1 * cnt + i <= (sum1 + i) * (cnt + 1):
sum1, cnt = sum1 + i, cnt + 1
else:
sum2 += i
print(sum2 + ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER FOR VAR VAR IF BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | for _ in range(int(input())):
n = int(input())
(*a,) = map(int, input().split())
c = [i for i in a if i >= 0]
d = [i for i in a if i < 0]
s = sum(c)
l = len(c)
ans = s * l + sum(d)
for i in reversed(sorted(d)):
if i * l + s > 0:
ans += i * l + s
s += i
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR F... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | t = int(input())
for _ in range(t):
n = int(input())
a = sorted(list(map(int, input().strip().split())))
pos = 0
while pos < n and a[pos] < 0:
pos += 1
if pos == n:
print(sum(a))
continue
suma = sum(a[pos:])
lena = len(a[pos:])
sumb = sum(a[:pos])
prev = suma ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CAL... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | tc = int(input())
for _ in range(tc):
n = int(input())
lst = list(map(int, input().split()))
neg = []
pos = []
for elem in lst:
if elem >= 0:
pos.append(elem)
else:
neg.append(elem)
pos_sum = sum(pos)
pos_len = len(pos)
neg_sum = sum(neg)
i = 0... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | T = int(input())
i = 0
while i < T:
N = int(input())
negs = []
sump = 0
ns = input().split()
for e in ns:
e = int(e)
if e < 0:
negs.append(e)
else:
sump += e
negs.sort(reverse=True)
nump = N - len(negs)
j = 0
for e in negs:
cont... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CA... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | t = int(input())
for y in range(t):
n = int(input())
k = list(input().split())
k = [int(X) for X in k]
k.sort()
r = 0
s = 0
for i in range(n):
if k[i] < 0:
e = i
s = s + k[i]
else:
r = r + k[i]
if r == 0:
print(s)
elif s == ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_O... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | from sys import stdin
t = int(stdin.readline())
while t:
n = int(stdin.readline())
l = list(map(int, stdin.readline().split()))
ans = 0
s = 0
count = 0
l.sort(reverse=True)
temp = 0
for i in range(0, len(l)):
if (s + l[i]) * (count + 1) >= temp:
count += 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | for _ in range(int(input())):
n = int(input())
l = [int(i) for i in input().split()]
pos_sum = 0
pos_cnt = 0
neg_sum = 0
neg_li = []
for i in l:
if i >= 0:
pos_sum += i
pos_cnt += 1
else:
neg_sum += i
neg_li.append(i)
if len... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR NUMBER VAR VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR FUN... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | t = int(input())
for i in range(t):
n = int(input())
arr = [int(x) for x in input().split()]
pos = []
neg = []
for i in arr:
if i < 0:
neg.append(i)
else:
pos.append(i)
length = len(pos)
max_sum = sum(pos) * length + sum(neg)
if len(neg) > 0:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP F... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | for t in range(int(input())):
n = int(input())
l = list(map(int, input().split()))
sumx = 0
count = 0
sumd = 0
l.sort(reverse=True)
for i in l:
if (sumx + i) * (count + 1) + sumd >= sumx * count + (sumd + i):
sumx += i
count += 1
else:
sumd... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR VAR IF BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER VAR BIN_OP BIN_OP VAR ... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | t = int(input())
for i in range(t):
n = int(input())
a = list(map(int, input().split()))
s = 0
p = 0
l = 0
res = 0
ng = []
for j in range(len(a)):
if a[j] < 0:
ng.append(a[j])
else:
p += a[j]
l += 1
ng.sort()
for k in ng[::-1]:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXP... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | t = int(input())
for i in range(t):
n = int(input())
a = sorted(map(int, input().split()), reverse=True)
ans = s = c = 0
for j in range(n):
s += a[j]
if s * (j + 1) > ans:
ans = s * (j + 1)
c = j + 1
else:
break
print(ans + sum(a[c:])) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR IF BIN_OP VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER AS... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
posSum = 0
negSum = 0
no = 0
neg = []
for x in a:
if x <= 0:
negSum += x
neg.append(x)
else:
posSum += x
no += 1
ans = posSum * no + negSum
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP ... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | t = int(input())
for e in range(t):
a, ng, ps, c = [], 0, 0, 0
x, y = [], []
n = int(input())
a = list(map(int, input().split()))
for i in a:
if i >= 0:
ps += i
c += 1
x.append(i)
else:
y.append(i)
ng += i
ans = ps * c +... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR LIST NUMBER NUMBER NUMBER ASSIGN VAR VAR LIST LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR VAR IF VAR NUMBER VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FU... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | t = int(input())
while t > 0:
n = int(input())
t -= 1
list1 = list(map(int, input().split()))
c = 0
neglist = []
maxi = -1
sum1 = 0
for x in list1:
if x >= 0:
sum1 += x
c += 1
maxi = max(maxi, sum1 * c)
else:
neglist.append(... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | import itertools
T = int(input())
for case in range(T):
n = int(input())
xs = list(map(int, input().split()))
xs.sort()
sl = list(itertools.accumulate(xs))
ans = sum(xs) * len(xs)
s = sum(xs)
for i, x in enumerate(xs):
ans = max(ans, sl[i] + (s - sl[i]) * (n - i - 1))
print(ans) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR V... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | test = int(input())
for t in range(test):
n = int(input())
count = 0
res = 0
exclude = 0
for number in sorted(map(int, input().split()))[::-1]:
including_cur = (res + number) * (count + 1)
excluding_cur = res * count + number
if including_cur >= excluding_cur:
res... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF ... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | for _ in range(int(input())):
n = int(input())
arr = list(map(int, input().split()))
pos = 0
pos_size = 0
neg = 0
neg_li = []
for it in arr:
if it >= 0:
pos += it
pos_size += 1
else:
neg_li.append(it)
neg += it
if pos == 0:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR NUMBER VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR IF VAR NUMBER EXPR... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | for _ in range(int(input())):
input()
a = sorted(int(x) for x in input().split())
n = s = 0
while a:
if s + n * a[-1] >= 0:
n += 1
x = a.pop()
s += x
else:
break
print(s * n + sum(a)) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER WHILE VAR IF BIN_OP VAR BIN_OP VAR VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | cases = int(input())
for case_i in range(cases):
n = int(input())
arr = [int(k) for k in input().split(" ")]
arr.sort(reverse=True)
pos_sum = 0
pos_total = 0
total_sum = 0
i = 0
while i < n and (
arr[i] >= 0 or (pos_sum + arr[i]) * (pos_total + 1) >= pos_sum * i
):
po... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR NUMBER BIN_OP BIN_OP VAR VAR VAR... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | t = int(input())
while t:
n = int(input())
li = [int(i) for i in input().strip().split()]
res, s, m = 0, 0, 0
neg = []
for i in li:
if i < 0:
neg += [i]
else:
s += i
m += 1
neg.sort()
for i in neg[::-1]:
if (s + i) * (m + 1) >= s * ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE 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 NUMBER NUMBER NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR NUMBER VAR LIST VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FOR VAR VAR NUMBER IF BIN_OP BIN... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | t = int(input())
for i in range(t):
n = int(input())
arr = list(map(int, input().split()))
ans = 0
count = 0
negatives = []
for x in arr:
if x >= 0:
count += 1
ans += x
else:
negatives.append(x)
if len(negatives) == 0:
print(ans * c... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR NUMBER VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER E... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | for _ in range(int(input())):
n = int(input())
s = sorted(list(map(int, input().split())), reverse=True)
negatives, positives = s[:], s[:]
negatives = list(x for x in s if x < 0)
positives = list(x for x in s if x >= 0)
nlen = len(negatives)
plen = len(positives)
finalSum = sum(positives... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | for ti in range(int(input())):
n = int(input())
m = list(map(int, input().split()))
m.sort(reverse=True)
r = 0
s = m[0]
c = 1
for i in range(1, n):
if (s + m[i]) * (c + 1) >= s * c + m[i]:
s = s + m[i]
c = c + 1
else:
r = r + s * c
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER ... |
Read problems statements in Russian.
Chef has prepared a feast with N dishes for you. You like Chef's cooking, and so you want to eat all the dishes he has prepared for you. You are also given an array A of size N, where A_{i} represents the happiness you get by eating the i-th dish.You will eat all the dishes in a s... | t = int(input().strip())
def partition(a, p):
j = -1
a[p], a[-1] = a[-1], a[p]
pivot = a[-1]
for i in range(len(a) - 1):
if a[i] < pivot or a[i] == pivot and pivot < 0:
j += 1
a[i], a[j] = a[j], a[i]
a[j + 1], a[-1] = a[-1], a[j + 1]
return j + 1
def closeToZe... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR VAR NUMBER VAR NUMBER VAR VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NU... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.