description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
The only difference between easy and hard versions is the maximum value of $n$.
You are given a positive integer number $n$. You really love good numbers so you want to find the smallest good number greater than or equal to $n$.
The positive integer is called good if it can be represented as a sum of distinct powers ... | import sys
input = sys.stdin.readline
I = lambda: list(map(int, input().split()))
(t,) = I()
for _ in range(t):
(n,) = I()
k = ""
x = n
while x:
k += str(x % 3)
x //= 3
k = k[::-1]
ix = 0
if "2" not in k:
print(n)
else:
p = k.find("2")
if p == 0 o... | IMPORT ASSIGN VAR 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 FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR VAR WHILE VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER IF STRING VAR EXPR FUNC_C... |
A car number in Berland consists of exactly n digits. A number is called beautiful if it has at least k equal digits. Vasya wants to change the digits in his car's number so that the number became beautiful. To replace one of n digits Vasya has to pay the sum of money, equal to the absolute difference between the old d... | n, k = map(int, input().split())
s = input()
Cnt = [0] * 10
for item in s:
Cnt[int(item)] += 1
Ans = []
H = []
for i in range(0, 10):
S = list(map(int, s))
e = Cnt[i]
j = 1
C = [i]
while e < k:
if i + j < 10:
e += Cnt[i + j]
C.append(i + j)
if i - j >= 0 a... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER ASSIGN V... |
A car number in Berland consists of exactly n digits. A number is called beautiful if it has at least k equal digits. Vasya wants to change the digits in his car's number so that the number became beautiful. To replace one of n digits Vasya has to pay the sum of money, equal to the absolute difference between the old d... | n, k = map(int, input().split())
s = list(map(int, input()))
e = list(enumerate(s))
min_cost = 9 * n
a = [9] * n
for j in range(10):
r = s[:]
cost = 0
for x, y in sorted(
e, key=lambda t: (abs(t[1] - j), -t[1], t[0] * (-1) ** (j > t[1]))
)[:k]:
r[x] = j
cost += abs(y - j)
if ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR FUNC_CAL... |
A car number in Berland consists of exactly n digits. A number is called beautiful if it has at least k equal digits. Vasya wants to change the digits in his car's number so that the number became beautiful. To replace one of n digits Vasya has to pay the sum of money, equal to the absolute difference between the old d... | import sys
n, k = map(int, input().split())
s = list(input())
anss = ""
minn = sys.maxsize
for i in range(10):
d = []
s1 = s[:]
for j in range(n):
d.append([abs(int(s[j]) - i), j - n if int(s[j]) >= i else n - j])
d.sort()
c = 0
for k1 in range(k):
c += d[k1][0]
s1[n - a... | IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR B... |
A car number in Berland consists of exactly n digits. A number is called beautiful if it has at least k equal digits. Vasya wants to change the digits in his car's number so that the number became beautiful. To replace one of n digits Vasya has to pay the sum of money, equal to the absolute difference between the old d... | from sys import stdin
def get_freq(string):
freq = [0] * 10
for i in string:
freq[ord(i) - ord("0")] += 1
return freq
def print_string(cstring, marr):
aux = []
for mark in marr:
string = cstring[:]
num = str(mark)
require = k - freq[mark]
diff = 1
... | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING NUMBER RETURN VAR FUNC_DEF ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VA... |
A car number in Berland consists of exactly n digits. A number is called beautiful if it has at least k equal digits. Vasya wants to change the digits in his car's number so that the number became beautiful. To replace one of n digits Vasya has to pay the sum of money, equal to the absolute difference between the old d... | n, k = map(int, input().split())
p = {i: (0) for i in "0123456789"}
t, s = input(), 10 * n
for i in t:
p[i] += 1
p = [p[i] for i in "0123456789"]
for i in range(0, 10):
a, d, b = p[i], 1, 0
while a < k and d < 10:
j = i + d
if j < 10:
if a + p[j] > k:
b += d * (k ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR STRING ASSIGN VAR VAR FUNC_CALL VAR BIN_OP NUMBER VAR FOR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR STRING FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR VAR VAR VAR NUMBER NUMBER WHILE VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VA... |
You are given an undirected unweighted graph consisting of $n$ vertices and $m$ edges (which represents the map of Bertown) and the array of prices $p$ of length $m$. It is guaranteed that there is a path between each pair of vertices (districts).
Mike has planned a trip from the vertex (district) $a$ to the vertex (d... | from sys import stdin
input = stdin.readline
def bfs(g, r):
it = -1
p = [0] * len(g)
q = [r]
v = [0] * len(g)
while it < len(q) - 1:
it += 1
v[q[it]] = 1
for i in range(len(g[q[it]])):
if v[g[q[it]][i]] == 0:
v[g[q[it]][i]] = 1
q... | ASSIGN VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR LIST VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR VAR VAR VAR NUMBER ASSIG... |
You are given an undirected unweighted graph consisting of $n$ vertices and $m$ edges (which represents the map of Bertown) and the array of prices $p$ of length $m$. It is guaranteed that there is a path between each pair of vertices (districts).
Mike has planned a trip from the vertex (district) $a$ to the vertex (d... | import sys
input = sys.stdin.buffer.readline
for f in range(int(input())):
n, m, x, y, z = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
x -= 1
y -= 1
z -= 1
neig = [0] * n
dx = [-1] * n
dy = [-1] * n
dz = [-1] * n
dx[x] = 0
dy[y] = 0
dz[z] =... | IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUM... |
You are given an undirected unweighted graph consisting of $n$ vertices and $m$ edges (which represents the map of Bertown) and the array of prices $p$ of length $m$. It is guaranteed that there is a path between each pair of vertices (districts).
Mike has planned a trip from the vertex (district) $a$ to the vertex (d... | import sys
input = sys.stdin.readline
INF = 10**16
Q = int(input())
Query = []
for _ in range(Q):
N, M, a, b, c = map(int, input().split())
P = list(map(int, input().split()))
graph = [[] for _ in range(N)]
for _ in range(M):
u, v = map(int, input().split())
graph[u - 1].append(v - 1)
... | IMPORT ASSIGN VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUN... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | def solve():
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
summ = sum(a)
if summ <= k:
print(0)
return
ans = summ - k
summ -= a[0]
for i in range(1, n):
summ -= a[n - i]
x = max(a[0] + (summ - k + i) // (i + 1), 0)
a... | 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 FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR BIN_OP VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR BIN_OP VAR VA... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | import sys
input = sys.stdin.readline
def inp():
return int(input())
def st():
return input().rstrip("\n")
def lis():
return list(map(int, input().split()))
def ma():
return map(int, input().split())
t = inp()
while t:
t -= 1
n, k = ma()
a = lis()
a.sort()
cur = sum(a) - a... | IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR AS... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | from sys import stdin, stdout
input = stdin.readline
def output(answer):
stdout.write("{}\n".format(answer))
for _ in range(int(input())):
n, k = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
curr_sum = sum(arr)
if curr_sum <= k:
output(0)
contin... | ASSIGN VAR VAR FUNC_DEF EXPR FUNC_CALL VAR FUNC_CALL STRING VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMB... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | import sys
input = sys.stdin.readline
for _ in range(int(input())):
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
tot = sum(a) - len(a) * a[0]
osum = sum(a)
ans = max(0, osum - k)
if n == 1:
print(ans)
continue
for i in range(1, n):
... | IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSI... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if n == 1:
ans = max(0, a[0] - k)
else:
y = []
for i in range(n - 1, 0, -1):
y.append(a[i] - a[0])
s = ... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR ASSIGN VAR LIST FOR VA... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | for _ in range(int(input())):
n, k = map(int, input().split())
a = [int(x) for x in input().split()]
a.sort()
ans = 10**18
s = sum(a) - a[0]
for y in range(n):
need_min = (k - s) // (y + 1)
x = max(0, a[0] - need_min)
ans = min(ans, x + y)
s -= a[-y - 1]
print... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | t = int(input())
for i in range(t):
n, k = map(int, input().split())
arr = list(map(int, input().split()))
prefix = [(0) for i in range(n)]
arr.sort()
prefix[0] = 0
ans = float("inf")
for i in range(1, n):
prefix[i] = arr[i] + prefix[i - 1]
for i in range(n - 1, -1, -1):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CA... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | t = int(input())
for i in range(t):
n, k = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
sm = sum(arr)
if sm <= k:
print(0)
else:
mn = sm - k
x = arr[-1]
cnt = 2
for i in range(2, n):
arr[i] += arr[i - 1]
fo... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR NUMBE... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | def better_floor(a, b):
c = a // b
while c * b > a:
c -= 1
return c
def solve(a, n, k):
result = 1e18
a.sort()
pSum = [a[0]]
for ii in range(1, len(a)):
pSum.append(pSum[ii - 1] + a[ii])
for y in range(len(a)):
x = a[0] - better_floor(k - pSum[n - 1 - y] + a[0],... | FUNC_DEF ASSIGN VAR BIN_OP VAR VAR WHILE BIN_OP VAR VAR VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR ... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | t = int(input())
for _ in range(t):
n, k = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
tmpTarget = sum(arr)
arrIfSet = [None for _ in range(n + 1)]
arrIfSet[-1] = tmpTarget
for i in range(n - 1, -1, -1):
tmpTarget -= arr[i] - arr[0]
arrIfSet[i] ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NONE VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FOR VAR F... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | def answer(arr, n, k):
arr.sort()
sum1 = sum(arr)
if sum1 <= k:
return 0
minimum = sum1 - k
ans = minimum
total = 0
for i in range(n - 1, 0, -1):
total += arr[i] - arr[0]
rem = minimum - total
if rem <= 0:
ans = min(ans, n - i)
return a... | FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR RETURN NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR RETURN VAR ... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | for _ in range(int(input())):
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
a = A[0]
if len(A) == 1:
print(max(0, a - K))
continue
S = [a]
for v in A[1:]:
S.append(S[-1] + v)
ans = 1 << 60
for l in range(N):
x = max(0, -... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR ASSIGN VAR LIST VAR FO... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | from sys import stdin
for _ in range(int(stdin.readline())):
n, k = map(int, stdin.readline().split())
arr = list(map(int, stdin.readline().split()))
arr.sort()
m = arr[0]
t = 0
for i in arr[1:]:
t += i
ans = m + t - k
if ans < 0:
ans = 0
sub = 0
j = n - 1
fo... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF VAR NUMBER ASSIGN VA... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | t = int(input())
while t:
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
pre = [i for i in a]
for i in range(1, n):
pre[i] += pre[i - 1]
if pre[-1] < k:
print(0)
else:
ans = pre[-1] - k
i = n - 1
cnt = 0
while i >... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE 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 VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBE... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | _ = int(input())
for __ in range(_):
n, k = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
li = arr[0]
s = sum(arr)
if s <= k:
print(0)
continue
if n == 1:
print(li - k)
continue
avg = k // n
wyn = s - k
tmp_wyn = 10**18... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | for _ in range(int(input())):
n, k = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
if sum(arr) <= k:
print(0)
else:
ans = 10**20
pref = [0] * n
pref[0] = arr[0]
for i in range(1, len(arr)):
pref[i] = pref[i - 1] + arr[i... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | R = lambda: map(int, input().split())
(t,) = R()
while t:
t -= 1
n, k = R()
a = sorted(R())
r = 2000000000.0
for x in a:
k -= x
n -= 1
r = min(r, n - min(0, k - a[0] * n) // (n + 1))
print(r) | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR BIN_OP FUNC_CALL VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER VAR BIN... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | for _ in range(int(input())):
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
total = sum(a)
l = []
for i in range(1, n):
l.append(a[i] - a[0])
t = 10**18
ans = 0
while len(l) > 0 and total > k:
t = min(t, ans + (total - k + ans) //... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR 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 FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR V... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | def udiv(a, b):
if a % b == 0:
return a // b
else:
return a // b + 1
for kfjdkf in range(int(input())):
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
sum = 0
for i in a:
sum += i
ans = 0
i = n - 1
mn = a[0]
if su... | FUNC_DEF IF BIN_OP VAR VAR NUMBER RETURN BIN_OP VAR VAR RETURN BIN_OP BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR 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 NUMBER FOR... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | import sys
int1 = lambda x: int(x) - 1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II():
return int(sys.stdin.readline())
def LI():
return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number):
return [LI() for... | IMPORT ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR STRING VAR ASSIGN VAR FUNC_CALL VAR VAR STRING STRING VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | import sys
def func():
n, k = map(int, input().split())
l = list(map(int, input().split()))
sm = sum(l)
l.sort()
s = []
for i in range(1, n):
s.append(l[i] - l[0])
count = 0
mn = sys.maxsize
while len(s) and sm > k:
mn = min(mn, count + (sm - k + count) // (count + ... | IMPORT 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 EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | import sys
input = sys.stdin.readline
def inp():
return int(input())
def st():
return input().rstrip("\n")
def lis():
return list(map(int, input().split()))
def ma():
return map(int, input().split())
t = inp()
while t:
t -= 1
n, k = ma()
a = lis()
a.sort()
cur = sum(a) - a... | IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR AS... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | for _ in range(int(input())):
n, k = map(int, input().split())
l = list(map(int, input().split()))
l = sorted(l)
pre = [0] * (n + 1)
for i in range(1, n):
pre[i] = pre[i - 1] + l[i]
ans = int(1000000000000000.0 + 1)
for i in range(n - 1, -1, -1):
s = pre[i]
cnt = n - ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | from sys import stdin
input = stdin.readline
def get(this):
l, h = 0, n - 1
while l <= h:
mid = (l + h) // 2
value = prefix[mid] + (n - mid) * this
if value > k:
h = mid - 1
else:
ans = n - mid - 1
l = mid + 1
return ans
def answer(m):... | ASSIGN VAR VAR FUNC_DEF ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL ... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | for _ in range(int(input())):
n, k = map(int, input().split())
a_list = [int(i) for i in input().split()]
a_list.sort(reverse=True)
a_len = len(a_list)
a_sum = sum(a_list)
a_min = a_list[-1]
awn = max((a_sum - k, 0))
a = a_sum - k
i0 = 0
for i in range(n - 1):
i0 += 1
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASS... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | I = lambda: [*map(int, input().split())]
for _ in [0] * I()[0]:
n, k = I()
a = sorted(I())
k += a[0]
b = 1 << 50
for i in range(n):
k -= a[i]
b = min(max(0, a[0] - k // (n - i)) + n - i - 1, b)
print(b) | ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR BIN_OP LIST NUMBER FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP FUNC_CALL VAR N... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | t = int(input())
def solve(n, k, a):
a = sorted(a)
s = sum(a)
if s <= k:
return 0
if n == 1:
return s - k
mn = a[0]
rs = s - mn
ans = s - k
for i in range(n - 1, 0, -1):
rs -= a[i]
c = 1 + n - i
nmn = (k - rs) // c
ans = min(ans, c - 1 + ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR RETURN NUMBER IF VAR NUMBER RETURN BIN_OP VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER VAR VAR VAR ASSIGN VAR BI... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | for i in range(int(input())):
n, m = map(int, input().split())
arr = list(map(int, input().split()))
x = sum(arr)
cnt = 0
arr.sort()
stack = []
minn = 1000000000000000007
for i in range(1, n):
stack.append(arr[i] - arr[0])
while stack and x > m:
minn = min(minn, cnt +... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CAL... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | for _ in range(int(input())):
n, maxx = [int(i) for i in input().split()]
arr = [int(i) for i in input().split()]
summ = sum(arr)
if summ <= maxx:
print(0)
continue
arr.sort()
summ = 0
prefix = [0]
for i in range(1, n):
summ += arr[i]
prefix.append(summ)
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMB... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | def solve(n, k, arr):
if n == 1:
return 0 if arr[0] <= k else arr[0] - k
arr.sort()
S = sum(arr)
a0 = arr[0]
if S <= k:
return 0
prefixSum = [0] * n
curr = 0
for i in range(n):
curr += arr[i]
prefixSum[i] = curr
ans = S - k
for i in range(n - 1, 0,... | FUNC_DEF IF VAR NUMBER RETURN VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER IF VAR VAR RETURN NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CAL... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | import sys
I = lambda: [*map(int, sys.stdin.readline().split())]
(t,) = I()
for _ in range(t):
n, k = I()
a = I()
a.sort()
orig = a[0]
partial = [0]
for i in range(1, n):
partial.append(partial[-1] + a[i])
best = float("inf")
for i in range(n):
need = max(0, orig - (k - ... | IMPORT ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR ASSIGN V... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | for _ in range(int(input())):
n, k = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
minVal = arr[0]
s = sum(arr) - minVal
res = max(0, minVal + s - k)
for i in range(n - 1, 0, -1):
s -= arr[i]
target = (k - s) // (1 + n - i)
if target >= mi... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR VAR FOR VAR... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | T = int(input())
for t in range(T):
n, k = [int(i) for i in input().split()]
arr = [int(i) for i in input().split()]
summ = sum(arr)
arr.sort()
stack = []
for i in range(1, n):
stack.append(arr[i] - arr[0])
count = 0
top = n - 2
mnm = 100000000000000000000000
while len(st... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR NU... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | import sys
def solve():
n, k = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
su = sum(arr)
if n == 1:
return max(0, su - k)
if su <= k:
return 0
ans = 10**18
if arr[0] * n <= k:
t = 0
for i in range(n - 1, -1, -1):
... | IMPORT 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 FUNC_CALL VAR VAR IF VAR NUMBER RETURN FUNC_CALL VAR NUMBER BIN_OP VAR VAR IF VAR VAR RETURN NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER IF BIN_OP VAR NUMB... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | def solve(n, k, arr):
s = sum(arr)
if s <= k:
return 0
if n == 1:
return s - k
arr.sort()
stack = [(arr[i] - arr[0]) for i in range(1, n)]
ans = 0
m = 10**18
while stack and s > k:
z = ans + (s - k + ans) // (ans + 1)
m = min(m, z)
s -= stack[-1]
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR RETURN NUMBER IF VAR NUMBER RETURN BIN_OP VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER WHILE VAR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NU... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | t = int(input())
while t:
t -= 1
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
a1 = []
s1 = 0
for i in range(n):
s1 += a[i]
a1.append(s1)
s = sum(a)
ans = []
for i in range(n):
if (i * a[0] + a1[n - i - 1] - k) % (i + 1) == ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER 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 ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL V... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | def solve():
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
smallest = a.pop()
n -= 1
sums = [0] * (n + 1)
for i in range(n - 1, -1, -1):
sums[i] = sums[i + 1] + a[i]
ans = int(1e30)
for i in range(n + 1):
level = (k - sums[i... | 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 NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR BIN_OP V... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | def solve(n, k, a):
a = sorted(a)
s = sum(a)
if s <= k:
return 0
best = s - k
rest = 0
for cols in range(1, n):
rest += a[n - cols] - a[0]
if rest >= s - k:
return min(best, cols)
x = (s - k - rest + cols) // (cols + 1)
best = min(best, x + col... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR RETURN NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR BIN_OP VAR BIN_OP VAR VAR VAR NUMBER IF VAR BIN_OP VAR VAR RETURN FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR BIN_... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | for _ in range(int(input())):
n, k = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
m = l[0]
l[0] = 0
for i in range(1, n):
l[i] += l[i - 1]
ans = float("inf")
for i in range(n):
a = (k - l[i]) // (n - i)
if a >= m:
ans = min(an... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_C... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | import sys
from sys import stdin
tt = int(stdin.readline())
ANS = []
for loop in range(tt):
n, k = map(int, stdin.readline().split())
a = list(map(int, stdin.readline().split()))
a.sort()
nmov = 1
nsum = sum(a)
ans = max(0, nsum - k)
for i in range(n - 1, 0, -1):
nsum = nsum - a[i] ... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | t = int(input())
for i in range(t):
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if n == 1:
print(max(0, sum(a) - k))
continue
if sum(a) <= k:
print(0)
continue
diff = sum(a) - k
pref = [0] * (n + 1)
for i in range(n):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR VAR EXPR... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | def solve(k, a):
diff = -k
for ai in a:
diff += ai
if diff <= 0:
return 0
diffList = [(ai - a[0]) for ai in a]
postSum = [(0) for _ in range(len(a))]
postSum[len(a) - 1] = diffList[len(a) - 1]
for i in reversed(range(len(a) - 1)):
postSum[i] = diffList[i] + postSum[i ... | FUNC_DEF ASSIGN VAR VAR FOR VAR VAR VAR VAR IF VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | def solve():
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
s = sum(a)
ans = 10**18
prefix = [0]
for i in range(1, n):
prefix.append(prefix[i - 1] + a[i])
for i in range(n):
m = (k - prefix[i]) // (n - i)
if m < a[0]:
ans... | 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 FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR... |
You are given an integer array $a_1, a_2, \dots, a_n$ and integer $k$.
In one step you can
either choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);
or choose two indices $i$ and $j$ and set $a_i$ equal to $a_j$ (make $a_i = a_j$).
What is the minimum number of steps you need to make the sum of... | from sys import stdin
def read_input():
n, k = map(int, stdin.readline().split())
a = list(map(int, stdin.readline().split()))
return n, k, a
def solve(n, k, a):
if n == 1:
return max(a[0] - k, 0)
answer = 10**10
a.sort(reverse=True)
s = [a[0] - a[-1]]
for ai in a[1:-1]:
... | 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 RETURN VAR VAR VAR FUNC_DEF IF VAR NUMBER RETURN FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST BIN_OP VAR NUMBER VAR... |
Read problem statement in Mandarin chinese and Vietnamese.
Suzumo is the coach of the ChefLand OI team. Physical condition is very important in any olympiad, so he wants to make the children run a bit as a warmup.
The team consists of $N$ children numbered $1$ through $N$ standing at some positions on the $x$-axis. ... | def check(mid, arr):
pr = 0
n = len(arr)
an = [0]
for i in range(1, n):
x1 = arr[i - 1][0]
x2 = arr[i][0]
v1 = arr[i - 1][1]
v2 = arr[i][1]
if pr == 0:
if x2 - x1 >= mid * (v2 - v1):
pr = 0
else:
pr = 1
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR NUMBER IF VAR NUMBER IF BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ... |
Read problem statement in Mandarin chinese and Vietnamese.
Suzumo is the coach of the ChefLand OI team. Physical condition is very important in any olympiad, so he wants to make the children run a bit as a warmup.
The team consists of $N$ children numbered $1$ through $N$ standing at some positions on the $x$-axis. ... | def optimal_assignment(cs):
PREC = 1e-10
cs.sort()
lo, hi = 0.0, 2000000000.0
if has_solution(hi, cs):
return -1
for _ in range(1000):
mid = lo + (hi - lo) / 2
if has_solution(mid, cs):
lo = mid
else:
hi = mid
if hi - lo < PREC:
... | FUNC_DEF ASSIGN VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER IF FUNC_CALL VAR VAR VAR RETURN NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR IF BIN_OP VAR VAR VAR RETURN BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER FU... |
Read problem statement in Mandarin chinese and Vietnamese.
Suzumo is the coach of the ChefLand OI team. Physical condition is very important in any olympiad, so he wants to make the children run a bit as a warmup.
The team consists of $N$ children numbered $1$ through $N$ standing at some positions on the $x$-axis. ... | for query in range(int(input())):
n = int(input())
child = []
for i in range(n):
child.append([int(v) for v in input().split()])
child.sort()
d = [float("inf"), float("inf")]
for i in range(1, n):
if child[i][1] <= child[i - 1][1]:
left_left = d[0]
else:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR STRING FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR NUM... |
Read problem statement in Mandarin chinese and Vietnamese.
Suzumo is the coach of the ChefLand OI team. Physical condition is very important in any olympiad, so he wants to make the children run a bit as a warmup.
The team consists of $N$ children numbered $1$ through $N$ standing at some positions on the $x$-axis. ... | LEFT = 0
RIGHT = 1
T = int(input())
coordinates = None
def f():
ans = [[100000000000.0, 100000000000.0]]
for i in range(1, len(coordinates)):
ans.append([0, 0])
distance = coordinates[i][0] - coordinates[i - 1][0]
velocity = coordinates[i][1] + coordinates[i - 1][1]
time_taken ... | ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NONE FUNC_DEF ASSIGN VAR LIST LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER VAR B... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | n = int(input())
val = list(map(int, input().split()))
val.sort()
b_a = 10**9
for i in range(len(val) - 1):
for j in range(i + 1, len(val)):
if i == j:
continue
ans = 0
a, b = val[i], val[j]
val.pop(j)
val.pop(i)
ans = 0
for k in range(len(val)):
... | 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 NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | numPeople = int(input("")) * 2
peopleWeights = input("").split(" ")
peopleWeights = [int(x) for x in peopleWeights]
peopleWeights.sort()
minUns = 9999999999
for i in range(numPeople):
for j in range(numPeople):
if i < j:
curUns = 0
temp = peopleWeights.copy()
temp.pop(j)
... | ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR STRING NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUN... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | N = int(input())
weight = list(map(int, input().split()))
weight.sort()
mc = -1
for i in range(0, len(weight) - 1):
for x in range(i + 1, len(weight)):
count = 0
tl = weight.copy()
tl.pop(i)
tl.pop(x - 1)
for k in range(0, len(tl) - 1, 2):
count += tl[k + 1] - tl[... | 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 NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL ... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | from itertools import combinations
n = int(input())
weights = list(map(int, input().split(" ")))
weights = sorted(weights)
best = float("inf")
for first, second in combinations(range(len(weights)), 2):
result = (
weights[0:first]
+ weights[first + 1 : second]
+ weights[second + 1 : len(weig... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR ... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | n = int(input())
w = sorted([int(x) for x in input().split()])
best = 999999999999
for ex1 in range(1, n * 2):
for ex2 in range(0, ex1):
prev = -1
sum = 0
for i in range(0, n * 2):
if i == ex1 or i == ex2:
continue
if prev == -1:
prev =... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR VAR IF VAR NUM... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | n = int(input())
w = input()
weights = [int(x) for x in w.split(" ")]
weights.sort()
def get_instability(i, j):
test = (
weights[: min(i, j)]
+ weights[min(i, j) + 1 : max(i, j)]
+ weights[max(i, j) + 1 :]
)
instability = 0
for k in range(0, len(test) - 1, 2):
instabili... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER FUNC_CALL VAR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | n = int(input())
w = list(map(int, input().split()))
w.sort()
m = 10**20
for i in range(2 * n):
for j in range(i + 1, 2 * n):
v = []
s = 0
for k in range(2 * n):
if k != i and k != j:
v.append(w[k])
for k in range(0, len(v) - 1, 2):
s += v[k + ... | 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 NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP NU... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | n = int(input())
w = list(map(int, input().split()))
w.sort()
p = 2 * n
num = []
for i in range(p):
for j in range(i + 1, p):
l = []
dif = 0
for k in range(p):
if k != i and k != j:
l.append(w[k])
for x in range(1, n):
dif += l[2 * x - 1] - l[2... | 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 NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR E... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | n = int(input())
arr = list(map(int, input().split()))
arr.sort()
minIns = 0
for k in range(len(arr) - 1):
minIns += arr[k + 1] - arr[k]
for i in range(0, 2 * n):
for j in range(i + 1, 2 * n):
newArr = arr[0:i] + arr[i + 1 : j] + arr[j + 1 :]
minIns = min(
minIns, sum(newArr[k + 1] -... | 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 NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NU... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | n = int(input())
n *= 2
a = [int(i) for i in input().split()]
a.sort()
ans = 100000000
for i in range(n):
for j in range(i + 1, n):
b = a[:i] + a[i + 1 : j] + a[j + 1 :]
cr = 0
for k in range(1, len(b), 2):
cr += b[k] - b[k - 1]
ans = min(ans, cr)
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | n = int(input())
p = list(map(int, input().split()))
p.sort()
temp = 0
ans = 10**10
for i in range(2 * n):
for j in range(i + 1, 2 * n):
s = 0
for k in range(2 * n):
if k != i and k != j:
if temp == 0:
temp = p[k]
else:
... | 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 NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP ... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | n = int(input())
a = list(map(int, input().split()))
a.sort()
an = 10**9
for i in range(2 * n):
for j in range(i + 1, 2 * n):
if i == j:
continue
b = a[:]
del b[j], b[i]
c = 0
for k in range(0, 2 * n - 2, 2):
c += abs(b[k] - b[k + 1])
an = min(... | 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 NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR IF VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER FOR V... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | def strip2(nums, s1, s2):
res = [0] * (len(nums) - 2)
j = 0
for i in range(0, len(nums)):
if i == s1 or i == s2:
continue
res[j] = nums[i]
j += 1
return res
def countPairwiseDiff(nums):
total = 0
for i in range(1, len(nums), 2):
total += nums[i] - nu... | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBE... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | n = int(input())
n = n * 2
arr = sorted(map(int, input().split()))
x = arr[n - 1]
for i in range(n):
for j in range(i):
a, h, q = 0, 0, 0
while h < n:
if h == i or h == j:
pass
else:
if q % 2 == 0:
a -= arr[h]
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER WHILE VAR VAR IF VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | n = int(input())
nums = list(map(int, input().strip().split()))
weight = sorted(nums)
min_total = sum(weight)
for i in range(0, 2 * n - 1):
for j in range(i + 1, 2 * n):
nums_tmp = []
for k in range(2 * n):
if k != i and k != j:
nums_tmp.append(weight[k])
total = ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR LIST FOR VAR FUN... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | from sys import stdin, stdout
n = int(stdin.readline())
values = sorted(list(map(int, stdin.readline().split())))
ans = float("inf")
for i in range(2 * n):
for j in range(i + 1, 2 * n):
res = []
for z in range(2 * n):
if z == i or z == j:
continue
res.append(... | 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 FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR IF VAR VAR VAR... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | n = int(input())
w = list(map(int, input().split()))
w.sort()
ans = 50000
for i in range(2 * n - 1):
for j in range(i + 1, 2 * n):
tmp = 0
for k in range(2 * n):
if k < i or j < k:
if k % 2 == 0:
tmp -= w[k]
else:
tm... | 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 NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR IF VAR ... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | n = int(input())
w = list(map(int, input().split()))
w.sort()
stab1 = 0
stab2 = 0
stab3 = 0
stabmin = 99999999999999999
for i in range(2 * n):
for j in range(i + 1, 2 * n):
temp = w.copy()
del temp[i]
del temp[j - 1]
stab1 = 0
for k in range(n - 1):
stab1 += temp[... | 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 NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR ... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | n = int(input())
w = list(map(int, input().split(" ")))
w.sort()
best = sum(w)
for i in range(0, 2 * n):
for j in range(i + 1, 2 * n):
k = 0
k2 = 1
s = 0
while k2 < 2 * n:
while k == i or k == j:
k += 1
if k >= 2 * n:
break
... | 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 ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | n = int(input().strip().split()[0]) * 2
a = [int(x) for x in input().strip().split()]
a.sort()
ans = 1000000000
for i in range(n):
for j in range(i + 1, n):
idx = 0
res = 0
for k in range(n // 2 - 1):
while idx == i or idx == j:
idx += 1
r = idx + 1
... | ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP B... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | s = int(input())
n = 2 * s
a = [int(x) for x in input().split()]
a.sort()
m = 10**100
for i in range(n - 1):
for j in range(i + 1, n):
b = []
for k in range(n):
if k != i and k != j:
b.append(a[k])
summa = 0
for k in range(0, n - 3, 2):
summa =... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | from sys import stdin, stdout
def func(data, x, y):
data_c = data[:]
data_c.remove(x)
data_c.remove(y)
result = 0
for x in range(len(data_c) // 2):
result += abs(data_c[x * 2] - data_c[x * 2 + 1])
return result
n = int(stdin.readline().rstrip())
data = list(map(int, stdin.readline().... | FUNC_DEF ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP BIN_OP VAR NUMBER NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL ... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | def diff(arr):
ans = []
for i in range(1, len(arr), 2):
ans.append(arr[i] - arr[i - 1])
return sum(ans)
n = int(input())
a = list(map(int, input().split()))
a.sort()
real_ans = []
for i in range(2 * n - 1):
for j in range(i + 1, 2 * n):
b = a.copy()
b.pop(i)
b.pop(j - 1... | FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER RETURN 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 LIST FOR VAR FUNC_CALL V... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | import itertools
n = int(input())
weights = sorted([int(x) for x in input().split(" ")])
combs = itertools.combinations(weights, len(weights) - 2)
def instability(c):
return sum([abs(c[i + 1] - c[i]) for i in range(0, len(c), 2)])
min_instability = float("inf")
for c in combs:
min_instability = min(instabi... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSI... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | n = int(input())
l = list(map(int, input().split()))
nat = False
for i in range(2 * n):
for c in range(i + 1, 2 * n):
ls = l[:]
ls[i] = 0
ls[c] = 0
ls = sorted(ls)
now = 0
for loc in range(1, len(ls), 2):
now += ls[loc] - ls[loc - 1]
if now < nat o... | 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 FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | N = int(input())
Kayak = {}
for i in [int(i) for i in input().split()]:
if i in Kayak and Kayak[i] == 1:
del Kayak[i]
else:
Kayak[i] = 1
k = list(Kayak.keys())
k.sort()
def func(li):
result = 0
for i in range(int(len(li) / 2)):
result += abs(li[2 * i] - li[2 * i + 1])
retur... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR VAR VAR NUMBER VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER VA... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | diffs = int(input())
weights1 = sorted(list(map(int, input().split())))
instabilities = []
for x in range(len(weights1)):
for y in range(len(weights1) - 1):
weights2 = weights1[:]
weights2.pop(x)
weights2.pop(y)
instability = 0
for i in range(diffs - 1):
val = 999... | 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 LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUN... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | def readln():
return map(int, input().rstrip().split())
def cal(dt):
rs = 0
for i in range(len(dt) // 2):
rs += abs(dt[2 * i] - dt[2 * i + 1])
return rs
n = int(input())
data = list(readln())
data.sort()
minw = 500000
for i in range(0, 2 * n - 1):
for j in range(i + 1, 2 * n):
dt... | FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER VAR VAR BIN_OP BIN_OP NUMBER VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | def get_instability(w, x, y):
total = 0
last = -1
for i in range(len(w)):
if i == x or i == y:
continue
if last == -1:
last = w[i]
else:
total += w[i] - last
last = -1
return total
def main():
n = int(input())
weights = so... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR IF VAR NUMBER ASSIGN VAR VAR VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR NUMBER RETURN VAR FUNC_DEF 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 AS... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | n = int(input())
w = list(map(int, input().split()))
w.sort()
ans = []
for i in range(2 * n):
for j in range(i + 1, 2 * n):
m = w[0:i] + w[i + 1 : j] + w[j + 1 :]
var = sum(m[1::2]) - sum(m[::2])
ans.append(var)
print(min(ans)) | 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 LIST FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR ... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | import itertools
n = int(input())
A = list(map(int, input().split()))
ans = 10**18
for c in itertools.combinations(range(2 * n), 2):
c1, c2 = c
B = []
for i in range(2 * n):
if i != c1 and i != c2:
B.append(A[i])
B.sort()
temp = 0
for i in range(n - 1):
temp += B[2 *... | 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 BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP NUMBER VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR V... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | n = input()
kayaks = list(map(int, input().split(" ")))
kayaks.sort()
def calc_sum(kayaks):
curr_sum = 0
for i in range(1, len(kayaks), 2):
curr_sum += kayaks[i] - kayaks[i - 1]
return curr_sum
min_sum = sum(kayaks)
for i in range(len(kayaks)):
for j in range(i + 1, len(kayaks)):
new... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | n = int(input())
w = list(map(int, input().split()))
ans = []
w.sort()
ans = float("inf")
n *= 2
for i in range(n - 1):
for j in range(i + 1, n):
cur = 0
a = list(w[:i] + w[i + 1 : j] + w[j + 1 :])
for k in range(0, len(a) - 1, 2):
cur += a[k + 1] - a[k]
ans = min(ans, cu... | 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 EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BI... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | n = int(input())
a = list(map(int, input().split()))
res = int(1000000000.0 + 7)
for i in range(2 * n):
for j in range(i + 1, 2 * n):
b = [a[k] for k in range(2 * n) if k != i and k != j]
b.sort()
s = 0
for k in range(n - 1):
s += b[2 * k + 1] - b[2 * k]
res = min... | 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 BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR BIN_OP NUMBER VAR VAR VAR VAR VAR... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | n = int(input())
list = [int(x) for x in input().split(" ")]
l = sorted(list)
result = max(list)
for i in range(len(l)):
for j in range(len(l)):
l = sorted(list)
if i == j:
break
else:
l[i] = 0
l[j] = 0
l.remove(0)
l.remove(0)
temp ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NU... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | n = int(input())
weights = input().split()
weights = [int(w) for w in weights]
min_ans = float("inf")
perm = list(weights)
perm.sort()
for i in range(0, len(perm)):
for j in range(i, len(perm)):
if i == j:
continue
weights = list(perm)
weights.pop(max(i, j))
weights.pop(m... | 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 STRING ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VA... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | def vals(i, j, L):
for x in range(len(L)):
if x not in (i, j):
yield L[x]
def pairs(i, j, L):
s = []
for x in vals(i, j, L):
s.append(x)
if len(s) == 2:
yield s
s = []
def summa(i, j, L):
count = 0
for a, b in pairs(i, j, L):
co... | FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR VAR VAR FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR VAR ASSIGN VAR LIST FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR RETURN VAR... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | n = int(input())
a = sorted(list(map(int, input().split())))
x = 10**20
for i in range(2 * n):
for j in range(i + 1, 2 * n):
s, l, r = 0, 0, 1
while l < 2 * n - 1:
while l == i or l == j:
l += 1
r = l + 1
while r == i or r == j:
r +... | 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 BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER WHILE VAR BIN_OP BIN_OP NUMBER... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | n = int(input())
v = [int(i) for i in input().split()]
v = sorted(v)
def dp(i, chose):
if chose == 0:
d = 0
while i < len(v):
d += v[i + 1] - v[i]
i += 2
return d
if i >= len(v) - 1:
return 0
return min(v[i + 1] - v[i] + dp(i + 2, chose), dp(i + 1, c... | 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 FUNC_DEF IF VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER RETURN VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER RETURN NUMBER RETURN FUN... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | n = int(input())
weights = [int(i) for i in input().split()]
weights.sort()
total_instability = []
for i in range(len(weights) - 1):
a = weights[i]
for j in range(i + 1, len(weights)):
instability = 0
try:
b = weights[j]
weights.remove(a)
weights.remove(b)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR VA... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | ct = int(input())
weights = sorted(list(map(int, input().split())))
ultidiffs = []
for j in range(2 * ct):
for i in range(2 * ct):
if i != j:
diffs = []
new_weights = []
for k in range(2 * ct):
if k != i and k != j:
new_weights.append(w... | 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 LIST FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR IF VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR IF VAR VAR VAR VAR EX... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | n = int(input())
s = list(map(int, input().split()))
s = list(sorted(s))
ansm = 100000000
for i in range(len(s)):
s1 = s[:i] + s[i + 1 :]
for j in range(len(s1)):
s2 = s1[:j] + s1[j + 1 :]
ans = 0
for i in range(1, 2 * n - 2, 2):
ans += s2[i] - s2[i - 1]
if ans < ansm... | 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 FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR... |
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly... | def codeforces(numbers):
results = []
numbers.sort()
for i in range(len(numbers)):
for j in range(len(numbers)):
if i == j:
continue
nums = [numbers[indx] for indx in range(len(numbers)) if indx not in [i, j]]
results.append(calculate(nums))
re... | FUNC_DEF ASSIGN VAR LIST EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR LIST VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NU... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.