description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of n light bulbs in a single row. Each bulb has a number from 1 to n (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the garland.... | n = int(input())
p = list(map(int, input().split()))
inf = 10**12
dp = [[[inf, inf] for j in range(101)] for i in range(n)]
if p[0] != 0:
if p[0] % 2 == 0:
dp[0][1][0] = 0
else:
dp[0][0][1] = 0
else:
dp[0][1][0] = 0
dp[0][0][1] = 0
for i in range(1, n):
for j in range(101):
f... | ASSIGN VAR FUNC_CALL VAR 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 LIST VAR VAR VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR IF VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR NUMBE... |
Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $n$ light bulbs in a single row. Each bulb has a number from $1$ to $n$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the ga... | INF = 9999999999999999999999
n = int(input())
a = list(map(int, input().split()))
e = 0
o = 0
pref = [(0) for i in range(n)]
for i in range(n):
pref[i] = pref[i - 1]
if a[i] == 0:
pref[i] += 1
continue
if a[i] % 2 == 0:
e += 1
else:
o += 1
ie = n // 2
io = ie
if n % 2 == ... | 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR NUMBER IF VAR VAR NUMBER VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER... |
Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $n$ light bulbs in a single row. Each bulb has a number from $1$ to $n$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the ga... | import sys
N = int(input())
a = [int(x) for x in input().split(" ")]
if all(x == 0 for x in a):
print(0 if N == 1 else 1)
sys.exit(0)
sz = [[], []]
sl, sr, pl, pr = None, None, None, None
cnt = [N // 2, (N + 1) // 2]
flips = 0
pp, pi = None, -1
for i, x in enumerate(a):
if x != 0:
if pp == None:
... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF FUNC_CALL VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST LIST LIST ASSIGN VAR VAR VAR VAR NONE NONE NONE NONE ASSIGN VAR LIST BIN_OP VAR NUMBER B... |
Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $n$ light bulbs in a single row. Each bulb has a number from $1$ to $n$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the ga... | import sys
mod = 1000000007
eps = 10**-9
def main():
import sys
input = sys.stdin.readline
N = int(input())
P = list(map(int, input().split()))
if N == 1:
print(0)
exit()
if N == 2:
print(1)
exit()
odd = (N + 1) // 2
even = N // 2
for p in P:
... | IMPORT ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FUNC_DEF IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN V... |
Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $n$ light bulbs in a single row. Each bulb has a number from $1$ to $n$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the ga... | n = int(input())
pis = [int(pi) for pi in input().split()]
prev, current_gap, odd, even = "d", 0, 0, 0
first_gap = "e", 0
even_gaps, odd_gaps, any_gaps = [], [], []
for pi in pis:
if pi == 0:
current_gap += 1
elif pi % 2 == 0:
even += 1
if prev == "o":
any_gaps.append(current... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR STRING NUMBER NUMBER NUMBER ASSIGN VAR STRING NUMBER ASSIGN VAR VAR VAR LIST LIST LIST FOR VAR VAR IF VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER IF VAR STRING EXPR FUNC_CALL VAR VAR I... |
Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $n$ light bulbs in a single row. Each bulb has a number from $1$ to $n$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the ga... | import sys
def updiv(x, y):
if x % y == 0:
return x // y
else:
return x // y + 1
n = int(input())
p = list(map(int, input().split()))
if n == 1:
print(0)
sys.exit()
o = updiv(n, 2)
e = n // 2
for i in range(n):
if p[i] > 0 and p[i] % 2 == 0:
e -= 1
p[i] = 2
el... | IMPORT FUNC_DEF IF BIN_OP VAR VAR NUMBER RETURN BIN_OP VAR VAR RETURN BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VA... |
Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $n$ light bulbs in a single row. Each bulb has a number from $1$ to $n$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the ga... | n = int(input())
a = [int(x) for x in input().split()]
imp, par = 0, 0
for i in range(n):
if a[i] == 0:
a[i] -= 1
else:
a[i] %= 2
imp += a[i] % 2 == 1
par += a[i] % 2 == 0
ans = 0
for i in range(n - 1):
if a[i] != -1 and a[i + 1] != -1 and a[i] + a[i + 1] == 1:
ans +=... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR BIN_OP VAR VAR NUMBER NUMBER VAR BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMB... |
Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $n$ light bulbs in a single row. Each bulb has a number from $1$ to $n$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the ga... | import sys
n = int(input())
arr = list(map(int, input().split()))
nope = []
for i in range(1, n + 1):
if i not in arr:
nope.append(i)
chet = 0
nechet = 0
for i in nope:
if i % 2 == 0:
chet += 1
else:
nechet += 1
ans = 0
for i in range(n - 1):
if arr[i] != 0 and arr[i + 1] != 0 a... | IMPORT 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 FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR N... |
Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $n$ light bulbs in a single row. Each bulb has a number from $1$ to $n$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the ga... | import sys
inf = 2**30
def solution(a):
n = len(a)
m = (n + 1 >> 1) - sum([(v & 1) for v in a])
f = [[[inf for k in range(2)] for j in range(m + 1)] for i in range(n + 1)]
f[0][0][0], f[0][0][1] = 0, 0
for i in range(n):
for j in range(min(m, i) + 1):
for k in range(2):
... | IMPORT ASSIGN VAR BIN_OP NUMBER NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER VAR NUMBE... |
Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $n$ light bulbs in a single row. Each bulb has a number from $1$ to $n$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the ga... | n = int(input())
p = list(map(int, input().split()))
odd = (n + 1) // 2
memo = {}
def best(i, odd_count, last):
if i == n:
return 0
key = i, odd_count, last
if key in memo:
return memo[key]
poss = range(2) if p[i] == 0 else [p[i] % 2]
res = 10**9
for parity in poss:
new... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR DICT FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR VAR VAR VAR IF VAR VAR RETURN VAR VAR ASSIGN VAR VAR VAR NUMBER FUNC_CALL VAR NUMBER LIST BIN_OP VAR VAR NUMBE... |
Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $n$ light bulbs in a single row. Each bulb has a number from $1$ to $n$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the ga... | n = int(input())
bulb = list(map(int, input().split()))
def complex(n, bulb):
temp = 0
for x in range(n - 1):
if (
bulb[x] % 2 == 0
and bulb[x + 1] % 2 != 0
and bulb[x] != 0
and bulb[x + 1] != 0
):
temp += 1
elif (
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR NUMBER NUMBER BIN_OP VAR BIN_OP VAR NUMBER NUMBER NUMBER VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER IF BIN_OP VAR VAR... |
Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $n$ light bulbs in a single row. Each bulb has a number from $1$ to $n$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the ga... | import sys
input = sys.stdin.readline
n = int(input())
A = list(map(int, input().split()))
DP0 = [([200] * (n + 1)) for i in range(n + 1)]
DP1 = [([200] * (n + 1)) for i in range(n + 1)]
DP0[0][0] = 0
DP1[0][0] = 0
for i in range(n):
SUM = i + 1
if A[i] != 0:
if A[i] % 2 == 1:
for j in rang... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER... |
Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $n$ light bulbs in a single row. Each bulb has a number from $1$ to $n$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the ga... | import sys
def minp():
return sys.stdin.readline().strip()
def mint():
return int(minp())
def mints():
return map(int, minp().split())
def solve():
n = mint()
a = list(mints())
o_all = 0
for i in range(1, n + 1, 2):
o_all += 1
e_all = 0
for i in range(2, n + 1, 2):
... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR NUMB... |
Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $n$ light bulbs in a single row. Each bulb has a number from $1$ to $n$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the ga... | n = int(input())
x = list(map(int, input().split()))
p1, p2, c = [0] * 101, [0] * 101, [0] * 2
c[1], c[0] = n // 2 + n % 2, n // 2
count, edge, ans, temp1, temp2 = 0, [[] for i in range(2)], 0, 0, 0
for i in range(n):
if x[i] == 0:
count += 1
if i == n - 1:
edge[x[i - count] % 2].append(... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR BIN_OP LIST NUMBER NUMBER BIN_OP LIST NUMBER NUMBER BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER VAR NUMBER BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR VAR ... |
Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $n$ light bulbs in a single row. Each bulb has a number from $1$ to $n$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the ga... | 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 ... |
Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $n$ light bulbs in a single row. Each bulb has a number from $1$ to $n$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the ga... | n = int(input())
arr = list(map(lambda x: int(x), input().split(" ")))
count_ans = 0
arr_1 = []
for i in range(n - 1):
if (arr[i] + arr[i + 1]) % 2 == 1 and arr[i] != 0 and arr[i + 1] != 0:
count_ans += 1
prev = -1
count = 0
count_odd = 0
count_even = 0
for i in range(n):
if arr[i] % 2 == 1:
cou... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER NUMBER NUMBER VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER ASS... |
Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $n$ light bulbs in a single row. Each bulb has a number from $1$ to $n$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the ga... | import sys
n = int(input())
ar = list(map(int, input().split()))
no = set([i for i in range(1, n + 1)])
ars = set(ar)
if 0 in ars:
ars.remove(0)
dif = no - ars
odds = 0
even = 0
for i in dif:
if i % 2 == 0:
even += 1
odds = len(dif) - even
n1 = len(dif)
dp = {}
def gar(i, odds, typ, n1):
global d... | IMPORT 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 VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF NUMBER VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR ... |
Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $n$ light bulbs in a single row. Each bulb has a number from $1$ to $n$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the ga... | n = int(input())
l = list(map(int, input().split()))
dp = []
ans = 0
sp1 = [0, 0]
sp2 = [0, 0]
if n % 2 == 0:
ev = n // 2
od = n // 2
else:
od = 1 + n // 2
ev = n // 2
a = -1
b = -1
c = 0
for i in range(n - 1):
if l[i] != 0 and l[i + 1] != 0:
if l[i] % 2 != l[i + 1] % 2:
ans += 1... | 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 NUMBER ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP VA... |
Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $n$ light bulbs in a single row. Each bulb has a number from $1$ to $n$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the ga... | import sys
def main():
n = int(input())
a = readIntArr()
arr = []
items = set(range(1, n + 1))
for x in a:
if x == 0:
arr.append(-1)
else:
arr.append(x % 2)
items.remove(x)
itemModCnts = [0, 0]
for x in items:
itemModCnts[x % 2] +... | IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER NUMBER FOR VAR VAR VAR BI... |
Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $n$ light bulbs in a single row. Each bulb has a number from $1$ to $n$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the ga... | import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
n = int(input())
p = list(map(int, input().split()))
odd = (n + 1) // 2
even = n - odd
for i in p:
if i:
if i % 2 == 0:
even -= 1
else:
odd -= 1
if even == 0:
p = [(i if i else 1) for i in p]
if ... | IMPORT ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR FOR VAR VAR IF VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN ... |
Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $n$ light bulbs in a single row. Each bulb has a number from $1$ to $n$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the ga... | n = int(input())
z = float("INF")
a = [int(x) for x in input().split()]
dp = [[[([z] * 2) for k in range(n + 1)] for j in range(n + 1)] for i in range(n + 1)]
dp[0][0][0][0] = 0
dp[0][0][0][1] = 0
for i in range(1, n + 1):
for j in range(n + 1):
if a[i - 1] & 1:
dp[i][j][i - j][1] = min(
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER NUMBER NUMBER ASSI... |
Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $n$ light bulbs in a single row. Each bulb has a number from $1$ to $n$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the ga... | n = int(input())
x = y = 0
a = list(map(int, input().split()))
pref = [0]
for q in range(n):
if a[q] != 0 and a[q] % 2 == 0:
x += 1
elif a[q] != 0:
y += 1
if a[q] % 2 == 0 and a[q] != 0:
a[q] = 2
pref.append(pref[-1])
elif a[q] % 2 == 1:
a[q] = 1
pref.appe... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR 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 VAR IF VAR VAR NUMBER BIN_OP VAR VAR NUMBER NUMBER VAR NUMBER IF VAR VAR NUMBER VAR NUMBER IF BIN_OP VAR VAR NUMBER NUMBER VAR VAR NUMBER ASSIGN VA... |
Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $n$ light bulbs in a single row. Each bulb has a number from $1$ to $n$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the ga... | n = int(input().strip())
even, odd = n // 2, n // 2 + n % 2
ints = list(map(int, input().split()))
prev, previ, count = None, -1, 0
complexity = 0
groups = []
for i, x in enumerate(ints):
if x == 0:
count += 1
else:
if not prev:
if count:
groups.append((1, -count, x %... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NONE NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER I... |
Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $n$ light bulbs in a single row. Each bulb has a number from $1$ to $n$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the ga... | n = int(input())
p = list(map(int, input().split()))
o = (n + 1) // 2
e = n // 2
for i in range(n):
if p[i]:
p[i] %= 2
if p[i]:
o -= 1
else:
e -= 1
else:
p[i] = -1
l = []
if 0 not in p and 1 not in p:
if n > 1:
print(1)
else:
print(... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER IF VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST IF NUMBER VAR NUMBE... |
Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $n$ light bulbs in a single row. Each bulb has a number from $1$ to $n$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the ga... | n = int(input())
a = list(map(int, input().split()))
INF = 10**5
dp = [[([INF] * (n + 1)) for i in range(n + 1)] for i in range(2)]
dp[0][0][0] = 0
dp[1][0][0] = 0
for i in range(n):
if a[i] != 0:
parity = a[i] % 2
if parity % 2 == 0:
for j in range(n + 1):
dp[0][i + 1][j... | ASSIGN VAR FUNC_CALL VAR 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 VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER NUMBE... |
Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $n$ light bulbs in a single row. Each bulb has a number from $1$ to $n$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the ga... | n = int(input())
a = list(map(int, input().split()))
if n == 1:
print(0)
exit(0)
dp = [[[10**9, 10**9] for i in range(n + 1)] for j in range(n + 1)]
dp[0][0][0] = 0
dp[0][0][1] = 0
even, odd = 0, 0
for i in range(1, n + 1):
for j in range(1, n + 1):
if a[i - 1] == 0 or a[i - 1] % 2:
dp[i... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST BIN_OP NUMBER NUMBER BIN_OP NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ... |
Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $n$ light bulbs in a single row. Each bulb has a number from $1$ to $n$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the ga... | n = int(input())
nums = [int(x) for x in input().split()]
missing = set([x for x in range(1, n + 1)])
if nums.count(0) == n:
if n == 1:
print(0)
else:
print(1)
else:
for x in nums:
if x != 0:
missing.remove(x)
odds = 0
evens = 0
for x in missing:
if x ... | 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 VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF FUNC_CALL VAR NUMBER VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VA... |
Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $n$ light bulbs in a single row. Each bulb has a number from $1$ to $n$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the ga... | import sys
input = sys.stdin.readline
n = int(input())
b = list(map(int, input().split()))
dum = n // 2 + 1
nxtd_arr = [[[101, 101] for _ in range(dum)] for _ in range(n + 1)]
nxtd_arr[0][0][0] = nxtd_arr[0][0][1] = 0
for i in range(1, n + 1):
if b[i - 1] == 0:
for j in range(1, dum):
nxtd_arr[... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER VAR NUMBER NUMBER NUMBER NUMB... |
Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $n$ light bulbs in a single row. Each bulb has a number from $1$ to $n$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the ga... | def main():
n = int(input())
a = input()
even_count = int(n / 2)
odd_count = n - even_count
result = 0
arr = list(map(int, a.split()))
left = -1
right = -1
odd = {}
even = {}
diff = 0
zero = 0
special_odd = {}
special_even = {}
for x in arr:
if x == 0:... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR NUMBER... |
Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $n$ light bulbs in a single row. Each bulb has a number from $1$ to $n$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the ga... | def abc(l, odd, even, i, x):
try:
return dp[i, odd, even, x]
except:
pass
if i == len(l):
return 0
if l[i]:
c = 0
if x != l[i] % 2:
c += 1
return c + abc(l, odd, even, i + 1, l[i] % 2)
ans = n
if odd:
c = 0
if not x % 2:... | FUNC_DEF RETURN VAR VAR VAR VAR VAR IF VAR FUNC_CALL VAR VAR RETURN NUMBER IF VAR VAR ASSIGN VAR NUMBER IF VAR BIN_OP VAR VAR NUMBER VAR NUMBER RETURN BIN_OP VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR VAR IF VAR ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL... |
Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $n$ light bulbs in a single row. Each bulb has a number from $1$ to $n$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the ga... | n = int(input())
a = list(map(int, input().split()))
s = set(a)
u, v = 0, 0
for i in range(1, n + 1):
if i not in s:
if i & 1:
u += 1
else:
v += 1
dp = [[[([n] * (v + 1)) for _ in range(u + 1)] for _ in range(2)] for _ in range(n + 1)]
dp[0][0][u][v] = 0
for i in range(1, n +... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR IF BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP LIST VAR BIN_OP VAR NUMBER VAR FUNC_C... |
Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $n$ light bulbs in a single row. Each bulb has a number from $1$ to $n$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the ga... | n = int(input())
nums = list(map(int, input().split(" ")))
if n == 1:
print(0)
exit()
memory = {}
def dp(i, j, k):
if i < k - 1:
return 100
if i < 0:
if j == 1 and k != 0 or j == 0 and k != -1:
return 100
else:
return 0
if nums[i] != 0:
if nu... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR DICT FUNC_DEF IF VAR BIN_OP VAR NUMBER RETURN NUMBER IF VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER RETURN NUMBER RETURN NU... |
Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $n$ light bulbs in a single row. Each bulb has a number from $1$ to $n$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the ga... | N = int(input())
A = [int(a) for a in input().split()]
M = A.count(0)
A2 = [(a % 2) for a in A]
O = A2.count(1)
E = N - M - O
O = (N + 1) // 2 - O
E = N // 2 - E
C = [M]
for a in A:
C.append(C[-1] - (a == 0))
X = [([999] * 102) for _ in range(N)]
Y = [([999] * 102) for _ in range(N)]
if A[0] % 2:
X[0][O] = 0
el... | 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 NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR NUM... |
Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $n$ light bulbs in a single row. Each bulb has a number from $1$ to $n$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the ga... | import sys
readline = sys.stdin.readline
N = int(readline())
S = list(map(int, readline().split()))
S = [(0 if s == 0 else 1 if s & 1 else -1) for s in S]
odd = -(-N // 2)
even = N // 2
for s in S:
if s:
if s == 1:
odd -= 1
else:
even -= 1
inf = 10**9
dpe = [([inf] * (odd + ... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER NUMBER VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR VAR IF VAR IF VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR... |
Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $n$ light bulbs in a single row. Each bulb has a number from $1$ to $n$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the ga... | n = int(input())
l = list(map(int, input().split()))
a = [0, 0]
for i in range(1, n + 1):
if i not in l:
if i % 2 == 0:
a[0] += 1
else:
a[1] += 1
s = -1
e = -1
ind = -1
ans = 0
ind1 = -1
f = n - 1
end = 0
for i in range(n):
if l[i] != 0:
f = i
break
for i ... | 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 NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN V... |
Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $n$ light bulbs in a single row. Each bulb has a number from $1$ to $n$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the ga... | n = int(input())
p = [int(x) for x in input().split()]
pi = [i for i in range(len(p)) if p[i] != 0]
even, odd = 0, 0
ans = 0
ee, oo = [], []
oe = 0
for x in p:
if x != 0:
if x & 1:
odd += 1
else:
even += 1
st = [-1, -1]
en = [-1, -1]
if len(pi) > 0 and pi[0] > 0:
st = [p[... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR LIST LIST ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER IF BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER... |
Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $n$ light bulbs in a single row. Each bulb has a number from $1$ to $n$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the ga... | n = int(input())
cou = [n // 2, n // 2]
if n % 2 != 0:
cou[1] += 1
a = [int(o) for o in input().split()]
for i in range(n):
if a[i] == 0:
a[i] = -1
else:
a[i] %= 2
cou[a[i]] -= 1
curr = 0
ps = []
ans = 0
ns = []
fl = []
for i in range(1, n):
if a[i] != -1:
if a[i] != a[cu... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN V... |
Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $n$ light bulbs in a single row. Each bulb has a number from $1$ to $n$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the ga... | n = int(input())
ps0 = [int(x) for x in input().split()]
to_add = [x for x in range(1, n + 1) if x not in ps0]
if all(x == 0 for x in ps0):
if n == 1:
print(0)
exit()
print(1)
exit()
ANS = 1000
for I in range(2):
ps = ps0[:]
if I == 0:
to_add.sort(key=lambda x: x % 2)
els... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | n, m = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)
ruiseki = [0] * (n + 1)
for i in range(n):
ruiseki[i + 1] = ruiseki[i] + a[i]
ans = [0] * n
for i in range(n):
if i - m >= 0:
ans[i] = ruiseki[i + 1] + ans[i - m]
else:
ans[i] = ruiseki[i + 1]
print(*ans) | 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 BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | n, m = map(int, input().split())
l1 = list(map(int, input().split()))
l1.sort()
dp = [0] * m
sum = 0
for i in range(n):
dp[i % m] = dp[i % m] + l1[i]
sum = sum + dp[i % m]
print(sum, end=" ") | 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 ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR BIN_OP VAR VA... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | from sys import stdin, stdout
n, m = map(int, stdin.readline().split())
arr = list(map(int, stdin.readline().split()))
arr.sort()
ans = list()
prefix = list()
curr = 0
for i in range(0, n):
curr += arr[i]
prefix.append(curr)
for i in range(n):
if i + 1 <= m:
ans.append(prefix[i])
else:
... | 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 ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR N... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
pref = [a[0]]
tab = [0] * n
for i in range(1, n):
pref.append(pref[-1] + a[i])
dp = [0] * n
for i in range(n):
if i < m:
dp[i] = pref[i]
else:
dp[i] = dp[i - m] + pref[i]
print(*dp) | 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 ASSIGN VAR LIST VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR ... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | n, m = map(int, input().split())
a = [0] + sorted(map(int, input().split()))
ma = [0] * m
total = 0
ans = [0] * n
for i in range(1, n + 1):
ma[i % m] += a[i]
total += ma[i % m]
ans[i - 1] = total
print(*ans) | ASSIGN 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 ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR BIN_OP VAR VAR VAR VAR VAR VAR BIN_OP VA... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | from sys import stdin, stdout
def INI():
return int(stdin.readline())
def INL():
return [int(_) for _ in stdin.readline().split()]
def INS():
return stdin.readline()
def MOD():
return pow(10, 9) + 7
def OPS(ans):
stdout.write(str(ans) + "\n")
def OPL(ans):
[stdout.write(str(_) + " ")... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF RETURN BIN_OP FUNC_CALL VAR NUMBER NUMBER NUMBER FUNC_DEF EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR STRING FUNC_DEF EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR STRING VAR VA... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | from sys import stdin
def input():
return stdin.readline()[:-1]
def intput():
return int(input())
def sinput():
return input().split()
def intsput():
return map(int, sinput())
n, m = intsput()
a = list(intsput())
a.sort()
cumsum = [a[0]]
for i in range(1, n):
cumsum.append(cumsum[-1] + a[i... | FUNC_DEF RETURN FUNC_CALL VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | def numbersListInput():
aux = list(map(int, input().strip().split()))
return aux
a = numbersListInput()
n = a[0]
m = a[1]
a = numbersListInput()
a.sort()
penalty = a[:]
sweet = 0
for k in range(n):
sweet += a[k]
penalty[k] = sweet
if k >= m:
penalty[k] += penalty[k - m]
print(*penalty) | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR IF VAR VAR VAR VAR V... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | from itertools import accumulate
n, m = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
S = 0
temp = [(0) for i in range(m)]
for k in range(n):
temp[k % m] += l[k]
S += temp[k % m]
print(S, end=" ")
print() | 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CAL... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | n, m = list(map(lambda x: int(x), input().split()))
a = list(map(lambda x: int(x), input().split()))
a.sort()
ans = [0]
trail = []
for i in range(m):
trail.append(a[i])
ans.append(ans[-1] + trail[i])
for i in range(m, n):
trail.append(a[i] + trail[i - m])
ans.append(ans[-1] + trail[i])
print(" ".join(st... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VA... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | n, m = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
ans = [0] * n
a.sort()
cur = [0] * m
sum = 0
for i in range(0, n):
sum = sum + a[i] + cur[i % m]
cur[i % m] = cur[i % m] + a[i]
print(sum, end=" ") | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR ASSIGN V... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | n, m = map(int, input().split())
l = [int(x) for x in input().split()]
l.sort()
j = 0
ans = []
for i in range(m, n):
l[i] += l[i - m]
prev = 0
total = 0
for k in range(len(l)):
total += l[k]
ans.append(total)
print(*ans) | ASSIGN VAR VAR FUNC_CALL 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 ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUN... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
p = [(0) for i in range(n)]
dp = [(0) for i in range(n)]
p[0] = a[0]
dp[0] = a[0]
print(dp[0], end=" ")
for i in range(1, n):
p[i] = p[i - 1] + a[i]
dp[i] = p[i]
if i >= m:
dp[i] += dp[i - m]
print(dp[i], end=" ")
print... | ASSIGN 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 NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER STRING FOR VAR... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | n, m = map(int, input().split())
li = list(map(int, input().split()))
ans = [0] * (n + 1)
new_li = [0] * (n + 1)
li.sort()
for i in range(1, n + 1):
new_li[i] = li[i - 1]
cur_sum = 0
for i in range(1, n + 1):
cur_sum += new_li[i]
ans[i] = cur_sum
if i > m:
ans[i] += ans[i - m]
print(ans[i], ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMB... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | n, m = list(map(lambda x: int(x), input().split()))
a = list(map(lambda x: int(x), input().split()))
dp = [(0) for _ in range(m)]
a.sort()
ans = 0
final = []
for i in range(n):
ans += a[i] + dp[i % m]
dp[i % m] += a[i]
final.append(ans)
print(*final) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR V... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | n, m = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
k = [l[0]]
for i in range(1, n):
k.append(k[-1] + l[i])
ans = []
for i in range(n):
if i < m:
ans.append(k[i])
print(ans[-1], end=" ")
else:
ans.append(ans[i - m] + k[i])
print(ans[-1], end=" ") | 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 ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR ... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | n, m = map(int, input().split())
lst = [*map(int, input().split())]
lst.sort()
item, res, s = lst[:m], [], 0
app = res.append
for i, x in enumerate(item):
s += x
res.append(s)
append = item.append
for i, x in enumerate(lst[m:]):
append(item[i] + x)
app(res[-1] + item[-1])
print(*res) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR LIST NUMBER ASSIGN VAR VAR FOR VAR VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR FOR VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | N, M = map(int, input().split())
candy = list(map(int, input().split()))
ans = [0] * (N + 1)
candy.sort()
for i in range(N):
if i > 0:
candy[i] += candy[i - 1]
ans[i] = candy[i]
if i - M >= 0:
ans[i] += ans[i - M]
print(ans[i], end=" ") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR IF BIN_OP VAR VAR NUMBER VAR VAR VAR... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | n, m = tuple(map(int, input().split()))
lis = list(map(int, input().split()))
lis.sort(reverse=True)
acc = [sum(lis)]
for i in range(1, n):
acc.append(acc[-1] - lis[i - 1])
if n == m:
print(*acc[::-1])
exit()
ans = acc[n - 1 : n - m - 1 : -1]
for i in range(m, n):
ans.append(acc[-i - 1] + ans[i - m])
pr... | 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 EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR ... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | import sys
from itertools import accumulate
input = sys.stdin.readline
n, m = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
S = list(accumulate(A))
ANS = S[:m]
for i in range(m, n):
ANS.append(ANS[i - m] + S[i])
print(" ".join(map(str, ANS))) | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | n, m = map(int, input().split())
a = sorted(map(int, input().split()))
l = [a[0]]
y = [0] * m
y[0] = a[0]
for i in range(1, m):
l.append(l[-1] + a[i])
y[i] = a[i]
for i in range(m, n):
x = l[-1]
y[i % m] += a[i]
if i - m >= 0:
x += y[i % m]
l.append(x)
print(*l) | 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 LIST VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR VAR VAR VAR FOR V... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
b = list()
b.append(a[0])
try:
a[m] += a[0]
except:
c = 0
sn = a[0]
for i in range(1, n):
r = a[i]
try:
a[i + m] += r
except:
c = 0
sn += r
b.append(sn)
for i in range(n):
print(b[i], end=" ") | 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 ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR VAR BIN_OP ... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | def sol():
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)
sum = []
ts = 0
for i in range(n):
ts += a[i]
sum.append(ts)
dp = sum[:m]
for i in range(m, n):
dp.append(dp[i - m] + sum[i])
for i in range(n - 1):
print(dp[... | 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 FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | n, m = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
a.sort()
a_cs = [0] * n
a_cs[0] = a[0]
for i in range(1, n):
a_cs[i] = a_cs[i - 1] + a[i]
dp = [0] * (n + 1)
for i in range(1, n + 1):
dp[i] = a_cs[i - 1] + dp[max(i - m, 0)]
print(" ".join(map(str, dp[1:]))) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | from sys import stdin
input = stdin.readline
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = [0] * 200005
sum = [0] * 200005
for i in range(1, n + 1):
sum[i] = sum[i - 1] + a[i - 1]
ans[i] = ans[max(i - m, 0)] + sum[i]
print(*ans[1 : n + 1]) | ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMB... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
g = [a[i::m] for i in range(m)]
for i in range(m):
for j in range(1, len(g[i])):
g[i][j] += g[i][j - 1]
ans = [0]
for i in range(n):
ans.append(ans[-1] + g[i % m][i // m])
print(*ans[1:]) | 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 ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR LIST N... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | import sys
nm = sys.stdin.readline().split(" ")
m = int(nm[1])
sweets = sorted(map(int, sys.stdin.readline().split(" ")))
print(sweets[0], end=" ")
toAdd = [0] * m
toAdd[0] = last = sweets[0]
for k in range(1, len(sweets)):
toAdd[k % m] += sweets[k]
last += toAdd[k % m]
print(last, end=" ") | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR NUMBER STRING ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR BIN_OP... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | a = input().split(" ")
n = int(a[0])
m = int(a[1])
s = []
l = input().split(" ")
for i in range(n):
x = int(l[i])
s.append(x)
s.sort()
d = [0] * m
sum = 0
ans = []
for i in range(n):
sum = sum + s[i] + d[i % m]
ans.append(sum)
d[i % m] += s[i]
print(" ".join([str(i) for i in ans])) | ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NU... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | n, m = [int(i) for i in input().split()]
d = [int(i) for i in input().split()]
d.sort()
ans = []
tot = 0
psum = [0] * m
for i in range(n):
md = i % m
psum[md] += d[i]
tot += psum[md]
ans.append(tot)
print(" ".join(map(str, ans))) | 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 EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CA... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | def get_sums(n, a):
sums = [0] * n
sums[0] = a[0]
for index in range(1, n):
sums[index] = sums[index - 1] + a[index]
return sums
def get_partial_sums(n, a, m):
partial_sums = [0] * n
partial_sums[0] = a[0]
for i in range(1, n):
if i < m:
partial_sums[i] = partia... | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | n, m = map(int, input().split())
a = [int(s) for s in input().split()]
a.sort()
b = [(0) for i in range(m)]
res = []
x = 0
for k in range(n):
b[k % m] += a[k]
x += b[k % m]
res.append(str(x))
print(" ".join(res)) | ASSIGN VAR VAR FUNC_CALL 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 VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
pref_sum = [(0) for i in range(n + 1)]
for i in range(1, n + 1):
pref_sum[i] += a[i - 1] + pref_sum[i - 1]
pr_s_m = [(0) for i in range(n + 1)]
pr_s_m1 = [(0) for i in range(n + 1)]
for i in range(0, n):
pr_s_m[i] = pr_s_m[i - m]
p... | ASSIGN 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 NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR ... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | n, m = map(int, input().split())
l = list(map(int, input().split()))
d = dict()
for i in range(m):
d[i] = 0
l.sort()
ls = []
ss = 0
for i in range(n):
y = i % m
xs = d[y]
ss += xs + l[i]
ls.append(ss)
d[y] += l[i]
print(*ls) | 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 FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | n, m = map(int, input().split())
a = [0] + list(map(int, input().split()))
a.sort()
price = 0
increase = [0] * (m + 1)
p = 1
for i in range(1, n + 1):
price += a[i]
if i > m:
foc = i % m
if foc == 0:
foc = m
increase[foc] += a[i - m]
price += increase[foc]
print(p... | ASSIGN 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 EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR VAR IF VAR VAR ASSI... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | def f(a, k):
ans = [0] * len(a)
a = sorted(a)
tl = 0
pref = [0] * (len(a) + 1)
for i in range(0, len(a)):
pref[i] = pref[i - 1] + a[i]
tl += 1
if tl > k:
ans[i] = pref[i] + ans[i - k]
else:
ans[i] = pref[i]
return ans
n, m = map(int, inpu... | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | n, m = list(map(int, input().split()))
arr = list(map(int, input().split()))
arr.sort()
ans = []
for i in range(n):
if i == 0:
ans.append(arr[0])
else:
ans.append(ans[-1] + arr[i])
final = [(0) for i in range(n)]
for i in range(n):
if i < m:
final[i] += ans[i]
else:
final... | 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 EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL ... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | import sys
input = sys.stdin.buffer.readline
n, m = map(int, input().split())
ls = list(map(int, input().split()))
ls.sort()
sm = []
for i in range(n):
sm.append(sm[-1] + ls[i] if sm else ls[i])
sw = [0] * n
for i in range(n):
sw[i] = (sw[i - m] if i - m >= 0 else 0) + sm[i]
print(" ".join(map(str, sw)) + "\n"... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR ... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | def main():
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
p = [0] * n
b = [0] * n
p[0] = a[0]
for i in range(1, n):
p[i] = a[i] + p[i - 1]
for i in range(n):
b[i] = p[i]
if i >= m:
b[i] += b[i - m]
print(*b)
retu... | 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 EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR BIN_... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | n, m = [int(x) for x in input().split()]
a = list(sorted([int(x) for x in input().split()]))
res = [0] * n
ma = [0] * m
res[0] = a[0]
ma[0] = a[0]
for k in range(1, n):
ma[k % m] += a[k]
res[k] = res[k - 1] + ma[k % m]
print(*res) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR BIN_OP VAR ... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | MOD = 1000000007
ii = lambda: int(input())
si = lambda: input()
dgl = lambda: list(map(int, input()))
f = lambda: map(int, input().split())
il = lambda: list(map(int, input().split()))
ls = lambda: list(input())
n, m = f()
l = sorted(il())
dpm = [0] * n
dpsm = [0] * n
dpm[0] = l[0]
dpsm[0] = l[0]
for i in range(1, m):
... | ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CA... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | def solve(n, m, ar):
ar = sorted(ar)
ans = [0] * n
cursum = 0
for i in range(n):
cursum += ar[i]
ans[i] = cursum
if i >= m:
ans[i] += ans[i - m]
print(" ".join(map(str, ans)))
n, m = map(int, input().split())
ar = list(map(int, input().split()))
solve(n, m, ar) | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR IF VAR VAR VAR VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | n, m = map(int, input().split())
l = [int(x) for x in input().split()]
l.sort()
dp = [0] * n
for i in range(n):
dp[i] = l[i]
if i >= m:
dp[i] += dp[i - m]
t = 0
ans = []
for i in dp:
t += i
ans.append(t)
print(*ans) | ASSIGN VAR VAR FUNC_CALL 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 BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR IF VAR VAR VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR VAR VAR EXPR FUNC_CA... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | n_m = list(map(int, input().split(" ")))
n, m = n_m
arr = list(map(int, input().split(" ")))
arr.sort()
dic = {}
dic[1] = arr[0]
prev_sum = 0
for i in range(1, n):
if i + 1 <= m:
dic[i + 1] = dic[i] + arr[i]
elif i + 1 > m and i + 1 <= 2 * m:
if prev_sum:
prev_sum -= arr[i - m]
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR NUMBER VAR ASSIGN VAR BI... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | from sys import stdin
def input():
return stdin.readline().strip()
n, m = map(int, input().split())
sweets = list(map(int, input().split()))
sweets.sort()
K = [0] * (n + 1)
add = 0
for i in range(1, n + 1):
K[i] += K[i - 1] + sweets[i - 1]
for i in range(m, n + 1):
K[i] += K[i - m]
print(*K[1:]) | FUNC_DEF RETURN FUNC_CALL 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 ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR BIN_OP VAR BIN_O... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | n, m = tuple(map(int, input().split()))
a = list(map(int, input().split()))
a = sorted(a)
t = 1
prefix = [0] * n
result = [0] * n
for i in range(m):
for j in range(i, n, m):
if j < m:
prefix[j] = a[i]
else:
prefix[j] = prefix[j - m] + a[j]
for i in range(n):
if i == 0:
... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR IF VAR ... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | import sys
n, m = map(int, sys.stdin.readline().split())
a = list(map(int, sys.stdin.readline().split()))
a.sort()
val = list(a)
for i in range(1, n):
val[i] += val[i - 1]
ans = list(val)
for i in range(m, n):
ans[i] += ans[i - m]
print(*ans) | IMPORT 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 ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR BIN_OP ... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | t = lambda: map(int, input().split())
n, m = t()
a = sorted(t())
x, s = [0] * n, 0
for i in range(n):
s += a[i]
x[i] = s if i < m else s + x[i - m]
print(*x) | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP LIST NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | s = input()
s1 = s.split()
k = int(s1[1])
s = input()
s1 = s.split()
l = [int(i) for i in s1]
l.sort()
dp = [(0) for i in range(len(l))]
dp[0] = l[0]
pre = [(0) for i in range(len(l))]
pre[0] = l[0]
for i in range(1, len(l)):
pre[i] = pre[i - 1] + l[i]
for i in range(1, len(l)):
if i >= k:
dp[i] = dp[i ... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | n, m = [int(i) for i in input().split()]
lst = [int(i) for i in input().split()]
lst.sort()
arr1, arr2 = [0] * 200001, [-1] * 200001
arr2[0], s = 0, 0
for i in range(len(lst)):
s += lst[i]
arr1[i + 1] = s
def eat(n):
if arr2[n] > 0:
return arr2[n]
if n < m:
arr2[n] = arr1[n]
re... | 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 EXPR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP LIST NUMBER NUMBER BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | n, m = map(int, input().split())
lt = [int(x) for x in input().split()]
lt.sort()
pref = [(0) for _ in range(n)]
pref[0] = lt[0]
for i in range(1, n):
pref[i] = lt[i] + pref[i - 1]
pref = [0] + pref
ans = [(0) for _ in range(n + 1)]
for i in range(1, m + 1):
ans[i] = pref[i]
for i in range(m + 1, n + 1):
an... | ASSIGN VAR VAR FUNC_CALL 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 VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | n, m = map(int, input().split())
aa = [int(i) for i in input().split()]
aa = sorted(aa)
k = [0] * m
ans = []
ss = 0
for i in range(0, n):
k[i % m] += aa[i]
ss += k[i % m]
ans.append(ss)
print(*ans) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR EXP... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | numbers = list(map(int, input().split()))
n = numbers[0]
m = numbers[1]
sweets = list(map(int, input().split()))
sweets.sort()
sweets = [0] + sweets
rez = [0] * n
t = 0
penalty = [0] * m
for i in range(1, n + 1):
x = i % m
penalty[x] = penalty[x] + sweets[i]
t = t + penalty[x]
rez[i - 1] = t
for i in ra... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | ints = lambda: [int(x) for x in input().split()]
def main():
while 1:
try:
n, m = ints()
except EOFError:
break
a = sorted(ints())
z = [0] * n
for k in range(n):
z[k] = a[k] + (0 if k < m else z[k - m])
x = [0] * (n + 1)
f... | ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF WHILE NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR VAR NUMBER VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMB... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | R = lambda: map(int, input().split())
n, m = R()
nums = sorted(R())
dp = [0] * (n + 1)
acc = 0
for i, num in enumerate(nums):
acc += num
dp[i] = acc + (dp[i - m] if i >= m else 0)
print(dp[i], end=" ") | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR STRING |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | n, m = map(int, input().split())
l = [*map(int, input().split())]
array = l.copy()
array.sort()
array1 = [(0) for i in range(n + 10)]
array2 = array1.copy()
ans = 0
for i in range(n):
array1[i] += array[i]
array1[i] += array2[i % m]
array2[i % m] += array[i]
ans += array1[i]
print(ans, end=" ") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR VAR BIN_OP VAR... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | n, m = map(int, input().split())
a = [int(x) for x in input().split()]
a.append(0)
a.sort()
for i in range(m, n + 1):
a[i] += a[i - m]
for i in range(1, n + 1):
a[i] += a[i - 1]
print(a[i], end=" ") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CAL... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | n, m = map(int, input().split(" "))
a = sorted(list(map(int, input().split())))
pref = [0] * n
pref[0] = a[0]
for i in range(1, n):
pref[i] = pref[i - 1] + a[i]
for i in range(n):
if i >= m:
pref[i] += pref[i - m]
print(*pref) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR VAR I... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | n, m = map(int, input().split())
x = list(map(int, input().split()))
dp, ans = list([0] * 200000), 0
x.sort()
for i in range(n):
if i >= m:
dp[i] += dp[i - m]
if i > 0:
dp[i] += x[i]
else:
dp[0] = x[0]
ans += dp[i]
print(ans) | 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 VAR FUNC_CALL VAR BIN_OP LIST NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR BIN_OP VAR VAR IF VAR NUMBER VAR VAR VAR VAR ASSIGN VAR NUMBER VAR... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | from itertools import accumulate
n, m = map(int, input().split())
xs = sorted([int(x) for x in input().split()])
ms = [list(accumulate(xs[i::m])) for i in range(m)]
ans = 0
i, j = 0, 0
for k in range(1, n + 1):
ans += ms[i][j]
i += 1
if i == m:
i = 0
j += 1
print(ans, end=" ") | ASSIGN VAR VAR FUNC_CALL 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 FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR VAR VAR VAR NUMBE... |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | n, m = [int(i) for i in input().split(" ")]
sweets = [int(i) for i in input().split(" ")]
sweets.sort()
track = [(0) for i in range(m)]
penalty = 0
for i in range(n):
j = i % m
track[j] += sweets[i]
penalty += track[j]
print(penalty, end=" ") | ASSIGN 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 EXPR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR STRING |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | n, m = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
for i in range(m, n):
arr[i] += arr[i - m]
for i in range(1, n):
arr[i] += arr[i - 1]
print(*arr) | 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 FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR |
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.
Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons.
Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t... | n, m = map(int, input().split())
arr = sorted(list(map(int, input().split())))
R = [0] * n
P = [0] * n
for i in range(m):
R[i] = arr[i] + (0 if i == 0 else R[i - 1])
P[i] = arr[i]
for i in range(m, n):
P[i] = arr[i] + P[i - m]
R[i] = R[i - 1] + P[i - m] + arr[i]
print(*R) | ASSIGN 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 BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.